SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
13 // Copyright (C) 2001-2014 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  {"undefined", GLO_MAX}
71 };
72 
73 
75  GUIGlObjectTypeNamesInitializer, GLO_MAX);
76 
77 // ===========================================================================
78 // method definitions
79 // ===========================================================================
80 GUIGlObject::GUIGlObject(GUIGlObjectType type, const std::string& microsimID) :
81  myGLObjectType(type),
82  myMicrosimID(microsimID),
83  myPrefix(TypeNames.getString(type)) {
86 }
87 
88 
89 GUIGlObject::GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID) :
90  myGLObjectType(type),
91  myMicrosimID(microsimID),
92  myPrefix(prefix) {
95 }
96 
97 
98 
100  for (std::set<GUIParameterTableWindow*>::iterator i = myParamWindows.begin(); i != myParamWindows.end(); ++i) {
101  (*i)->removeObject(this);
102  }
104 }
105 
106 
107 void
108 GUIGlObject::setMicrosimID(const std::string& newID) {
109  myMicrosimID = newID;
111 }
112 
113 
114 void
116  bool addSeparator) {
117  new MFXMenuHeader(ret, app.getBoldFont(), getFullName().c_str(), 0, 0, 0);
118  if (addSeparator) {
119  new FXMenuSeparator(ret);
120  }
121 }
122 
123 
124 void
127  if (addSeparator) {
128  new FXMenuSeparator(ret);
129  }
130 }
131 
132 
133 void
135  new FXMenuCommand(ret, "Copy name to clipboard", 0, ret, MID_COPY_NAME);
136  new FXMenuCommand(ret, "Copy typed name to clipboard", 0, ret, MID_COPY_TYPED_NAME);
137  if (addSeparator) {
138  new FXMenuSeparator(ret);
139  }
140 }
141 
142 
143 void
145  if (gSelected.isSelected(getType(), getGlID())) {
146  new FXMenuCommand(ret, "Remove From Selected", GUIIconSubSys::getIcon(ICON_FLAG_MINUS), ret, MID_REMOVESELECT);
147  } else {
148  new FXMenuCommand(ret, "Add To Selected", GUIIconSubSys::getIcon(ICON_FLAG_PLUS), ret, MID_ADDSELECT);
149  }
150  if (addSeparator) {
151  new FXMenuSeparator(ret);
152  }
153 }
154 
155 
156 void
158  new FXMenuCommand(ret, "Show Parameter", GUIIconSubSys::getIcon(ICON_APP_TABLE), ret, MID_SHOWPARS);
159  if (addSeparator) {
160  new FXMenuSeparator(ret);
161  }
162 }
163 
164 
165 void
167  new FXMenuCommand(ret, "Copy cursor position to clipboard", 0, ret, MID_COPY_CURSOR_POSITION);
168  if (GeoConvHelper::getFinal().usingGeoProjection()) {
169  new FXMenuCommand(ret, "Copy cursor geo-position to clipboard", 0, ret, MID_COPY_CURSOR_GEOPOSITION);
170  }
171  if (addSeparator) {
172  new FXMenuSeparator(ret);
173  }
174 }
175 
176 
177 void
179  new FXMenuCommand(ret, "Open Manipulator...", GUIIconSubSys::getIcon(ICON_MANIP), ret, MID_MANIP);
180  if (addSeparator) {
181  new FXMenuSeparator(ret);
182  }
183 }
184 
185 
186 void
188  myParamWindows.insert(t);
189 }
190 
191 
192 void
194  std::set<GUIParameterTableWindow*>::iterator i = myParamWindows.find(t);
195  if (i != myParamWindows.end()) {
196  myParamWindows.erase(i);
197  }
198 }
199 
200 
201 void
202 GUIGlObject::setPrefix(const std::string& prefix) {
203  myPrefix = prefix;
205 }
206 
207 std::string
209  return myPrefix + ":" + getMicrosimID();
210 }
211 
212 
213 void
214 GUIGlObject::drawName(const Position& pos, const SUMOReal scale,
215  const GUIVisualizationTextSettings& settings, const SUMOReal angle) const {
216  if (settings.show) {
217  GLHelper::drawText(getMicrosimID(), pos, GLO_MAX, settings.size / scale, settings.color, angle);
218  }
219 }
220 
221 /****************************************************************************/
222 
Copy cursor position - popup entry.
Definition: GUIAppEnum.h:215
a lane speed trigger,
a polygon
Copy object name - popup entry.
Definition: GUIAppEnum.h:211
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
GUIGlObjectType
a vehicles
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:213
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.
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:378
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
Add to selected items - menu entry.
Definition: GUIAppEnum.h:227
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
Center view to object - popup entry.
Definition: GUIAppEnum.h:209
void removeParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was closed.
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.
Definition: GUIGlObject.cpp:99
void addParameterTable(GUIParameterTableWindow *w)
Lets this object know a parameter window showing the object's values was opened.
Remove from selected items - Menu Etry.
Definition: GUIAppEnum.h:229
FXFont * getBoldFont()
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.
Show object parameter - popup entry.
Definition: GUIAppEnum.h:219
void setMicrosimID(const std::string &newID)
Changes the microsimID of the object (happens in NETEDIT)
Copy cursor geo-coordinate position - popup entry.
Definition: GUIAppEnum.h:217
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:99
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:215
empty max
GUIGlObject(GUIGlObjectType type, const std::string &microsimID)
Constructor.
Definition: GUIGlObject.cpp:80
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
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
Open the object's manipulator.
Definition: GUIAppEnum.h:231