SceneGroup.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 "SceneGroup.h"
25 
26 #include <algorithm>
27 #include <string>
28 #include <vector>
29 
30 std::string
32 {
33  return this->groupID;
34 }
35 
36 std::vector<scene3D::SceneObjectPtr>
38 {
39  return this->objects;
40 }
41 
42 bool
44 {
45  return std::find(objects.begin(), objects.end(), object) != objects.end();
46 }
47 
48 void
50 {
51  //Check if object already exists in group
52  if (object == NULL || this->contains(object))
53  {
54  return;
55  }
56 
57  //Otherwise push object in our list
58  objects.push_back(object);
59 }
60 
61 void
63 {
64  //Parameter is not null and object is contained in group
65  if (object != NULL && this->contains(object))
66  {
67  //Remove object from list
68  objects.erase(std::remove(objects.begin(), objects.end(), object), objects.end());
69  }
70 }
71 
72 void
74 {
75  this->objects.clear();
76 }
77 
78 scene3D::SceneGroup::SceneGroup(const std::string& groupID) : groupID(groupID)
79 {
80 }
81 
82 void
83 scene3D::SceneGroup::setGroupId(std::string groupId)
84 {
85  this->groupID = groupId;
86 }
scene3D::SceneGroup::getGroupId
std::string getGroupId()
Returns the ID of the SceneGroup.
Definition: SceneGroup.cpp:31
scene3D::SceneGroup::addObject
void addObject(scene3D::SceneObjectPtr object)
Adds an Object to the SceneGroup.
Definition: SceneGroup.cpp:49
scene3D::SceneGroup::clearGroup
void clearGroup()
Removes all Objects from the SceneGroup.
Definition: SceneGroup.cpp:73
armarx::armem::contains
bool contains(const MemoryID &general, const MemoryID &specific)
Indicates whether general is "less specific" than, or equal to, specific, i.e.
Definition: MemoryID.cpp:563
scene3D::SceneGroup::contains
bool contains(scene3D::SceneObjectPtr object)
Checks, if SceneGroup contains Object.
Definition: SceneGroup.cpp:43
SceneGroup.h
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
scene3D::SceneGroup::getAllObjects
std::vector< scene3D::SceneObjectPtr > getAllObjects()
Returns all Objects in SceneGroup.
Definition: SceneGroup.cpp:37
scene3D::SceneGroup::SceneGroup
SceneGroup(const std::string &groupID)
Constructor Creates an instance of the class.
Definition: SceneGroup.cpp:78
scene3D::SceneGroup::removeObject
void removeObject(scene3D::SceneObjectPtr object)
Removes an Object from the SceneGroup.
Definition: SceneGroup.cpp:62