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-2023 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
56
57#ifdef HAVE_OSG
58namespace osg {
59class Node;
60}
61#endif
62
63// ===========================================================================
64// class definitions
65// ===========================================================================
66
68public:
71 static const GUIGlID INVALID_ID;
72
83 GUIGlObject(GUIGlObjectType type, const std::string& microsimID, FXIcon* icon);
84
86 virtual ~GUIGlObject();
87
92 inline const std::string& getFullName() const {
93 return myFullName;
94 }
95
98 virtual std::string getParentName() const;
99
102 inline GUIGlID getGlID() const {
103 return myGlID;
104 }
105
107 FXIcon* getGLIcon() const;
108
110
113
120
122 virtual void removedPopupMenu() {}
123
131
139
141 inline const std::string& getMicrosimID() const {
142 return myMicrosimID;
143 }
144
146 virtual const std::string getOptionalName() const;
147
150 virtual void setMicrosimID(const std::string& newID);
151
154 inline GUIGlObjectType getType() const {
155 return myGLObjectType;
156 }
157
159 virtual double getClickPriority() const {
160 return (double)myGLObjectType;
161 }
162
164 inline bool isBlocked() const {
165 return myAmBlocked;
166 }
167
169 inline void setBlocked(const bool state = true) {
170 myAmBlocked = state;
171 }
172
174 virtual double getExaggeration(const GUIVisualizationSettings& s) const {
176 return 1.;
177 }
178
180 virtual Boundary getCenteringBoundary() const = 0;
181
184 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
185
187 virtual bool isGLObjectLocked();
188
190 virtual void markAsFrontElement();
191
193 virtual void deleteGLObject();
194
196 virtual void selectGLObject();
197
199 virtual void updateGLObject();
200
201 virtual double getColorValue(const GUIVisualizationSettings& /*s*/, int /*activeScheme*/) const {
202 return 0;
203 }
205
210 virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
211
213 virtual void removeActiveAddVisualisation(GUISUMOAbstractView* const /*parent*/, int /*which*/) {}
214
216 virtual void onLeftBtnPress(void* /*data*/) {}
217
218#ifdef HAVE_OSG
220 osg::Node* getNode() const;
221
223 void setNode(osg::Node* node);
224#endif
225
231
236
238 void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0, bool forceShow = false) const;
239
240protected:
243
247 void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
248
253 void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
254
259 void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
260
265 void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
266
271 void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
272
277 void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
278
284 void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, const GUIMainWindow& app) const;
285
290 void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
292
294 void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
295
297 void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
298
300 bool mouseWithinGeometry(const Position center, const double radius) const;
301
303 bool mouseWithinGeometry(const PositionVector shape) const;
304
306 bool mouseWithinGeometry(const PositionVector shape, const double width) const;
307
309 bool mouseWithinGeometry(const PositionVector shape, const double width, GUIGlObject* parent) const;
310
312 bool mouseWithinGeometry(const Position& pos, const double width, const double height,
313 const double offsetX, const double offsetY, const double rot) const;
314
315private:
318
321
323 std::string myMicrosimID;
324
326 std::string myFullName;
327
329 FXIcon* myIcon;
330
333
335 std::set<GUIParameterTableWindow*> myParamWindows;
336
337#ifdef HAVE_OSG
339 osg::Node* myOSGNode;
340#endif
341
343 std::string createFullName() const;
344
347
349 GUIGlObject(const GUIGlObject&) = delete;
350
353};
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
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:71
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:51
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:92
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:70
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
bool mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
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()
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
A list of positions.