SUMO - Simulation of Urban MObility
GUIGlObject.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // Base class for all objects that may be displayed within the openGL-gui
21 /****************************************************************************/
22 #ifndef GUIGlObject_h
23 #define GUIGlObject_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <set>
37 #include "GUIGlObjectTypes.h"
38 #include <utils/geom/Boundary.h>
39 #include <utils/common/StdDefs.h>
42 #include <utils/common/RGBColor.h>
43 
44 
45 // ===========================================================================
46 // definitions
47 // ===========================================================================
48 
49 typedef unsigned int GUIGlID;
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 
55 class GUIGlObjectStorage;
57 class GUIMainWindow;
62 #ifdef HAVE_OSG
63 namespace osg {
64 class Node;
65 }
66 #endif
67 
68 // ===========================================================================
69 // class definitions
70 // ===========================================================================
71 
72 class GUIGlObject {
73 public:
76  static const GUIGlID INVALID_ID;
77 
86  GUIGlObject(GUIGlObjectType type, const std::string& microsimID);
87 
96  GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID);
97 
99  virtual ~GUIGlObject();
100 
105  const std::string& getFullName() const;
106 
109  virtual const std::string& getParentName() const;
110 
113  GUIGlID getGlID() const;
115 
118 
124  virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0;
125 
132  virtual GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0;
133 
140  virtual GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent);
141 
143  virtual const std::string& getMicrosimID() const;
144 
147  virtual void setMicrosimID(const std::string& newID);
148 
151  GUIGlObjectType getType() const;
152 
154  virtual Boundary getCenteringBoundary() const = 0;
155 
158  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
160 
165  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
166 
167 #ifdef HAVE_OSG
168  osg::Node* getNode() const;
170 
172  void setNode(osg::Node* node);
173 #endif
174 
179  void addParameterTable(GUIParameterTableWindow* w);
180 
183  void removeParameterTable(GUIParameterTableWindow* w);
185 
187  void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0) const;
188 
189 protected:
192 
196  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
197 
202  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
203 
208  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
209 
214  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
215 
220  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
221 
226  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
227 
233  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
234 
239  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
241 
242 protected:
244  void setPrefix(const std::string& prefix);
245 
247  void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
248 
250  void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
251 
252 private:
255 
258 
260  std::string myMicrosimID;
261 
263  std::string myPrefix;
264 
266  std::string myFullName;
267 
269  std::set<GUIParameterTableWindow*> myParamWindows;
270 
272  std::string createFullName() const;
273 
274 #ifdef HAVE_OSG
275  osg::Node* myOSGNode;
277 #endif
278 
280  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
281 
283  static StringBijection<GUIGlObjectType>::Entry GUIGlObjectTypeNamesInitializer[];
284 
285 private:
287  GUIGlObject(const GUIGlObject&);
288 
290  GUIGlObject& operator=(const GUIGlObject&);
291 };
292 #endif
293 
294 /****************************************************************************/
295 
GUIGlObjectType
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:254
Stores the information about how to visualize structures.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
std::string myMicrosimID
ID of GL object.
Definition: GUIGlObject.h:260
A storage for of displayed objects via their numerical id.
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:257
unsigned int GUIGlID
Definition: GUIGlObject.h:49
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:75
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:76
The popup menu of a globject.
std::string myPrefix
prefix of GL Object
Definition: GUIGlObject.h:263
std::string myFullName
full name of GL Object
Definition: GUIGlObject.h:266
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:269
A window containing a gl-object&#39;s parameter.