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-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>
35
36#include "GUIGlObjectTypes.h"
37
38
39// ===========================================================================
40// definitions
41// ===========================================================================
42
43typedef unsigned int GUIGlID;
44
45// ===========================================================================
46// class declarations
47// ===========================================================================
48
51class GUIMainWindow;
56
57#ifdef HAVE_OSG
58namespace osg {
59class Node;
60}
61#endif
62
63// ===========================================================================
64// class definitions
65// ===========================================================================
66
68
69public:
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 {
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
242protected:
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
301private:
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
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
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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: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.
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:94
virtual std::string getParentName() const
Returns the name of the parent object (if any)
virtual void onLeftBtnPress(void *)
notify object about left click
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.
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.
FXIcon * myIcon
icon associatd with this GL Object
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,...
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