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