SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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.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 
50 typedef unsigned int GUIGlID;
51 
52 // ===========================================================================
53 // class declarations
54 // ===========================================================================
55 
56 class GUIGlObjectStorage;
58 class GUIMainWindow;
63 #ifdef HAVE_OSG
64 namespace osg {
65 class Node;
66 }
67 #endif
68 
69 // ===========================================================================
70 // class definitions
71 // ===========================================================================
72 
73 class GUIGlObject {
74 public:
77  static const GUIGlID INVALID_ID;
78 
87  GUIGlObject(GUIGlObjectType type, const std::string& microsimID);
88 
97  GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID);
98 
100  virtual ~GUIGlObject();
101 
106  const std::string& getFullName() const;
107 
110  virtual const std::string& getParentName() const;
111 
114  GUIGlID getGlID() const;
116 
119 
126 
134 
142 
144  virtual const std::string& getMicrosimID() const;
145 
148  virtual void setMicrosimID(const std::string& newID);
149 
152  GUIGlObjectType getType() const;
153 
155  virtual Boundary getCenteringBoundary() const = 0;
156 
159  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
161 
166  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
167 
168 #ifdef HAVE_OSG
169  osg::Node* getNode() const;
171 
173  void setNode(osg::Node* node);
174 #endif
175 
181 
186 
188  void drawName(const Position& pos, const SUMOReal scale, const GUIVisualizationTextSettings& settings, const SUMOReal angle = 0) const;
189 
190 protected:
193 
197  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
198 
203  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
204 
209  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
210 
215  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
216 
221  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
222 
227  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
228 
234  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
235 
240  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
242 
243 protected:
245  void setPrefix(const std::string& prefix);
246 
247 private:
250 
253 
255  std::string myMicrosimID;
256 
258  std::string myPrefix;
259 
261  std::string myFullName;
262 
264  std::set<GUIParameterTableWindow*> myParamWindows;
265 
267  std::string createFullName() const;
268 
269 #ifdef HAVE_OSG
270  osg::Node* myOSGNode;
272 #endif
273 
275  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
276 
279 
280 private:
282  GUIGlObject(const GUIGlObject&);
283 
286 };
287 #endif
288 
289 /****************************************************************************/
290 
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:249
std::string createFullName() const
create full name
const std::string & getFullName() const
Stores the information about how to visualize structures.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additional, user-triggered visualisations.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
virtual Boundary getCenteringBoundary() const =0
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.
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
GUIGlID getGlID() const
Returns the numerical id of the object.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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.
virtual GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window (optional)
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
ID of GL object.
Definition: GUIGlObject.h:255
virtual ~GUIGlObject()
Destructor.
void addParameterTable(GUIParameterTableWindow *w)
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
draw name of item
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:252
unsigned int GUIGlID
Definition: GUIGlObject.h:50
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.
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:76
virtual const std::string & getParentName() const
Returns the name of the parent object (if any)
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:77
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[]
LinkStates (Currently unused)
Definition: GUIGlObject.h:278
std::string myPrefix
prefix of GL Object
Definition: GUIGlObject.h:258
std::string myFullName
full name of GL Object
Definition: GUIGlObject.h:261
#define SUMOReal
Definition: config.h:214
GUIGlObject(GUIGlObjectType type, const std::string &microsimID)
Constructor.
Definition: GUIGlObject.cpp:86
GUIGlObject & operator=(const GUIGlObject &)
Invalidated assignment operator.
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:264
void setPrefix(const std::string &prefix)
usually names are prefixed by a type-specific string. this method can be used to change the default ...
A window containing a gl-object's parameter.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.