SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
13 // Copyright (C) 2001-2013 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>
42 #include <utils/common/RGBColor.h>
43 
44 
45 // ===========================================================================
46 // definitions
47 // ===========================================================================
48 typedef unsigned int GUIGlID;
49 
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 class GUIGlObjectStorage;
56 class GUIMainWindow;
61 #ifdef HAVE_OSG
62 namespace osg {
63 class Node;
64 }
65 #endif
66 
67 
68 // ===========================================================================
69 // class definitions
70 // ===========================================================================
71 class GUIGlObject {
72 public:
81  GUIGlObject(GUIGlObjectType type, const std::string& microsimID);
82 
83 
92  GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID);
93 
94 
96  virtual ~GUIGlObject();
97 
100 
103 
107  const std::string& getFullName() const {
108  return myFullName;
109  }
110 
111 
115  GUIGlID getGlID() const {
116  return myGlID;
117  }
119 
120 
122 
123 
131 
132 
140 
141 
146  const std::string& getMicrosimID() const {
147  return myMicrosimID;
148  };
149 
150 
152  void setMicrosimID(const std::string& newID);
153 
154 
160  return myGLObjectType;
161  };
162 
163 
168  virtual Boundary getCenteringBoundary() const = 0;
169 
170 
174  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
176 
177 
182  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const {
183  UNUSED_PARAMETER(&s);
184  UNUSED_PARAMETER(parent);
185  };
186 
187 #ifdef HAVE_OSG
188  void setNode(osg::Node* node) {
189  myOSGNode = node;
190  }
191 
192  osg::Node* getNode() const {
193  return myOSGNode;
194  }
195 #endif
196 
199 
204 
205 
211 
212 
213  void drawName(const Position& pos, const SUMOReal scale,
214  const GUIVisualizationTextSettings& settings, const SUMOReal angle = 0) const;
215 
216 
217 protected:
219 
220 
225  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
226 
227 
232  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
233 
234 
239  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
240 
241 
246  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
247 
248 
253  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
254 
255 
261  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
262 
263 
268  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
270 
271 protected:
272  /* usually names are prefixed by a type-specific string. this method can be
273  * used to change the default */
274  void setPrefix(const std::string& prefix);
275 
276 private:
279 
282 
283  std::string myMicrosimID;
284 
285  std::string myPrefix;
286 
287  std::string myFullName;
288 
290  std::set<GUIParameterTableWindow*> myParamWindows;
291 
292  std::string createFullName() const;
293 
294 #ifdef HAVE_OSG
295  osg::Node* myOSGNode;
296 #endif
297 
298  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
299 
301 
302 private:
304  GUIGlObject(const GUIGlObject&);
305 
308 
309 };
310 #endif
311 
312 /****************************************************************************/
313 
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:278
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:146
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:115
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:36
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:182
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
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&#39;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:283
virtual ~GUIGlObject()
Destructor.
Definition: GUIGlObject.cpp:99
void addParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object&#39;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
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:281
unsigned int GUIGlID
Definition: GUIGlObject.h:48
void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the manipulator window.
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:99
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:300
std::string myPrefix
Definition: GUIGlObject.h:285
std::string myFullName
Definition: GUIGlObject.h:287
#define SUMOReal
Definition: config.h:221
GUIGlObject(GUIGlObjectType type, const std::string &microsimID)
Constructor.
Definition: GUIGlObject.cpp:80
GUIGlObject & operator=(const GUIGlObject &)
Invalidated assignment operator.
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:290
void setPrefix(const std::string &prefix)
const std::string & getFullName() const
Returns the full name appearing in the tool tip.
Definition: GUIGlObject.h:107
A window containing a gl-object&#39;s parameter.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.