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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Base class for all objects that may be displayed within the openGL-gui
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <string>
27 #include <set>
28 #include "GUIGlObjectTypes.h"
29 #include <utils/geom/Boundary.h>
30 #include <utils/common/StdDefs.h>
33 #include <utils/common/RGBColor.h>
34 
35 
36 // ===========================================================================
37 // definitions
38 // ===========================================================================
39 
40 typedef unsigned int GUIGlID;
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 
46 class GUIGlObjectStorage;
48 class GUIMainWindow;
53 #ifdef HAVE_OSG
54 namespace osg {
55 class Node;
56 }
57 #endif
58 
59 // ===========================================================================
60 // class definitions
61 // ===========================================================================
62 
63 class GUIGlObject {
64 public:
67  static const GUIGlID INVALID_ID;
68 
78  GUIGlObject(GUIGlObjectType type, const std::string& microsimID);
79 
81  virtual ~GUIGlObject();
82 
87  const std::string& getFullName() const;
88 
91  virtual std::string getParentName() const;
92 
95  GUIGlID getGlID() const;
97 
100 
107 
109  virtual void removedPopupMenu() {}
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 
160  virtual void removeActiveAddVisualisation(GUISUMOAbstractView* const /*parent*/, int /*which*/) {}
161 
163  virtual void onLeftBtnPress(void* /*data*/) {}
164 
165 #ifdef HAVE_OSG
167  osg::Node* getNode() const;
168 
170  void setNode(osg::Node* node);
171 #endif
172 
178 
183 
185  void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0) const;
186 
187 protected:
190 
194  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
195 
200  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
201 
206  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
207 
212  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
213 
218  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
219 
224  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
225 
231  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
232 
237  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
239 
240 protected:
242  void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
243 
245  void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
246 
247 private:
250 
253 
255  std::string myMicrosimID;
256 
258  std::string myFullName;
259 
261  std::set<GUIParameterTableWindow*> myParamWindows;
262 
264  std::string createFullName() const;
265 
266 #ifdef HAVE_OSG
268  osg::Node* myOSGNode;
269 #endif
270 
272  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
273 
276 
277 private:
279  GUIGlObject(const GUIGlObject&) = delete;
280 
282  GUIGlObject& operator=(const GUIGlObject&) = delete;
283 };
unsigned int GUIGlID
Definition: GUIGlObject.h:40
GUIGlObjectType
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
The popup menu of a globject.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
std::string myMicrosimID
ID of GL object.
Definition: GUIGlObject.h:255
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:148
std::string myFullName
full name of GL Object
Definition: GUIGlObject.h:258
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the manipulator window.
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:252
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window (optional)
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:67
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
static StringBijection< GUIGlObjectType >::Entry GUIGlObjectTypeNamesInitializer[]
LinkStates (Currently unused)
Definition: GUIGlObject.h:275
virtual Boundary getCenteringBoundary() const =0
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
const std::string & getFullName() const
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:249
virtual std::string getParentName() const
Returns the name of the parent object (if any)
virtual void onLeftBtnPress(void *)
notify object about left click
Definition: GUIGlObject.h:163
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
GUIGlObject(const GUIGlObject &)=delete
Invalidated copy constructor.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void addParameterTable(GUIParameterTableWindow *w)
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:66
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
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
virtual ~GUIGlObject()
Destructor.
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
void removeParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was closed.
virtual void drawGLAdditional(GUISUMOAbstractView *const parent, const GUIVisualizationSettings &s) const
Draws additional, user-triggered visualisations.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
GUIGlObject(GUIGlObjectType type, const std::string &microsimID)
Constructor.
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual void removedPopupMenu()
notify object about popup menu removal
Definition: GUIGlObject.h:109
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIGlObject & operator=(const GUIGlObject &)=delete
Invalidated assignment operator.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
std::string createFullName() const
create full name
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:261
virtual void removeActiveAddVisualisation(GUISUMOAbstractView *const, int)
remove additional user-griggered visualisations
Definition: GUIGlObject.h:160
A storage for of displayed objects via their numerical id.
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
Definition: Node.h:31
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36