SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIDialog_ViewSettings.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // The dialog to change the view (gui) settings.
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
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 <fstream>
38 #include <utils/common/RGBColor.h>
40 #include <utils/common/ToString.h>
49 #include "GUIDialog_ViewSettings.h"
50 
51 #ifdef CHECK_MEMORY_LEAKS
52 #include <foreign/nvwa/debug_new.h>
53 #endif // CHECK_MEMORY_LEAKS
54 
55 
56 // ===========================================================================
57 // FOX callback mapping
58 // ===========================================================================
59 FXDEFMAP(GUIDialog_ViewSettings) GUIDialog_ViewSettingsMap[] = {
63  FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_OK, GUIDialog_ViewSettings::onCmdOk),
66 
75 
78 
79 };
80 
81 
82 FXIMPLEMENT(GUIDialog_ViewSettings, FXDialogBox, GUIDialog_ViewSettingsMap, ARRAYNUMBER(GUIDialog_ViewSettingsMap))
83 
84 
85 // ===========================================================================
86 // method definitions
87 // ===========================================================================
89  GUIVisualizationSettings* settings,
90  std::vector<GUISUMOAbstractView::Decal>* decals,
91  MFXMutex* decalsLock) :
92  FXDialogBox(parent, "View Settings", DECOR_TITLE | DECOR_BORDER | DECOR_RESIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
93  myParent(parent), mySettings(settings),
94  myDecals(decals), myDecalsLock(decalsLock),
95  myDecalsTable(0) {
96  myBackup = (*mySettings);
97 
98  FXVerticalFrame* contentFrame =
99  new FXVerticalFrame(this, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y,
100  0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
101  //
102  {
103  FXHorizontalFrame* frame0 =
104  new FXHorizontalFrame(contentFrame, FRAME_THICK, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
105  mySchemeName = new FXComboBox(frame0, 20, this, MID_SIMPLE_VIEW_NAMECHANGE, COMBOBOX_INSERT_LAST | FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_CENTER_Y | COMBOBOX_STATIC);
106  const std::vector<std::string>& names = gSchemeStorage.getNames();
107  for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
108  size_t index = mySchemeName->appendItem((*i).c_str());
109  if ((*i) == mySettings->name) {
110  mySchemeName->setCurrentItem((FXint) index);
111  }
112  }
113  mySchemeName->setNumVisible(5);
114 
115  new FXButton(frame0, "\t\tSave the setting to registry",
117  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
118  new FXButton(frame0, "\t\tRemove the setting from registry",
120  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
121  new FXButton(frame0, "\t\tExport setting to file",
123  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
124  new FXButton(frame0, "\t\tLoad setting from file",
126  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
127 
128  }
129  //
130  FXTabBook* tabbook =
131  new FXTabBook(contentFrame, 0, 0, TABBOOK_LEFTTABS | PACK_UNIFORM_WIDTH | PACK_UNIFORM_HEIGHT | LAYOUT_FILL_X | LAYOUT_FILL_Y | LAYOUT_RIGHT,
132  0, 0, 0, 0, 0, 0, 0, 0);
133  {
134  // tab for the background
135  new FXTabItem(tabbook, "Background", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
136  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
137  FXVerticalFrame* frame1 =
138  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
139 
140  FXMatrix* m11 =
141  new FXMatrix(frame1, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
142  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
143  new FXLabel(m11, "Color", 0, LAYOUT_CENTER_Y);
144  myBackgroundColor = new FXColorWell(m11, MFXUtils::getFXColor(settings->backgroundColor),
146  LAYOUT_FIX_WIDTH | LAYOUT_CENTER_Y | LAYOUT_SIDE_TOP | FRAME_SUNKEN | FRAME_THICK | ICON_AFTER_TEXT,
147  0, 0, 100, 0, 0, 0, 0, 0);
148 
149  new FXHorizontalSeparator(frame1, SEPARATOR_GROOVE | LAYOUT_FILL_X);
150 
151  FXVerticalFrame* frame11 =
152  new FXVerticalFrame(frame1, LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
153  new FXLabel(frame11, "Decals:");
154  myDecalsFrame = new FXVerticalFrame(frame11);
155  FXHorizontalFrame* frame111 = new FXHorizontalFrame(frame11, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
156  new FXButton(frame111, "&Load Decals", NULL, this, MID_SIMPLE_VIEW_LOAD_DECALS, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 20, 20, 4, 4);
157  new FXButton(frame111, "&Save Decals", NULL, this, MID_SIMPLE_VIEW_SAVE_DECALS, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 20, 20, 4, 4);
158 
159  new FXHorizontalSeparator(frame1, SEPARATOR_GROOVE | LAYOUT_FILL_X);
160 
161  FXMatrix* m12 =
162  new FXMatrix(frame1, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
163  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
164  myShowGrid =
165  new FXCheckButton(m12, "Show grid", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
166  myShowGrid->setCheck(mySettings->showGrid);
167  new FXLabel(m12, "");
168  FXMatrix* m121 =
169  new FXMatrix(m12, 2, LAYOUT_CENTER_Y | LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
170  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
171  new FXLabel(m121, "x-spacing", 0, LAYOUT_CENTER_Y);
172  myGridXSizeDialer =
173  new FXRealSpinDial(m121, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
174  LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
175  myGridXSizeDialer->setRange(1, 10000);
176  myGridXSizeDialer->setValue(mySettings->gridXSize);
177  FXMatrix* m122 =
178  new FXMatrix(m12, 2, LAYOUT_CENTER_Y | LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
179  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
180  new FXLabel(m122, "y-spacing", 0, LAYOUT_CENTER_Y);
181  myGridYSizeDialer =
182  new FXRealSpinDial(m122, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
183  LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
184  myGridYSizeDialer->setRange(1, 10000);
185  myGridYSizeDialer->setValue(mySettings->gridXSize);
186  }
187  {
188  // tab for the streets
189  new FXTabItem(tabbook, "Streets", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
190  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
191  FXVerticalFrame* frame2 =
192  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
193  // ... color settings
194  FXVerticalFrame* frame22 =
195  new FXVerticalFrame(frame2, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
196  FXMatrix* m21 =
197  new FXMatrix(frame22, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
198  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
199  new FXLabel(m21, "Color", 0, LAYOUT_CENTER_Y);
200  myLaneEdgeColorMode = new FXComboBox(m21, 30, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
201  myLaneEdgeColorMode->setNumVisible(21);
202  myLaneColorInterpolation = new FXCheckButton(m21, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
203  myLaneColorSettingFrame = new FXVerticalFrame(frame22, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
204 
205  new FXHorizontalSeparator(frame2, SEPARATOR_GROOVE | LAYOUT_FILL_X);
206  // ... scale settings
207  FXVerticalFrame* frame23 =
208  new FXVerticalFrame(frame2, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
209  FXMatrix* m23 =
210  new FXMatrix(frame23, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
211  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
212  new FXLabel(m23, "Scale width", 0, LAYOUT_CENTER_Y);
213  myLaneEdgeScaleMode = new FXComboBox(m23, 30, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
214  myLaneEdgeScaleMode->setNumVisible(21);
215  myLaneScaleInterpolation = new FXCheckButton(m23, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
216  myLaneScaleSettingFrame = new FXVerticalFrame(frame23, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
217 
218 #ifdef HAVE_INTERNAL
219  if (GUIVisualizationSettings::UseMesoSim) {
220  mySettings->edgeColorer.fill(*myLaneEdgeColorMode);
221  mySettings->edgeScaler.fill(*myLaneEdgeScaleMode);
222  } else {
223 #endif
224  mySettings->laneColorer.fill(*myLaneEdgeColorMode);
225  mySettings->laneScaler.fill(*myLaneEdgeScaleMode);
226 #ifdef HAVE_INTERNAL
227  }
228 #endif
229 
230  new FXHorizontalSeparator(frame2, SEPARATOR_GROOVE | LAYOUT_FILL_X);
231  FXMatrix* m22 =
232  new FXMatrix(frame2, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
233  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
234  myShowLaneBorders = new FXCheckButton(m22, "Show lane borders", this, MID_SIMPLE_VIEW_COLORCHANGE);
235  myShowLaneBorders->setCheck(mySettings->laneShowBorders);
236  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
237  myShowLaneDecals = new FXCheckButton(m22, "Show link decals", this, MID_SIMPLE_VIEW_COLORCHANGE);
238  myShowLaneDecals->setCheck(mySettings->showLinkDecals);
239  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
240  myShowRails = new FXCheckButton(m22, "Show rails", this, MID_SIMPLE_VIEW_COLORCHANGE);
241  myShowRails->setCheck(mySettings->showRails);
242  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
243  myHideMacroConnectors = new FXCheckButton(m22, "Hide macro connectors", this, MID_SIMPLE_VIEW_COLORCHANGE);
244  myHideMacroConnectors->setCheck(mySettings->hideConnectors);
245  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
246  new FXLabel(m22, "Exaggerate width by", 0, LAYOUT_CENTER_Y);
247  myLaneWidthUpscaleDialer =
248  new FXRealSpinDial(m22, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
249  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
250  myLaneWidthUpscaleDialer->setRange(0, 10000);
251  myLaneWidthUpscaleDialer->setValue(mySettings->laneWidthExaggeration);
252 
253  // edge name
254  myEdgeNamePanel = new NamePanel(m22, this, "Show edge name", mySettings->edgeName);
255  myStreetNamePanel = new NamePanel(m22, this, "Show street name", mySettings->streetName);
256  myInternalEdgeNamePanel = new NamePanel(m22, this, "Show internal edge name", mySettings->internalEdgeName);
257  myCwaEdgeNamePanel = new NamePanel(m22, this, "Show crossing and walkingarea name", mySettings->cwaEdgeName);
258  }
259  {
260  // vehicles
261  new FXTabItem(tabbook, "Vehicles", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
262  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
263  FXVerticalFrame* frame3 =
264  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
265 
266  FXMatrix* m31 =
267  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
268  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
269  new FXLabel(m31, "Show As", 0, LAYOUT_CENTER_Y);
270  myVehicleShapeDetail = new FXComboBox(m31, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
271  myVehicleShapeDetail->appendItem("'triangles'");
272  myVehicleShapeDetail->appendItem("'boxes'");
273  myVehicleShapeDetail->appendItem("'simple shapes'");
274  myVehicleShapeDetail->appendItem("'raster images'");
275  myVehicleShapeDetail->setNumVisible(4);
276  myVehicleShapeDetail->setCurrentItem(settings->vehicleQuality);
277 
278  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
279 
280  FXMatrix* m32 =
281  new FXMatrix(frame3, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
282  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
283  new FXLabel(m32, "Color", 0, LAYOUT_CENTER_Y);
284  myVehicleColorMode = new FXComboBox(m32, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
285  mySettings->vehicleColorer.fill(*myVehicleColorMode);
286  myVehicleColorMode->setNumVisible(24);
287  myVehicleColorInterpolation = new FXCheckButton(m32, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
288 
289  myVehicleColorSettingFrame =
290  new FXVerticalFrame(frame3, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
291 
292  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
293 
294  FXMatrix* m33 =
295  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
296  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
297  myShowBlinker = new FXCheckButton(m33, "Show blinker / brake lights", this, MID_SIMPLE_VIEW_COLORCHANGE);
298  myShowBlinker->setCheck(mySettings->showBlinker);
299  new FXLabel(m33, " ", 0, LAYOUT_CENTER_Y);
300  myShowMinGap = new FXCheckButton(m33, "Show minimum gap", this, MID_SIMPLE_VIEW_COLORCHANGE);
301  myShowMinGap->setCheck(mySettings->drawMinGap);
302  new FXLabel(m33, " ", 0, LAYOUT_CENTER_Y);
303  myShowBTRange = new FXCheckButton(m33, "Show Bluetooth range", this, MID_SIMPLE_VIEW_COLORCHANGE);
304  myShowBTRange->setCheck(mySettings->showBTRange);
305  new FXLabel(m33, " ", 0, LAYOUT_CENTER_Y);
306  /*
307  myShowLaneChangePreference = new FXCheckButton(m33, "Show lane change preference", this, MID_SIMPLE_VIEW_COLORCHANGE);
308  myShowLaneChangePreference->setCheck(mySettings->drawLaneChangePreference);
309  new FXLabel(m33, " ", 0, LAYOUT_CENTER_Y);
310  */
311  myVehicleNamePanel = new NamePanel(m33, this, "Show vehicle name", mySettings->vehicleName);
312  /*
313  FXCheckButton *tmpc = new FXCheckButton(m33, "Show braking lights", 0 ,0);
314  tmpc->disable();
315  tmpc = new FXCheckButton(m33, "Show needed headway", 0 ,0);
316  tmpc->disable();
317  */
318 
319  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
320 
321  FXMatrix* m34 =
322  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
323  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
324  myVehicleSizePanel = new SizePanel(m34, this, mySettings->vehicleSize);
325  }
326 
327  {
328  // persons
329  new FXTabItem(tabbook, "Persons", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
330  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
331  FXVerticalFrame* frame3 =
332  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
333 
334  FXMatrix* m101 =
335  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
336  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
337  new FXLabel(m101, "Show As", 0, LAYOUT_CENTER_Y);
338  myPersonShapeDetail = new FXComboBox(m101, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
339  myPersonShapeDetail->appendItem("'triangles'");
340  myPersonShapeDetail->appendItem("'boxes'");
341  myPersonShapeDetail->appendItem("'simple shapes'");
342  myPersonShapeDetail->appendItem("'raster images'");
343  myPersonShapeDetail->setNumVisible(4);
344  myPersonShapeDetail->setCurrentItem(settings->personQuality);
345 
346  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
347 
348  FXMatrix* m102 =
349  new FXMatrix(frame3, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
350  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
351  new FXLabel(m102, "Color", 0, LAYOUT_CENTER_Y);
352  myPersonColorMode = new FXComboBox(m102, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
353  mySettings->personColorer.fill(*myPersonColorMode);
354  myPersonColorMode->setNumVisible(9);
355  myPersonColorInterpolation = new FXCheckButton(m102, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
356 
357  myPersonColorSettingFrame =
358  new FXVerticalFrame(frame3, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
359 
360  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
361 
362  FXMatrix* m103 =
363  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
364  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
365  myPersonNamePanel = new NamePanel(m103, this, "Show person name", mySettings->personName);
366 
367  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
368 
369  FXMatrix* m104 =
370  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
371  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
372  myPersonSizePanel = new SizePanel(m104, this, mySettings->personSize);
373  }
374  {
375  // nodes
376  new FXTabItem(tabbook, "Junctions", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
377  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
378  FXVerticalFrame* frame4 =
379  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
380  FXMatrix* m41 =
381  new FXMatrix(frame4, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
382  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
383  new FXLabel(m41, "Color", 0, LAYOUT_CENTER_Y);
384  myJunctionColorMode = new FXComboBox(m41, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
385  mySettings->junctionColorer.fill(*myJunctionColorMode);
386  myJunctionColorMode->setNumVisible(3);
387  myJunctionColorInterpolation = new FXCheckButton(m41, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
388 
389  myJunctionColorSettingFrame =
390  new FXVerticalFrame(frame4, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
391 
392  new FXHorizontalSeparator(frame4, SEPARATOR_GROOVE | LAYOUT_FILL_X);
393  FXMatrix* m42 =
394  new FXMatrix(frame4, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
395  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
396  myShowTLIndex = new FXCheckButton(m42, "Show link tls index", this, MID_SIMPLE_VIEW_COLORCHANGE);
397  myShowTLIndex->setCheck(mySettings->drawLinkTLIndex);
398  new FXLabel(m42, " ", 0, LAYOUT_CENTER_Y);
399  myShowJunctionIndex = new FXCheckButton(m42, "Show link junction index", this, MID_SIMPLE_VIEW_COLORCHANGE);
400  myShowJunctionIndex->setCheck(mySettings->drawLinkJunctionIndex);
401  new FXLabel(m42, " ", 0, LAYOUT_CENTER_Y);
402  myShowLane2Lane = new FXCheckButton(m42, "Show lane to lane connections", this, MID_SIMPLE_VIEW_COLORCHANGE);
403  myShowLane2Lane->setCheck(mySettings->showLane2Lane);
404  new FXLabel(m42, " ", 0, LAYOUT_CENTER_Y);
405  myJunctionNamePanel = new NamePanel(m42, this, "Show junction name", mySettings->junctionName);
406  myInternalJunctionNamePanel = new NamePanel(m42, this, "Show internal junction name", mySettings->internalJunctionName);
407  myDrawJunctionShape = new FXCheckButton(m42, "Draw junction shape", this, MID_SIMPLE_VIEW_COLORCHANGE);
408  myDrawJunctionShape->setCheck(mySettings->drawJunctionShape);
409  } {
410  // detectors / triggers
411  new FXTabItem(tabbook, "Detectors/Trigger", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
412  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
413  FXVerticalFrame* frame5 =
414  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
415 
416  FXMatrix* m51 =
417  new FXMatrix(frame5, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
418  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
419  myAddNamePanel = new NamePanel(m51, this, "Show detector name", mySettings->addName);
420  new FXHorizontalSeparator(frame5 , SEPARATOR_GROOVE | LAYOUT_FILL_X);
421 
422  FXMatrix* m52 =
423  new FXMatrix(frame5, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
424  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
425  myAddSizePanel = new SizePanel(m52, this, mySettings->addSize);
426 
427  /*
428  new FXLabel(m522, "Color", 0, LAYOUT_CENTER_Y);
429  myDetectorNameColor = new FXColorWell(m522, MFXUtils::getFXColor(settings->addNameColor),
430  this, MID_SIMPLE_VIEW_COLORCHANGE,
431  LAYOUT_FIX_WIDTH|LAYOUT_CENTER_Y|LAYOUT_SIDE_TOP|FRAME_SUNKEN|FRAME_THICK|ICON_AFTER_TEXT,
432  0, 0, 100, 0, 0, 0, 0, 0);
433  */
434  } {
435  // POIs
436  new FXTabItem(tabbook, "POIs", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
437  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
438  FXVerticalFrame* frame6 =
439  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
440 
441  FXMatrix* m61 =
442  new FXMatrix(frame6, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
443  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
444  myPOINamePanel = new NamePanel(m61, this, "Show poi names", mySettings->poiName);
445  new FXHorizontalSeparator(frame6 , SEPARATOR_GROOVE | LAYOUT_FILL_X);
446 
447  FXMatrix* m62 =
448  new FXMatrix(frame6, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
449  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
450  myPOISizePanel = new SizePanel(m62, this, mySettings->poiSize);
451 
452  } {
453  // Polygons
454  new FXTabItem(tabbook, "Polygons", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
455  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
456  FXVerticalFrame* frame9 =
457  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
458 
459  FXMatrix* m91 =
460  new FXMatrix(frame9, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
461  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
462  myPolyNamePanel = new NamePanel(m91, this, "Show polygon names", mySettings->polyName);
463  new FXHorizontalSeparator(frame9 , SEPARATOR_GROOVE | LAYOUT_FILL_X);
464 
465  myPolySizePanel = new SizePanel(m91, this, mySettings->polySize);
466 
467  }{
468  // Legend
469  new FXTabItem(tabbook, "Legend", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
470  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
471  FXVerticalFrame* frame7 =
472  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
473 
474  FXMatrix* m72 =
475  new FXMatrix(frame7, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
476  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
477  myShowSizeLegend = new FXCheckButton(m72, "Show Size Legend", this, MID_SIMPLE_VIEW_COLORCHANGE);
478  myShowSizeLegend->setCheck(mySettings->showSizeLegend);
479  new FXLabel(m72, "");
480  } {
481  // openGL
482  new FXTabItem(tabbook, "openGL", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
483  FXScrollWindow* genScroll = new FXScrollWindow(tabbook);
484  FXVerticalFrame* frame8 =
485  new FXVerticalFrame(genScroll, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
486 
487  FXMatrix* m82 =
488  new FXMatrix(frame8, 1, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
489  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
490  myAntialiase = new FXCheckButton(m82, "Antialiase", this, MID_SIMPLE_VIEW_COLORCHANGE);
491  myAntialiase->setCheck(mySettings->antialiase);
492  myDither = new FXCheckButton(m82, "Dither", this, MID_SIMPLE_VIEW_COLORCHANGE);
493  myDither->setCheck(mySettings->dither);
494  }
495  FXHorizontalFrame* f2 = new FXHorizontalFrame(contentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
496  FXButton* initial = new FXButton(f2, "&Use", NULL, this, MID_SETTINGS_OK, BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
497  new FXButton(f2, "&Discard", NULL, this, MID_SETTINGS_CANCEL, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
498  initial->setFocus();
499 
500  rebuildColorMatrices(false);
502 
503  setX(getApp()->reg().readIntEntry("VIEWSETTINGS", "x", 150));
504  setY(getApp()->reg().readIntEntry("VIEWSETTINGS", "y", 150));
505  setWidth(getApp()->reg().readIntEntry("VIEWSETTINGS", "width", 700));
506  setHeight(getApp()->reg().readIntEntry("VIEWSETTINGS", "height", 500));
507 }
508 
509 
511  myParent->remove(this);
512  // delete name panels
515  delete myCwaEdgeNamePanel;
516  delete myStreetNamePanel;
517  delete myJunctionNamePanel;
518  delete myVehicleNamePanel;
519  delete myAddNamePanel;
520  delete myPOINamePanel;
521  delete myPolyNamePanel;
522  delete myEdgeNamePanel;
523  // delete size panels
524  delete myVehicleSizePanel;
525  delete myPersonSizePanel;
526  delete myPOISizePanel;
527  delete myPolySizePanel;
528  delete myAddSizePanel;
529 }
530 
531 
532 void
534  mySettings = settings;
535  myBackup = (*settings);
536  onCmdNameChange(0, 0, 0);
537 }
538 
539 
540 long
542  saveWindowSize();
543  hide();
544  return 1;
545 }
546 
547 
548 long
550  saveWindowSize();
551  hide();
552  (*mySettings) = myBackup;
553  return 1;
554 }
555 
556 
557 long
559  if (data != 0) {
560  FXString dataS = (char*) data; // !!!unicode
561  // check whether this item has been added twice
562  if (dataS == mySchemeName->getItemText(mySchemeName->getNumItems() - 1)) {
563  for (int i = 0; i < mySchemeName->getNumItems() - 1; ++i) {
564  if (dataS == mySchemeName->getItemText(i)) {
565  mySchemeName->removeItem(i);
566  }
567  }
568  }
569  myBackup = gSchemeStorage.get(dataS.text());
570  mySettings = &gSchemeStorage.get(dataS.text());
571  }
572  rebuildColorMatrices(true);
573 
575 
576  myLaneEdgeColorMode->setCurrentItem((FXint) mySettings->getLaneEdgeMode());
577  myLaneEdgeScaleMode->setCurrentItem((FXint) mySettings->getLaneEdgeScaleMode());
580  myShowRails->setCheck(mySettings->showRails);
587 
588  myVehicleColorMode->setCurrentItem((FXint) mySettings->vehicleColorer.getActive());
591  myShowMinGap->setCheck(mySettings->drawMinGap);
593  /*
594  myShowLaneChangePreference->setCheck(mySettings->drawLaneChangePreference);
595  */
598 
599  myPersonColorMode->setCurrentItem((FXint) mySettings->personColorer.getActive());
600  myPersonShapeDetail->setCurrentItem(mySettings->personQuality);
603 
604  myJunctionColorMode->setCurrentItem((FXint) mySettings->junctionColorer.getActive());
609 
612 
615 
618 
621  myAntialiase->setCheck(mySettings->antialiase);
622  myDither->setCheck(mySettings->dither);
624 
626  update();
627  myParent->update();
628  return 1;
629 }
630 
631 
632 bool
633 GUIDialog_ViewSettings::updateColorRanges(FXObject* sender, std::vector<FXColorWell*>::const_iterator colIt,
634  std::vector<FXColorWell*>::const_iterator colEnd,
635  std::vector<FXRealSpinDial*>::const_iterator threshIt,
636  std::vector<FXRealSpinDial*>::const_iterator threshEnd,
637  std::vector<FXButton*>::const_iterator buttonIt,
638  GUIColorScheme& scheme) {
639  size_t pos = 0;
640  while (colIt != colEnd) {
641  if (scheme.isFixed()) {
642  if (sender == *colIt) {
643  scheme.setColor(pos, MFXUtils::getRGBColor((*colIt)->getRGBA()));
644  }
645  } else {
646  if (sender == *threshIt) {
647  const SUMOReal val = (*threshIt)->getValue();
648  double lo, hi;
649  if (pos != 0) {
650  threshIt--;
651  (*threshIt)->getRange(lo, hi);
652  (*threshIt)->setRange(lo, val);
653  threshIt++;
654  }
655  threshIt++;
656  if (threshIt != threshEnd) {
657  (*threshIt)->getRange(lo, hi);
658  (*threshIt)->setRange(val, hi);
659  }
660  scheme.setThreshold(pos, val);
661  return false;
662  }
663  if (sender == *colIt) {
664  scheme.setColor(pos, MFXUtils::getRGBColor((*colIt)->getRGBA()));
665  return false;
666  }
667  if (sender == *buttonIt) {
668  if (pos == 0) {
669  scheme.addColor(MFXUtils::getRGBColor((*colIt)->getRGBA()), (*threshIt)->getValue());
670  } else {
671  scheme.removeColor(pos);
672  }
673  return true;
674  }
675  ++threshIt;
676  ++buttonIt;
677  }
678  ++colIt;
679  pos++;
680  }
681  return false;
682 }
683 
684 
685 bool
686 GUIDialog_ViewSettings::updateScaleRanges(FXObject* sender, std::vector<FXRealSpinDial*>::const_iterator scaleIt,
687  std::vector<FXRealSpinDial*>::const_iterator scaleEnd,
688  std::vector<FXRealSpinDial*>::const_iterator threshIt,
689  std::vector<FXRealSpinDial*>::const_iterator threshEnd,
690  std::vector<FXButton*>::const_iterator buttonIt,
691  GUIScaleScheme& scheme) {
692  size_t pos = 0;
693  while (scaleIt != scaleEnd) {
694  if (scheme.isFixed()) {
695  if (sender == *scaleIt) {
696  scheme.setColor(pos, (*scaleIt)->getValue());
697  }
698  } else {
699  if (sender == *threshIt) {
700  const SUMOReal val = (*threshIt)->getValue();
701  double lo, hi;
702  if (pos != 0) {
703  threshIt--;
704  (*threshIt)->getRange(lo, hi);
705  (*threshIt)->setRange(lo, val);
706  threshIt++;
707  }
708  threshIt++;
709  if (threshIt != threshEnd) {
710  (*threshIt)->getRange(lo, hi);
711  (*threshIt)->setRange(val, hi);
712  }
713  scheme.setThreshold(pos, val);
714  return false;
715  }
716  if (sender == *scaleIt) {
717  scheme.setColor(pos, (*scaleIt)->getValue());
718  return false;
719  }
720  if (sender == *buttonIt) {
721  if (pos == 0) {
722  scheme.addColor((*scaleIt)->getValue(), (*threshIt)->getValue());
723  } else {
724  scheme.removeColor(pos);
725  }
726  return true;
727  }
728  ++threshIt;
729  ++buttonIt;
730  }
731  ++scaleIt;
732  pos++;
733  }
734  return false;
735 }
736 
737 
738 long
739 GUIDialog_ViewSettings::onCmdColorChange(FXObject* sender, FXSelector, void* /*val*/) {
740  GUIVisualizationSettings tmpSettings = *mySettings;
741  size_t prevLaneMode = mySettings->getLaneEdgeMode();
742  size_t prevLaneScaleMode = mySettings->getLaneEdgeScaleMode();
743  size_t prevVehicleMode = mySettings->vehicleColorer.getActive();
744  size_t prevPersonMode = mySettings->personColorer.getActive();
745  size_t prevJunctionMode = mySettings->junctionColorer.getActive();
746  bool doRebuildColorMatrices = false;
747 
748  tmpSettings.name = mySettings->name;
749  tmpSettings.backgroundColor = MFXUtils::getRGBColor(myBackgroundColor->getRGBA());
750  tmpSettings.showGrid = (myShowGrid->getCheck() != FALSE);
751  tmpSettings.gridXSize = (SUMOReal) myGridXSizeDialer->getValue();
752  tmpSettings.gridYSize = (SUMOReal) myGridYSizeDialer->getValue();
753 
754 #ifdef HAVE_INTERNAL
755  if (GUIVisualizationSettings::UseMesoSim) {
756  tmpSettings.edgeColorer.setActive(myLaneEdgeColorMode->getCurrentItem());
757  tmpSettings.edgeScaler.setActive(myLaneEdgeScaleMode->getCurrentItem());
758  } else {
759 #endif
760  tmpSettings.laneColorer.setActive(myLaneEdgeColorMode->getCurrentItem());
761  tmpSettings.laneScaler.setActive(myLaneEdgeScaleMode->getCurrentItem());
762 #ifdef HAVE_INTERNAL
763  }
764 #endif
765  tmpSettings.laneShowBorders = (myShowLaneBorders->getCheck() != FALSE);
766  tmpSettings.showLinkDecals = (myShowLaneDecals->getCheck() != FALSE);
767  tmpSettings.showRails = (myShowRails->getCheck() != FALSE);
768  tmpSettings.edgeName = myEdgeNamePanel->getSettings();
770  tmpSettings.cwaEdgeName = myCwaEdgeNamePanel->getSettings();
771  tmpSettings.streetName = myStreetNamePanel->getSettings();
772  tmpSettings.hideConnectors = (myHideMacroConnectors->getCheck() != FALSE);
773  tmpSettings.laneWidthExaggeration = (SUMOReal) myLaneWidthUpscaleDialer->getValue();
774 
775  tmpSettings.vehicleColorer.setActive(myVehicleColorMode->getCurrentItem());
776  tmpSettings.vehicleQuality = myVehicleShapeDetail->getCurrentItem();
777  tmpSettings.showBlinker = (myShowBlinker->getCheck() != FALSE);
778  tmpSettings.drawMinGap = (myShowMinGap->getCheck() != FALSE);
779  tmpSettings.showBTRange = (myShowBTRange->getCheck() != FALSE);
780  /*
781  tmpSettings.drawLaneChangePreference = (myShowLaneChangePreference->getCheck() != FALSE);
782  */
783  tmpSettings.vehicleName = myVehicleNamePanel->getSettings();
784  tmpSettings.vehicleSize = myVehicleSizePanel->getSettings();
785 
786  tmpSettings.personColorer.setActive(myPersonColorMode->getCurrentItem());
787  tmpSettings.personQuality = myPersonShapeDetail->getCurrentItem();
788  tmpSettings.personName = myPersonNamePanel->getSettings();
789  tmpSettings.personSize = myPersonSizePanel->getSettings();
790 
791  tmpSettings.junctionColorer.setActive(myJunctionColorMode->getCurrentItem());
792  tmpSettings.drawLinkTLIndex = (myShowTLIndex->getCheck() != FALSE);
793  tmpSettings.drawLinkJunctionIndex = (myShowJunctionIndex->getCheck() != FALSE);
796 
797  tmpSettings.addName = myAddNamePanel->getSettings();
798  tmpSettings.addSize = myAddSizePanel->getSettings();
799 
800  tmpSettings.poiName = myPOINamePanel->getSettings();
801  tmpSettings.poiSize = myPOISizePanel->getSettings();
802 
803  tmpSettings.polyName = myPolyNamePanel->getSettings();
804  tmpSettings.polySize = myPolySizePanel->getSettings();
805 
806  tmpSettings.showLane2Lane = (myShowLane2Lane->getCheck() != FALSE);
807  tmpSettings.drawJunctionShape = (myDrawJunctionShape->getCheck() != FALSE);
808  tmpSettings.antialiase = (myAntialiase->getCheck() != FALSE);
809  tmpSettings.dither = (myDither->getCheck() != FALSE);
810  tmpSettings.showSizeLegend = (myShowSizeLegend->getCheck() != FALSE);
811 
812  // lanes (colors)
813  if (tmpSettings.getLaneEdgeMode() == prevLaneMode) {
814  if (updateColorRanges(sender, myLaneColors.begin(), myLaneColors.end(),
815  myLaneThresholds.begin(), myLaneThresholds.end(), myLaneButtons.begin(),
816  tmpSettings.getLaneEdgeScheme())) {
817  doRebuildColorMatrices = true;
818  }
819  if (sender == myLaneColorInterpolation) {
820  tmpSettings.getLaneEdgeScheme().setInterpolated(myLaneColorInterpolation->getCheck() != FALSE);
821  doRebuildColorMatrices = true;
822  }
823  } else {
824  doRebuildColorMatrices = true;
825  }
826  // lanes (scaling)
827  if (tmpSettings.getLaneEdgeScaleMode() == prevLaneScaleMode) {
828  if (updateScaleRanges(sender, myLaneScales.begin(), myLaneScales.end(),
830  tmpSettings.getLaneEdgeScaleScheme())) {
831  doRebuildColorMatrices = true;
832  }
833  if (sender == myLaneScaleInterpolation) {
834  tmpSettings.getLaneEdgeScaleScheme().setInterpolated(myLaneScaleInterpolation->getCheck() != FALSE);
835  doRebuildColorMatrices = true;
836  }
837  } else {
838  doRebuildColorMatrices = true;
839  }
840  // vehicles
841  if (tmpSettings.vehicleColorer.getActive() == prevVehicleMode) {
842  if (updateColorRanges(sender, myVehicleColors.begin(), myVehicleColors.end(),
844  tmpSettings.vehicleColorer.getScheme())) {
845  doRebuildColorMatrices = true;
846  }
847  if (sender == myVehicleColorInterpolation) {
848  tmpSettings.vehicleColorer.getScheme().setInterpolated(myVehicleColorInterpolation->getCheck() != FALSE);
849  doRebuildColorMatrices = true;
850  }
851  } else {
852  doRebuildColorMatrices = true;
853  }
854  // persons
855  if (tmpSettings.personColorer.getActive() == prevPersonMode) {
856  if (updateColorRanges(sender, myPersonColors.begin(), myPersonColors.end(),
857  myPersonThresholds.begin(), myPersonThresholds.end(), myPersonButtons.begin(),
858  tmpSettings.personColorer.getScheme())) {
859  doRebuildColorMatrices = true;
860  }
861  if (sender == myPersonColorInterpolation) {
862  tmpSettings.personColorer.getScheme().setInterpolated(myPersonColorInterpolation->getCheck() != FALSE);
863  doRebuildColorMatrices = true;
864  }
865  } else {
866  doRebuildColorMatrices = true;
867  }
868  // junctions
869  if (tmpSettings.junctionColorer.getActive() == prevJunctionMode) {
870  if (updateColorRanges(sender, myJunctionColors.begin(), myJunctionColors.end(),
872  tmpSettings.junctionColorer.getScheme())) {
873  doRebuildColorMatrices = true;
874  }
875  if (sender == myJunctionColorInterpolation) {
876  tmpSettings.junctionColorer.getScheme().setInterpolated(myJunctionColorInterpolation->getCheck() != FALSE);
877  doRebuildColorMatrices = true;
878  }
879  } else {
880  doRebuildColorMatrices = true;
881  }
882 
883  if (tmpSettings == *mySettings) {
884  return 1;
885  }
886 
887  int index = mySchemeName->getCurrentItem();
888  if (index < (int) gSchemeStorage.getNumInitialSettings()) {
889  // one of the initial settings is modified
890  // every time this happens we create a new scheme
891  int suffix = 1;
892  while (gSchemeStorage.contains("custom_" + toString(suffix))) {
893  suffix++;
894  }
895  tmpSettings.name = "custom_" + toString(suffix);
896  // the newly created settings must be entered in several places:
897  // - the comboBox mySchemeName of this dialog
898  // - the comboBox of the parent view (set as active)
899  // - the comboBox of all other views (only append) XXX @todo
900  index = mySchemeName->appendItem(tmpSettings.name.c_str());
901  mySchemeName->setCurrentItem(index);
902  myParent->getColoringSchemesCombo().appendItem(tmpSettings.name.c_str());
903  }
904  myParent->getColoringSchemesCombo().setCurrentItem(
905  myParent->getColoringSchemesCombo().findItem(tmpSettings.name.c_str()));
906  gSchemeStorage.add(tmpSettings); // overwrites existing
907  mySettings = &gSchemeStorage.get(tmpSettings.name);
908  myParent->setColorScheme(tmpSettings.name);
909 
910  if (doRebuildColorMatrices) {
911  rebuildColorMatrices(true);
912  }
913  myParent->forceRefresh();
914  getApp()->forceRefresh();
915  return 1;
916 }
917 
918 
919 void
920 GUIDialog_ViewSettings::loadSettings(const std::string& file) {
921  GUISettingsHandler handler(file);
922  std::string settingsName = handler.addSettings(myParent);
923  if (settingsName != "") {
924  FXint index = mySchemeName->appendItem(settingsName.c_str());
925  mySchemeName->setCurrentItem(index);
926  mySettings = &gSchemeStorage.get(settingsName);
927  }
928  rebuildColorMatrices(true);
929 }
930 
931 
932 void
933 GUIDialog_ViewSettings::saveDecals(const std::string& file) const {
934  try {
936  dev << "<decals>\n";
937  std::vector<GUISUMOAbstractView::Decal>::iterator j;
938  for (j = myDecals->begin(); j != myDecals->end(); ++j) {
940  dev << " <decal filename=\"" << d.filename
941  << "\" centerX=\"" << d.centerX
942  << "\" centerY=\"" << d.centerY
943  << "\" centerZ=\"" << d.centerZ
944  << "\" width=\"" << d.width
945  << "\" height=\"" << d.height
946  << "\" altitude=\"" << d.altitude
947  << "\" rotation=\"" << d.rot
948  << "\" tilt=\"" << d.tilt
949  << "\" roll=\"" << d.roll
950  << "\" layer=\"" << d.layer
951  << "\"/>\n";
952  }
953  dev << "</decals>\n";
954  dev.close();
955  } catch (IOError& e) {
956  FXMessageBox::error(myParent, MBOX_OK, "Storing failed!", "%s", e.what());
957  }
958 }
959 
960 
961 void
962 GUIDialog_ViewSettings::loadDecals(const std::string& file) {
963  myDecalsLock->lock();
964  GUISettingsHandler handler(file);
965  if (handler.hasDecals()) {
966  (*myDecals) = handler.getDecals();
967  }
968  rebuildList();
969  myParent->update();
970  myDecalsLock->unlock();
971 }
972 
973 
974 long
975 GUIDialog_ViewSettings::onCmdSaveSetting(FXObject*, FXSelector, void* /*data*/) {
976  int index = mySchemeName->getCurrentItem();
977  if (index < (int) gSchemeStorage.getNumInitialSettings()) {
978  return 1;
979  }
980  // get the name
981  std::string name = "";
982  while (name.length() == 0) {
983  FXDialogBox dialog(this, "Enter a name", DECOR_TITLE | DECOR_BORDER);
984  FXVerticalFrame* content = new FXVerticalFrame(&dialog, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10);
985  new FXLabel(content, "Please enter an alphanumeric name: ", NULL, LAYOUT_FILL_X | JUSTIFY_LEFT);
986  FXTextField* text = new FXTextField(content, 40, &dialog, FXDialogBox::ID_ACCEPT, TEXTFIELD_ENTER_ONLY | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_X);
987  new FXHorizontalSeparator(content, SEPARATOR_GROOVE | LAYOUT_FILL_X);
988  FXHorizontalFrame* buttons = new FXHorizontalFrame(content, LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 0, 0, 0, 0);
989  new FXButton(buttons, "&OK", NULL, &dialog, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_RIGHT);
990  new FXButton(buttons, "&Cancel", NULL, &dialog, FXDialogBox::ID_CANCEL, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_RIGHT, 0, 0, 0, 0, 20, 20);
991  dialog.create();
992  text->setFocus();
993  if (!dialog.execute()) {
994  return 1;
995  }
996  name = text->getText().text();
997  for (size_t i = 0; i < name.length(); ++i) {
998  if (name[i] != '_' && (name[i] < 'a' || name[i] > 'z') && (name[i] < 'A' || name[i] > 'Z') && (name[i] < '0' || name[i] > '9')) {
999  name = "";
1000  break;
1001  }
1002  }
1003  }
1004  GUIVisualizationSettings tmpSettings = *mySettings;
1006  tmpSettings.name = name;
1007  gSchemeStorage.add(tmpSettings);
1008  mySchemeName->setItemText(index, tmpSettings.name.c_str());
1009  myParent->getColoringSchemesCombo().setItemText(index, tmpSettings.name.c_str());
1010  myParent->setColorScheme(tmpSettings.name);
1011  mySettings = &gSchemeStorage.get(name);
1012  myBackup = *mySettings;
1013  gSchemeStorage.writeSettings(getApp());
1014  return 1;
1015 }
1016 
1017 
1018 long
1019 GUIDialog_ViewSettings::onUpdSaveSetting(FXObject* sender, FXSelector, void* ptr) {
1020  sender->handle(this,
1021  mySchemeName->getCurrentItem() < (int) gSchemeStorage.getNumInitialSettings()
1022  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1023  ptr);
1024  return 1;
1025 }
1026 
1027 
1028 long
1030  int index = mySchemeName->getCurrentItem();
1031  if (index < (int) gSchemeStorage.getNumInitialSettings()) {
1032  return 1;
1033  }
1034  std::string name = mySchemeName->getItem(index).text();
1035  gSchemeStorage.remove(name);
1036  mySchemeName->removeItem(index);
1037  onCmdNameChange(0, 0, (void*) mySchemeName->getItem(0).text());
1038  gSchemeStorage.writeSettings(getApp());
1039  return 1;
1040 }
1041 
1042 
1043 long
1044 GUIDialog_ViewSettings::onUpdDeleteSetting(FXObject* sender, FXSelector, void* ptr) {
1045  sender->handle(this,
1046  mySchemeName->getCurrentItem() < (int) gSchemeStorage.getNumInitialSettings()
1047  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1048  ptr);
1049  return 1;
1050 }
1051 
1052 
1053 long
1055  FXString file = MFXUtils::getFilename2Write(this, "Export view settings", ".xml", GUIIconSubSys::getIcon(ICON_EMPTY), gCurrentFolder);
1056  if (file == "") {
1057  return 1;
1058  }
1059  try {
1060  OutputDevice& dev = OutputDevice::getDevice(file.text());
1061  mySettings->save(dev);
1062  dev.close();
1063  } catch (IOError& e) {
1064  FXMessageBox::error(this, MBOX_OK, "Storing failed!", "%s", e.what());
1065  }
1066  return 1;
1067 }
1068 
1069 
1070 long
1071 GUIDialog_ViewSettings::onUpdExportSetting(FXObject* sender, FXSelector, void* ptr) {
1072  sender->handle(this,
1073  mySchemeName->getCurrentItem() < (int) gSchemeStorage.getNumInitialSettings()
1074  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
1075  ptr);
1076  return 1;
1077 }
1078 
1079 
1080 long
1082  FXFileDialog opendialog(this, "Import view settings");
1083  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
1084  opendialog.setSelectMode(SELECTFILE_ANY);
1085  opendialog.setPatternList("*.xml");
1086  if (gCurrentFolder.length() != 0) {
1087  opendialog.setDirectory(gCurrentFolder);
1088  }
1089  if (opendialog.execute()) {
1090  gCurrentFolder = opendialog.getDirectory();
1091  loadSettings(opendialog.getFilename().text());
1092  }
1093  return 1;
1094 }
1095 
1096 
1097 long
1098 GUIDialog_ViewSettings::onCmdLoadDecals(FXObject*, FXSelector, void* /*data*/) {
1099  FXFileDialog opendialog(this, "Load Decals");
1100  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
1101  opendialog.setSelectMode(SELECTFILE_ANY);
1102  opendialog.setPatternList("*.xml");
1103  if (gCurrentFolder.length() != 0) {
1104  opendialog.setDirectory(gCurrentFolder);
1105  }
1106  if (opendialog.execute()) {
1107  gCurrentFolder = opendialog.getDirectory();
1108  loadDecals(opendialog.getFilename().text());
1109  }
1110  return 1;
1111 }
1112 
1113 
1114 long
1115 GUIDialog_ViewSettings::onCmdSaveDecals(FXObject*, FXSelector, void* /*data*/) {
1116  FXString file = MFXUtils::getFilename2Write(this, "Save Decals", ".xml", GUIIconSubSys::getIcon(ICON_EMPTY), gCurrentFolder);
1117  if (file == "") {
1118  return 1;
1119  }
1120  saveDecals(file.text());
1121  return 1;
1122 }
1123 
1124 
1125 
1126 
1127 long
1128 GUIDialog_ViewSettings::onUpdImportSetting(FXObject* sender, FXSelector, void* ptr) {
1129  sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
1130  return 1;
1131 }
1132 
1133 
1134 void
1136  myDecalsTable->clearItems();
1137  // set table attributes
1138  myDecalsTable->setTableSize(10, 7);
1139  myDecalsTable->setColumnText(0, "picture file");
1140  myDecalsTable->setColumnText(1, "center x");
1141  myDecalsTable->setColumnText(2, "center y");
1142  myDecalsTable->setColumnText(3, "width");
1143  myDecalsTable->setColumnText(4, "height");
1144  myDecalsTable->setColumnText(5, "rotation");
1145  myDecalsTable->setColumnText(6, "layer");
1146  FXHeader* header = myDecalsTable->getColumnHeader();
1147  header->setHeight(getApp()->getNormalFont()->getFontHeight() + getApp()->getNormalFont()->getFontAscent());
1148  int k;
1149  for (k = 0; k < 7; k++) {
1150  header->setItemJustify(k, JUSTIFY_CENTER_X | JUSTIFY_TOP);
1151  header->setItemSize(k, 60);
1152  }
1153  header->setItemSize(0, 150);
1154  // insert already known decals information into table
1155  FXint row = 0;
1156  std::vector<GUISUMOAbstractView::Decal>::iterator j;
1157  for (j = myDecals->begin(); j != myDecals->end(); ++j) {
1159  myDecalsTable->setItemText(row, 0, d.filename.c_str());
1160  myDecalsTable->setItemText(row, 1, toString<SUMOReal>(d.centerX).c_str());
1161  myDecalsTable->setItemText(row, 2, toString<SUMOReal>(d.centerY).c_str());
1162  myDecalsTable->setItemText(row, 3, toString<SUMOReal>(d.width).c_str());
1163  myDecalsTable->setItemText(row, 4, toString<SUMOReal>(d.height).c_str());
1164  myDecalsTable->setItemText(row, 5, toString<SUMOReal>(d.rot).c_str());
1165  myDecalsTable->setItemText(row, 6, toString<SUMOReal>(d.layer).c_str());
1166  row++;
1167  }
1168  // insert dummy last field
1169  for (k = 0; k < 7; k++) {
1170  myDecalsTable->setItemText(row, k, " ");
1171  }
1172 }
1173 
1174 
1175 FXMatrix*
1177  std::vector<FXColorWell*>& colors,
1178  std::vector<FXRealSpinDial*>& thresholds,
1179  std::vector<FXButton*>& buttons,
1180  FXCheckButton* interpolation,
1181  GUIColorScheme& scheme) {
1182  MFXUtils::deleteChildren(frame);
1183  FXMatrix* m = new FXMatrix(frame, 3,
1184  LAYOUT_FILL_X | MATRIX_BY_COLUMNS,
1185  0, 0, 0, 0, 10, 10, 0, 0, 5, 3);
1186  colors.clear();
1187  thresholds.clear();
1188  buttons.clear();
1189  const bool fixed = scheme.isFixed();
1190  std::vector<RGBColor>::const_iterator colIt = scheme.getColors().begin();
1191  std::vector<SUMOReal>::const_iterator threshIt = scheme.getThresholds().begin();
1192  std::vector<std::string>::const_iterator nameIt = scheme.getNames().begin();
1193  FX::FXString buttonText = "Add";
1194  while (colIt != scheme.getColors().end()) {
1195  colors.push_back(new FXColorWell(m , MFXUtils::getFXColor(*colIt),
1197  LAYOUT_FIX_WIDTH | LAYOUT_CENTER_Y | FRAME_SUNKEN | FRAME_THICK | ICON_AFTER_TEXT,
1198  0, 0, 100, 0, 0, 0, 0, 0));
1199  if (fixed) {
1200  new FXLabel(m, nameIt->c_str());
1201  new FXLabel(m, "");
1202  } else {
1203  const int dialerOptions = scheme.allowsNegativeValues() ? SPINDIAL_NOMIN : 0;
1204  FXRealSpinDial* threshDialer = new FXRealSpinDial(m, 10, this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | SPINDIAL_NOMAX | dialerOptions);
1205  threshDialer->setValue(*threshIt);
1206  thresholds.push_back(threshDialer);
1207  buttons.push_back(new FXButton(m, buttonText, NULL, this, MID_SIMPLE_VIEW_COLORCHANGE, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 20, 20, 4, 4));
1208  buttonText = "Remove";
1209  }
1210  colIt++;
1211  threshIt++;
1212  nameIt++;
1213  }
1214  interpolation->setCheck(scheme.isInterpolated());
1215  if (fixed) {
1216  interpolation->disable();
1217  } else {
1218  if (colors.size() > 1) {
1219  interpolation->enable();
1220  if (interpolation->getCheck() != FALSE) {
1221  thresholds.front()->enable();
1222  } else {
1223  thresholds.front()->disable();
1224  }
1225  } else {
1226  interpolation->disable();
1227  thresholds.front()->disable();
1228  }
1229  }
1230  return m;
1231 }
1232 
1233 
1234 FXMatrix*
1236  std::vector<FXRealSpinDial*>& scales,
1237  std::vector<FXRealSpinDial*>& thresholds,
1238  std::vector<FXButton*>& buttons,
1239  FXCheckButton* interpolation,
1240  GUIScaleScheme& scheme) {
1241  MFXUtils::deleteChildren(frame);
1242  FXMatrix* m = new FXMatrix(frame, 3,
1243  LAYOUT_FILL_X | MATRIX_BY_COLUMNS,
1244  0, 0, 0, 0, 10, 10, 0, 0, 5, 3);
1245  scales.clear();
1246  thresholds.clear();
1247  buttons.clear();
1248  const bool fixed = scheme.isFixed();
1249  std::vector<SUMOReal>::const_iterator scaleIt = scheme.getColors().begin();
1250  std::vector<SUMOReal>::const_iterator threshIt = scheme.getThresholds().begin();
1251  std::vector<std::string>::const_iterator nameIt = scheme.getNames().begin();
1252  FX::FXString buttonText = "Add";
1253  while (scaleIt != scheme.getColors().end()) {
1254  FXRealSpinDial* scaleDialer = new FXRealSpinDial(m, 10, this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | SPINDIAL_NOMAX);
1255  scaleDialer->setValue(*scaleIt);
1256  scales.push_back(scaleDialer);
1257  if (fixed) {
1258  new FXLabel(m, nameIt->c_str());
1259  new FXLabel(m, "");
1260  } else {
1261  const int dialerOptions = scheme.allowsNegativeValues() ? SPINDIAL_NOMIN : 0;
1262  FXRealSpinDial* threshDialer = new FXRealSpinDial(m, 10, this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | SPINDIAL_NOMAX | dialerOptions);
1263  threshDialer->setValue(*threshIt);
1264  thresholds.push_back(threshDialer);
1265  buttons.push_back(new FXButton(m, buttonText, NULL, this, MID_SIMPLE_VIEW_COLORCHANGE, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 20, 20, 4, 4));
1266  buttonText = "Remove";
1267  }
1268  scaleIt++;
1269  threshIt++;
1270  nameIt++;
1271  }
1272  interpolation->setCheck(scheme.isInterpolated());
1273  if (fixed) {
1274  interpolation->disable();
1275  } else {
1276  if (scales.size() > 1) {
1277  interpolation->enable();
1278  if (interpolation->getCheck() != FALSE) {
1279  thresholds.front()->enable();
1280  } else {
1281  thresholds.front()->disable();
1282  }
1283  } else {
1284  interpolation->disable();
1285  thresholds.front()->disable();
1286  }
1287  }
1288  return m;
1289 }
1290 
1291 
1292 void
1294  // decals
1295  delete myDecalsTable;
1297  LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH/*|LAYOUT_FIX_HEIGHT*/, 0, 0, 470, 0);
1298  myDecalsTable->setVisibleRows(5);
1299  myDecalsTable->setVisibleColumns(7);
1300  myDecalsTable->setTableSize(5, 7);
1301  myDecalsTable->setBackColor(FXRGB(255, 255, 255));
1302  myDecalsTable->getRowHeader()->setWidth(0);
1303  for (int i = 1; i <= 5; ++i) {
1305  myDecalsTable->setNumberCellParams(i, -10000000, 10000000, 1, 10, 100, "%.2f");
1306  }
1307  rebuildList();
1308  if (doCreate) {
1309  myDecalsTable->create();
1310  }
1312  if (doCreate) {
1313  m->create();
1314  }
1315  myLaneColorSettingFrame->getParent()->recalc();
1316 
1318  if (doCreate) {
1319  m->create();
1320  }
1321  myLaneScaleSettingFrame->getParent()->recalc();
1322 
1324  if (doCreate) {
1325  m->create();
1326  }
1327  myPersonColorSettingFrame->getParent()->recalc();
1328 
1330  if (doCreate) {
1331  m->create();
1332  }
1333  myPersonColorSettingFrame->getParent()->recalc();
1334 
1336  if (doCreate) {
1337  m->create();
1338  }
1339  myJunctionColorSettingFrame->getParent()->recalc();
1340 
1341  layout();
1342  update();
1343 }
1344 
1345 
1346 long
1349  std::string value = i->item->getText().text();
1350  // check whether the inserted value is empty
1351  if (value.find_first_not_of(" ") == std::string::npos) {
1352  return 1;
1353  }
1355  int row = i->row;
1356  // check whether we add a new entry or edit an existing entry
1357  if (row == static_cast<int>(myDecals->size())) {
1358  d.filename = "";
1359  d.centerX = SUMOReal(myParent->getGridWidth() / 2.);
1360  d.centerY = SUMOReal(myParent->getGridHeight() / 2.);
1361  d.width = 0.;
1362  d.height = 0.;
1363  d.initialised = false;
1364  d.rot = 0;
1365  d.layer = 0;
1366  myDecalsLock->lock();
1367  myDecals->push_back(d);
1368  myDecalsLock->unlock();
1369  } else if (row > static_cast<int>(myDecals->size())) {
1370  // ignore clicks two lines below existing entries
1371  return 1;
1372  } else {
1373  d = (*myDecals)[row];
1374  }
1375 
1376  switch (i->col) {
1377  case 0:
1378  if (d.initialised && d.filename != value) {
1379  d.initialised = false;
1380  }
1381  d.filename = value;
1382  break;
1383  case 1:
1384  try {
1385  d.centerX = TplConvert::_2SUMOReal(value.c_str());
1386  } catch (NumberFormatException&) {
1387  std::string msg = "The value must be a float, is:" + value;
1388  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1389  }
1390  break;
1391  case 2:
1392  try {
1393  d.centerY = TplConvert::_2SUMOReal(value.c_str());
1394  } catch (NumberFormatException&) {
1395  std::string msg = "The value must be a float, is:" + value;
1396  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1397  }
1398  break;
1399  case 3:
1400  try {
1401  d.width = TplConvert::_2SUMOReal(value.c_str());
1402  } catch (NumberFormatException&) {
1403  std::string msg = "The value must be a float, is:" + value;
1404  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1405  }
1406  break;
1407  case 4:
1408  try {
1409  d.height = TplConvert::_2SUMOReal(value.c_str());
1410  } catch (NumberFormatException&) {
1411  std::string msg = "The value must be a float, is:" + value;
1412  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1413  }
1414  break;
1415  case 5:
1416  try {
1417  d.rot = TplConvert::_2SUMOReal(value.c_str());
1418  } catch (NumberFormatException&) {
1419  std::string msg = "The value must be a float, is:" + value;
1420  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1421  }
1422  break;
1423  case 6:
1424  try {
1425  d.layer = TplConvert::_2SUMOReal(value.c_str());
1426  } catch (NumberFormatException&) {
1427  std::string msg = "The value must be a float, is:" + value;
1428  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1429  }
1430  break;
1431  default:
1432  throw 1;
1433  }
1434  (*myDecals)[row] = d;
1435  if (!i->updateOnly) {
1436  rebuildList();
1437  }
1438  myParent->update();
1439  return 1;
1440 }
1441 
1442 
1443 std::string
1445  return mySchemeName->getItem(mySchemeName->getCurrentItem()).text();
1446 }
1447 
1448 
1449 void
1451  if (name.c_str() == mySchemeName->getItemText(mySchemeName->getCurrentItem())) {
1452  return;
1453  }
1454  for (int i = 0; i < mySchemeName->getNumItems(); ++i) {
1455  if (name.c_str() == mySchemeName->getItemText(i)) {
1456  mySchemeName->setCurrentItem(i);
1457  onCmdNameChange(0, 0, (void*)name.c_str());
1458  return;
1459  }
1460  }
1461 }
1462 
1464  FXMatrix* parent,
1465  GUIDialog_ViewSettings* target,
1466  const std::string& title,
1467  const GUIVisualizationTextSettings& settings) {
1468  myCheck = new FXCheckButton(parent, title.c_str(), target, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
1469  myCheck->setCheck(settings.show);
1470  new FXLabel(parent, "");
1471  FXMatrix* m1 = new FXMatrix(parent, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
1472  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
1473  new FXLabel(m1, "Size", 0, LAYOUT_CENTER_Y);
1474  mySizeDial = new FXRealSpinDial(m1, 10, target, MID_SIMPLE_VIEW_COLORCHANGE,
1475  LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
1476  mySizeDial->setRange(10, 1000);
1477  mySizeDial->setValue(settings.size);
1478  FXMatrix* m2 = new FXMatrix(parent, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
1479  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
1480  new FXLabel(m2, "Color", 0, LAYOUT_CENTER_Y);
1481  myColorWell = new FXColorWell(m2, MFXUtils::getFXColor(settings.color),
1482  target, MID_SIMPLE_VIEW_COLORCHANGE,
1483  LAYOUT_FIX_WIDTH | LAYOUT_CENTER_Y | LAYOUT_SIDE_TOP | FRAME_SUNKEN | FRAME_THICK | ICON_AFTER_TEXT,
1484  0, 0, 100, 0, 0, 0, 0, 0);
1485 }
1486 
1487 
1490  return GUIVisualizationTextSettings(myCheck->getCheck() != FALSE,
1491  mySizeDial->getValue(), MFXUtils::getRGBColor(myColorWell->getRGBA()));
1492 }
1493 
1494 
1495 void
1497  myCheck->setCheck(settings.show);
1498  mySizeDial->setValue(settings.size);
1499  myColorWell->setRGBA(MFXUtils::getFXColor(settings.color));
1500 }
1501 
1502 
1504  FXMatrix* parent,
1505  GUIDialog_ViewSettings* target,
1506  const GUIVisualizationSizeSettings& settings) {
1507  myCheck = new FXCheckButton(parent, "Draw with constant size when zoomed out", target, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
1508  myCheck->setCheck(settings.constantSize);
1509  new FXLabel(parent, "");
1510  FXMatrix* m1 = new FXMatrix(parent, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
1511  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
1512  new FXLabel(m1, "Minimum Size", 0, LAYOUT_CENTER_Y);
1513  myMinSizeDial = new FXRealSpinDial(m1, 10, target, MID_SIMPLE_VIEW_COLORCHANGE,
1514  LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
1515  myMinSizeDial->setValue(settings.minSize);
1516  FXMatrix* m2 = new FXMatrix(parent, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
1517  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
1518  new FXLabel(m2, "Exaggerate by", 0, LAYOUT_CENTER_Y);
1519  myExaggerateDial = new FXRealSpinDial(m2, 10, target, MID_SIMPLE_VIEW_COLORCHANGE,
1520  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
1521  myExaggerateDial->setRange(0, 10000);
1522  myExaggerateDial->setValue(settings.exaggeration);
1523 }
1524 
1525 
1529  myMinSizeDial->getValue(), myExaggerateDial->getValue(), myCheck->getCheck() != FALSE);
1530 }
1531 
1532 
1533 void
1535  myCheck->setCheck(settings.constantSize);
1536  myMinSizeDial->setValue(settings.minSize);
1537  myExaggerateDial->setValue(settings.exaggeration);
1538 }
1539 
1540 
1541 void
1543  getApp()->reg().writeIntEntry("VIEWSETTINGS", "x", getX());
1544  getApp()->reg().writeIntEntry("VIEWSETTINGS", "y", getY());
1545  getApp()->reg().writeIntEntry("VIEWSETTINGS", "width", getWidth());
1546  getApp()->reg().writeIntEntry("VIEWSETTINGS", "height", getHeight());
1547 }
1548 
1549 /****************************************************************************/
1550 
void rebuildColorMatrices(bool doCreate=false)
Rebuilds color changing dialogs after choosing another coloring scheme.
GUIVisualizationTextSettings junctionName
A decal (an image) that can be shown.
FXVerticalFrame * myVehicleColorSettingFrame
long onUpdSaveSetting(FXObject *, FXSelector, void *data)
Called when updating the button that allows to save the settings into the registry.
FXCheckButton * myLaneColorInterpolation
void close()
Closes the device and removes it from the dictionary.
const std::vector< T > & getColors() const
GUICompleteSchemeStorage gSchemeStorage
bool showSizeLegend
Information whether the size legend shall be drawn.
FXCheckButton * myJunctionColorInterpolation
bool isInterpolated() const
For the delete - button.
Definition: GUIAppEnum.h:331
Cancel-button was pushed.
Definition: GUIAppEnum.h:275
FXVerticalFrame * myLaneScaleSettingFrame
GUIVisualizationTextSettings streetName
float laneWidthExaggeration
The lane exaggeration (upscale thickness)
size_t getLaneEdgeMode() const
Returns the number of the active lane (edge) coloring schme.
SUMOReal roll
The roll of the image to the ground plane (in degrees)
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
Informs the dialog about switching to another scheme.
Definition: GUIAppEnum.h:327
For the export-to-file - button.
Definition: GUIAppEnum.h:333
bool showBlinker
Information whether vehicle blinkers shall be drawn.
GUIVisualizationTextSettings addName
void removeColor(const size_t pos)
GUIVisualizationTextSettings personName
std::vector< FXButton * > myLaneButtons
bool drawLinkTLIndex
Information whether a link&#39;s tls index shall be drawn.
static SUMOReal _2SUMOReal(const E *const data)
Definition: TplConvert.h:223
GUIVisualizationTextSettings poiName
GUIColorScheme & getLaneEdgeScheme()
Returns the current lane (edge) coloring schme.
bool showBTRange
Information whether the communication range shall be drawn.
GUIColorer laneColorer
The lane colorer.
Stores the information about how to visualize structures.
The dialog to change the view (gui) settings.
SizePanel(FXMatrix *parent, GUIDialog_ViewSettings *target, const GUIVisualizationSizeSettings &settings)
static RGBColor getRGBColor(FXColor col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:119
void remove(GUIDialog_EditViewport *)
std::vector< FXRealSpinDial * > myLaneScaleThresholds
std::vector< GUISUMOAbstractView::Decal > * myDecals
The parent&#39;s decals.
void setColor(const size_t pos, const T &color)
bool showRails
Information whether rails shall be drawn.
void loadDecals(const std::string &file)
Loads decals from a file.
std::vector< FXButton * > myPersonButtons
FXMatrix * rebuildScaleMatrix(FXVerticalFrame *frame, std::vector< FXRealSpinDial * > &scales, std::vector< FXRealSpinDial * > &thresholds, std::vector< FXButton * > &buttons, FXCheckButton *interpolation, GUIScaleScheme &scheme)
Rebuilds manipulators for the current scaling scheme.
std::vector< FXColorWell * > myJunctionColors
GUIVisualizationTextSettings vehicleName
void loadSettings(const std::string &file)
Loads a scheme from a file.
bool hasDecals() const
Returns whether any decals have been parsed.
static void deleteChildren(FXWindow *w)
Deletes all children of the given window.
Definition: MFXUtils.cpp:43
long onCmdSaveDecals(FXObject *, FXSelector, void *data)
Called if the decals shall be saved to a file.
void setActive(size_t scheme)
Definition: GUIColorer.h:67
GUIVisualizationTextSettings cwaEdgeName
FXString gCurrentFolder
The folder used as last.
long onCmdSaveSetting(FXObject *, FXSelector, void *data)
Called if the settings shall be saved into the registry.
bool laneShowBorders
Information whether lane borders shall be drawn.
SUMOReal getGridHeight() const
SUMOReal centerZ
The center of the image in z-direction (net coordinates, in m)
long onCmdExportSetting(FXObject *, FXSelector, void *data)
Called if the settings shall be exported into a file.
SUMOReal width
The width of the image (net coordinates in x-direction, in m)
long onCmdEditTable(FXObject *, FXSelector, void *data)
Called if the decals-table was changed.
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:95
bool dither
Information whether dithering shall be enabled.
Ok-button was pushed.
Definition: GUIAppEnum.h:273
std::vector< FXRealSpinDial * > myPersonThresholds
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
long onCmdNameChange(FXObject *, FXSelector, void *)
Called if the name of the scheme was changed.
void setThreshold(const size_t pos, const SUMOReal threshold)
void saveDecals(const std::string &file) const
Writes the currently used decals into a file.
GUIVisualizationSizeSettings polySize
GUIColorer vehicleColorer
The vehicle colorer.
bool isFixed() const
GUIVisualizationTextSettings edgeName
FXTableItem * item
void setInterpolated(const bool interpolate, SUMOReal interpolationStart=0.f)
FXCheckButton * myVehicleColorInterpolation
GUIVisualizationSizeSettings addSize
size_t getActive() const
Definition: GUIColorer.h:73
const std::vector< std::string > & getNames() const
Returns a list of stored settings names.
For the load-decals - button.
Definition: GUIAppEnum.h:337
std::string name
The name of this setting.
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
void rebuildList()
Rebuilds the decals table.
The Table.
Definition: GUIAppEnum.h:261
void update(const GUIVisualizationSizeSettings &settings)
SUMOReal altitude
The altitude of the image (net coordinates in z-direction, in m)
GUIVisualizationSettings * mySettings
The current settings.
GUIVisualizationTextSettings internalEdgeName
FXMatrix * rebuildColorMatrix(FXVerticalFrame *frame, std::vector< FXColorWell * > &colors, std::vector< FXRealSpinDial * > &thresholds, std::vector< FXButton * > &buttons, FXCheckButton *interpolation, GUIColorScheme &scheme)
Rebuilds manipulators for the current coloring scheme.
std::vector< FXRealSpinDial * > myLaneScales
SUMOReal centerY
The center of the image in y-direction (net coordinates, in m)
bool drawMinGap
Information whether the minimum gap shall be drawn.
std::vector< FXColorWell * > myVehicleColors
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
FXRealSpinDial * myLaneWidthUpscaleDialer
void remove(const std::string &name)
Removes the setting with the given name.
unsigned int getNumInitialSettings() const
Returns the number of initial settings.
void saveWindowSize()
save window position and size to the registry
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
bool allowsNegativeValues() const
FXVerticalFrame * myLaneColorSettingFrame
FXComboBox & getColoringSchemesCombo()
bool initialised
Whether this image was initialised (inserted as a texture)
GUIColorer personColorer
The person colorer.
GUIVisualizationTextSettings internalJunctionName
const std::vector< std::string > & getNames() const
float minSize
The minimum size to draw this object.
GUIColorer junctionColorer
The junction colorer.
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
std::string filename
The path to the file the image is located at.
For the save-to-db - button.
Definition: GUIAppEnum.h:329
SUMOReal gridXSize
Information about the grid spacings.
long onUpdDeleteSetting(FXObject *, FXSelector, void *data)
Called when updating the button that allows to delete settings.
FXVerticalFrame * myJunctionColorSettingFrame
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
FXCheckButton * myLaneScaleInterpolation
unsigned int addColor(const T &color, const SUMOReal threshold, const std::string &name="")
GUIScaleScheme & getLaneEdgeScaleScheme()
Returns the current lane (edge) scaling schme.
std::vector< FXColorWell * > myPersonColors
FXRealSpinDial * myGridYSizeDialer
long onCmdCancel(FXObject *, FXSelector, void *)
Called if the Cancel-button was pressed.
RGBColor backgroundColor
The background color to use.
bool antialiase
Information whether antialiase shall be enabled.
std::vector< FXButton * > myLaneScaleButtons
long onCmdOk(FXObject *, FXSelector, void *)
Called if the OK-button was pressed.
For the save-decals - button.
Definition: GUIAppEnum.h:339
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
SUMOReal height
The height of the image (net coordinates in y-direction, in m)
GUIVisualizationSizeSettings poiSize
bool updateScaleRanges(FXObject *sender, std::vector< FXRealSpinDial * >::const_iterator colIt, std::vector< FXRealSpinDial * >::const_iterator colEnd, std::vector< FXRealSpinDial * >::const_iterator threshIt, std::vector< FXRealSpinDial * >::const_iterator threshEnd, std::vector< FXButton * >::const_iterator buttonIt, GUIScaleScheme &scheme)
SUMOReal centerX
The center of the image in x-direction (net coordinates, in m)
MFXAddEditTypedTable * myDecalsTable
float exaggeration
The size exaggeration (upscale)
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
NamePanel(FXMatrix *parent, GUIDialog_ViewSettings *target, const std::string &title, const GUIVisualizationTextSettings &settings)
FXComboBox * myLaneEdgeScaleMode
... lane scaler
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
GUIVisualizationTextSettings getSettings()
void writeSettings(FXApp *app)
Writes the current scheme into the registry.
FXComboBox * myLaneEdgeColorMode
... lane colorer
void setCurrent(GUIVisualizationSettings *settings)
Sets current settings (called if reopened)
FXCheckButton * myHideMacroConnectors
bool drawLinkJunctionIndex
Information whether a link&#39;s junction index shall be drawn.
SUMOReal getGridWidth() const
GUIVisualizationSizeSettings personSize
virtual bool setColorScheme(const std::string &)
int personQuality
The quality of person drawing.
void lock()
lock mutex
Definition: MFXMutex.cpp:86
void text()
Definition: gl2psTest.c:260
bool showGrid
Information whether a grid shall be shown.
long onUpdExportSetting(FXObject *, FXSelector, void *data)
Called when updating the button that allows to export settings into a file.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:125
SUMOReal layer
The layer of the image.
long onCmdColorChange(FXObject *, FXSelector, void *)
Called if something (color, width, etc.) has been changed.
bool showLane2Lane
Information whether lane-to-lane arrows shall be drawn.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
void setCellType(size_t pos, CellType t)
#define SUMOReal
Definition: config.h:218
FXRealSpinDial * myGridXSizeDialer
An XML-handler for visualisation schemes.
void save(OutputDevice &dev) const
Writes the settings into an output device.
FXCheckButton * myPersonColorInterpolation
GUIVisualizationSizeSettings vehicleSize
bool drawJunctionShape
whether the shape of the junction should be drawn
long onCmdLoadDecals(FXObject *, FXSelector, void *data)
Called if the decals shall be loaded from a file.
void update(const GUIVisualizationTextSettings &settings)
std::vector< FXRealSpinDial * > myVehicleThresholds
SUMOReal tilt
The tilt of the image to the ground plane (in degrees)
GUIVisualizationSizeSettings getSettings()
int vehicleQuality
The quality of vehicle drawing.
bool updateColorRanges(FXObject *sender, std::vector< FXColorWell * >::const_iterator colIt, std::vector< FXColorWell * >::const_iterator colEnd, std::vector< FXRealSpinDial * >::const_iterator threshIt, std::vector< FXRealSpinDial * >::const_iterator threshEnd, std::vector< FXButton * >::const_iterator buttonIt, GUIColorScheme &scheme)
MFXMutex * myDecalsLock
Lock used when changing the decals.
void setNumberCellParams(size_t pos, double min, double max, double steps1, double steps2, double steps3, const std::string &format)
std::vector< FXRealSpinDial * > myJunctionThresholds
GUIScaler laneScaler
The lane scaler.
For the import-from-file - button.
Definition: GUIAppEnum.h:335
const std::vector< SUMOReal > & getThresholds() const
long onCmdDeleteSetting(FXObject *, FXSelector, void *data)
Called if the settings shall be deleted.
GUISUMOAbstractView * myParent
The parent view (which settings are changed)
FXVerticalFrame * myPersonColorSettingFrame
static FXIcon * getIcon(GUIIcon which)
std::vector< FXButton * > myJunctionButtons
GUIVisualizationSettings myBackup
A backup of the settings (used if the &quot;Cancel&quot; button is pressed)
size_t getLaneEdgeScaleMode() const
Returns the number of the active lane (edge) scaling schme.
std::vector< FXColorWell * > myLaneColors
std::vector< FXRealSpinDial * > myLaneThresholds
Informs the dialog about a value&#39;s change.
Definition: GUIAppEnum.h:325
std::vector< FXButton * > myVehicleButtons
SUMOReal rot
The rotation of the image in the ground plane (in degrees)
long onCmdImportSetting(FXObject *, FXSelector, void *data)
Called if the settings shall be read from a file.
void add(const GUIVisualizationSettings &scheme)
Adds a visualization scheme.
long onUpdImportSetting(FXObject *, FXSelector, void *data)
Called when updating the button that allows to read settings from a file.
GUIVisualizationTextSettings polyName