SceneSelectionManager.h
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 #pragma once
25 
26 #include <vector>
27 
28 #include <Inventor/SoPickedPoint.h>
29 #include <Inventor/SoPath.h>
30 
31 #include "Scene.h"
32 #include "SceneObject.h"
33 #include "SceneGroup.h"
34 
35 namespace scene3D
36 {
38  {
39 
40  friend class Scene;
41 
42  public:
43  /**
44  * Constructor
45  * Creates an Instance of the Class.
46  *
47  * @param scene Existing Scene
48  */
50 
51  /**
52  * Returns all selected SceneObjects.
53  *
54  * @return vector<scene3D::SceneObjectPtr > Vector of all selected SceneObjects
55  */
56  std::vector<scene3D::SceneObjectPtr> getAllSelected();
57 
58  /**
59  * Determines whether a SceneObject is selected.
60  *
61  * @param object SceneObject to check
62  * @return bool SceneObject is selected?
63  */
65 
66  /**
67  * Adds a SceneObject to the Selection.
68  *
69  * @param object SceneObject to be added
70  */
72 
73  /**
74  * Removes a SceneObject from the Selection.
75  *
76  * @param object SceneObject to be removed
77  */
79 
80  /**
81  * Adds a SceneGroup to the Selection.
82  *
83  * @param group SceneGroup to be added
84  */
86 
87  /**
88  * Removes a SceneGroup from the Selection.
89  *
90  * @param group SceneGroup to be removed
91  */
93 
94  /**
95  * Deselects all SceneObjects.
96  *
97  */
98  void deselectAll();
99 
100  /**
101  * Executes all commands when an Item is selected and the Callback is voked.
102  *
103  * @param userData UserData
104  * @param selectionPath Path of selected Object
105  */
106  static void selectionCallback(void* userData, SoPath* selectionPath);
107  /**
108  * Executes all commands when an Item is deselected and the Callback is voked.
109  *
110  * @param userData UserData
111  * @param selectionPath Path of deselected Object
112  */
113  static void deselectionCallback(void* userData, SoPath* selectionPath);
114  /**
115  * Adjusts a path so that it always show to a valid Object.
116  *
117  * @param userData UserData
118  * @param pick The Point picked in the Scene
119  * @return SoPath New adjusted Path
120  */
121  static SoPath* pickFilterCB(void* userData, const SoPickedPoint* pick);
122 
123  void setCreateOperations(bool enable);
124  bool getCreateOperations();
125  private:
126  SceneWeakPtr scene;
127  static bool createOperations;
128  std::vector<scene3D::SceneObjectPtr> historySelected;
129 
130  void storeHistory();
131 
132  void restoreHistory();
133 
134  scene3D::SceneObjectPtr getLastSelected();
135  };
136 }
137 
scene3D::Scene
Definition: Scene.h:61
scene3D::SceneSelectionManager::selectionCallback
static void selectionCallback(void *userData, SoPath *selectionPath)
Executes all commands when an Item is selected and the Callback is voked.
Definition: SceneSelectionManager.cpp:30
scene3D::SceneSelectionManager::getCreateOperations
bool getCreateOperations()
Definition: SceneSelectionManager.cpp:276
scene3D::ScenePtr
std::shared_ptr< Scene > ScenePtr
Definition: PointerDefinitions.h:36
scene3D::SceneSelectionManager::deselectAll
void deselectAll()
Deselects all SceneObjects.
Definition: SceneSelectionManager.cpp:243
scene3D::SceneSelectionManager::getAllSelected
std::vector< scene3D::SceneObjectPtr > getAllSelected()
Returns all selected SceneObjects.
Definition: SceneSelectionManager.cpp:131
scene3D::SceneSelectionManager::addToSelection
void addToSelection(scene3D::SceneObjectPtr object)
Adds a SceneObject to the Selection.
Definition: SceneSelectionManager.cpp:174
scene3D::SceneSelectionManager::pickFilterCB
static SoPath * pickFilterCB(void *userData, const SoPickedPoint *pick)
Adjusts a path so that it always show to a valid Object.
Definition: SceneSelectionManager.cpp:88
Scene.h
SceneObject.h
scene3D
Definition: ManipulatorMode.h:26
scene3D::SceneGroupPtr
std::shared_ptr< SceneGroup > SceneGroupPtr
Definition: PointerDefinitions.h:53
scene3D::SceneSelectionManager::setCreateOperations
void setCreateOperations(bool enable)
Definition: SceneSelectionManager.cpp:271
SceneGroup.h
scene3D::SceneWeakPtr
std::weak_ptr< Scene > SceneWeakPtr
Definition: PointerDefinitions.h:37
scene3D::SceneSelectionManager::isSelected
bool isSelected(scene3D::SceneObjectPtr object)
Determines whether a SceneObject is selected.
Definition: SceneSelectionManager.cpp:155
scene3D::SceneSelectionManager::removeFromSelection
void removeFromSelection(scene3D::SceneObjectPtr object)
Removes a SceneObject from the Selection.
Definition: SceneSelectionManager.cpp:194
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
scene3D::SceneSelectionManager::SceneSelectionManager
SceneSelectionManager(ScenePtr scene)
Constructor Creates an Instance of the Class.
Definition: SceneSelectionManager.cpp:124
scene3D::SceneSelectionManager::deselectionCallback
static void deselectionCallback(void *userData, SoPath *selectionPath)
Executes all commands when an Item is deselected and the Callback is voked.
Definition: SceneSelectionManager.cpp:59
scene3D::SceneSelectionManager
Definition: SceneSelectionManager.h:37