SceneGroupManager.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package MemoryX::gui-plugins::SceneEditor
19 * @date 2015
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24#include "SceneGroupManager.h"
25
26#include <algorithm>
27
28std::vector<scene3D::SceneGroupPtr>
30{
31 return sceneGroups;
32}
33
36{
37 for (SceneGroupPtr group : sceneGroups)
38 {
39 if (group->getGroupId().compare(groupId) == 0)
40 {
41 return group;
42 }
43 }
44
46}
47
48void
50{
51 //Check whether an object with same ID already exists
52 if (this->getGroupById(group->getGroupId()) != NULL)
53 {
54 throw std::logic_error("Group already exists!");
55 }
56
57 //Otherwise push object in our list
58 sceneGroups.push_back(group);
59}
60
61void
63{
64 if (group != NULL)
65 {
66 if (std::find(sceneGroups.begin(), sceneGroups.end(), group) != sceneGroups.end())
67 {
68 //Remove object from list
69 sceneGroups.erase(std::remove(sceneGroups.begin(), sceneGroups.end(), group),
70 sceneGroups.end());
71 }
72 else
73 {
74 throw std::runtime_error("This group is not registered in the sceneGroupManager!");
75 }
76 }
77 else
78 {
79 throw std::runtime_error("Group is null!");
80 }
81}
82
83void
85{
86 if (this->getGroupById(newGroupId) != NULL)
87 {
88 throw std::invalid_argument("New ID of Group already exists!");
89 }
90
91 //Otherwise change ID of group
92 group->setGroupId(newGroupId);
93}
scene3D::SceneGroupPtr getGroupById(std::string groupId)
Returns a SceneGroup specified by an ID.
void removeGroup(scene3D::SceneGroupPtr group)
Removes a SceneGroup.
std::vector< scene3D::SceneGroupPtr > getAllGroups()
Returns all SceneGroups.
void renameGroup(scene3D::SceneGroupPtr group, std::string newGroupId)
Renames a SceneGroup.
void addGroup(SceneGroupPtr group)
Adds a SceneGroup.
std::shared_ptr< SceneGroup > SceneGroupPtr