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-2015 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 
154  const std::string& getMicrosimID() const {
155  return myMicrosimID;
156  };
157 
158 
160  virtual void setMicrosimID(const std::string& newID);
161 
162 
168  return myGLObjectType;
169  };
170 
171 
176  virtual Boundary getCenteringBoundary() const = 0;
177 
178 
182  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
184 
185 
190  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const {
191  UNUSED_PARAMETER(&s);
192  UNUSED_PARAMETER(parent);
193  };
194 
195 #ifdef HAVE_OSG
196  void setNode(osg::Node* node) {
197  myOSGNode = node;
198  }
199 
200  osg::Node* getNode() const {
201  return myOSGNode;
202  }
203 #endif
204 
207 
211  void addParameterTable(GUIParameterTableWindow* w);
212 
213 
217  void removeParameterTable(GUIParameterTableWindow* w);
219 
220 
221  void drawName(const Position& pos, const SUMOReal scale,
222  const GUIVisualizationTextSettings& settings, const SUMOReal angle = 0) const;
223 
224 
225 protected:
227 
228 
233  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
234 
235 
240  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
241 
242 
247  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
248 
249 
254  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
255 
256 
261  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
262 
263 
269  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
270 
271 
276  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
278 
279 protected:
280  /* usually names are prefixed by a type-specific string. this method can be
281  * used to change the default */
282  void setPrefix(const std::string& prefix);
283 
284 private:
287 
290 
291  std::string myMicrosimID;
292 
293  std::string myPrefix;
294 
295  std::string myFullName;
296 
298  std::set<GUIParameterTableWindow*> myParamWindows;
299 
300  std::string createFullName() const;
301 
302 #ifdef HAVE_OSG
303  osg::Node* myOSGNode;
304 #endif
305 
306  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
307 
308  static StringBijection<GUIGlObjectType>::Entry GUIGlObjectTypeNamesInitializer[];
309 
310 private:
312  GUIGlObject(const GUIGlObject&);
313 
315  GUIGlObject& operator=(const GUIGlObject&);
316 
317 };
318 #endif
319 
320 /****************************************************************************/
321 
GUIGlObjectType
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:286
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:154
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 void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additional, user-triggered visualisations.
Definition: GUIGlObject.h:190
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:167
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
std::string myMicrosimID
Definition: GUIGlObject.h:291
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:289
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:293
std::string myFullName
Definition: GUIGlObject.h:295
#define SUMOReal
Definition: config.h:214
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:298
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.