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 
139 
140 
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 
212 
213 
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 
309 
310 private:
312  GUIGlObject(const GUIGlObject&);
313 
316 
317 };
318 #endif
319 
320 /****************************************************************************/
321 
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
GUIGlObjectType
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:286
std::string createFullName() const
Stores the information about how to visualize structures.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:154
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
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
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
void removeParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was closed.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
std::string myMicrosimID
Definition: GUIGlObject.h:291
virtual ~GUIGlObject()
Destructor.
void addParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was opened.
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
A storage for of displayed objects via their numerical id.
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
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
void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the manipulator window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object (happens in NETEDIT)
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:100
The popup menu of a globject.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
static StringBijection< GUIGlObjectType >::Entry GUIGlObjectTypeNamesInitializer[]
Definition: GUIGlObject.h:308
std::string myPrefix
Definition: GUIGlObject.h:293
std::string myFullName
Definition: GUIGlObject.h:295
#define SUMOReal
Definition: config.h:215
GUIGlObject(GUIGlObjectType type, const std::string &microsimID)
Constructor.
Definition: GUIGlObject.cpp:82
GUIGlObject & operator=(const GUIGlObject &)
Invalidated assignment operator.
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:298
void setPrefix(const std::string &prefix)
const std::string & getFullName() const
Returns the full name appearing in the tool tip.
Definition: GUIGlObject.h:108
A window containing a gl-object's parameter.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.