Eclipse SUMO - Simulation of Urban MObility
GUIGlObject.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Base class for all objects that may be displayed within the openGL-gui
19 /****************************************************************************/
20 #ifndef GUIGlObject_h
21 #define GUIGlObject_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <set>
31 #include "GUIGlObjectTypes.h"
32 #include <utils/geom/Boundary.h>
33 #include <utils/common/StdDefs.h>
36 #include <utils/common/RGBColor.h>
37 
38 
39 // ===========================================================================
40 // definitions
41 // ===========================================================================
42 
43 typedef unsigned int GUIGlID;
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 
49 class GUIGlObjectStorage;
51 class GUIMainWindow;
56 #ifdef HAVE_OSG
57 namespace osg {
58 class Node;
59 }
60 #endif
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
65 
66 class GUIGlObject {
67 public:
70  static const GUIGlID INVALID_ID;
71 
81  GUIGlObject(GUIGlObjectType type, const std::string& microsimID);
82 
84  virtual ~GUIGlObject();
85 
90  const std::string& getFullName() const;
91 
94  virtual std::string getParentName() const;
95 
98  GUIGlID getGlID() const;
100 
103 
110 
118 
126 
128  virtual const std::string& getMicrosimID() const;
129 
131  virtual const std::string getOptionalName() const;
132 
135  virtual void setMicrosimID(const std::string& newID);
136 
139  GUIGlObjectType getType() const;
140 
142  virtual Boundary getCenteringBoundary() const = 0;
143 
146  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
147 
148  virtual double getColorValue(const GUIVisualizationSettings& /*s*/, int /*activeScheme*/) const {
149  return 0;
150  }
152 
157  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
158 
159 #ifdef HAVE_OSG
160  osg::Node* getNode() const;
162 
164  void setNode(osg::Node* node);
165 #endif
166 
172 
177 
179  void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0) const;
180 
181 protected:
184 
188  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
189 
194  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
195 
200  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
201 
206  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
207 
212  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
213 
218  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
219 
225  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
226 
231  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
233 
234 protected:
236  void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
237 
239  void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
240 
241 private:
244 
247 
249  std::string myMicrosimID;
250 
252  std::string myFullName;
253 
255  std::set<GUIParameterTableWindow*> myParamWindows;
256 
258  std::string createFullName() const;
259 
260 #ifdef HAVE_OSG
261  osg::Node* myOSGNode;
263 #endif
264 
266  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
267 
270 
271 private:
273  GUIGlObject(const GUIGlObject&) = delete;
274 
276  GUIGlObject& operator=(const GUIGlObject&) = delete;
277 };
278 #endif
279 
280 /****************************************************************************/
281 
GUIGlObject::getType
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.cpp:181
Boundary.h
GUIGlObjectTypes.h
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
GUIGlObject::removeParameterTable
void removeParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was closed.
Definition: GUIGlObject.cpp:294
GUIGlObject::myMicrosimID
std::string myMicrosimID
ID of GL object.
Definition: GUIGlObject.h:249
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GUIGlObjectStorage
A storage for of displayed objects via their numerical id.
Definition: GUIGlObjectStorage.h:52
GUIGlObject::getTypeParameterWindow
virtual GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window (optional)
Definition: GUIGlObject.cpp:156
GUIGlObject::getColorValue
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:148
GUIGlObject::drawName
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
Definition: GUIGlObject.cpp:355
StringBijection.h
GUIGlObject::myGLObjectType
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:246
GUIGlObject::buildSelectionPopupEntry
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
Definition: GUIGlObject.cpp:236
GUIGlObject::getPopUpMenu
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
GUIGlObject::getParameterWindow
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
GUIGlObject::GUIGlObjectTypeNamesInitializer
static StringBijection< GUIGlObjectType >::Entry GUIGlObjectTypeNamesInitializer[]
LinkStates (Currently unused)
Definition: GUIGlObject.h:269
GUIGlObject::TypeNames
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:69
GUIGlObject::buildShowManipulatorPopupEntry
void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the manipulator window.
Definition: GUIGlObject.cpp:279
GUIGlObject::getFullName
const std::string & getFullName() const
Definition: GUIGlObject.cpp:138
GUIVisualizationTextSettings
Definition: GUIVisualizationSettings.h:51
GUIGlObject::myFullName
std::string myFullName
full name of GL Object
Definition: GUIGlObject.h:252
GUIGlObject::getOptionalName
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
Definition: GUIGlObject.cpp:169
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GUIGlObject::buildAdditionalsPopupOptions
void buildAdditionalsPopupOptions(GUIMainWindow &app, GUIGLObjectPopupMenu *ret, const std::string &type)
build basic additional popup options. Used to unify pop-ups menu in netedit and SUMO-GUI
Definition: GUIGlObject.cpp:326
RGBColor.h
GUIGlObject::createFullName
std::string createFullName() const
create full name
Definition: GUIGlObject.cpp:349
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:40
GUIGlObject::GUIGlObject
GUIGlObject(GUIGlObjectType type, const std::string &microsimID)
Constructor.
Definition: GUIGlObject.cpp:118
GUIGlObject::setMicrosimID
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
Definition: GUIGlObject.cpp:174
GUIGlObject::INVALID_ID
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:70
StringBijection< GUIGlObjectType >
GUIGlObject::drawGLAdditional
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additional, user-triggered visualisations.
Definition: GUIGlObject.cpp:187
GUIGlObject::buildNameCopyPopupEntry
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
Definition: GUIGlObject.cpp:226
GUIGlObject::myParamWindows
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:255
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:150
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GUIGlObject
Definition: GUIGlObject.h:66
GUIGlObject::buildPopupHeader
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
Definition: GUIGlObject.cpp:208
GUIGlObject::myGlID
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:243
GUIGlObject::operator=
GUIGlObject & operator=(const GUIGlObject &)=delete
Invalidated assignment operator.
StringUtils.h
GUIMainWindow
Definition: GUIMainWindow.h:47
GUIGlObject::getCenteringBoundary
virtual Boundary getCenteringBoundary() const =0
GUIGlObject::buildShapePopupOptions
void buildShapePopupOptions(GUIMainWindow &app, GUIGLObjectPopupMenu *ret, const std::string &type)
build basic shape popup options. Used to unify pop-ups menu in netedit and SUMO-GUI
Definition: GUIGlObject.cpp:303
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GUIGlObject::buildShowTypeParamsPopupEntry
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
Definition: GUIGlObject.cpp:258
GUIGlObject::drawGL
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
GUIGlObject::buildShowParamsPopupEntry
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
Definition: GUIGlObject.cpp:249
GUIGlObject::buildCenterPopupEntry
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
Definition: GUIGlObject.cpp:217
GUIGlObject::buildPositionCopyEntry
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
Definition: GUIGlObject.cpp:267
config.h
StdDefs.h
GUIGlObject::addParameterTable
void addParameterTable(GUIParameterTableWindow *w)
Definition: GUIGlObject.cpp:288
GUIGlObject::~GUIGlObject
virtual ~GUIGlObject()
Destructor.
Definition: GUIGlObject.cpp:128
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GUIGlObject::getMicrosimID
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.cpp:164
GUIGlObject::getParentName
virtual std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GUIGlObject.cpp:144