SUMO - Simulation of Urban MObility
GUIGlObject.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Base class for all objects that may be displayed within the openGL-gui
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <stack>
36 #include <utils/common/ToString.h>
46 #include <utils/gui/div/GLHelper.h>
47 #include "GUIGlObject.h"
48 #include "GUIGlObjectStorage.h"
49 
50 #ifdef CHECK_MEMORY_LEAKS
51 #include <foreign/nvwa/debug_new.h>
52 #endif // CHECK_MEMORY_LEAKS
53 
54 // ===========================================================================
55 // static members
56 // ===========================================================================
58  {"network", GLO_NETWORK},
59  {"edge", GLO_EDGE},
60  {"lane", GLO_LANE},
61  {"junction", GLO_JUNCTION},
62  {"tlLogic", GLO_TLLOGIC},
63  {"detector", GLO_DETECTOR},
64  {"trigger", GLO_TRIGGER},
65  {"additional", GLO_ADDITIONAL},
66  {"polygon", GLO_POLYGON},
67  {"poi", GLO_POI},
68  {"vehicle", GLO_VEHICLE},
69  {"person", GLO_PERSON},
70  {"container", GLO_CONTAINER},
71  {"undefined", GLO_MAX}
72 };
73 
74 
76  GUIGlObjectTypeNamesInitializer, GLO_MAX);
77 
78 // ===========================================================================
79 // method definitions
80 // ===========================================================================
81 GUIGlObject::GUIGlObject(GUIGlObjectType type, const std::string& microsimID) :
82  myGLObjectType(type),
83  myMicrosimID(microsimID),
84  myPrefix(TypeNames.getString(type)) {
87 }
88 
89 
90 GUIGlObject::GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID) :
91  myGLObjectType(type),
92  myMicrosimID(microsimID),
93  myPrefix(prefix) {
96 }
97 
98 
99 
101  for (std::set<GUIParameterTableWindow*>::iterator i = myParamWindows.begin(); i != myParamWindows.end(); ++i) {
102  (*i)->removeObject(this);
103  }
105 }
106 
107 
108 void
109 GUIGlObject::setMicrosimID(const std::string& newID) {
110  myMicrosimID = newID;
112 }
113 
114 
115 void
117  bool addSeparator) {
118  new MFXMenuHeader(ret, app.getBoldFont(), getFullName().c_str(), 0, 0, 0);
119  if (addSeparator) {
120  new FXMenuSeparator(ret);
121  }
122 }
123 
124 
125 void
128  if (addSeparator) {
129  new FXMenuSeparator(ret);
130  }
131 }
132 
133 
134 void
136  new FXMenuCommand(ret, "Copy name to clipboard", 0, ret, MID_COPY_NAME);
137  new FXMenuCommand(ret, "Copy typed name to clipboard", 0, ret, MID_COPY_TYPED_NAME);
138  if (addSeparator) {
139  new FXMenuSeparator(ret);
140  }
141 }
142 
143 
144 void
146  if (gSelected.isSelected(getType(), getGlID())) {
147  new FXMenuCommand(ret, "Remove From Selected", GUIIconSubSys::getIcon(ICON_FLAG_MINUS), ret, MID_REMOVESELECT);
148  } else {
149  new FXMenuCommand(ret, "Add To Selected", GUIIconSubSys::getIcon(ICON_FLAG_PLUS), ret, MID_ADDSELECT);
150  }
151  if (addSeparator) {
152  new FXMenuSeparator(ret);
153  }
154 }
155 
156 
157 void
159  new FXMenuCommand(ret, "Show Parameter", GUIIconSubSys::getIcon(ICON_APP_TABLE), ret, MID_SHOWPARS);
160  if (addSeparator) {
161  new FXMenuSeparator(ret);
162  }
163 }
164 
165 
166 void
168  new FXMenuCommand(ret, "Copy cursor position to clipboard", 0, ret, MID_COPY_CURSOR_POSITION);
169  if (GeoConvHelper::getFinal().usingGeoProjection()) {
170  new FXMenuCommand(ret, "Copy cursor geo-position to clipboard", 0, ret, MID_COPY_CURSOR_GEOPOSITION);
171  }
172  if (addSeparator) {
173  new FXMenuSeparator(ret);
174  }
175 }
176 
177 
178 void
180  new FXMenuCommand(ret, "Open Manipulator...", GUIIconSubSys::getIcon(ICON_MANIP), ret, MID_MANIP);
181  if (addSeparator) {
182  new FXMenuSeparator(ret);
183  }
184 }
185 
186 
187 void
189  myParamWindows.insert(t);
190 }
191 
192 
193 void
195  std::set<GUIParameterTableWindow*>::iterator i = myParamWindows.find(t);
196  if (i != myParamWindows.end()) {
197  myParamWindows.erase(i);
198  }
199 }
200 
201 
202 void
203 GUIGlObject::setPrefix(const std::string& prefix) {
204  myPrefix = prefix;
206 }
207 
208 std::string
210  return myPrefix + ":" + getMicrosimID();
211 }
212 
213 
214 void
215 GUIGlObject::drawName(const Position& pos, const SUMOReal scale,
216  const GUIVisualizationTextSettings& settings, const SUMOReal angle) const {
217  if (settings.show) {
218  GLHelper::drawText(getMicrosimID(), pos, GLO_MAX, settings.size / scale, settings.color, angle);
219  }
220 }
221 
222 /****************************************************************************/
223 
a lane speed trigger,
Center view to object - popup entry.
Definition: GUIAppEnum.h:215
a polygon
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
GUIGlObjectType
a vehicles
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:278
std::string createFullName() const
bool remove(GUIGlID id)
Removes the named object from this container.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:146
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:219
static void drawText(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &col=RGBColor::BLACK, const SUMOReal angle=0)
draw Text with given parameters
Definition: GLHelper.cpp:459
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
Remove from selected items - Menu Etry.
Definition: GUIAppEnum.h:235
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
a container
void removeParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was closed.
Copy object name - popup entry.
Definition: GUIAppEnum.h:217
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
a person
std::string myMicrosimID
Definition: GUIGlObject.h:283
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
a tl-logic
virtual ~GUIGlObject()
Destructor.
void addParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was opened.
FXFont * getBoldFont()
Open the object's manipulator.
Definition: GUIAppEnum.h:237
Show object parameter - popup entry.
Definition: GUIAppEnum.h:225
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
a detector
compound additional
void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the manipulator window.
void setMicrosimID(const std::string &newID)
Changes the microsimID of the object (happens in NETEDIT)
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:99
Add to selected items - menu entry.
Definition: GUIAppEnum.h:233
The popup menu of a globject.
an edge
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
static StringBijection< GUIGlObjectType >::Entry GUIGlObjectTypeNamesInitializer[]
Definition: GUIGlObject.h:300
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
The network - empty.
std::string myPrefix
Definition: GUIGlObject.h:285
std::string myFullName
Definition: GUIGlObject.h:287
GUIGlID registerObject(GUIGlObject *object, const std::string &fullName)
Registers an object.
#define SUMOReal
Definition: config.h:218
Copy cursor geo-coordinate position - popup entry.
Definition: GUIAppEnum.h:223
empty max
GUIGlObject(GUIGlObjectType type, const std::string &microsimID)
Constructor.
Definition: GUIGlObject.cpp:81
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:290
void setPrefix(const std::string &prefix)
const std::string & getFullName() const
Returns the full name appearing in the tool tip.
Definition: GUIGlObject.h:107
Copy cursor position - popup entry.
Definition: GUIAppEnum.h:221
GUISelectedStorage gSelected
A global holder of selected objects.
A window containing a gl-object's parameter.
static FXIcon * getIcon(GUIIcon which)
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
a junction