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.dev/sumo
3 // Copyright (C) 2001-2024 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 
29 #include <utils/geom/Boundary.h>
30 #include <utils/common/StdDefs.h>
33 #include <utils/common/RGBColor.h>
35 
36 #include "GUIGlObjectTypes.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 
57 #ifdef HAVE_OSG
58 namespace osg {
59 class Node;
60 }
61 #endif
62 
63 // ===========================================================================
64 // class definitions
65 // ===========================================================================
66 
67 class GUIGlObject {
68 
69 public:
72  static const GUIGlID INVALID_ID;
73  static const double INVALID_PRIORITY;
74 
85  GUIGlObject(GUIGlObjectType type, const std::string& microsimID, FXIcon* icon);
86 
88  virtual ~GUIGlObject();
89 
94  inline const std::string& getFullName() const {
95  return myFullName;
96  }
97 
100  virtual std::string getParentName() const;
101 
104  inline GUIGlID getGlID() const {
105  return myGlID;
106  }
107 
109  FXIcon* getGLIcon() const;
110 
112 
115 
122 
124  virtual void removedPopupMenu() {}
125 
133 
141 
143  inline const std::string& getMicrosimID() const {
144  return myMicrosimID;
145  }
146 
148  virtual const std::string getOptionalName() const;
149 
152  virtual void setMicrosimID(const std::string& newID);
153 
156  inline GUIGlObjectType getType() const {
157  return myGLObjectType;
158  }
159 
161  virtual double getClickPriority() const {
162  return (double)myGLObjectType;
163  }
164 
166  inline bool isBlocked() const {
167  return myAmBlocked;
168  }
169 
171  inline void setBlocked(const bool state = true) {
172  myAmBlocked = state;
173  }
174 
176  virtual double getExaggeration(const GUIVisualizationSettings& s) const {
177  UNUSED_PARAMETER(s);
178  return 1.;
179  }
180 
182  virtual Boundary getCenteringBoundary() const = 0;
183 
186  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
187 
189  virtual bool isGLObjectLocked() const;
190 
192  virtual void markAsFrontElement();
193 
195  virtual void deleteGLObject();
196 
198  virtual void selectGLObject();
199 
201  virtual void updateGLObject();
202 
203  virtual double getColorValue(const GUIVisualizationSettings& /*s*/, int /*activeScheme*/) const {
204  return 0;
205  }
207 
212  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
213 
215  virtual void removeActiveAddVisualisation(GUISUMOAbstractView* const /*parent*/, int /*which*/) {}
216 
218  virtual void onLeftBtnPress(void* /*data*/) {}
219 
220 #ifdef HAVE_OSG
222  osg::Node* getNode() const;
223 
225  void setNode(osg::Node* node);
226 #endif
227 
233 
238 
240  void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0, bool forceShow = false) const;
241 
242 protected:
245 
249  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
250 
255  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
256 
261  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
262 
267  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
268 
273  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
274 
279  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
280 
286  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, const GUIMainWindow& app) const;
287 
292  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
294 
296  void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
297 
299  void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
300 
301 private:
304 
307 
309  std::string myMicrosimID;
310 
312  std::string myFullName;
313 
315  FXIcon* myIcon;
316 
318  bool myAmBlocked = false;
319 
321  std::set<GUIParameterTableWindow*> myParamWindows;
322 
323 #ifdef HAVE_OSG
325  osg::Node* myOSGNode = nullptr;
326 #endif
327 
329  std::string createFullName() const;
330 
333 
335  GUIGlObject(const GUIGlObject&) = delete;
336 
338  GUIGlObject& operator=(const GUIGlObject&) = delete;
339 };
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GUIGlObjectType
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
The popup menu of a globject.
FXIcon * getGLIcon() const
get icon associated with this GL Object
static const double INVALID_PRIORITY
Definition: GUIGlObject.h:73
std::string myMicrosimID
ID of GL object.
Definition: GUIGlObject.h:309
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:203
virtual void markAsFrontElement()
mark element as front element (Currently used only in netedit)
std::string myFullName
full name of GL Object
Definition: GUIGlObject.h:312
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
bool isBlocked() const
get blocking status
Definition: GUIGlObject.h:166
void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the manipulator window.
virtual void deleteGLObject()
delete GLObject (Currently used only in netedit)
const std::string & getFullName() const
Definition: GUIGlObject.h:94
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:306
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:72
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
virtual double getClickPriority() const
Returns the priority of receiving mouse clicks.
Definition: GUIGlObject.h:161
static StringBijection< GUIGlObjectType >::Entry GUIGlObjectTypeNamesInitializer[]
vector for TypeNames Initializer
Definition: GUIGlObject.h:332
virtual Boundary getCenteringBoundary() const =0
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
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:218
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
GUIGlObject(const GUIGlObject &)=delete
Invalidated copy constructor.
virtual void updateGLObject()
update GLObject (geometry, ID, etc.) (optional)
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:71
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.
Definition: GUIGlObject.h:156
virtual ~GUIGlObject()
Destructor.
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
void setBlocked(const bool state=true)
set blocking status
Definition: GUIGlObject.h:171
bool myAmBlocked
whether the object can be deleted
Definition: GUIGlObject.h:318
virtual double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GUIGlObject.h:176
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:143
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.
virtual bool isGLObjectLocked() const
check if element is locked (Currently used only in netedit)
virtual void selectGLObject()
select GLObject (Currently used only in netedit)
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
FXIcon * myIcon
icon associatd with this GL Object
Definition: GUIGlObject.h:315
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
virtual void removedPopupMenu()
notify object about popup menu removal
Definition: GUIGlObject.h:124
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:104
GUIGlObject & operator=(const GUIGlObject &)=delete
Invalidated assignment operator.
std::string createFullName() const
create full name
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:321
GUIGlObject(GUIGlObjectType type, const std::string &microsimID, FXIcon *icon)
Constructor.
virtual void removeActiveAddVisualisation(GUISUMOAbstractView *const, int)
remove additional user-griggered visualisations
Definition: GUIGlObject.h:215
const GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:303
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
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:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37