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.sourceforge.net/
13 // Copyright (C) 2001-2012 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