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.sourceforge.net/
13 // Copyright (C) 2001-2013 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
93  myParent(parent), mySettings(settings),
94  myDecals(decals), myDecalsLock(decalsLock), myDecalsTable(0) {
95  myBackup = (*mySettings);
96 
97  FXVerticalFrame* contentFrame =
98  new FXVerticalFrame(this, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y,
99  0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
100  //
101  {
102  FXHorizontalFrame* frame0 =
103  new FXHorizontalFrame(contentFrame, FRAME_THICK, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
104  mySchemeName = new FXComboBox(frame0, 20, this, MID_SIMPLE_VIEW_NAMECHANGE, COMBOBOX_INSERT_LAST | FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_CENTER_Y | COMBOBOX_STATIC);
105  const std::vector<std::string>& names = gSchemeStorage.getNames();
106  for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
107  size_t index = mySchemeName->appendItem((*i).c_str());
108  if ((*i) == mySettings->name) {
109  mySchemeName->setCurrentItem((FXint) index);
110  }
111  }
112  mySchemeName->setNumVisible(5);
113 
114  new FXButton(frame0, "\t\tSave the setting to registry",
116  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
117  new FXButton(frame0, "\t\tRemove the setting from registry",
119  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
120  new FXButton(frame0, "\t\tExport setting to file",
122  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
123  new FXButton(frame0, "\t\tLoad setting from file",
125  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
126 
127  }
128  //
129  FXTabBook* tabbook =
130  new FXTabBook(contentFrame, 0, 0, TABBOOK_LEFTTABS | PACK_UNIFORM_WIDTH | PACK_UNIFORM_HEIGHT | LAYOUT_FILL_X | LAYOUT_FILL_Y | LAYOUT_RIGHT,
131  0, 0, 0, 0, 0, 0, 0, 0);
132  {
133  // tab for the background
134  new FXTabItem(tabbook, "Background", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
135  FXVerticalFrame* frame1 =
136  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
137 
138  FXMatrix* m11 =
139  new FXMatrix(frame1, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
140  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
141  new FXLabel(m11, "Color", 0, LAYOUT_CENTER_Y);
142  myBackgroundColor = new FXColorWell(m11, MFXUtils::getFXColor(settings->backgroundColor),
144  LAYOUT_FIX_WIDTH | LAYOUT_CENTER_Y | LAYOUT_SIDE_TOP | FRAME_SUNKEN | FRAME_THICK | ICON_AFTER_TEXT,
145  0, 0, 100, 0, 0, 0, 0, 0);
146 
147  new FXHorizontalSeparator(frame1, SEPARATOR_GROOVE | LAYOUT_FILL_X);
148 
149  FXVerticalFrame* frame11 =
150  new FXVerticalFrame(frame1, LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
151  new FXLabel(frame11, "Decals:");
152  myDecalsFrame = new FXVerticalFrame(frame11);
153  FXHorizontalFrame* frame111 = new FXHorizontalFrame(frame11, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
154  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);
155  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);
156 
157  new FXHorizontalSeparator(frame1, SEPARATOR_GROOVE | LAYOUT_FILL_X);
158 
159  FXMatrix* m12 =
160  new FXMatrix(frame1, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
161  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
162  myShowGrid =
163  new FXCheckButton(m12, "Show grid", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
164  myShowGrid->setCheck(mySettings->showGrid);
165  new FXLabel(m12, "");
166  FXMatrix* m121 =
167  new FXMatrix(m12, 2, LAYOUT_CENTER_Y | LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
168  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
169  new FXLabel(m121, "x-spacing", 0, LAYOUT_CENTER_Y);
170  myGridXSizeDialer =
171  new FXRealSpinDial(m121, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
172  LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
173  myGridXSizeDialer->setRange(1, 10000);
174  myGridXSizeDialer->setValue(mySettings->gridXSize);
175  FXMatrix* m122 =
176  new FXMatrix(m12, 2, LAYOUT_CENTER_Y | LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
177  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
178  new FXLabel(m122, "y-spacing", 0, LAYOUT_CENTER_Y);
179  myGridYSizeDialer =
180  new FXRealSpinDial(m122, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
181  LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
182  myGridYSizeDialer->setRange(1, 10000);
183  myGridYSizeDialer->setValue(mySettings->gridXSize);
184  }
185  {
186  // tab for the streets
187  new FXTabItem(tabbook, "Streets", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
188 
189  FXVerticalFrame* frame2 =
190  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
191  FXMatrix* m21 =
192  new FXMatrix(frame2, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
193  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
194  new FXLabel(m21, "Color", 0, LAYOUT_CENTER_Y);
195  myLaneEdgeColorMode = new FXComboBox(m21, 30, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
196  myLaneEdgeColorMode->setNumVisible(10);
197  myLaneColorInterpolation = new FXCheckButton(m21, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
198  FXScrollWindow* genScroll = new FXScrollWindow(frame2, LAYOUT_FILL_X | LAYOUT_SIDE_TOP | FRAME_RAISED | FRAME_THICK | LAYOUT_FIX_HEIGHT, 0, 0, 0, 80);
199  myLaneColorSettingFrame =
200  new FXVerticalFrame(genScroll, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
201 //we should insert a FXScrollWindow around the frame2
202 #ifdef HAVE_INTERNAL
203  if (GUIVisualizationSettings::UseMesoSim) {
204  mySettings->edgeColorer.fill(*myLaneEdgeColorMode);
205  } else {
206 #endif
207  mySettings->laneColorer.fill(*myLaneEdgeColorMode);
208 #ifdef HAVE_INTERNAL
209  }
210 #endif
211 
212  new FXHorizontalSeparator(frame2, SEPARATOR_GROOVE | LAYOUT_FILL_X);
213  FXMatrix* m22 =
214  new FXMatrix(frame2, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
215  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
216  myShowLaneBorders = new FXCheckButton(m22, "Show lane borders", this, MID_SIMPLE_VIEW_COLORCHANGE);
217  myShowLaneBorders->setCheck(mySettings->laneShowBorders);
218  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
219  myShowLaneDecals = new FXCheckButton(m22, "Show link decals", this, MID_SIMPLE_VIEW_COLORCHANGE);
220  myShowLaneDecals->setCheck(mySettings->showLinkDecals);
221  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
222  myShowRails = new FXCheckButton(m22, "Show rails", this, MID_SIMPLE_VIEW_COLORCHANGE);
223  myShowRails->setCheck(mySettings->showRails);
224  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
225  myHideMacroConnectors = new FXCheckButton(m22, "Hide macro connectors", this, MID_SIMPLE_VIEW_COLORCHANGE);
226  myHideMacroConnectors->setCheck(mySettings->hideConnectors);
227  new FXLabel(m22, " ", 0, LAYOUT_CENTER_Y);
228  new FXLabel(m22, "Exaggerate width by", 0, LAYOUT_CENTER_Y);
229  myLaneWidthUpscaleDialer =
230  new FXRealSpinDial(m22, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
231  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
232  myLaneWidthUpscaleDialer->setRange(0, 10000);
233  myLaneWidthUpscaleDialer->setValue(mySettings->laneWidthExaggeration);
234 
235  // edge name
236  myEdgeNamePanel = new NamePanel(m22, this, "Show edge name", mySettings->edgeName);
237  myStreetNamePanel = new NamePanel(m22, this, "Show street name", mySettings->streetName);
238  myInternalEdgeNamePanel = new NamePanel(m22, this, "Show internal edge name", mySettings->internalEdgeName);
239  }
240  {
241  new FXTabItem(tabbook, "Vehicles", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
242  FXVerticalFrame* frame3 =
243  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
244 
245  FXMatrix* m31 =
246  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
247  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
248  new FXLabel(m31, "Show As", 0, LAYOUT_CENTER_Y);
249  myVehicleShapeDetail = new FXComboBox(m31, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
250  myVehicleShapeDetail->appendItem("'triangles'");
251  myVehicleShapeDetail->appendItem("'boxes'");
252  myVehicleShapeDetail->appendItem("'simple shapes'");
253  myVehicleShapeDetail->appendItem("'raster images'");
254  myVehicleShapeDetail->setNumVisible(4);
255  myVehicleShapeDetail->setCurrentItem(settings->vehicleQuality);
256 
257  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
258 
259  FXMatrix* m32 =
260  new FXMatrix(frame3, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
261  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
262  new FXLabel(m32, "Color", 0, LAYOUT_CENTER_Y);
263  myVehicleColorMode = new FXComboBox(m32, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
264  mySettings->vehicleColorer.fill(*myVehicleColorMode);
265  myVehicleColorMode->setNumVisible(10);
266  myVehicleColorInterpolation = new FXCheckButton(m32, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
267 
268  FXScrollWindow* genScroll = new FXScrollWindow(frame3, LAYOUT_FILL_X | LAYOUT_SIDE_TOP | FRAME_RAISED | FRAME_THICK | LAYOUT_FIX_HEIGHT, 0, 0, 0, 80);
269  myVehicleColorSettingFrame =
270  new FXVerticalFrame(genScroll, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
271 
272  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
273 
274  FXMatrix* m33 =
275  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
276  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
277  myShowBlinker = new FXCheckButton(m33, "Show blinker / brake lights", this, MID_SIMPLE_VIEW_COLORCHANGE);
278  myShowBlinker->setCheck(mySettings->showBlinker);
279  new FXLabel(m33, " ", 0, LAYOUT_CENTER_Y);
280  myShowMinGap = new FXCheckButton(m33, "Show minimum gap", this, MID_SIMPLE_VIEW_COLORCHANGE);
281  myShowMinGap->setCheck(mySettings->drawMinGap);
282  new FXLabel(m33, " ", 0, LAYOUT_CENTER_Y);
283  /*
284  myShowLaneChangePreference = new FXCheckButton(m33, "Show lane change preference", this, MID_SIMPLE_VIEW_COLORCHANGE);
285  myShowLaneChangePreference->setCheck(mySettings->drawLaneChangePreference);
286  new FXLabel(m33, " ", 0, LAYOUT_CENTER_Y);
287  */
288  myVehicleNamePanel = new NamePanel(m33, this, "Show vehicle name", mySettings->vehicleName);
289  /*
290  FXCheckButton *tmpc = new FXCheckButton(m33, "Show braking lights", 0 ,0);
291  tmpc->disable();
292  tmpc = new FXCheckButton(m33, "Show needed headway", 0 ,0);
293  tmpc->disable();
294  */
295 
296  new FXHorizontalSeparator(frame3, SEPARATOR_GROOVE | LAYOUT_FILL_X);
297 
298  FXMatrix* m34 =
299  new FXMatrix(frame3, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
300  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
301  FXMatrix* m341 =
302  new FXMatrix(m34, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
303  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
304  new FXLabel(m341, "Minimum size", 0, LAYOUT_CENTER_Y);
305  myVehicleMinSizeDialer =
306  new FXRealSpinDial(m341, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
307  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
308  myVehicleMinSizeDialer->setValue(mySettings->minVehicleSize);
309  FXMatrix* m342 =
310  new FXMatrix(m34, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
311  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
312  new FXLabel(m342, "Exaggerate by", 0, LAYOUT_CENTER_Y);
313  myVehicleUpscaleDialer =
314  new FXRealSpinDial(m342, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
315  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
316  myVehicleUpscaleDialer->setRange(0, 10000);
317  myVehicleUpscaleDialer->setValue(mySettings->vehicleExaggeration);
318  } {
319  new FXTabItem(tabbook, "Nodes", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
320  FXVerticalFrame* frame4 =
321  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
322  FXMatrix* m41 =
323  new FXMatrix(frame4, 3, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
324  0, 0, 0, 0, 10, 10, 10, 2, 5, 5);
325  new FXLabel(m41, "Color", 0, LAYOUT_CENTER_Y);
326  myJunctionColorMode = new FXComboBox(m41, 20, this, MID_SIMPLE_VIEW_COLORCHANGE, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC);
327  mySettings->junctionColorer.fill(*myJunctionColorMode);
328  myJunctionColorMode->setNumVisible(2);
329  myJunctionColorInterpolation = new FXCheckButton(m41, "Interpolate", this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
330 
331  FXScrollWindow* genScroll = new FXScrollWindow(frame4, LAYOUT_FILL_X | LAYOUT_SIDE_TOP | FRAME_RAISED | FRAME_THICK | LAYOUT_FIX_HEIGHT, 0, 0, 0, 80);
332  myJunctionColorSettingFrame =
333  new FXVerticalFrame(genScroll, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 2, 8, 5, 2);
334 
335  new FXHorizontalSeparator(frame4, SEPARATOR_GROOVE | LAYOUT_FILL_X);
336  FXMatrix* m42 =
337  new FXMatrix(frame4, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
338  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
339  myShowTLIndex = new FXCheckButton(m42, "Show link tls index", this, MID_SIMPLE_VIEW_COLORCHANGE);
340  myShowTLIndex->setCheck(mySettings->drawLinkTLIndex);
341  new FXLabel(m42, " ", 0, LAYOUT_CENTER_Y);
342  myShowJunctionIndex = new FXCheckButton(m42, "Show link junction index", this, MID_SIMPLE_VIEW_COLORCHANGE);
343  myShowJunctionIndex->setCheck(mySettings->drawLinkJunctionIndex);
344  new FXLabel(m42, " ", 0, LAYOUT_CENTER_Y);
345  myShowLane2Lane = new FXCheckButton(m42, "Show lane to lane connections", this, MID_SIMPLE_VIEW_COLORCHANGE);
346  myShowLane2Lane->setCheck(mySettings->showLane2Lane);
347  new FXLabel(m42, " ", 0, LAYOUT_CENTER_Y);
348  myJunctionNamePanel = new NamePanel(m42, this, "Show junction name", mySettings->junctionName);
349  myInternalJunctionNamePanel = new NamePanel(m42, this, "Show internal junction name", mySettings->internalJunctionName);
350  } {
351  new FXTabItem(tabbook, "Detectors/Trigger", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
352  FXVerticalFrame* frame5 =
353  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
354 
355  FXMatrix* m51 =
356  new FXMatrix(frame5, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
357  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
358  myAddNamePanel = new NamePanel(m51, this, "Show detector name", mySettings->addName);
359  new FXHorizontalSeparator(frame5 , SEPARATOR_GROOVE | LAYOUT_FILL_X);
360 
361  FXMatrix* m52 =
362  new FXMatrix(frame5, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
363  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
364  FXMatrix* m521 =
365  new FXMatrix(m52, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
366  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
367  new FXLabel(m521, "Minimum size", 0, LAYOUT_CENTER_Y);
368  myDetectorMinSizeDialer =
369  new FXRealSpinDial(m521, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
370  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
371  FXMatrix* m522 =
372  new FXMatrix(m52, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
373  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
374  myDetectorMinSizeDialer->setValue(mySettings->minAddSize);
375  new FXLabel(m522, "Exaggerate by", 0, LAYOUT_CENTER_Y);
376  myDetectorUpscaleDialer =
377  new FXRealSpinDial(m522, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
378  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
379  myDetectorUpscaleDialer->setRange(0, 10000);
380  myDetectorUpscaleDialer->setValue(mySettings->addExaggeration);
381 
382 
383  /*
384  new FXLabel(m522, "Color", 0, LAYOUT_CENTER_Y);
385  myDetectorNameColor = new FXColorWell(m522, MFXUtils::getFXColor(settings->addNameColor),
386  this, MID_SIMPLE_VIEW_COLORCHANGE,
387  LAYOUT_FIX_WIDTH|LAYOUT_CENTER_Y|LAYOUT_SIDE_TOP|FRAME_SUNKEN|FRAME_THICK|ICON_AFTER_TEXT,
388  0, 0, 100, 0, 0, 0, 0, 0);
389  */
390  } {
391  new FXTabItem(tabbook, "POIs", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
392  FXVerticalFrame* frame6 =
393  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
394 
395  FXMatrix* m61 =
396  new FXMatrix(frame6, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
397  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
398  myPOINamePanel = new NamePanel(m61, this, "Show poi names", mySettings->poiName);
399  new FXHorizontalSeparator(frame6 , SEPARATOR_GROOVE | LAYOUT_FILL_X);
400 
401  FXMatrix* m62 =
402  new FXMatrix(frame6, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
403  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
404  FXMatrix* m621 =
405  new FXMatrix(m62, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
406  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
407  new FXLabel(m621, "Minimum size to show", 0, LAYOUT_CENTER_Y);
408  myPOIMinSizeDialer =
409  new FXRealSpinDial(m621, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
410  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
411  FXMatrix* m622 =
412  new FXMatrix(m62, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
413  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
414  myPOIMinSizeDialer->setValue(mySettings->minPOISize);
415  new FXLabel(m622, "Exaggerate by", 0, LAYOUT_CENTER_Y);
416  myPOIUpscaleDialer =
417  new FXRealSpinDial(m622, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
418  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
419  myPOIUpscaleDialer->setRange(0, 10000);
420  myPOIUpscaleDialer->setValue(mySettings->addExaggeration);
421 
422 
423  } {
424  new FXTabItem(tabbook, "Polygons", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
425  FXVerticalFrame* frame9 =
426  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
427 
428  FXMatrix* m91 =
429  new FXMatrix(frame9, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
430  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
431  myPolyNamePanel = new NamePanel(m91, this, "Show polygon names", mySettings->polyName);
432  new FXHorizontalSeparator(frame9 , SEPARATOR_GROOVE | LAYOUT_FILL_X);
433 
434  FXMatrix* m92 =
435  new FXMatrix(frame9, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
436  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
437  FXMatrix* m921 =
438  new FXMatrix(m92, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
439  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
440  new FXLabel(m921, "Minimum size to show", 0, LAYOUT_CENTER_Y);
441  myPolyMinSizeDialer =
442  new FXRealSpinDial(m921, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
443  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
444  FXMatrix* m922 =
445  new FXMatrix(m92, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
446  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
447  myPolyMinSizeDialer->setValue(mySettings->minPolySize);
448  new FXLabel(m922, "Exaggerate by", 0, LAYOUT_CENTER_Y);
449  myPolyUpscaleDialer =
450  new FXRealSpinDial(m922, 10, this, MID_SIMPLE_VIEW_COLORCHANGE,
451  LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
452  myPolyUpscaleDialer->setRange(0, 10000);
453  myPolyUpscaleDialer->setValue(mySettings->addExaggeration);
454 
455 
456  }{
457  new FXTabItem(tabbook, "Legend", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
458  FXVerticalFrame* frame7 =
459  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
460 
461  FXMatrix* m72 =
462  new FXMatrix(frame7, 2, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
463  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
464  myShowSizeLegend = new FXCheckButton(m72, "Show Size Legend", this, MID_SIMPLE_VIEW_COLORCHANGE);
465  myShowSizeLegend->setCheck(mySettings->showSizeLegend);
466  new FXLabel(m72, "");
467  } {
468  new FXTabItem(tabbook, "openGL", NULL, TAB_LEFT_NORMAL, 0, 0, 0, 0, 4, 8, 4, 4);
469  FXVerticalFrame* frame8 =
470  new FXVerticalFrame(tabbook, FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
471 
472  FXMatrix* m82 =
473  new FXMatrix(frame8, 1, LAYOUT_FILL_X | LAYOUT_TOP | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
474  0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
475  myAntialiase = new FXCheckButton(m82, "Antialiase", this, MID_SIMPLE_VIEW_COLORCHANGE);
476  myAntialiase->setCheck(mySettings->antialiase);
477  myDither = new FXCheckButton(m82, "Dither", this, MID_SIMPLE_VIEW_COLORCHANGE);
478  myDither->setCheck(mySettings->dither);
479  }
480  FXHorizontalFrame* f2 = new FXHorizontalFrame(contentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
481  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);
482  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);
483  initial->setFocus();
484 
485  rebuildColorMatrices(false);
487 }
488 
489 
491  myParent->remove(this);
492  delete myEdgeNamePanel;
494  delete myStreetNamePanel;
495  delete myJunctionNamePanel;
497  delete myVehicleNamePanel;
498  delete myAddNamePanel;
499  delete myPOINamePanel;
500  delete myPolyNamePanel;
501 }
502 
503 
504 void
506  mySettings = settings;
507  myBackup = (*settings);
508  onCmdNameChange(0, 0, 0);
509 }
510 
511 
512 long
514  hide();
515  return 1;
516 }
517 
518 
519 long
521  hide();
522  (*mySettings) = myBackup;
523  return 1;
524 }
525 
526 
527 long
529  if (data != 0) {
530  FXString dataS = (char*) data; // !!!unicode
531  // check whether this item has been added twice
532  if (dataS == mySchemeName->getItemText(mySchemeName->getNumItems() - 1)) {
533  for (int i = 0; i < mySchemeName->getNumItems() - 1; ++i) {
534  if (dataS == mySchemeName->getItemText(i)) {
535  mySchemeName->removeItem(i);
536  }
537  }
538  }
539  myBackup = gSchemeStorage.get(dataS.text());
540  mySettings = &gSchemeStorage.get(dataS.text());
541  }
542  rebuildColorMatrices(true);
543 
545 
546  myLaneEdgeColorMode->setCurrentItem((FXint) mySettings->getLaneEdgeMode());
549  myShowRails->setCheck(mySettings->showRails);
555 
556  myVehicleColorMode->setCurrentItem((FXint) mySettings->vehicleColorer.getActive());
561  myShowMinGap->setCheck(mySettings->drawMinGap);
562  /*
563  myShowLaneChangePreference->setCheck(mySettings->drawLaneChangePreference);
564  */
566 
567  myJunctionColorMode->setCurrentItem((FXint) mySettings->junctionColorer.getActive());
572 
576 
580 
584 
586  myAntialiase->setCheck(mySettings->antialiase);
587  myDither->setCheck(mySettings->dither);
589 
591  update();
592  myParent->update();
593  return 1;
594 }
595 
596 
597 bool
598 GUIDialog_ViewSettings::updateColorRanges(FXObject* sender, std::vector<FXColorWell*>::const_iterator colIt,
599  std::vector<FXColorWell*>::const_iterator colEnd,
600  std::vector<FXRealSpinDial*>::const_iterator threshIt,
601  std::vector<FXRealSpinDial*>::const_iterator threshEnd,
602  std::vector<FXButton*>::const_iterator buttonIt,
603  GUIColorScheme& scheme) {
604  size_t pos = 0;
605  while (colIt != colEnd) {
606  if (scheme.isFixed()) {
607  if (sender == *colIt) {
608  scheme.setColor(pos, MFXUtils::getRGBColor((*colIt)->getRGBA()));
609  }
610  } else {
611  if (sender == *threshIt) {
612  const SUMOReal val = (*threshIt)->getValue();
613  double lo, hi;
614  if (pos != 0) {
615  threshIt--;
616  (*threshIt)->getRange(lo, hi);
617  (*threshIt)->setRange(lo, val);
618  threshIt++;
619  }
620  threshIt++;
621  if (threshIt != threshEnd) {
622  (*threshIt)->getRange(lo, hi);
623  (*threshIt)->setRange(val, hi);
624  }
625  scheme.setThreshold(pos, val);
626  return false;
627  }
628  if (sender == *colIt) {
629  scheme.setColor(pos, MFXUtils::getRGBColor((*colIt)->getRGBA()));
630  return false;
631  }
632  if (sender == *buttonIt) {
633  if (pos == 0) {
634  scheme.addColor(MFXUtils::getRGBColor((*colIt)->getRGBA()), (*threshIt)->getValue());
635  } else {
636  scheme.removeColor(pos);
637  }
638  return true;
639  }
640  ++threshIt;
641  ++buttonIt;
642  }
643  ++colIt;
644  pos++;
645  }
646  return false;
647 }
648 
649 
650 long
651 GUIDialog_ViewSettings::onCmdColorChange(FXObject* sender, FXSelector, void* /*val*/) {
652  GUIVisualizationSettings tmpSettings = *mySettings;
653  size_t prevLaneMode = mySettings->getLaneEdgeMode();
654  size_t prevVehicleMode = mySettings->vehicleColorer.getActive();
655  size_t prevJunctionMode = mySettings->junctionColorer.getActive();
656  bool doRebuildColorMatrices = false;
657 
658  tmpSettings.name = mySettings->name;
659  tmpSettings.backgroundColor = MFXUtils::getRGBColor(myBackgroundColor->getRGBA());
660  tmpSettings.showGrid = (myShowGrid->getCheck() != FALSE);
661  tmpSettings.gridXSize = (SUMOReal) myGridXSizeDialer->getValue();
662  tmpSettings.gridYSize = (SUMOReal) myGridYSizeDialer->getValue();
663 
664 #ifdef HAVE_INTERNAL
665  if (GUIVisualizationSettings::UseMesoSim) {
666  tmpSettings.edgeColorer.setActive(myLaneEdgeColorMode->getCurrentItem());
667  } else {
668 #endif
669  tmpSettings.laneColorer.setActive(myLaneEdgeColorMode->getCurrentItem());
670 #ifdef HAVE_INTERNAL
671  }
672 #endif
673  tmpSettings.laneShowBorders = (myShowLaneBorders->getCheck() != FALSE);
674  tmpSettings.showLinkDecals = (myShowLaneDecals->getCheck() != FALSE);
675  tmpSettings.showRails = (myShowRails->getCheck() != FALSE);
676  tmpSettings.edgeName = myEdgeNamePanel->getSettings();
678  tmpSettings.streetName = myStreetNamePanel->getSettings();
679  tmpSettings.hideConnectors = (myHideMacroConnectors->getCheck() != FALSE);
680  tmpSettings.laneWidthExaggeration = (SUMOReal) myLaneWidthUpscaleDialer->getValue();
681 
682  tmpSettings.vehicleColorer.setActive(myVehicleColorMode->getCurrentItem());
683  tmpSettings.vehicleQuality = myVehicleShapeDetail->getCurrentItem();
684  tmpSettings.vehicleExaggeration = (SUMOReal) myVehicleUpscaleDialer->getValue();
685  tmpSettings.minVehicleSize = (SUMOReal) myVehicleMinSizeDialer->getValue();
686  tmpSettings.showBlinker = (myShowBlinker->getCheck() != FALSE);
687  tmpSettings.drawMinGap = (myShowMinGap->getCheck() != FALSE);
688  /*
689  tmpSettings.drawLaneChangePreference = (myShowLaneChangePreference->getCheck() != FALSE);
690  */
691  tmpSettings.vehicleName = myVehicleNamePanel->getSettings();
692 
693  tmpSettings.junctionColorer.setActive(myJunctionColorMode->getCurrentItem());
694  tmpSettings.drawLinkTLIndex = (myShowTLIndex->getCheck() != FALSE);
695  tmpSettings.drawLinkJunctionIndex = (myShowJunctionIndex->getCheck() != FALSE);
698 
699  tmpSettings.addExaggeration = (SUMOReal) myDetectorUpscaleDialer->getValue();
700  tmpSettings.minAddSize = (SUMOReal) myDetectorMinSizeDialer->getValue();
701  tmpSettings.addName = myAddNamePanel->getSettings();
702 
703  tmpSettings.poiExaggeration = (SUMOReal) myPOIUpscaleDialer->getValue();
704  tmpSettings.minPOISize = (SUMOReal) myPOIMinSizeDialer->getValue();
705  tmpSettings.poiName = myPOINamePanel->getSettings();
706 
707  tmpSettings.polyExaggeration = (SUMOReal) myPolyUpscaleDialer->getValue();
708  tmpSettings.minPolySize = (SUMOReal) myPolyMinSizeDialer->getValue();
709  tmpSettings.polyName = myPolyNamePanel->getSettings();
710 
711  tmpSettings.showLane2Lane = (myShowLane2Lane->getCheck() != FALSE);
712  tmpSettings.antialiase = (myAntialiase->getCheck() != FALSE);
713  tmpSettings.dither = (myDither->getCheck() != FALSE);
714  tmpSettings.showSizeLegend = (myShowSizeLegend->getCheck() != FALSE);
715 
716  // lanes
717  if (tmpSettings.getLaneEdgeMode() == prevLaneMode) {
718  if (updateColorRanges(sender, myLaneColors.begin(), myLaneColors.end(),
719  myLaneThresholds.begin(), myLaneThresholds.end(), myLaneButtons.begin(),
720  tmpSettings.getLaneEdgeScheme())) {
721  doRebuildColorMatrices = true;
722  }
723  if (sender == myLaneColorInterpolation) {
724  tmpSettings.getLaneEdgeScheme().setInterpolated(myLaneColorInterpolation->getCheck() != FALSE);
725  doRebuildColorMatrices = true;
726  }
727  } else {
728  doRebuildColorMatrices = true;
729  }
730  // vehicles
731  if (tmpSettings.vehicleColorer.getActive() == prevVehicleMode) {
732  if (updateColorRanges(sender, myVehicleColors.begin(), myVehicleColors.end(),
734  tmpSettings.vehicleColorer.getScheme())) {
735  doRebuildColorMatrices = true;
736  }
737  if (sender == myVehicleColorInterpolation) {
738  tmpSettings.vehicleColorer.getScheme().setInterpolated(myVehicleColorInterpolation->getCheck() != FALSE);
739  doRebuildColorMatrices = true;
740  }
741  } else {
742  doRebuildColorMatrices = true;
743  }
744  // junctions
745  if (tmpSettings.junctionColorer.getActive() == prevJunctionMode) {
746  if (updateColorRanges(sender, myJunctionColors.begin(), myJunctionColors.end(),
748  tmpSettings.junctionColorer.getScheme())) {
749  doRebuildColorMatrices = true;
750  }
751  if (sender == myJunctionColorInterpolation) {
752  tmpSettings.junctionColorer.getScheme().setInterpolated(myJunctionColorInterpolation->getCheck() != FALSE);
753  doRebuildColorMatrices = true;
754  }
755  } else {
756  doRebuildColorMatrices = true;
757  }
758 
759  if (tmpSettings == *mySettings) {
760  return 1;
761  }
762 
763  int index = mySchemeName->getCurrentItem();
764  if (index < (int) gSchemeStorage.getNumInitialSettings()) {
765  // one of the initial settings is modified
766  // every time this happens we create a new scheme
767  int suffix = 1;
768  while (gSchemeStorage.contains("custom_" + toString(suffix))) {
769  suffix++;
770  }
771  tmpSettings.name = "custom_" + toString(suffix);
772  // the newly created settings must be entered in several places:
773  // - the comboBox mySchemeName of this dialog
774  // - the comboBox of the parent view (set as active)
775  // - the comboBox of all other views (only append) XXX @todo
776  index = mySchemeName->appendItem(tmpSettings.name.c_str());
777  mySchemeName->setCurrentItem(index);
778  myParent->getColoringSchemesCombo().appendItem(tmpSettings.name.c_str());
779  }
780  myParent->getColoringSchemesCombo().setCurrentItem(
781  myParent->getColoringSchemesCombo().findItem(tmpSettings.name.c_str()));
782  gSchemeStorage.add(tmpSettings); // overwrites existing
783  mySettings = &gSchemeStorage.get(tmpSettings.name);
784  myParent->setColorScheme(tmpSettings.name);
785 
786  if (doRebuildColorMatrices) {
787  rebuildColorMatrices(true);
788  }
789  myParent->forceRefresh();
790  getApp()->forceRefresh();
791  return 1;
792 }
793 
794 
795 void
796 GUIDialog_ViewSettings::loadSettings(const std::string& file) {
797  GUISettingsHandler handler(file);
798  std::string settingsName = handler.addSettings(myParent);
799  if (settingsName != "") {
800  FXint index = mySchemeName->appendItem(settingsName.c_str());
801  mySchemeName->setCurrentItem(index);
802  mySettings = &gSchemeStorage.get(settingsName);
803  }
804 }
805 
806 
807 void
808 GUIDialog_ViewSettings::saveDecals(const std::string& file) const {
809  try {
811  dev << "<decals>\n";
812  std::vector<GUISUMOAbstractView::Decal>::iterator j;
813  for (j = myDecals->begin(); j != myDecals->end(); ++j) {
815  dev << " <decal filename=\"" << d.filename
816  << "\" centerX=\"" << d.centerX
817  << "\" centerY=\"" << d.centerY
818  << "\" centerZ=\"" << d.centerZ
819  << "\" width=\"" << d.width
820  << "\" height=\"" << d.height
821  << "\" altitude=\"" << d.altitude
822  << "\" rotation=\"" << d.rot
823  << "\" tilt=\"" << d.tilt
824  << "\" roll=\"" << d.roll
825  << "\" layer=\"" << d.layer
826  << "\"/>\n";
827  }
828  dev << "</decals>\n";
829  dev.close();
830  } catch (IOError& e) {
831  FXMessageBox::error(myParent, MBOX_OK, "Storing failed!", "%s", e.what());
832  }
833 }
834 
835 
836 void
837 GUIDialog_ViewSettings::loadDecals(const std::string& file) {
838  myDecalsLock->lock();
839  GUISettingsHandler handler(file);
840  if (handler.hasDecals()) {
841  (*myDecals) = handler.getDecals();
842  }
843  rebuildList();
844  myParent->update();
845  myDecalsLock->unlock();
846 }
847 
848 
849 long
850 GUIDialog_ViewSettings::onCmdSaveSetting(FXObject*, FXSelector, void* /*data*/) {
851  int index = mySchemeName->getCurrentItem();
852  if (index < (int) gSchemeStorage.getNumInitialSettings()) {
853  return 1;
854  }
855  // get the name
856  std::string name = "";
857  while (name.length() == 0) {
858  FXDialogBox dialog(this, "Enter a name", DECOR_TITLE | DECOR_BORDER);
859  FXVerticalFrame* content = new FXVerticalFrame(&dialog, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10);
860  new FXLabel(content, "Please enter an alphanumeric name: ", NULL, LAYOUT_FILL_X | JUSTIFY_LEFT);
861  FXTextField* text = new FXTextField(content, 40, &dialog, FXDialogBox::ID_ACCEPT, TEXTFIELD_ENTER_ONLY | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_X);
862  new FXHorizontalSeparator(content, SEPARATOR_GROOVE | LAYOUT_FILL_X);
863  FXHorizontalFrame* buttons = new FXHorizontalFrame(content, LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 0, 0, 0, 0);
864  new FXButton(buttons, "&OK", NULL, &dialog, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_RIGHT);
865  new FXButton(buttons, "&Cancel", NULL, &dialog, FXDialogBox::ID_CANCEL, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_RIGHT, 0, 0, 0, 0, 20, 20);
866  dialog.create();
867  text->setFocus();
868  if (!dialog.execute()) {
869  return 1;
870  }
871  name = text->getText().text();
872  for (size_t i = 0; i < name.length(); ++i) {
873  if (name[i] != '_' && (name[i] < 'a' || name[i] > 'z') && (name[i] < 'A' || name[i] > 'Z') && (name[i] < '0' || name[i] > '9')) {
874  name = "";
875  break;
876  }
877  }
878  }
879  GUIVisualizationSettings tmpSettings = *mySettings;
881  tmpSettings.name = name;
882  gSchemeStorage.add(tmpSettings);
883  mySchemeName->setItemText(index, tmpSettings.name.c_str());
884  myParent->getColoringSchemesCombo().setItemText(index, tmpSettings.name.c_str());
885  myParent->setColorScheme(tmpSettings.name);
886  mySettings = &gSchemeStorage.get(name);
887  myBackup = *mySettings;
888  gSchemeStorage.writeSettings(getApp());
889  return 1;
890 }
891 
892 
893 long
894 GUIDialog_ViewSettings::onUpdSaveSetting(FXObject* sender, FXSelector, void* ptr) {
895  sender->handle(this,
896  mySchemeName->getCurrentItem() < (int) gSchemeStorage.getNumInitialSettings()
897  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
898  ptr);
899  return 1;
900 }
901 
902 
903 long
905  int index = mySchemeName->getCurrentItem();
906  if (index < (int) gSchemeStorage.getNumInitialSettings()) {
907  return 1;
908  }
909  std::string name = mySchemeName->getItem(index).text();
910  gSchemeStorage.remove(name);
911  mySchemeName->removeItem(index);
912  onCmdNameChange(0, 0, (void*) mySchemeName->getItem(0).text());
913  gSchemeStorage.writeSettings(getApp());
914  return 1;
915 }
916 
917 
918 long
919 GUIDialog_ViewSettings::onUpdDeleteSetting(FXObject* sender, FXSelector, void* ptr) {
920  sender->handle(this,
921  mySchemeName->getCurrentItem() < (int) gSchemeStorage.getNumInitialSettings()
922  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
923  ptr);
924  return 1;
925 }
926 
927 
928 long
930  FXFileDialog opendialog(this, "Export view settings");
931  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
932  opendialog.setSelectMode(SELECTFILE_ANY);
933  opendialog.setPatternList("*.xml");
934  if (gCurrentFolder.length() != 0) {
935  opendialog.setDirectory(gCurrentFolder);
936  }
937  if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
938  return 1;
939  }
940  try {
941  OutputDevice& dev = OutputDevice::getDevice(opendialog.getFilename().text());
942  mySettings->save(dev);
943  dev.close();
944  } catch (IOError& e) {
945  FXMessageBox::error(this, MBOX_OK, "Storing failed!", "%s", e.what());
946  }
947  return 1;
948 }
949 
950 
951 long
952 GUIDialog_ViewSettings::onUpdExportSetting(FXObject* sender, FXSelector, void* ptr) {
953  sender->handle(this,
954  mySchemeName->getCurrentItem() < (int) gSchemeStorage.getNumInitialSettings()
955  ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
956  ptr);
957  return 1;
958 }
959 
960 
961 long
963  FXFileDialog opendialog(this, "Import view settings");
964  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
965  opendialog.setSelectMode(SELECTFILE_ANY);
966  opendialog.setPatternList("*.xml");
967  if (gCurrentFolder.length() != 0) {
968  opendialog.setDirectory(gCurrentFolder);
969  }
970  if (opendialog.execute()) {
971  gCurrentFolder = opendialog.getDirectory();
972  loadSettings(opendialog.getFilename().text());
973  }
974  return 1;
975 }
976 
977 
978 long
979 GUIDialog_ViewSettings::onCmdLoadDecals(FXObject*, FXSelector, void* /*data*/) {
980  FXFileDialog opendialog(this, "Load Decals");
981  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
982  opendialog.setSelectMode(SELECTFILE_ANY);
983  opendialog.setPatternList("*.xml");
984  if (gCurrentFolder.length() != 0) {
985  opendialog.setDirectory(gCurrentFolder);
986  }
987  if (opendialog.execute()) {
988  gCurrentFolder = opendialog.getDirectory();
989  loadDecals(opendialog.getFilename().text());
990  }
991  return 1;
992 }
993 
994 
995 long
996 GUIDialog_ViewSettings::onCmdSaveDecals(FXObject*, FXSelector, void* /*data*/) {
997  FXFileDialog opendialog(this, "Save Decals");
998  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
999  opendialog.setSelectMode(SELECTFILE_ANY);
1000  opendialog.setPatternList("*.xml");
1001  if (gCurrentFolder.length() != 0) {
1002  opendialog.setDirectory(gCurrentFolder);
1003  }
1004  if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
1005  return 1;
1006  }
1007  saveDecals(opendialog.getFilename().text());
1008  return 1;
1009 }
1010 
1011 
1012 
1013 
1014 long
1015 GUIDialog_ViewSettings::onUpdImportSetting(FXObject* sender, FXSelector, void* ptr) {
1016  sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
1017  return 1;
1018 }
1019 
1020 
1021 void
1023  myDecalsTable->clearItems();
1024  // set table attributes
1025  myDecalsTable->setTableSize(10, 7);
1026  myDecalsTable->setColumnText(0, "picture file");
1027  myDecalsTable->setColumnText(1, "center x");
1028  myDecalsTable->setColumnText(2, "center y");
1029  myDecalsTable->setColumnText(3, "width");
1030  myDecalsTable->setColumnText(4, "height");
1031  myDecalsTable->setColumnText(5, "rotation");
1032  myDecalsTable->setColumnText(6, "layer");
1033  FXHeader* header = myDecalsTable->getColumnHeader();
1034  header->setHeight(getApp()->getNormalFont()->getFontHeight() + getApp()->getNormalFont()->getFontAscent());
1035  int k;
1036  for (k = 0; k < 7; k++) {
1037  header->setItemJustify(k, JUSTIFY_CENTER_X | JUSTIFY_TOP);
1038  header->setItemSize(k, 60);
1039  }
1040  header->setItemSize(0, 150);
1041  // insert already known decals information into table
1042  FXint row = 0;
1043  std::vector<GUISUMOAbstractView::Decal>::iterator j;
1044  for (j = myDecals->begin(); j != myDecals->end(); ++j) {
1046  myDecalsTable->setItemText(row, 0, d.filename.c_str());
1047  myDecalsTable->setItemText(row, 1, toString<SUMOReal>(d.centerX).c_str());
1048  myDecalsTable->setItemText(row, 2, toString<SUMOReal>(d.centerY).c_str());
1049  myDecalsTable->setItemText(row, 3, toString<SUMOReal>(d.width).c_str());
1050  myDecalsTable->setItemText(row, 4, toString<SUMOReal>(d.height).c_str());
1051  myDecalsTable->setItemText(row, 5, toString<SUMOReal>(d.rot).c_str());
1052  myDecalsTable->setItemText(row, 6, toString<SUMOReal>(d.layer).c_str());
1053  row++;
1054  }
1055  // insert dummy last field
1056  for (k = 0; k < 7; k++) {
1057  myDecalsTable->setItemText(row, k, " ");
1058  }
1059 }
1060 
1061 
1062 FXMatrix*
1064  std::vector<FXColorWell*>& colors,
1065  std::vector<FXRealSpinDial*>& thresholds,
1066  std::vector<FXButton*>& buttons,
1067  FXCheckButton* interpolation,
1068  GUIColorScheme& scheme) {
1069  MFXUtils::deleteChildren(frame);
1070  FXMatrix* m = new FXMatrix(frame, 3,
1071  LAYOUT_FILL_X | MATRIX_BY_COLUMNS,
1072  0, 0, 0, 0, 10, 10, 0, 0, 5, 3);
1073  colors.clear();
1074  thresholds.clear();
1075  buttons.clear();
1076  const bool fixed = scheme.isFixed();
1077  std::vector<RGBColor>::const_iterator colIt = scheme.getColors().begin();
1078  std::vector<SUMOReal>::const_iterator threshIt = scheme.getThresholds().begin();
1079  std::vector<std::string>::const_iterator nameIt = scheme.getNames().begin();
1080  FX::FXString buttonText = "Add";
1081  while (colIt != scheme.getColors().end()) {
1082  colors.push_back(new FXColorWell(m , MFXUtils::getFXColor(*colIt),
1084  LAYOUT_FIX_WIDTH | LAYOUT_CENTER_Y | FRAME_SUNKEN | FRAME_THICK | ICON_AFTER_TEXT,
1085  0, 0, 100, 0, 0, 0, 0, 0));
1086  if (fixed) {
1087  new FXLabel(m, nameIt->c_str());
1088  new FXLabel(m, "");
1089  } else {
1090  const int dialerOptions = scheme.allowsNegativeValues() ? SPINDIAL_NOMIN : 0;
1091  FXRealSpinDial* threshDialer = new FXRealSpinDial(m, 10, this, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | SPINDIAL_NOMAX | dialerOptions);
1092  threshDialer->setValue(*threshIt);
1093  thresholds.push_back(threshDialer);
1094  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));
1095  buttonText = "Remove";
1096  }
1097  colIt++;
1098  threshIt++;
1099  nameIt++;
1100  }
1101  interpolation->setCheck(scheme.isInterpolated());
1102  if (fixed) {
1103  interpolation->disable();
1104  } else {
1105  if (colors.size() > 1) {
1106  interpolation->enable();
1107  if (interpolation->getCheck() != FALSE) {
1108  thresholds.front()->enable();
1109  } else {
1110  thresholds.front()->disable();
1111  }
1112  } else {
1113  interpolation->disable();
1114  thresholds.front()->disable();
1115  }
1116  }
1117  return m;
1118 }
1119 
1120 
1121 void
1123  // decals
1124  delete myDecalsTable;
1126  LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH/*|LAYOUT_FIX_HEIGHT*/, 0, 0, 470, 0);
1127  myDecalsTable->setVisibleRows(5);
1128  myDecalsTable->setVisibleColumns(7);
1129  myDecalsTable->setTableSize(5, 7);
1130  myDecalsTable->setBackColor(FXRGB(255, 255, 255));
1131  myDecalsTable->getRowHeader()->setWidth(0);
1132  for (int i = 1; i <= 5; ++i) {
1134  myDecalsTable->setNumberCellParams(i, -10000000, 10000000, 1, 10, 100, "%.2f");
1135  }
1136  rebuildList();
1137  if (doCreate) {
1138  myDecalsTable->create();
1139  }
1141  if (doCreate) {
1142  m->create();
1143  }
1144  myLaneColorSettingFrame->getParent()->recalc();
1146  if (doCreate) {
1147  m->create();
1148  }
1149  myVehicleColorSettingFrame->getParent()->recalc();
1151  if (doCreate) {
1152  m->create();
1153  }
1154  myJunctionColorSettingFrame->getParent()->recalc();
1155  layout();
1156  update();
1157 }
1158 
1159 
1160 long
1163  std::string value = i->item->getText().text();
1164  // check whether the inserted value is empty
1165  if (value.find_first_not_of(" ") == std::string::npos) {
1166  return 1;
1167  }
1169  int row = i->row;
1170  // check whether we add a new entry or edit an existing entry
1171  if (row == static_cast<int>(myDecals->size())) {
1172  d.filename = "";
1173  d.centerX = SUMOReal(myParent->getGridWidth() / 2.);
1174  d.centerY = SUMOReal(myParent->getGridHeight() / 2.);
1177  d.initialised = false;
1178  d.rot = 0;
1179  d.layer = 0;
1180  myDecalsLock->lock();
1181  myDecals->push_back(d);
1182  myDecalsLock->unlock();
1183  } else if (row > static_cast<int>(myDecals->size())) {
1184  // ignore clicks two lines below existing entries
1185  return 1;
1186  } else {
1187  d = (*myDecals)[row];
1188  }
1189 
1190  switch (i->col) {
1191  case 0:
1192  if (d.initialised && d.filename != value) {
1193  d.initialised = false;
1194  }
1195  d.filename = value;
1196  break;
1197  case 1:
1198  try {
1199  d.centerX = TplConvert::_2SUMOReal(value.c_str());
1200  } catch (NumberFormatException&) {
1201  std::string msg = "The value must be a float, is:" + value;
1202  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1203  }
1204  break;
1205  case 2:
1206  try {
1207  d.centerY = TplConvert::_2SUMOReal(value.c_str());
1208  } catch (NumberFormatException&) {
1209  std::string msg = "The value must be a float, is:" + value;
1210  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1211  }
1212  break;
1213  case 3:
1214  try {
1215  d.width = TplConvert::_2SUMOReal(value.c_str());
1216  } catch (NumberFormatException&) {
1217  std::string msg = "The value must be a float, is:" + value;
1218  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1219  }
1220  break;
1221  case 4:
1222  try {
1223  d.height = TplConvert::_2SUMOReal(value.c_str());
1224  } catch (NumberFormatException&) {
1225  std::string msg = "The value must be a float, is:" + value;
1226  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1227  }
1228  break;
1229  case 5:
1230  try {
1231  d.rot = TplConvert::_2SUMOReal(value.c_str());
1232  } catch (NumberFormatException&) {
1233  std::string msg = "The value must be a float, is:" + value;
1234  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1235  }
1236  break;
1237  case 6:
1238  try {
1239  d.layer = TplConvert::_2SUMOReal(value.c_str());
1240  } catch (NumberFormatException&) {
1241  std::string msg = "The value must be a float, is:" + value;
1242  FXMessageBox::error(this, MBOX_OK, "Number format error", "%s", msg.c_str());
1243  }
1244  break;
1245  default:
1246  throw 1;
1247  }
1248  (*myDecals)[row] = d;
1249  if (!i->updateOnly) {
1250  rebuildList();
1251  }
1252  myParent->update();
1253  return 1;
1254 }
1255 
1256 
1257 std::string
1259  return mySchemeName->getItem(mySchemeName->getCurrentItem()).text();
1260 }
1261 
1262 
1263 void
1265  if (name.c_str() == mySchemeName->getItemText(mySchemeName->getCurrentItem())) {
1266  return;
1267  }
1268  for (int i = 0; i < mySchemeName->getNumItems(); ++i) {
1269  if (name.c_str() == mySchemeName->getItemText(i)) {
1270  mySchemeName->setCurrentItem(i);
1271  onCmdNameChange(0, 0, (void*)name.c_str());
1272  return;
1273  }
1274  }
1275 }
1276 
1278  FXMatrix* parent,
1279  GUIDialog_ViewSettings* target,
1280  const std::string& title,
1281  const GUIVisualizationTextSettings& settings) {
1282  myCheck = new FXCheckButton(parent, title.c_str(), target, MID_SIMPLE_VIEW_COLORCHANGE, LAYOUT_CENTER_Y | CHECKBUTTON_NORMAL);
1283  myCheck->setCheck(settings.show);
1284  new FXLabel(parent, "");
1285  FXMatrix* m1 = new FXMatrix(parent, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
1286  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
1287  new FXLabel(m1, "Size", 0, LAYOUT_CENTER_Y);
1288  mySizeDial = new FXRealSpinDial(m1, 10, target, MID_SIMPLE_VIEW_COLORCHANGE,
1289  LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
1290  mySizeDial->setRange(10, 1000);
1291  mySizeDial->setValue(settings.size);
1292  FXMatrix* m2 = new FXMatrix(parent, 2, LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS,
1293  0, 0, 0, 0, 10, 10, 0, 0, 5, 5);
1294  new FXLabel(m2, "Color", 0, LAYOUT_CENTER_Y);
1295  myColorWell = new FXColorWell(m2, MFXUtils::getFXColor(settings.color),
1296  target, MID_SIMPLE_VIEW_COLORCHANGE,
1297  LAYOUT_FIX_WIDTH | LAYOUT_CENTER_Y | LAYOUT_SIDE_TOP | FRAME_SUNKEN | FRAME_THICK | ICON_AFTER_TEXT,
1298  0, 0, 100, 0, 0, 0, 0, 0);
1299 }
1300 
1303  return GUIVisualizationTextSettings(myCheck->getCheck() != FALSE,
1304  mySizeDial->getValue(), MFXUtils::getRGBColor(myColorWell->getRGBA()));
1305 }
1306 
1307 
1308 void
1310  myCheck->setCheck(settings.show);
1311  mySizeDial->setValue(settings.size);
1312  myColorWell->setRGBA(MFXUtils::getFXColor(settings.color));
1313 }
1314 /****************************************************************************/
1315