Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2025 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>
36
37#include "GUIGlObjectTypes.h"
38
39
40// ===========================================================================
41// definitions
42// ===========================================================================
43
44typedef unsigned int GUIGlID;
45
46// ===========================================================================
47// class declarations
48// ===========================================================================
49
57
58#ifdef HAVE_OSG
59namespace osg {
60class Node;
61}
62#endif
63
64// ===========================================================================
65// class definitions
66// ===========================================================================
67
69
70public:
73 static const GUIGlID INVALID_ID;
74 static const double INVALID_PRIORITY;
75
86 GUIGlObject(GUIGlObjectType type, const std::string& microsimID, FXIcon* icon);
87
89 virtual ~GUIGlObject();
90
95 inline const std::string& getFullName() const {
96 return myFullName;
97 }
98
101 virtual std::string getParentName() const;
102
105 inline GUIGlID getGlID() const {
106 return myGlID;
107 }
108
110 FXIcon* getGLIcon() const;
111
113
116
123
125 virtual void removedPopupMenu() {}
126
134
142
144 inline const std::string& getMicrosimID() const {
145 return myMicrosimID;
146 }
147
149 virtual const std::string getOptionalName() const;
150
153 virtual void setMicrosimID(const std::string& newID);
154
157 inline GUIGlObjectType getType() const {
158 return myGLObjectType;
159 }
160
162 virtual double getClickPriority() const {
163 return (double)myGLObjectType;
164 }
165
167 inline bool isBlocked() const {
168 return myAmBlocked;
169 }
170
172 inline void setBlocked(const bool state = true) {
173 myAmBlocked = state;
174 }
175
177 virtual double getExaggeration(const GUIVisualizationSettings& s) const {
179 return 1.;
180 }
181
183 virtual Boundary getCenteringBoundary() const = 0;
184
185 virtual Position getCenter() const {
187 }
188
190 virtual double getScaleVisual() const {
191 return 1;
192 }
193
196 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
197
199 virtual bool isGLObjectLocked() const;
200
202 virtual void markAsFrontElement();
203
205 virtual void deleteGLObject();
206
208 virtual void selectGLObject();
209
211 virtual void updateGLObject();
212
213 virtual double getColorValue(const GUIVisualizationSettings& /*s*/, int /*activeScheme*/) const {
214 return 0;
215 }
217
222 virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
223
225 virtual void removeActiveAddVisualisation(GUISUMOAbstractView* const /*parent*/, int /*which*/) {}
226
228 virtual void onLeftBtnPress(void* /*data*/) {}
229
230#ifdef HAVE_OSG
232 osg::Node* getNode() const;
233
235 void setNode(osg::Node* node);
236#endif
237
243
248
250 void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0, bool forceShow = false) const;
251
252protected:
257 const bool selected, bool addSeparator = true);
258
263 void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
264
269 void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
270
275 void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
276
281 void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
282
287 void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
288
293 void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
294
300 void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, const GUIMainWindow& app, bool addSeparator = true) const;
301
306 void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
307
309
311 void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
312
314 void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
315
316private:
319
322
324 std::string myMicrosimID;
325
327 std::string myFullName;
328
330 FXIcon* myIcon;
331
333 bool myAmBlocked = false;
334
336 std::set<GUIParameterTableWindow*> myParamWindows;
337
338#ifdef HAVE_OSG
340 osg::Node* myOSGNode = nullptr;
341#endif
342
344 std::string createFullName() const;
345
348
350 GUIGlObject(const GUIGlObject&) = delete;
351
354};
unsigned int GUIGlID
Definition GUIGlObject.h:44
GUIGlObjectType
SumoXMLTag
Numbers representing SUMO-XML - element names.
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition Boundary.cpp:109
The popup menu of a globject.
FXIcon * getGLIcon() const
get icon associated with this GL Object
static const double INVALID_PRIORITY
Definition GUIGlObject.h:74
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app, bool addSeparator=true) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
std::string myMicrosimID
ID of GL object.
virtual double getColorValue(const GUIVisualizationSettings &, int) const
virtual void markAsFrontElement()
mark element as front element (Currently used only in netedit)
std::string myFullName
full name of GL Object
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
bool isBlocked() const
get blocking status
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 GUIGlObjectType myGLObjectType
The type of the object.
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 const std::string getOptionalName() const
Returns the name of the object (default "")
static const GUIGlID INVALID_ID
Definition GUIGlObject.h:73
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.
static StringBijection< GUIGlObjectType >::Entry GUIGlObjectTypeNamesInitializer[]
vector for TypeNames Initializer
Definition GUIGlObject.h:52
virtual Boundary getCenteringBoundary() const =0
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
const std::string & getFullName() const
Definition GUIGlObject.h:95
virtual std::string getParentName() const
Returns the name of the parent object (if any)
virtual void onLeftBtnPress(void *)
notify object about left click
virtual double getScaleVisual() const
return individual scaling factor for this object
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:72
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.
void setBlocked(const bool state=true)
set blocking status
bool myAmBlocked
whether the object can be deleted
virtual double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
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.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
virtual Position getCenter() const
FXIcon * myIcon
icon associatd with this GL Object
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
GUIGlObject & operator=(const GUIGlObject &)=delete
Invalidated assignment operator.
virtual void removedPopupMenu()
notify object about popup menu removal
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
GUIGlID getGlID() const
Returns the numerical id of the object.
std::string createFullName() const
create full name
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
virtual void removeActiveAddVisualisation(GUISUMOAbstractView *const, int)
remove additional user-griggered visualisations
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
const GUIGlID myGlID
The numerical id of the object.
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
#define UNUSED_PARAMETER(x)
bijection entry