SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIVisualizationSettings.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Stores the information about how to visualize structures
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <map>
34 #include <vector>
36 #include "GUIColorScheme.h"
37 
38 #ifdef CHECK_MEMORY_LEAKS
39 #include <foreign/nvwa/debug_new.h>
40 #endif // CHECK_MEMORY_LEAKS
41 
42 // ===========================================================================
43 // static members
44 // ===========================================================================
45 #ifdef HAVE_INTERNAL
46 bool GUIVisualizationSettings::UseMesoSim = false;
47 #endif
48 
49 // ===========================================================================
50 // member method definitions
51 // ===========================================================================
53  : name(""), antialiase(false), dither(false),
54  backgroundColor(RGBColor::WHITE),
55  showGrid(false), gridXSize(100), gridYSize(100),
56  laneShowBorders(false), showLinkDecals(true), showRails(true),
57  edgeName(false, 50, RGBColor(255, 128, 0, 255)),
58  internalEdgeName(false, 40, RGBColor(128, 64, 0, 255)),
59  streetName(false, 55, RGBColor::YELLOW),
60  hideConnectors(false), laneWidthExaggeration(1), vehicleQuality(0),
61  minVehicleSize(1), vehicleExaggeration(1), showBlinker(true),
62  drawLaneChangePreference(false), drawMinGap(false),
63  vehicleName(false, 50, RGBColor(204, 153, 0, 255)),
64  drawLinkTLIndex(false), drawLinkJunctionIndex(false),
65  junctionName(false, 50, RGBColor(0, 255, 128, 255)),
66  internalJunctionName(false, 50, RGBColor(0, 204, 128, 255)),
67  showLane2Lane(false), addMode(0), minAddSize(1), addExaggeration(1),
68  addName(false, 50, RGBColor(255, 0, 128, 255)),
69  minPOISize(0), poiExaggeration(1), poiName(false, 50, RGBColor(255, 0, 128, 255)),
70  minPolySize(0), polyExaggeration(1), polyName(false, 50, RGBColor(255, 0, 128, 255)),
71  showSizeLegend(true),
72  gaming(false),
73  selectionScale(1) {
75  GUIColorScheme scheme = GUIColorScheme("uniform", RGBColor::BLACK, "", true);
76  laneColorer.addScheme(scheme);
77  scheme = GUIColorScheme("by selection (lane-/streetwise)", RGBColor(179, 179, 179, 255), "unselected", true);
78  scheme.addColor(RGBColor(0, 102, 204, 255), 1, "selected");
79  laneColorer.addScheme(scheme);
80  scheme = GUIColorScheme("by vclass", RGBColor::BLACK, "all", true);
81  scheme.addColor(RGBColor(0, 26, 128, 255), 1, "public");
82  laneColorer.addScheme(scheme);
83  // ... traffic states ...
84  scheme = GUIColorScheme("by allowed speed (lanewise)", RGBColor::RED);
85  scheme.addColor(RGBColor::BLUE, (SUMOReal)(150.0 / 3.6));
86  laneColorer.addScheme(scheme);
87  scheme = GUIColorScheme("by current occupancy (lanewise)", RGBColor::BLUE);
88  scheme.addColor(RGBColor::RED, (SUMOReal)0.95);
89  laneColorer.addScheme(scheme);
90  scheme = GUIColorScheme("by first vehicle waiting time (lanewise)", RGBColor::GREEN);
91  scheme.addColor(RGBColor::RED, (SUMOReal)200);
92  laneColorer.addScheme(scheme);
93  scheme = GUIColorScheme("by lane number (streetwise)", RGBColor::RED);
94  scheme.addColor(RGBColor::BLUE, (SUMOReal)5);
95  laneColorer.addScheme(scheme);
96  // ... emissions ...
97  scheme = GUIColorScheme("by CO2 emissions (HBEFA)", RGBColor::GREEN);
98  scheme.addColor(RGBColor::RED, (SUMOReal)(10. / 7.5 / 5.));
99  laneColorer.addScheme(scheme);
100  scheme = GUIColorScheme("by CO emissions (HBEFA)", RGBColor::GREEN);
101  scheme.addColor(RGBColor::RED, (SUMOReal)(0.05 / 7.5 / 2.));
102  laneColorer.addScheme(scheme);
103  scheme = GUIColorScheme("by PMx emissions (HBEFA)", RGBColor::GREEN);
104  scheme.addColor(RGBColor::RED, (SUMOReal)(.005 / 7.5 / 5.));
105  laneColorer.addScheme(scheme);
106  scheme = GUIColorScheme("by NOx emissions (HBEFA)", RGBColor::GREEN);
107  scheme.addColor(RGBColor::RED, (SUMOReal)(.125 / 7.5 / 5.));
108  laneColorer.addScheme(scheme);
109  scheme = GUIColorScheme("by HC emissions (HBEFA)", RGBColor::GREEN);
110  scheme.addColor(RGBColor::RED, (SUMOReal)(.02 / 7.5 / 4.));
111  laneColorer.addScheme(scheme);
112  scheme = GUIColorScheme("by fuel consumption (HBEFA)", RGBColor::GREEN);
113  scheme.addColor(RGBColor::RED, (SUMOReal)(.005 / 7.5 * 100.));
114  laneColorer.addScheme(scheme);
115  scheme = GUIColorScheme("by noise emissions (Harmonoise)", RGBColor::GREEN);
116  scheme.addColor(RGBColor::RED, (SUMOReal)100);
117  laneColorer.addScheme(scheme);
118  // ... weights (experimental) ...
119  scheme = GUIColorScheme("by global travel time", RGBColor::GREEN);
120  scheme.addColor(RGBColor::RED, (SUMOReal)100);
121  scheme.setAllowsNegativeValues(true);
122  laneColorer.addScheme(scheme);
123  scheme = GUIColorScheme("by global speed percentage", RGBColor::RED);
124  scheme.addColor(RGBColor::YELLOW, (SUMOReal)50);
125  scheme.addColor(RGBColor::GREEN, (SUMOReal)100);
126  scheme.setAllowsNegativeValues(true);
127  laneColorer.addScheme(scheme);
128 
129 
131  vehicleColorer.addScheme(GUIColorScheme("given vehicle/type/route color", RGBColor::YELLOW, "", true));
133  vehicleColorer.addScheme(GUIColorScheme("given/assigned vehicle color", RGBColor::YELLOW, "", true));
134  vehicleColorer.addScheme(GUIColorScheme("given/assigned type color", RGBColor::YELLOW, "", true));
135  vehicleColorer.addScheme(GUIColorScheme("given/assigned route color", RGBColor::YELLOW, "", true));
136  vehicleColorer.addScheme(GUIColorScheme("depart position as HSV", RGBColor::YELLOW, "", true));
137  vehicleColorer.addScheme(GUIColorScheme("arrival position as HSV", RGBColor::YELLOW, "", true));
138  vehicleColorer.addScheme(GUIColorScheme("direction/distance as HSV", RGBColor::YELLOW, "", true));
139  scheme = GUIColorScheme("by speed", RGBColor::RED);
140  scheme.addColor(RGBColor::BLUE, (SUMOReal)(150.0 / 3.6));
141  vehicleColorer.addScheme(scheme);
142  scheme = GUIColorScheme("by waiting time", RGBColor::BLUE);
143  scheme.addColor(RGBColor::RED, (SUMOReal)(5 * 60));
144  vehicleColorer.addScheme(scheme);
145  scheme = GUIColorScheme("by time since last lanechange", RGBColor::WHITE);
146  scheme.addColor(RGBColor::GREY, (SUMOReal)(5 * 60));
147  vehicleColorer.addScheme(scheme);
148  scheme = GUIColorScheme("by max speed", RGBColor::RED);
149  scheme.addColor(RGBColor::BLUE, (SUMOReal)(150.0 / 3.6));
150  vehicleColorer.addScheme(scheme);
151  // ... emissions ...
152  scheme = GUIColorScheme("by CO2 emissions (HBEFA)", RGBColor::GREEN);
153  scheme.addColor(RGBColor::RED, (SUMOReal)5.);
154  vehicleColorer.addScheme(scheme);
155  scheme = GUIColorScheme("by CO emissions (HBEFA)", RGBColor::GREEN);
156  scheme.addColor(RGBColor::RED, (SUMOReal)0.05);
157  vehicleColorer.addScheme(scheme);
158  scheme = GUIColorScheme("by PMx emissions (HBEFA)", RGBColor::GREEN);
159  scheme.addColor(RGBColor::RED, (SUMOReal).005);
160  vehicleColorer.addScheme(scheme);
161  scheme = GUIColorScheme("by NOx emissions (HBEFA)", RGBColor::GREEN);
162  scheme.addColor(RGBColor::RED, (SUMOReal).125);
163  vehicleColorer.addScheme(scheme);
164  scheme = GUIColorScheme("by HC emissions (HBEFA)", RGBColor::GREEN);
165  scheme.addColor(RGBColor::RED, (SUMOReal).02);
166  vehicleColorer.addScheme(scheme);
167  scheme = GUIColorScheme("by fuel consumption (HBEFA)", RGBColor::GREEN);
168  scheme.addColor(RGBColor::RED, (SUMOReal).005);
169  vehicleColorer.addScheme(scheme);
170  scheme = GUIColorScheme("by noise emissions (Harmonoise)", RGBColor::GREEN);
171  scheme.addColor(RGBColor::RED, (SUMOReal)100.);
172  vehicleColorer.addScheme(scheme);
173  scheme = GUIColorScheme("by reroute number", RGBColor::RED);
174  scheme.addColor(RGBColor::YELLOW, (SUMOReal)1.);
175  scheme.addColor(RGBColor::WHITE, (SUMOReal)10.);
176  vehicleColorer.addScheme(scheme);
177 
178 #ifdef HAVE_INTERNAL
179 
180  edgeColorer.addScheme(GUIColorScheme("uniform (streetwise)", RGBColor::BLACK, "", true));
181  scheme = GUIColorScheme("by selection (streetwise)", RGBColor(179, 179, 179, 255), "unselected", true);
182  scheme.addColor(RGBColor(0, 102, 204, 255), 1, "selected");
183  edgeColorer.addScheme(scheme);
184  scheme = GUIColorScheme("by purpose (streetwise)", RGBColor(), "normal", true);
185  scheme.addColor(RGBColor(128, 0, 128, 255), 1, "connector"); // see MSEdge::EdgeBasicFunction::EDGEFUNCTION_CONNECTOR
186  scheme.addColor(RGBColor::BLUE, 2, "internal"); // see MSEdge::EdgeBasicFunction::EDGEFUNCTION_INTERNAL
187  edgeColorer.addScheme(scheme);
188  scheme = GUIColorScheme("by allowed speed (streetwise)", RGBColor::RED);
189  scheme.addColor(RGBColor::BLUE, (SUMOReal)(150.0 / 3.6));
190  edgeColorer.addScheme(scheme);
191  scheme = GUIColorScheme("by current occupancy (streetwise)", RGBColor::BLUE);
192  scheme.addColor(RGBColor::RED, (SUMOReal)0.95);
193  edgeColorer.addScheme(scheme);
194  scheme = GUIColorScheme("by current speed (streetwise)", RGBColor::RED);
195  scheme.addColor(RGBColor::BLUE, (SUMOReal)(150.0 / 3.6));
196  edgeColorer.addScheme(scheme);
197  scheme = GUIColorScheme("by current flow (streetwise)", RGBColor::BLUE);
198  scheme.addColor(RGBColor::RED, (SUMOReal)5000);
199  edgeColorer.addScheme(scheme);
200  scheme = GUIColorScheme("by relative speed (streetwise)", RGBColor::RED);
201  scheme.addColor(RGBColor::BLUE, (SUMOReal)1);
202  edgeColorer.addScheme(scheme);
203 #endif
204 
206  scheme = GUIColorScheme("by selection", RGBColor(179, 179, 179, 255), "unselected", true);
207  scheme.addColor(RGBColor(0, 102, 204, 255), 1, "selected");
208  junctionColorer.addScheme(scheme);
209 }
210 
211 
212 size_t
214 #ifdef HAVE_INTERNAL
215  if (UseMesoSim) {
216  return edgeColorer.getActive();
217  }
218 #endif
219  return laneColorer.getActive();
220 }
221 
222 
225 #ifdef HAVE_INTERNAL
226  if (UseMesoSim) {
227  return edgeColorer.getScheme();
228  }
229 #endif
230  return laneColorer.getScheme();
231 }
232 
233 
234 void
236  dev << "<viewsettings>\n";
237  dev << " <scheme name=\"" << name << "\">\n";
238  dev << " <opengl antialiase=\"" << antialiase << "\" dither=\"" << dither << "\"/>\n";
239  dev << " <background backgroundColor=\"" << backgroundColor << "\"\n"
240  << " showGrid=\"" << showGrid
241  << "\" gridXSize=\"" << gridXSize << "\" gridYSize=\"" << gridYSize << "\"/>\n";
242  dev << " <edges laneEdgeMode=\"" << getLaneEdgeMode()
243  << "\" laneShowBorders=\"" << laneShowBorders
244  << "\" showLinkDecals=\"" << showLinkDecals
245  << "\" showRails=\"" << showRails
246  << "\" hideConnectors=\"" << hideConnectors << "\"\n"
247  << " " << edgeName.print("edgeName") << "\n"
248  << " " << internalEdgeName.print("internalEdgeName") << "\n"
249  << " " << streetName.print("streetName") << ">\n";
250  laneColorer.save(dev);
251 #ifdef HAVE_INTERNAL
252  edgeColorer.save(dev);
253 #endif
254  dev << " </edges>\n";
255 
256  dev << " <vehicles vehicleMode=\"" << vehicleColorer.getActive()
257  << "\" vehicleQuality=\"" << vehicleQuality
258  << "\" minVehicleSize=\"" << minVehicleSize
259  << "\" vehicleExaggeration=\"" << vehicleExaggeration
260  << "\" showBlinker=\"" << showBlinker << "\"\n"
261  << " " << vehicleName.print("vehicleName")
262  << ">\n";
263  vehicleColorer.save(dev);
264  dev << " </vehicles>\n";
265 
266  dev << " <junctions junctionMode=\"" << junctionColorer.getActive()
267  << "\" drawLinkTLIndex=\"" << drawLinkTLIndex
268  << "\" drawLinkJunctionIndex=\"" << drawLinkJunctionIndex << "\"\n"
269  << " " << junctionName.print("junctionName") << "\n"
270  << " " << internalJunctionName.print("internalJunctionName") << "\n"
271  << " showLane2Lane=\"" << showLane2Lane << "\">\n";
272  junctionColorer.save(dev);
273  dev << " </junctions>\n";
274 
275  dev << " <additionals addMode=\"" << addMode
276  << "\" minAddSize=\"" << minAddSize
277  << "\" addExaggeration=\"" << addExaggeration << "\"\n"
278  << " " << addName.print("addName")
279  << "/>\n";
280 
281  dev << " <pois poiExaggeration=\"" << poiExaggeration
282  << "\" minPOISize=\"" << minPOISize << "\"\n"
283  << " " << poiName.print("poiName")
284  << "/>\n";
285 
286  dev << " <polys polyExaggeration=\"" << polyExaggeration
287  << "\" minPolySize=\"" << minPolySize << "\"\n"
288  << " " << polyName.print("polyName")
289  << "/>\n";
290 
291  dev << " <legend showSizeLegend=\"" << showSizeLegend << "\"/>\n";
292  dev << " </scheme>\n";
293  dev << "</viewsettings>\n";
294 }
295 
296 
297 bool
299  if (antialiase != v2.antialiase) {
300  return false;
301  }
302  if (dither != v2.dither) {
303  return false;
304  }
305  if (backgroundColor != v2.backgroundColor) {
306  return false;
307  }
308  if (showGrid != v2.showGrid) {
309  return false;
310  }
311  if (gridXSize != v2.gridXSize) {
312  return false;
313  }
314  if (gridYSize != v2.gridYSize) {
315  return false;
316  }
317 
318 #ifdef HAVE_INTERNAL
319  if (!(edgeColorer == v2.edgeColorer)) {
320  return false;
321  }
322 #endif
323  if (!(laneColorer == v2.laneColorer)) {
324  return false;
325  }
326  if (laneShowBorders != v2.laneShowBorders) {
327  return false;
328  }
329  if (showLinkDecals != v2.showLinkDecals) {
330  return false;
331  }
332  if (showRails != v2.showRails) {
333  return false;
334  }
335  if (edgeName != v2.edgeName) {
336  return false;
337  }
339  return false;
340  }
341  if (streetName != v2.streetName) {
342  return false;
343  }
344  if (hideConnectors != v2.hideConnectors) {
345  return false;
346  }
348  return false;
349  }
350  if (!(vehicleColorer == v2.vehicleColorer)) {
351  return false;
352  }
353  if (vehicleQuality != v2.vehicleQuality) {
354  return false;
355  }
356  if (minVehicleSize != v2.minVehicleSize) {
357  return false;
358  }
360  return false;
361  }
362  if (showBlinker != v2.showBlinker) {
363  return false;
364  }
366  return false;
367  }
368  if (drawMinGap != v2.drawMinGap) {
369  return false;
370  }
371  if (vehicleName != v2.vehicleName) {
372  return false;
373  }
374  if (!(junctionColorer == v2.junctionColorer)) {
375  return false;
376  }
377  if (drawLinkTLIndex != v2.drawLinkTLIndex) {
378  return false;
379  }
381  return false;
382  }
383  if (junctionName != v2.junctionName) {
384  return false;
385  }
387  return false;
388  }
389 
390  if (showLane2Lane != v2.showLane2Lane) {
391  return false;
392  }
393 
394  if (addMode != v2.addMode) {
395  return false;
396  }
397  if (minAddSize != v2.minAddSize) {
398  return false;
399  }
400  if (addExaggeration != v2.addExaggeration) {
401  return false;
402  }
403  if (addName != v2.addName) {
404  return false;
405  }
406 
407  if (minPOISize != v2.minPOISize) {
408  return false;
409  }
410  if (poiExaggeration != v2.poiExaggeration) {
411  return false;
412  }
413  if (poiName != v2.poiName) {
414  return false;
415  }
416 
417  if (minPolySize != v2.minPolySize) {
418  return false;
419  }
421  return false;
422  }
423  if (polyName != v2.polyName) {
424  return false;
425  }
426 
427  if (showSizeLegend != v2.showSizeLegend) {
428  return false;
429  }
430 
431  return true;
432 }
433 
434 
435 
436 /****************************************************************************/
437