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
30std::string
32{
33 return this->groupID;
34}
35
36std::vector<scene3D::SceneObjectPtr>
38{
39 return this->objects;
40}
41
42bool
44{
45 return std::find(objects.begin(), objects.end(), object) != objects.end();
46}
47
48void
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
61void
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
72void
74{
75 this->objects.clear();
76}
77
78scene3D::SceneGroup::SceneGroup(const std::string& groupID) : groupID(groupID)
79{
80}
81
82void
83scene3D::SceneGroup::setGroupId(std::string groupId)
84{
85 this->groupID = groupId;
86}
SceneGroup(const std::string &groupID)
Constructor Creates an instance of the class.
void removeObject(scene3D::SceneObjectPtr object)
Removes an Object from the SceneGroup.
void clearGroup()
Removes all Objects from the SceneGroup.
bool contains(scene3D::SceneObjectPtr object)
Checks, if SceneGroup contains Object.
std::vector< scene3D::SceneObjectPtr > getAllObjects()
Returns all Objects in SceneGroup.
std::string getGroupId()
Returns the ID of the SceneGroup.
void addObject(scene3D::SceneObjectPtr object)
Adds an Object to the SceneGroup.
boost::intrusive_ptr< SceneObject > SceneObjectPtr