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-2022 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
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 = 0;
175
177 virtual Boundary getCenteringBoundary() const = 0;
178
181 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
182
184 virtual bool isGLObjectLocked();
185
187 virtual void markAsFrontElement();
188
190 virtual void deleteGLObject();
191
193 virtual void selectGLObject();
194
196 virtual void updateGLObject();
197
198 virtual double getColorValue(const GUIVisualizationSettings& /*s*/, int /*activeScheme*/) const {
199 return 0;
200 }
202
207 virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
208
210 virtual void removeActiveAddVisualisation(GUISUMOAbstractView* const /*parent*/, int /*which*/) {}
211
213 virtual void onLeftBtnPress(void* /*data*/) {}
214
215#ifdef HAVE_OSG
217 osg::Node* getNode() const;
218
220 void setNode(osg::Node* node);
221#endif
222
228
233
235 void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0, bool forceShow = false) const;
236
237protected:
240
244 void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
245
250 void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
251
256 void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
257
262 void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
263
268 void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
269
274 void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
275
281 void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, const GUIMainWindow& app) const;
282
287 void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
289
291 void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
292
294 void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
295
297 void mouseWithinGeometry(const Position center, const double radius) const;
298
300 void mouseWithinGeometry(const PositionVector shape) const;
301
303 void mouseWithinGeometry(const PositionVector shape, const double width) const;
304
306 void mouseWithinGeometry(const PositionVector shape, const double width, GUIGlObject* parent) const;
307
309 void mouseWithinGeometry(const Position& pos, const double width, const double height,
310 const double offsetX, const double offsetY, const double rot) const;
311
312private:
315
318
320 std::string myMicrosimID;
321
323 std::string myFullName;
324
326 FXIcon* myIcon;
327
330
332 std::set<GUIParameterTableWindow*> myParamWindows;
333
334#ifdef HAVE_OSG
336 osg::Node* myOSGNode;
337#endif
338
340 std::string createFullName() const;
341
344
346 GUIGlObject(const GUIGlObject&) = delete;
347
350};
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GUIGlObjectType
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.
Definition: GUIGlObject.h:141
std::string myMicrosimID
ID of GL object.
Definition: GUIGlObject.h:320
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:198
virtual void markAsFrontElement()
mark element as front element (Currently used only in NETEDIT)
std::string myFullName
full name of GL Object
Definition: GUIGlObject.h:323
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:164
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.
Definition: GUIGlObject.h:317
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.
Definition: GUIGlObject.h:159
static StringBijection< GUIGlObjectType >::Entry GUIGlObjectTypeNamesInitializer[]
vector for TypeNames Initializer
Definition: GUIGlObject.h:343
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
Definition: GUIGlObject.h:213
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 mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
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.
Definition: GUIGlObject.h:154
virtual ~GUIGlObject()
Destructor.
void setBlocked(const bool state=true)
set blocking status
Definition: GUIGlObject.h:169
bool myAmBlocked
whether the object can be deleted
Definition: GUIGlObject.h:329
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 double getExaggeration(const GUIVisualizationSettings &s) const =0
return exaggeration associated with this GLObject
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:326
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
Definition: GUIGlObject.h:122
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
std::string createFullName() const
create full name
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:332
GUIGlObject(GUIGlObjectType type, const std::string &microsimID, FXIcon *icon)
Constructor.
virtual void removeActiveAddVisualisation(GUISUMOAbstractView *const, int)
remove additional user-griggered visualisations
Definition: GUIGlObject.h:210
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own popup-menu.
const GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:314
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.