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 #ifdef WIN32
35 #include <windows.h>
36 #endif
37 
38 #include <GL/gl.h>
39 
40 #include <string>
41 #include <stack>
42 #include <utils/common/ToString.h>
52 #include <utils/gui/div/GLHelper.h>
53 #include "GUIGlObject.h"
54 #include "GUIGlObjectStorage.h"
55 
56 #ifdef CHECK_MEMORY_LEAKS
57 #include <foreign/nvwa/debug_new.h>
58 #endif // CHECK_MEMORY_LEAKS
59 
60 // ===========================================================================
61 // static members
62 // ===========================================================================
64  {"network", GLO_NETWORK},
65  {"edge", GLO_EDGE},
66  {"lane", GLO_LANE},
67  {"junction", GLO_JUNCTION},
68  {"tlLogic", GLO_TLLOGIC},
69  {"detector", GLO_DETECTOR},
70  {"trigger", GLO_TRIGGER},
71  {"shape", GLO_SHAPE},
72  {"vehicle", GLO_VEHICLE},
73  {"additional", GLO_ADDITIONAL},
74  {"undefined", GLO_MAX}
75 };
76 
77 
79  GUIGlObjectTypeNamesInitializer, GLO_MAX);
80 
81 // ===========================================================================
82 // method definitions
83 // ===========================================================================
84 GUIGlObject::GUIGlObject(GUIGlObjectType type, const std::string& microsimID) :
85  myGLObjectType(type),
86  myMicrosimID(microsimID),
87  myPrefix(TypeNames.getString(type)) {
90 }
91 
92 
93 GUIGlObject::GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID) :
94  myGLObjectType(type),
95  myMicrosimID(microsimID),
96  myPrefix(prefix) {
99 }
100 
101 
102 
104  for (std::set<GUIParameterTableWindow*>::iterator i = myParamWindows.begin(); i != myParamWindows.end(); ++i) {
105  (*i)->removeObject(this);
106  }
108 }
109 
110 
111 void
112 GUIGlObject::setMicrosimID(const std::string& newID) {
113  myMicrosimID = newID;
115 }
116 
117 
118 void
120  bool addSeparator) {
121  new MFXMenuHeader(ret, app.getBoldFont(), getFullName().c_str(), 0, 0, 0);
122  if (addSeparator) {
123  new FXMenuSeparator(ret);
124  }
125 }
126 
127 
128 void
131  if (addSeparator) {
132  new FXMenuSeparator(ret);
133  }
134 }
135 
136 
137 void
139  new FXMenuCommand(ret, "Copy name to clipboard", 0, ret, MID_COPY_NAME);
140  new FXMenuCommand(ret, "Copy typed name to clipboard", 0, ret, MID_COPY_TYPED_NAME);
141  if (addSeparator) {
142  new FXMenuSeparator(ret);
143  }
144 }
145 
146 
147 void
149  if (gSelected.isSelected(getType(), getGlID())) {
150  new FXMenuCommand(ret, "Remove From Selected", GUIIconSubSys::getIcon(ICON_FLAG_MINUS), ret, MID_REMOVESELECT);
151  } else {
152  new FXMenuCommand(ret, "Add To Selected", GUIIconSubSys::getIcon(ICON_FLAG_PLUS), ret, MID_ADDSELECT);
153  }
154  if (addSeparator) {
155  new FXMenuSeparator(ret);
156  }
157 }
158 
159 
160 void
162  new FXMenuCommand(ret, "Show Parameter", GUIIconSubSys::getIcon(ICON_APP_TABLE), ret, MID_SHOWPARS);
163  if (addSeparator) {
164  new FXMenuSeparator(ret);
165  }
166 }
167 
168 
169 void
171  new FXMenuCommand(ret, "Copy cursor position to clipboard", 0, ret, MID_COPY_CURSOR_POSITION);
172  if (GeoConvHelper::getFinal().usingGeoProjection()) {
173  new FXMenuCommand(ret, "Copy cursor geo-position to clipboard", 0, ret, MID_COPY_CURSOR_GEOPOSITION);
174  }
175  if (addSeparator) {
176  new FXMenuSeparator(ret);
177  }
178 }
179 
180 
181 void
183  new FXMenuCommand(ret, "Open Manipulator...", GUIIconSubSys::getIcon(ICON_MANIP), ret, MID_MANIP);
184  if (addSeparator) {
185  new FXMenuSeparator(ret);
186  }
187 }
188 
189 
190 void
192  myParamWindows.insert(t);
193 }
194 
195 
196 void
198  std::set<GUIParameterTableWindow*>::iterator i = myParamWindows.find(t);
199  if (i != myParamWindows.end()) {
200  myParamWindows.erase(i);
201  }
202 }
203 
204 
205 void
206 GUIGlObject::setPrefix(const std::string& prefix) {
207  myPrefix = prefix;
209 }
210 
211 std::string
213  return myPrefix + ":" + getMicrosimID();
214 }
215 
216 
217 void
218 GUIGlObject::drawName(const Position& pos, const SUMOReal scale,
219  const GUIVisualizationTextSettings& settings, const SUMOReal angle) const {
220  if (settings.show) {
221  GLHelper::drawText(getMicrosimID(), pos, GLO_MAX, settings.size / scale, settings.color, angle);
222  }
223 }
224 
225 /****************************************************************************/
226