SUMO - Simulation of Urban MObility
GUIGlObject.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Base class for all objects that may be displayed within the openGL-gui
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef GUIGlObject_h
24 #define GUIGlObject_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <set>
38 #include "GUIGlObjectTypes.h"
39 #include <utils/geom/Boundary.h>
40 #include <utils/common/StdDefs.h>
43 #include <utils/common/RGBColor.h>
44 
45 
46 // ===========================================================================
47 // definitions
48 // ===========================================================================
49 typedef unsigned int GUIGlID;
50 
51 
52 // ===========================================================================
53 // class declarations
54 // ===========================================================================
55 class GUIGlObjectStorage;
57 class GUIMainWindow;
62 #ifdef HAVE_OSG
63 namespace osg {
64 class Node;
65 }
66 #endif
67 
68 
69 // ===========================================================================
70 // class definitions
71 // ===========================================================================
72 class GUIGlObject {
73 public:
82  GUIGlObject(GUIGlObjectType type, const std::string& microsimID);
83 
84 
93  GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID);
94 
95 
97  virtual ~GUIGlObject();
98 
101 
104 
108  const std::string& getFullName() const {
109  return myFullName;
110  }
111 
115  virtual const std::string& getParentName() const {
117  }
118 
119 
123  GUIGlID getGlID() const {
124  return myGlID;
125  }
127 
128 
130 
131 
138  virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0;
139 
140 
147  virtual GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0;
148 
149 
157  UNUSED_PARAMETER(&app);
158  UNUSED_PARAMETER(&parent);
159  return 0;
160  }
161 
162 
167  const std::string& getMicrosimID() const {
168  return myMicrosimID;
169  };
170 
171 
173  virtual void setMicrosimID(const std::string& newID);
174 
175 
181  return myGLObjectType;
182  };
183 
184 
189  virtual Boundary getCenteringBoundary() const = 0;
190 
191 
195  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
197 
198 
203  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const {
204  UNUSED_PARAMETER(&s);
205  UNUSED_PARAMETER(parent);
206  };
207 
208 #ifdef HAVE_OSG
209  void setNode(osg::Node* node) {
210  myOSGNode = node;
211  }
212 
213  osg::Node* getNode() const {
214  return myOSGNode;
215  }
216 #endif
217 
220 
224  void addParameterTable(GUIParameterTableWindow* w);
225 
226 
230  void removeParameterTable(GUIParameterTableWindow* w);
232 
233 
234  void drawName(const Position& pos, const SUMOReal scale,
235  const GUIVisualizationTextSettings& settings, const SUMOReal angle = 0) const;
236 
237 
238 protected:
240 
241 
246  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
247 
248 
253  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
254 
255 
260  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
261 
262 
267  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
268 
269 
274  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
275 
276 
281  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
282 
283 
289  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
290 
291 
296  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
298 
299 protected:
300  /* usually names are prefixed by a type-specific string. this method can be
301  * used to change the default */
302  void setPrefix(const std::string& prefix);
303 
304 private:
307 
310 
311  std::string myMicrosimID;
312 
313  std::string myPrefix;
314 
315  std::string myFullName;
316 
318  std::set<GUIParameterTableWindow*> myParamWindows;
319 
320  std::string createFullName() const;
321 
322 #ifdef HAVE_OSG
323  osg::Node* myOSGNode;
324 #endif
325 
326  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
327 
328  static StringBijection<GUIGlObjectType>::Entry GUIGlObjectTypeNamesInitializer[];
329 
330 private:
332  GUIGlObject(const GUIGlObject&);
333 
335  GUIGlObject& operator=(const GUIGlObject&);
336 
337 };
338 #endif
339 
340 /****************************************************************************/
341 
GUIGlObjectType
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:306
Stores the information about how to visualize structures.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:167
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:123
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
virtual GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window (optional)
Definition: GUIGlObject.h:156
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additional, user-triggered visualisations.
Definition: GUIGlObject.h:203
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:180
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
std::string myMicrosimID
Definition: GUIGlObject.h:311
A storage for of displayed objects via their numerical id.
virtual const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GUIGlObject.h:115
static std::string emptyString
An empty string.
Definition: StringUtils.h:84
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:309
unsigned int GUIGlID
Definition: GUIGlObject.h:49
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:100
The popup menu of a globject.
std::string myPrefix
Definition: GUIGlObject.h:313
std::string myFullName
Definition: GUIGlObject.h:315
#define SUMOReal
Definition: config.h:213
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:318
const std::string & getFullName() const
Returns the full name appearing in the tool tip.
Definition: GUIGlObject.h:108
A window containing a gl-object&#39;s parameter.