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