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
28
std::vector<scene3D::SceneGroupPtr>
29
scene3D::SceneGroupManager::getAllGroups
()
30
{
31
return
sceneGroups;
32
}
33
34
scene3D::SceneGroupPtr
35
scene3D::SceneGroupManager::getGroupById
(std::string groupId)
36
{
37
for
(
SceneGroupPtr
group : sceneGroups)
38
{
39
if
(group->getGroupId().compare(groupId) == 0)
40
{
41
return
group;
42
}
43
}
44
45
return
scene3D::SceneGroupPtr
();
46
}
47
48
void
49
scene3D::SceneGroupManager::addGroup
(
SceneGroupPtr
group)
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
61
void
62
scene3D::SceneGroupManager::removeGroup
(
scene3D::SceneGroupPtr
group)
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
83
void
84
scene3D::SceneGroupManager::renameGroup
(
scene3D::SceneGroupPtr
group, std::string newGroupId)
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
}
SceneGroupManager.h
scene3D::SceneGroupManager::getGroupById
scene3D::SceneGroupPtr getGroupById(std::string groupId)
Returns a SceneGroup specified by an ID.
Definition
SceneGroupManager.cpp:35
scene3D::SceneGroupManager::removeGroup
void removeGroup(scene3D::SceneGroupPtr group)
Removes a SceneGroup.
Definition
SceneGroupManager.cpp:62
scene3D::SceneGroupManager::getAllGroups
std::vector< scene3D::SceneGroupPtr > getAllGroups()
Returns all SceneGroups.
Definition
SceneGroupManager.cpp:29
scene3D::SceneGroupManager::renameGroup
void renameGroup(scene3D::SceneGroupPtr group, std::string newGroupId)
Renames a SceneGroup.
Definition
SceneGroupManager.cpp:84
scene3D::SceneGroupManager::addGroup
void addGroup(SceneGroupPtr group)
Adds a SceneGroup.
Definition
SceneGroupManager.cpp:49
scene3D::SceneGroupPtr
std::shared_ptr< SceneGroup > SceneGroupPtr
Definition
PointerDefinitions.h:55
MemoryX
gui-plugins
SceneEditor
scene3D
SceneGroupManager.cpp
Generated by
1.13.2