SUMO - Simulation of Urban MObility
GNEApplicationWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The main window of Netedit (adapted from GUIApplicationWindow)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #ifdef HAVE_VERSION_H
32 #include <version.h>
33 #endif
34 
35 #include <string>
36 #include <sstream>
37 #include <algorithm>
38 
39 #include <utils/common/ToString.h>
42 #include <utils/xml/XMLSubSys.h>
58 #include <netimport/NIFrame.h>
59 #include <netbuild/NBFrame.h>
60 #include <netwrite/NWFrame.h>
63 
64 #include "GNEApplicationWindow.h"
65 #include "GNELoadThread.h"
66 #include "GNEEvent_NetworkLoaded.h"
67 #include "GNEViewParent.h"
68 #include "GNEViewNet.h"
69 #include "GNEDialog_About.h"
70 #include "GNEDialog_Wizard.h"
71 #include "GNENet.h"
72 #include "GNEEdge.h"
73 #include "GNEJunction.h"
74 #include "GNEUndoList.h"
75 #include "GNEPOI.h"
76 #include "GNEAdditionalHandler.h"
77 
78 
79 // ===========================================================================
80 // FOX-declarations
81 // ===========================================================================
82 FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[] = {
83  //________Message_Type____________ID________________________Message_Handler________
84  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GNEApplicationWindow::onCmdQuit),
85  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GNEApplicationWindow::onCmdQuit),
86  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GNEApplicationWindow::onCmdQuit),
87 
95  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GNEApplicationWindow::onCmdReload),
96  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GNEApplicationWindow::onCmdClose),
97  FXMAPFUNC(SEL_UPDATE, MID_CLOSE, GNEApplicationWindow::onUpdNeedsNetwork),
98 
99  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GNEApplicationWindow::onCmdAbout),
101 
103  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GNEApplicationWindow::onUpdOpen),
104  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GNEApplicationWindow::onUpdOpen),
108  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GNEApplicationWindow::onUpdReload),
109  FXMAPFUNC(SEL_UPDATE, MID_RECENTFILE, GNEApplicationWindow::onUpdOpen),
110  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNEApplicationWindow::onClipboardRequest),
111 
112  // forward requests to the active view
113  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GNEApplicationWindow::onCmdLocate),
114  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GNEApplicationWindow::onCmdLocate),
115  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GNEApplicationWindow::onCmdLocate),
119  FXMAPFUNC(SEL_KEYPRESS, 0, GNEApplicationWindow::onKeyPress),
120  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEApplicationWindow::onKeyRelease),
121 
124 
127  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_MOVE, GNEApplicationWindow::onCmdSetMode),
137  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_TLS, GNEApplicationWindow::onCmdSetMode),
145 
151  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_PLAIN_XML, GNEApplicationWindow::onUpdNeedsNetwork), // called when net is opened/closed
153  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_JOINED, GNEApplicationWindow::onUpdNeedsNetwork), // called when net is opened/closed
156  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_SHAPES_AS, GNEApplicationWindow::onUpdNeedsNetwork), // called when net is opened/closed
159  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_ADDITIONALS_AS, GNEApplicationWindow::onUpdNeedsNetwork), // called when net is opened/closed
160 
161  FXMAPFUNC(SEL_COMMAND, MID_GNE_ABORT, GNEApplicationWindow::onCmdAbort),
162  FXMAPFUNC(SEL_COMMAND, MID_GNE_HOTKEY_DEL, GNEApplicationWindow::onCmdDel),
165  FXMAPFUNC(SEL_COMMAND, MID_HELP, GNEApplicationWindow::onCmdHelp),
176  FXMAPFUNC(SEL_COMMAND, MID_GNE_OPTIONS, GNEApplicationWindow::onCmdOptions),
178 };
179 
180 // Object implementation
181 FXIMPLEMENT(GNEApplicationWindow, FXMainWindow, GNEApplicationWindowMap, ARRAYNUMBER(GNEApplicationWindowMap))
182 
183 // ===========================================================================
184 // member method definitions
185 // ===========================================================================
186 #ifdef _MSC_VER
187 #pragma warning(push)
188 #pragma warning(disable: 4355)
189 #endif
190 GNEApplicationWindow::GNEApplicationWindow(FXApp* a, const std::string& configPattern) :
191  GUIMainWindow(a),
192  myLoadThread(0),
193  myAmLoading(false),
194  myRecentNets(a, "nets"),
195  myConfigPattern(configPattern),
196  hadDependentBuild(false),
197  myNet(0),
198  myUndoList(new GNEUndoList(this)),
199  myTitlePrefix("NETEDIT " VERSION_STRING) {
200  // init icons
202  // init Textures
204 }
205 #ifdef _MSC_VER
206 #pragma warning(pop)
207 #endif
208 
209 
210 void
212  // do this not twice
213  if (hadDependentBuild) {
214  WRITE_ERROR("DEBUG: GNEApplicationWindow::dependentBuild called twice");
215  return;
216  }
217  hadDependentBuild = true;
218 
219  setTarget(this);
220  setSelector(MID_WINDOW);
221 
222  // build menu bar
223  myMenuBarDrag = new FXToolBarShell(this, GUIDesignToolBarShell3);
224  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag, GUIDesignBar);
225  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
226  // build the thread - io
229 
230  // build the status bar
231  myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
232  {
233  myGeoFrame =
234  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
235  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
237  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
238  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
239  }
240  // make the window a mdi-window
241  myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
242  myMDIClient = new FXMDIClient(myMainSplitter, GUIDesignSplitterMDI);
243  myMDIMenu = new FXMDIMenu(this, myMDIClient);
244  // Due netedit only have a view, this buttons must be disabled (see #2807)
245  //new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient, FXMDIClient::ID_MDI_MENUWINDOW, GUIDesignMDIButtonLeft);
246  //new FXMDIDeleteButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUCLOSE, GUIDesignMDIButtonRight);
247  //new FXMDIRestoreButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENURESTORE, GUIDesignMDIButtonRight);
248  //new FXMDIMinimizeButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUMINIMIZE, GUIDesignMDIButtonRight);
249 
250  // build the message window
252  myMainSplitter->setSplit(1, 65);
253  // fill menu and tool bar
254  fillMenuBar();
255  // build additional threads
256  myLoadThread = new GNELoadThread(getApp(), this, myEvents, myLoadThreadEvent);
257  // set the status bar
258  myStatusbar->getStatusLine()->setText("Ready.");
259  // set the caption
260  setTitle(myTitlePrefix);
261 
263 
264  //initialize some hotkeys
265  getAccelTable()->addAccel(parseAccel("e"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CREATE_EDGE));
266  getAccelTable()->addAccel(parseAccel("m"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_MOVE));
267  getAccelTable()->addAccel(parseAccel("d"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_DELETE));
268  getAccelTable()->addAccel(parseAccel("i"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_INSPECT));
269  getAccelTable()->addAccel(parseAccel("s"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_SELECT));
270  getAccelTable()->addAccel(parseAccel("c"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CONNECT));
271  getAccelTable()->addAccel(parseAccel("t"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_TLS));
272  getAccelTable()->addAccel(parseAccel("a"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_ADDITIONAL));
273  getAccelTable()->addAccel(parseAccel("r"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CROSSING));
274  getAccelTable()->addAccel(parseAccel("p"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_POLYGON));
275  getAccelTable()->addAccel(parseAccel("Esc"), this, FXSEL(SEL_COMMAND, MID_GNE_ABORT));
276  getAccelTable()->addAccel(parseAccel("Del"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_DEL));
277  getAccelTable()->addAccel(parseAccel("Enter"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_ENTER));
278  getAccelTable()->addAccel(parseAccel("F12"), this, FXSEL(SEL_COMMAND, MID_GNE_FOCUS_FRAME));
279  getAccelTable()->addAccel(parseAccel("v"), this, FXSEL(SEL_COMMAND, MID_EDITVIEWPORT));
280 }
281 
282 void
285  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
286  FXMainWindow::create();
287  myMenuBarDrag->create();
288  myFileMenu->create();
289  myEditMenu->create();
290  //mySettingsMenu->create();
291  myWindowsMenu->create();
292  myHelpMenu->create();
293 
294  FXint textWidth = getApp()->getNormalFont()->getTextWidth("8", 1) * 22;
295  myCartesianFrame->setWidth(textWidth);
296  myGeoFrame->setWidth(textWidth);
297 
298  show(PLACEMENT_DEFAULT);
299  if (!OptionsCont::getOptions().isSet("window-size")) {
300  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
301  maximize();
302  }
303  }
304 
305 }
306 
307 
309  closeAllWindows();
310  // Close icons
312  // Close gifs (Textures)
314  delete myGLVisual;
315  // must delete menus to avoid segfault on removing accelerators
316  // (http://www.fox-toolkit.net/faq#TOC-What-happens-when-the-application-s)
317  delete myFileMenu;
318  delete myEditMenu;
319  delete myLocatorMenu;
320  delete myProcessingMenu;
321  delete myWindowsMenu;
322  delete myHelpMenu;
323 
324  delete myLoadThread;
325 
326  while (!myEvents.empty()) {
327  // get the next event
328  GUIEvent* e = myEvents.top();
329  myEvents.pop();
330  delete e;
331  }
332  delete myUndoList;
333 }
334 
335 
336 void
338  FXMainWindow::detach();
339  myMenuBarDrag->detach();
340 }
341 
342 
343 void
345  // build file menu
346  myFileMenu = new FXMenuPane(this);
347  new FXMenuTitle(myMenuBar, "&File", 0, myFileMenu);
348  new FXMenuCommand(myFileMenu,
349  "&New Network...\tCtrl+N\tCreate a new network.",
351  new FXMenuCommand(myFileMenu,
352  "&Open Network...\tCtrl+O\tOpen a SUMO network.",
354  new FXMenuCommand(myFileMenu,
355  "Open Configura&tion...\tCtrl+T\tOpen a NETCONVERT configuration file.",
357  new FXMenuCommand(myFileMenu,
358  "Import &Foreign Network...\t\tImport a foreign network such as OSM.",
360  new FXMenuCommand(myFileMenu,
361  "Load S&hapes...\tCtrl+P\tLoad shapes into the network view.",
363  new FXMenuCommand(myFileMenu,
364  "Load A&dditionals...\tCtrl+D\tLoad additional elements.",
366  new FXMenuCommand(myFileMenu,
367  "&Reload\tCtrl+R\tReloads the network.",
369  new FXMenuCommand(myFileMenu,
370  "&Save Network...\tCtrl+S\tSave the network.",
372  new FXMenuCommand(myFileMenu,
373  "Save Net&work As...\tCtrl+Shift+S\tSave the network in another file.",
375  new FXMenuCommand(myFileMenu,
376  "Save plain XM&L...\tCtrl+L\tSave plain xml representation the network.",
378  new FXMenuCommand(myFileMenu,
379  "Save &joined junctions...\tCtrl+J\tSave log of joined junctions (allows reproduction of joins).",
381  mySaveShapesMenuCommand = new FXMenuCommand(myFileMenu,
382  "Save Shapes\tCtrl+Shift+P\tSave shapes elements.",
384  mySaveShapesMenuCommand->disable();
385  new FXMenuCommand(myFileMenu,
386  "Save Shapes As...\t\tSave shapes elements in another files.",
388  mySaveAdditionalsMenuCommand = new FXMenuCommand(myFileMenu,
389  "Save Additionals\tCtrl+Shift+D\tSave additional elements.",
391  mySaveAdditionalsMenuCommand->disable();
392  new FXMenuCommand(myFileMenu,
393  "Save Additionals As...\t\tSave additional elements in another file.",
395  new FXMenuSeparator(myFileMenu);
396  new FXMenuCommand(myFileMenu,
397  "Close\tCtrl+W\tClose the net&work.",
399  // Recent files
400  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
401  sep1->setTarget(&myRecentConfigs);
402  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
403  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
404  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
405  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
406  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
407  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
408  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
409  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
410  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
411  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
412  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
413  new FXMenuCommand(myFileMenu, "Clear Recent Configurat&ions", 0, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
414  myRecentConfigs.setTarget(this);
415  myRecentConfigs.setSelector(MID_RECENTFILE);
416  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
417  sep2->setTarget(&myRecentNets);
418  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
419  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
420  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
421  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
422  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
423  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
424  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
425  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
426  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
427  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
428  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
429  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", 0, &myRecentNets, FXRecentFiles::ID_CLEAR);
430  myRecentNets.setTarget(this);
431  myRecentNets.setSelector(MID_RECENTFILE);
432  new FXMenuSeparator(myFileMenu);
433  new FXMenuCommand(myFileMenu,
434  "&Quit\tCtrl+Q\tQuit the Application.",
435  0, this, MID_QUIT, 0);
436 
437  // build edit menu
438  myEditMenu = new FXMenuPane(this);
439  new FXMenuTitle(myMenuBar, "&Edit", 0, myEditMenu);
440 
441  // build undo/redo command
442  new FXMenuCommand(myEditMenu,
443  "&Undo\tCtrl+Z\tUndo the last change.",
444  GUIIconSubSys::getIcon(ICON_UNDO), myUndoList, FXUndoList::ID_UNDO);
445  new FXMenuCommand(myEditMenu,
446  "&Redo\tCtrl+Y\tRedo the last change.",
447  GUIIconSubSys::getIcon(ICON_REDO), myUndoList, FXUndoList::ID_REDO);
448 
449  new FXMenuSeparator(myEditMenu);
450 
451  // build modes command
452  new FXMenuCommand(myEditMenu,
453  "&Edge mode\tE\tCreate junction and edges.",
455  new FXMenuCommand(myEditMenu,
456  "&Move mode\tM\tMove elements.",
458  new FXMenuCommand(myEditMenu,
459  "&Delete mode\tD\tDelete elements.",
461  new FXMenuCommand(myEditMenu,
462  "&Inspect mode\tI\tInspect elements and change their attributes.",
464  new FXMenuCommand(myEditMenu,
465  "&Select mode\tS\tSelect elements.",
467  new FXMenuCommand(myEditMenu,
468  "&Connection mode\tC\tEdit connections between lanes.",
470  new FXMenuCommand(myEditMenu,
471  "&Traffic light mode\tT\tEdit traffic lights over junctions.",
473  new FXMenuCommand(myEditMenu,
474  "&Additional mode\tA\tCreate additional elements.",
476  new FXMenuCommand(myEditMenu,
477  "C&rossing mode\tR\tCreate crossings between edges.",
479  new FXMenuCommand(myEditMenu,
480  "&POI-Poly mode\tP\tCreate Points-Of-Interest and polygons.",
482 
483  /*
484  new FXMenuSeparator(myEditMenu);
485  new FXMenuCommand(myEditMenu,
486  "Edit Breakpoints...\t\tOpens a Dialog for editing breakpoints.",
487  0, this, MID_EDIT_BREAKPOINTS);
488  */
489 
490  // processing menu (trigger netbuild computations)
491  myProcessingMenu = new FXMenuPane(this);
492  new FXMenuTitle(myMenuBar, "&Processing", 0, myProcessingMenu);
493  new FXMenuCommand(myProcessingMenu,
494  "Compute Junctions\tF5\tComputes junction shape and logic.",
496  new FXMenuCommand(myProcessingMenu,
497  "Compute Junctions with volatile options\tShift+F5\tComputes junction shape and logic using volatile junctions.",
499  new FXMenuCommand(myProcessingMenu,
500  "Clean Junctions\tF6\tRemoves solitary junctions.",
502  new FXMenuCommand(myProcessingMenu,
503  "Join Selected Junctions\tF7\tJoins selected junctions into a single junction.",
505  new FXMenuCommand(myProcessingMenu,
506  "Clean invalid crossings\tF8\tClear invalid crossings.",
508  new FXMenuCommand(myProcessingMenu,
509  "Options\tF10\t\tConfigure Processing Options.",
511  // build settings menu
512  /*
513  mySettingsMenu = new FXMenuPane(this);
514  new FXMenuTitle(myMenuBar,"&Settings",0,mySettingsMenu);
515  new FXMenuCheck(mySettingsMenu,
516  "Gaming Mode\t\tToggle gaming mode on/off.",
517  this,MID_GAMING);
518  */
519  // build Locate menu
520  myLocatorMenu = new FXMenuPane(this);
521  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
522  new FXMenuCommand(myLocatorMenu,
523  "Locate &Junctions\tShift+J\tOpen a Dialog for Locating a Junction.",
525  new FXMenuCommand(myLocatorMenu,
526  "Locate &Edges\tShift+E\tOpen a Dialog for Locating an Edge.",
528  new FXMenuCommand(myLocatorMenu,
529  "Locate &TLS\tShift+T\tOpen a Dialog for Locating a Traffic Light.",
531 
532  // build windows menu
533  myWindowsMenu = new FXMenuPane(this);
534  new FXMenuTitle(myMenuBar, "&Windows", 0, myWindowsMenu);
535  new FXMenuCheck(myWindowsMenu,
536  "&Show Status Line\t\tToggle this Status Bar on/off.",
537  myStatusbar, FXWindow::ID_TOGGLESHOWN);
538  new FXMenuCheck(myWindowsMenu,
539  "Show &Message Window\t\tToggle the Message Window on/off.",
540  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
541  /*
542  new FXMenuSeparator(myWindowsMenu);
543  new FXMenuCommand(myWindowsMenu,"Tile &Horizontally",
544  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_HORI),
545  myMDIClient,FXMDIClient::ID_MDI_TILEHORIZONTAL);
546  new FXMenuCommand(myWindowsMenu,"Tile &Vertically",
547  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_VERT),
548  myMDIClient,FXMDIClient::ID_MDI_TILEVERTICAL);
549  new FXMenuCommand(myWindowsMenu,"C&ascade",
550  GUIIconSubSys::getIcon(ICON_WINDOWS_CASCADE),
551  myMDIClient,FXMDIClient::ID_MDI_CASCADE);
552  new FXMenuCommand(myWindowsMenu,"&Close",0,
553  myMDIClient,FXMDIClient::ID_MDI_CLOSE);
554  sep1=new FXMenuSeparator(myWindowsMenu);
555  sep1->setTarget(myMDIClient);
556  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
557  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_1);
558  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_2);
559  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_3);
560  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_4);
561  new FXMenuCommand(myWindowsMenu,"&Others...",0,myMDIClient,FXMDIClient::ID_MDI_OVER_5);
562  new FXMenuSeparator(myWindowsMenu);
563  */
564  new FXMenuCommand(myWindowsMenu,
565  "&Clear Message Window\t\tClear the message window.",
566  0, this, MID_CLEARMESSAGEWINDOW);
567 
568  // build help menu
569  myHelpMenu = new FXMenuPane(this);
570  new FXMenuTitle(myMenuBar,
571  "&Help",
572  0, myHelpMenu);
573  new FXMenuCommand(myHelpMenu,
574  "&Online Documentation\tF1\tOpen Online documentation.",
575  0, this, MID_HELP);
576  new FXMenuCommand(myHelpMenu,
577  "&About\tF2\tAbout netedit.",
578  0, this, MID_ABOUT);
579 }
580 
581 
582 long
583 GNEApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
585  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
586  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
587  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
588  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
589  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
590  if (isMaximized()) {
591  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 1);
592  } else {
593  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 0);
594  }
595  getApp()->exit(0);
596  }
597  return 1;
598 }
599 
600 
601 long
602 GNEApplicationWindow::onCmdEditChosen(FXObject*, FXSelector, void*) {
603  GUIDialog_GLChosenEditor* chooser =
605  chooser->create();
606  chooser->show();
607  return 1;
608 }
609 
610 
611 long
612 GNEApplicationWindow::onCmdNewNetwork(FXObject*, FXSelector, void*) {
613  // ask before we clobber options
615  return 1;
616  }
620  loadConfigOrNet("", true, false, true, true);
621  return 1;
622 }
623 
624 
625 long
626 GNEApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
627  // get the new file name
628  FXFileDialog opendialog(this, "Open Netconvert Configuration");
629  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
630  opendialog.setSelectMode(SELECTFILE_EXISTING);
631  opendialog.setPatternList(myConfigPattern.c_str());
632  if (gCurrentFolder.length() != 0) {
633  opendialog.setDirectory(gCurrentFolder);
634  }
635  if (opendialog.execute()) {
636  gCurrentFolder = opendialog.getDirectory();
637  std::string file = opendialog.getFilename().text();
638  loadConfigOrNet(file, false);
639  myRecentConfigs.appendFile(file.c_str());
640  }
641  return 1;
642 }
643 
644 
645 long
646 GNEApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
647  // get the new file name
648  FXFileDialog opendialog(this, "Open Network");
649  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
650  opendialog.setSelectMode(SELECTFILE_EXISTING);
651  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
652  if (gCurrentFolder.length() != 0) {
653  opendialog.setDirectory(gCurrentFolder);
654  }
655  if (opendialog.execute()) {
656  gCurrentFolder = opendialog.getDirectory();
657  std::string file = opendialog.getFilename().text();
658  loadConfigOrNet(file, true);
659  myRecentNets.appendFile(file.c_str());
660  // when a net is loaded, save additional and shapes are disabled
661  mySaveAdditionalsMenuCommand->disable();
662  mySaveShapesMenuCommand->disable();
663  }
664  return 1;
665 }
666 
667 
668 long
669 GNEApplicationWindow::onCmdOpenForeign(FXObject*, FXSelector, void*) {
670  // ask before we clobber options
672  return 1;
673  }
674  // get the new file name
675  FXFileDialog opendialog(this, "Import Foreign Network");
676  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
677  opendialog.setSelectMode(SELECTFILE_EXISTING);
678  FXString osmPattern("OSM net (*.osm.xml,*.osm)");
679  opendialog.setPatternText(0, osmPattern);
680  if (gCurrentFolder.length() != 0) {
681  opendialog.setDirectory(gCurrentFolder);
682  }
683  if (opendialog.execute()) {
684  gCurrentFolder = opendialog.getDirectory();
685  std::string file = opendialog.getFilename().text();
686 
689  if (osmPattern.contains(opendialog.getPattern())) {
690  oc.set("osm-files", file);
691  oc.set("ramps.guess", "true");
692  oc.set("tls.guess", "true");
693  } else {
694  throw ProcessError("Attempted to import unknown file format '" + file + "'.");
695  }
696 
697  GNEDialog_Wizard* wizard =
698  new GNEDialog_Wizard(this, "Select Import Options", getWidth(), getHeight());
699 
700  if (wizard->execute()) {
701  NIFrame::checkOptions(); // needed to set projection parameters
702  loadConfigOrNet(file, false, false, false);
703  }
704  }
705  return 1;
706 }
707 
708 
709 long
710 GNEApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
711  // get the shape file name
712  FXFileDialog opendialog(this, "Open Shapes file");
713  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
714  opendialog.setSelectMode(SELECTFILE_EXISTING);
715  opendialog.setPatternList("Shape files (*.xml)\nAll files (*)");
716  if (gCurrentFolder.length() != 0) {
717  opendialog.setDirectory(gCurrentFolder);
718  }
719  if (opendialog.execute()) {
720  gCurrentFolder = opendialog.getDirectory();
721  std::string file = opendialog.getFilename().text();
722  GNEShapeHandler handler(file, myNet);
723  if (!XMLSubSys::runParser(handler, file, false)) {
724  WRITE_MESSAGE("Loading of shapes failed.");
725  }
726  update();
727  }
728  return 1;
729 }
730 
731 
732 long
733 GNEApplicationWindow::onCmdOpenAdditionals(FXObject*, FXSelector, void*) {
734  // get the shape file name
735  FXFileDialog opendialog(this, "Open Additionals file");
736  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
737  opendialog.setSelectMode(SELECTFILE_EXISTING);
738  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
739  if (gCurrentFolder.length() != 0) {
740  opendialog.setDirectory(gCurrentFolder);
741  }
742  if (opendialog.execute()) {
743  gCurrentFolder = opendialog.getDirectory();
744  std::string file = opendialog.getFilename().text();
745  // Start operation for undo/redo
746  myUndoList->p_begin("load additionals");
747  // Create additional handler
748  GNEAdditionalHandler additionalHandler(file, myNet->getViewNet());
749  // Run parser
750  if (!XMLSubSys::runParser(additionalHandler, file, false)) {
751  WRITE_MESSAGE("Loading of " + file + " failed.");
752  // Abort undo/redo
753  myUndoList->abort();
754  } else {
755  // reset last tag (needed to avoid invalid E3s)
756  additionalHandler.resetLastTag();
757  // commit undo/redo operation
758  myUndoList->p_end();
759  update();
760  }
761  }
762  return 1;
763 }
764 
765 
766 long
767 GNEApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* fileData) {
768  if (myAmLoading) {
769  myStatusbar->getStatusLine()->setText("Already loading!");
770  return 1;
771  }
772  std::string file((const char*)fileData);
773  loadConfigOrNet(file, sender == &myRecentNets);
774  return 1;
775 }
776 
777 
778 long
779 GNEApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
780  // @note. If another network has been load during this session, it might not be desirable to set useStartupOptions
781  loadConfigOrNet(OptionsCont::getOptions().getString("sumo-net-file"), true, true);
782  return 1;
783 }
784 
785 
786 long
787 GNEApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
789  closeAllWindows();
790  // disable save additionals and shapes menu
791  mySaveAdditionalsMenuCommand->disable();
792  mySaveShapesMenuCommand->disable();
793  }
794  return 1;
795 }
796 
797 
798 long
799 GNEApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
800  if (myMDIClient->numChildren() > 0) {
801  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
802  if (w != 0) {
803  w->onCmdLocate(0, sel, 0);
804  }
805  }
806  return 1;
807 }
808 
809 long
810 GNEApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void*) {
811  sender->handle(this, myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
812  return 1;
813 }
814 
815 
816 long
817 GNEApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
819  return 1;
820 }
821 
822 
823 long
824 GNEApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
825  // write warning if netedit is running in testing mode
826  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
827  WRITE_WARNING("Opening about dialog");
828  }
829  // create and open about dialog
830  GNEDialog_About* about = new GNEDialog_About(this);
831  about->create();
832  about->show(PLACEMENT_OWNER);
833  // write warning if netedit is running in testing mode
834  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
835  WRITE_WARNING("Closed about dialog");
836  }
837  return 1;
838 }
839 
840 
841 long GNEApplicationWindow::onClipboardRequest(FXObject*, FXSelector, void* ptr) {
842  FXEvent* event = (FXEvent*)ptr;
843  FXString string = GUIUserIO::clipped.c_str();
844  setDNDData(FROM_CLIPBOARD, event->target, string);
845  return 1;
846 }
847 
848 
849 long
850 GNEApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
851  eventOccured();
852  return 1;
853 }
854 
855 
856 void
858  while (!myEvents.empty()) {
859  // get the next event
860  GUIEvent* e = myEvents.top();
861  myEvents.pop();
862  // process
863  switch (e->getOwnType()) {
866  break;
869  case EVENT_ERROR_OCCURED:
871  break;
872  default:
873  break;
874  }
875  delete e;
876  }
877 }
878 
879 
880 void
882  myAmLoading = false;
883  GNEEvent_NetworkLoaded* ec = static_cast<GNEEvent_NetworkLoaded*>(e);
884  // check whether the loading was successfull
885  if (ec->myNet == 0) {
886  // report failure
887  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
888  } else {
889  myNet = ec->myNet;
890  // report success
891  setStatusBarText("'" + ec->myFile + "' loaded.");
892  // initialise views
893  myViewNumber = 0;
895  if (view && ec->mySettingsFile != "") {
896  GUISettingsHandler settings(ec->mySettingsFile, true, true);
897  std::string settingsName = settings.addSettings(view);
898  view->addDecals(settings.getDecals());
899  settings.applyViewport(view);
900  settings.setSnapshots(view);
901  }
902  // set network name on the caption
903  setTitle(MFXUtils::getTitleText(myTitlePrefix, ec->myFile.c_str()));
905  gSchemeStorage.setViewport(getView()); // refit the network to accomodate mode specific panel
906  if (ec->myViewportFromRegistry) {
907  Position off, p;
908  off.set(getApp()->reg().readRealEntry("viewport", "x"), getApp()->reg().readRealEntry("viewport", "y"), getApp()->reg().readRealEntry("viewport", "z"));
909  getView()->setViewportFromTo(off, p);
910  }
911  }
912  getApp()->endWaitCursor();
914  // check if additionals has to be loaded at start
915  if (OptionsCont::getOptions().isSet("sumo-additionals-file") && myNet) {
916  myAdditionalsFile = OptionsCont::getOptions().getString("sumo-additionals-file");
917  WRITE_MESSAGE("Loading additionals from '" + myAdditionalsFile + "'");
919  // Run parser
920  if (!XMLSubSys::runParser(additionalHandler, myAdditionalsFile, false)) {
921  WRITE_ERROR("Loading of " + myAdditionalsFile + " failed.");
922  } else {
923  // reset last tag (needed if user want to load more additionals)
924  additionalHandler.resetLastTag();
925  }
926  }
927  // check if shapes has to be loaded at start
928  if (OptionsCont::getOptions().isSet("sumo-shapes-file") && myNet) {
929  myShapesFile = OptionsCont::getOptions().getString("sumo-shapes-file");
930  WRITE_MESSAGE("Loading shapes");
931  GNEShapeHandler shapeHandler(myShapesFile, myNet);
932  // Run parser
933  if (!XMLSubSys::runParser(shapeHandler, myShapesFile, false)) {
934  WRITE_ERROR("Loading of shapes failed.");
935  }
936  }
937  // check if additionals output must be changed
938  if (OptionsCont::getOptions().isSet("additionals-output")) {
939  myAdditionalsFile = OptionsCont::getOptions().getString("additionals-output");
940  }
941  // check if shapes output must be changed
942  if (OptionsCont::getOptions().isSet("shapes-output")) {
943  myShapesFile = OptionsCont::getOptions().getString("shapes-output");
944  }
945 
946  update();
947 }
948 
949 
950 void
952  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
954 }
955 
956 
957 void
958 GNEApplicationWindow::loadConfigOrNet(const std::string file, bool isNet, bool isReload, bool useStartupOptions, bool newNet) {
960  return;
961  }
962  getApp()->beginWaitCursor();
963  myAmLoading = true;
964  closeAllWindows();
965  if (isReload) {
966  myLoadThread->start();
967  setStatusBarText("Reloading.");
968  } else {
969  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
970  myLoadThread->loadConfigOrNet(file, isNet, useStartupOptions, newNet);
971  setStatusBarText("Loading '" + file + "'.");
972  }
973  update();
974 }
975 
976 
977 
980  std::string caption = "View #" + toString(myViewNumber++);
981  FXuint opts = MDI_TRACKING;
982  GNEViewParent* viewParent = new GNEViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()), this, getBuildGLCanvas(),
983  myNet, myUndoList, NULL, opts, 10, 10, 300, 200);
984  if (myMDIClient->numChildren() == 1) {
985  viewParent->maximize();
986  } else {
987  myMDIClient->vertical(true);
988  }
989  myMDIClient->setActiveChild(viewParent);
990  //v->grabKeyboard();
991  return viewParent->getView();
992 }
993 
994 
995 FXGLCanvas*
997  if (myMDIClient->numChildren() == 0) {
998  return 0;
999  }
1000  GNEViewParent* share_tmp1 =
1001  static_cast<GNEViewParent*>(myMDIClient->childAtIndex(0));
1002  return share_tmp1->getBuildGLCanvas();
1003 }
1004 
1005 
1006 SUMOTime
1008  return 0;
1009 }
1010 
1011 
1012 double
1014  return 1;
1015 }
1016 
1017 
1018 GNEUndoList*
1020  return myUndoList;
1021 }
1022 
1023 
1024 void
1026  myTrackerLock.lock();
1027  // remove trackers and other external windows
1028  for (int i = 0; i < (int)mySubWindows.size(); ++i) {
1029  mySubWindows[i]->destroy();
1030  }
1031  for (int i = 0; i < (int)myTrackerWindows.size(); ++i) {
1032  myTrackerWindows[i]->destroy();
1033  }
1034  // reset the caption
1035  setTitle(myTitlePrefix);
1036  // delete other children
1037  while (myTrackerWindows.size() != 0) {
1038  delete myTrackerWindows[0];
1039  }
1040  while (mySubWindows.size() != 0) {
1041  delete mySubWindows[0];
1042  }
1043  mySubWindows.clear();
1044  // clear selected items
1045  gSelected.clear();
1046  // add a separator to the log
1049  // remove coordinate information
1050  myGeoCoordinate->setText("N/A");
1051  myCartesianCoordinate->setText("N/A");
1052 
1053  myUndoList->p_clear();
1054  if (myNet != 0) {
1055  delete myNet;
1056  myNet = 0;
1058  }
1060  // Reset textures
1062 }
1063 
1064 
1065 FXCursor*
1067  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1068 }
1069 
1070 
1071 void
1073  const OptionsCont& oc = OptionsCont::getOptions();
1074  loadConfigOrNet("", true, false, true, oc.getBool("new"));
1075 }
1076 
1077 
1078 void
1079 GNEApplicationWindow::setStatusBarText(const std::string& statusBarText) {
1080  myStatusbar->getStatusLine()->setText(statusBarText.c_str());
1081  myStatusbar->getStatusLine()->setNormalText(statusBarText.c_str());
1082 }
1083 
1084 
1085 void
1086 GNEApplicationWindow::setAdditionalsFile(const std::string& additionalsFile) {
1087  myAdditionalsFile = additionalsFile;
1088 }
1089 
1090 
1091 void
1092 GNEApplicationWindow::setShapesFile(const std::string& shapesFile) {
1093  myShapesFile = shapesFile;
1094 }
1095 
1096 
1097 void
1099  mySaveAdditionalsMenuCommand->enable();
1100 }
1101 
1102 
1103 void
1105  mySaveShapesMenuCommand->enable();
1106 }
1107 
1108 
1109 long
1110 GNEApplicationWindow::onCmdSetMode(FXObject*, FXSelector sel, void*) {
1111  if (getView()) {
1112  getView()->setEditModeFromHotkey(FXSELID(sel));
1113  }
1114  return 1;
1115 }
1116 
1117 
1118 long
1119 GNEApplicationWindow::onCmdAbort(FXObject*, FXSelector, void*) {
1120  if (getView()) {
1121  // show extra information for tests
1122  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1123  WRITE_WARNING("Key ESC (abort) pressed");
1124  }
1125  // abort current operation
1126  getView()->abortOperation();
1127  getView()->update();
1128  }
1129  return 1;
1130 }
1131 
1132 
1133 long
1134 GNEApplicationWindow::onCmdDel(FXObject*, FXSelector, void*) {
1135  if (getView()) {
1136  // show extra information for tests
1137  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1138  WRITE_WARNING("Key DEL (delete) pressed");
1139  }
1140  getView()->hotkeyDel();
1141  }
1142  return 1;
1143 }
1144 
1145 
1146 long
1147 GNEApplicationWindow::onCmdEnter(FXObject*, FXSelector, void*) {
1148  if (getView()) {
1149  // show extra information for tests
1150  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1151  WRITE_WARNING("Key ENTER pressed");
1152  }
1153  getView()->hotkeyEnter();
1154  }
1155  return 1;
1156 }
1157 
1158 
1159 long
1160 GNEApplicationWindow::onCmdFocusFrame(FXObject*, FXSelector, void*) {
1161  if (getView()) {
1163  }
1164  return 1;
1165 }
1166 
1167 
1168 long
1169 GNEApplicationWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
1170  if (getView()) {
1172  }
1173  return 1;
1174 }
1175 
1176 
1177 long
1178 GNEApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
1179  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/NETEDIT");
1180  return 1;
1181 }
1182 
1183 
1184 long
1185 GNEApplicationWindow::onCmdComputeJunctions(FXObject*, FXSelector, void*) {
1186  // show extra information for tests
1187  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1188  WRITE_WARNING("Key F5 (Compute) pressed");
1189  }
1190  myNet->computeEverything(this, true, false);
1191  updateControls();
1192  return 1;
1193 }
1194 
1195 
1196 long
1198  // declare variable to save FXMessageBox outputs.
1199  FXuint answer = 0;
1200  // declare string to save paths in wich additionals and shapes will be saved
1201  std::string additionalSavePath = myAdditionalsFile;
1202  std::string shapeSavePath = myShapesFile;
1203  // write warning if netedit is running in testing mode
1204  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1205  WRITE_WARNING("Keys Shift + F5 (Compute with volatile options) pressed");
1206  WRITE_WARNING("Opening FXMessageBox 'Volatile Recomputing'");
1207  }
1208  // open question dialog box
1209  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Recompute with volatile options",
1210  "Changes produced in the net due a recomputing with volatile options cannot be undone. Continue?");
1211  if (answer != 1) { //1:yes, 2:no, 4:esc
1212  // write warning if netedit is running in testing mode
1213  if (answer == 2 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1214  WRITE_WARNING("Closed FXMessageBox 'Volatile Recomputing' with 'No'");
1215  } else if (answer == 4 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1216  WRITE_WARNING("Closed FXMessageBox 'Volatile Recomputing' with 'ESC'");
1217  }
1218  // abort recompute with volatile options
1219  return 0;
1220  } else {
1221  // write warning if netedit is running in testing mode
1222  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1223  WRITE_WARNING("Closed FXMessageBox 'Volatile Recomputing' with 'Yes'");
1224  }
1225  // Check if there are additionals in our net
1226  if (myNet->getNumberOfAdditionals() > 0) {
1227  // ask user if want to save additionals if weren't saved previously
1228  if (myAdditionalsFile == "") {
1229  // write warning if netedit is running in testing mode
1230  WRITE_WARNING("Opening FXMessageBox 'Save additionals before recomputing'");
1231  // open question dialog box
1232  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Save additionals before recomputing with volatile options",
1233  "Would you like to save additionals before recomputing?");
1234  if (answer != 1) { //1:yes, 2:no, 4:esc
1235  // write warning if netedit is running in testing mode
1236  if (answer == 2 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1237  WRITE_WARNING("Closed FXMessageBox 'Save additionals before recomputing' with 'No'");
1238  } else if (answer == 4 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1239  WRITE_WARNING("Closed FXMessageBox 'Save additionals before recomputing' with 'ESC'");
1240  }
1241  } else {
1242  // write warning if netedit is running in testing mode
1243  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1244  WRITE_WARNING("Closed FXMessageBox 'Save additionals before recomputing' with 'Yes'");
1245  }
1246  // Open a dialog to set filename output
1248  "Select name of the additional file", ".xml",
1250  gCurrentFolder).text();
1251  // set obtanied filename output into additionalSavePath (can be "")
1252  additionalSavePath = myAdditionalsFile;
1253  }
1254  }
1255  // Check if additional must be saved in a temporal directory, if user didn't define a directory for additionals
1256  if (myAdditionalsFile == "") {
1257  // Obtain temporal directory provided by FXSystem::getCurrentDirectory()
1258  additionalSavePath = FXSystem::getTempDirectory().text() + std::string("/tmpAdditionalsNetedit.xml");
1259  }
1260  // Start saving additionals
1261  getApp()->beginWaitCursor();
1262  try {
1263  myNet->saveAdditionals(additionalSavePath, true);
1264  } catch (IOError& e) {
1265  // write warning if netedit is running in testing mode
1266  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1267  WRITE_WARNING("Opening FXMessageBox 'Error saving additionals before recomputing'");
1268  }
1269  // open error message box
1270  FXMessageBox::error(this, MBOX_OK, "Saving additionals in temporal folder failed!", "%s", e.what());
1271  // write warning if netedit is running in testing mode
1272  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1273  WRITE_WARNING("Closed FXMessageBox 'Error saving additionals before recomputing' with 'OK'");
1274  }
1275  }
1276  // end saving additionals
1278  getApp()->endWaitCursor();
1279  } else {
1280  // clear additional path
1281  additionalSavePath = "";
1282  }
1283  // Check if there are shapes in our net
1284  if (myNet->getNumberOfShapes() > 0) {
1285  // ask user if want to save shapes if weren't saved previously
1286  if (myShapesFile == "") {
1287  // write warning if netedit is running in testing mode
1288  WRITE_WARNING("Opening FXMessageBox 'Save shapes before recomputing'");
1289  // open question dialog box
1290  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Save shapes before recomputing with volatile options",
1291  "Would you like to save shapes before recomputing?");
1292  if (answer != 1) { //1:yes, 2:no, 4:esc
1293  // write warning if netedit is running in testing mode
1294  if (answer == 2 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1295  WRITE_WARNING("Closed FXMessageBox 'Save shapes before recomputing' with 'No'");
1296  } else if (answer == 4 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1297  WRITE_WARNING("Closed FXMessageBox 'Save shapes before recomputing' with 'ESC'");
1298  }
1299  } else {
1300  // write warning if netedit is running in testing mode
1301  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1302  WRITE_WARNING("Closed FXMessageBox 'Save shapes before recomputing' with 'Yes'");
1303  }
1304  // Open a dialog to set filename output
1306  "Select name of the shape file", ".xml",
1308  gCurrentFolder).text();
1309  // set obtanied filename output into shapeSavePath (can be "")
1310  shapeSavePath = myShapesFile;
1311  }
1312  }
1313  // Check if shape must be saved in a temporal directory, if user didn't define a directory for shapes
1314  if (myShapesFile == "") {
1315  // Obtain temporal directory provided by FXSystem::getCurrentDirectory()
1316  shapeSavePath = FXSystem::getTempDirectory().text() + std::string("/tmpShapesNetedit.xml");
1317  }
1318  // Start saving shapes
1319  getApp()->beginWaitCursor();
1320  try {
1321  myNet->saveShapes(shapeSavePath);
1322  } catch (IOError& e) {
1323  // write warning if netedit is running in testing mode
1324  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1325  WRITE_WARNING("Opening FXMessageBox 'Error saving shapes before recomputing'");
1326  }
1327  // open error message box
1328  FXMessageBox::error(this, MBOX_OK, "Saving shapes in temporal folder failed!", "%s", e.what());
1329  // write warning if netedit is running in testing mode
1330  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1331  WRITE_WARNING("Closed FXMessageBox 'Error saving shapes before recomputing' with 'OK'");
1332  }
1333  }
1334  // end saving shapes
1336  getApp()->endWaitCursor();
1337  } else {
1338  // clear save path
1339  shapeSavePath = "";
1340  }
1341  // compute with volatile options
1342  myNet->computeEverything(this, true, true, additionalSavePath, shapeSavePath);
1343  updateControls();
1344  return 1;
1345  }
1346 }
1347 
1348 
1349 long
1350 GNEApplicationWindow::onCmdCleanJunctions(FXObject*, FXSelector, void*) {
1351  // show extra information for tests
1352  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1353  WRITE_WARNING("Key F6 (Clean junction) pressed");
1354  }
1356  return 1;
1357 }
1358 
1359 
1360 long
1361 GNEApplicationWindow::onCmdJoinJunctions(FXObject*, FXSelector, void*) {
1362  // show extra information for tests
1363  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1364  WRITE_WARNING("Key F7 (Join junctions) pressed");
1365  }
1367  return 1;
1368 }
1369 
1370 
1371 long
1373  // show extra information for tests
1374  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1375  WRITE_WARNING("Key F8 (Clean invalid crossings) pressed");
1376  }
1378  return 1;
1379 }
1380 
1381 
1382 long
1383 GNEApplicationWindow::onCmdOptions(FXObject*, FXSelector, void*) {
1384  GNEDialog_Wizard* wizard =
1385  new GNEDialog_Wizard(this, "Configure Options", getWidth(), getHeight());
1386 
1387  if (wizard->execute()) {
1388  NIFrame::checkOptions(); // needed to set projection parameters
1391  SystemFrame::checkOptions(); // needed to set precision
1392  }
1393  return 1;
1394 }
1395 
1396 
1397 long
1398 GNEApplicationWindow::onCmdSaveAsNetwork(FXObject*, FXSelector, void*) {
1399  FXString file = MFXUtils::getFilename2Write(this,
1400  "Save Network as", ".net.xml",
1402  gCurrentFolder);
1403  if (file == "") {
1404  return 1;
1405  }
1407  oc.resetWritable();
1408  oc.set("output-file", file.text());
1409  setTitle(MFXUtils::getTitleText(myTitlePrefix, file));
1410  onCmdSaveNetwork(0, 0, 0);
1411  return 1;
1412 }
1413 
1414 
1415 long
1416 GNEApplicationWindow::onCmdSaveAsPlainXML(FXObject*, FXSelector, void*) {
1417  FXString file = MFXUtils::getFilename2Write(this,
1418  "Select name of the plain-xml edge-file (other names will be deduced from this)", "",
1420  gCurrentFolder);
1421  if (file == "") {
1422  return 1;
1423  }
1425  bool wasSet = oc.isSet("plain-output-prefix");
1426  std::string oldPrefix = oc.getString("plain-output-prefix");
1427  oc.resetWritable();
1428  std::string prefix = file.text();
1429  // if the name of an edg.xml file was given, remove the suffix
1430  if (StringUtils::endsWith(prefix, ".edg.xml")) {
1431  prefix = prefix.substr(0, prefix.size() - 8);
1432  }
1433  if (StringUtils::endsWith(prefix, ".")) {
1434  prefix = prefix.substr(0, prefix.size() - 1);
1435  }
1436  oc.set("plain-output-prefix", prefix);
1437  getApp()->beginWaitCursor();
1438  try {
1439  myNet->savePlain(oc);
1440  myUndoList->unmark();
1441  myUndoList->mark();
1442  } catch (IOError& e) {
1443  // write warning if netedit is running in testing mode
1444  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1445  WRITE_WARNING("Opening FXMessageBox 'Error saving plainXML'");
1446  }
1447  // open message box
1448  FXMessageBox::error(this, MBOX_OK, "Saving plain xml failed!", "%s", e.what());
1449  // write warning if netedit is running in testing mode
1450  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1451  WRITE_WARNING("Closed FXMessageBox 'Error saving plainXML' with 'OK'");
1452  }
1453  }
1454  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Plain XML saved with prefix '" + prefix + "'.\n");
1456  if (wasSet) {
1457  oc.resetWritable();
1458  oc.set("plain-output-prefix", oldPrefix);
1459  } else {
1460  oc.unSet("plain-output-prefix");
1461  }
1462  getApp()->endWaitCursor();
1463  return 1;
1464 }
1465 
1466 
1467 long
1468 GNEApplicationWindow::onCmdSaveJoined(FXObject*, FXSelector, void*) {
1469  FXString file = MFXUtils::getFilename2Write(this,
1470  "Select name of the joined-junctions file", ".nod.xml",
1472  gCurrentFolder);
1473  if (file == "") {
1474  return 1;
1475  }
1477  bool wasSet = oc.isSet("junctions.join-output");
1478  std::string oldFile = oc.getString("junctions.join-output");
1479  oc.resetWritable();
1480  std::string filename = file.text();
1481  oc.set("junctions.join-output", filename);
1482  getApp()->beginWaitCursor();
1483  try {
1484  myNet->saveJoined(oc);
1485  } catch (IOError& e) {
1486  // write warning if netedit is running in testing mode
1487  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1488  WRITE_WARNING("Opening FXMessageBox 'error saving joined'");
1489  }
1490  // opening error message
1491  FXMessageBox::error(this, MBOX_OK, "Saving joined junctions failed!", "%s", e.what());
1492  // write warning if netedit is running in testing mode
1493  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1494  WRITE_WARNING("Closed FXMessageBox 'error saving joined' with 'OK'");
1495  }
1496  }
1497  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Joined junctions saved to '" + filename + "'.\n");
1499  if (wasSet) {
1500  oc.resetWritable();
1501  oc.set("junctions.join-output", oldFile);
1502  } else {
1503  oc.unSet("junctions.join-output");
1504  }
1505  getApp()->endWaitCursor();
1506  return 1;
1507 }
1508 
1509 
1510 long
1511 GNEApplicationWindow::onCmdSaveShapes(FXObject*, FXSelector, void*) {
1512  // check if save shapes menu is enabled
1513  if(mySaveShapesMenuCommand->isEnabled()) {
1514  // Check if shapes file was already set at start of netedit or with a previous save
1515  if (myShapesFile == "") {
1516  FXString file = MFXUtils::getFilename2Write(this,
1517  "Select name of the shape file", ".xml",
1519  gCurrentFolder);
1520  if (file == "") {
1521  // None shapes file was selected, then stop function
1522  return 0;
1523  } else {
1524  myShapesFile = file.text();
1525  }
1526  }
1527  getApp()->beginWaitCursor();
1528  try {
1530  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Shapes saved in " + myShapesFile + ".\n");
1531  mySaveShapesMenuCommand->disable();
1532  } catch (IOError& e) {
1533  // write warning if netedit is running in testing mode
1534  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1535  WRITE_WARNING("Opening FXMessageBox 'Error saving shapes'");
1536  }
1537  // open error dialog box
1538  FXMessageBox::error(this, MBOX_OK, "Saving POIs failed!", "%s", e.what());
1539  // write warning if netedit is running in testing mode
1540  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1541  WRITE_WARNING("Closed FXMessageBox 'Error saving shapes' with 'OK'");
1542  }
1543  }
1545  getApp()->endWaitCursor();
1546  return 1;
1547  } else {
1548  return 0;
1549  }
1550 }
1551 
1552 
1553 long GNEApplicationWindow::onCmdSaveShapesAs(FXObject*, FXSelector, void*) {
1554  // Open window to select shape file
1555  FXString file = MFXUtils::getFilename2Write(this,
1556  "Select name of the shape file", ".xml",
1558  gCurrentFolder);
1559  if (file != "") {
1560  // Set new shape file
1561  myShapesFile = file.text();
1562  // save shapes
1563  return onCmdSaveShapes(0, 0, 0);
1564  } else {
1565  return 1;
1566  }
1567 }
1568 
1569 
1570 long
1571 GNEApplicationWindow::onUpdNeedsNetwork(FXObject* sender, FXSelector, void*) {
1572  sender->handle(this, myNet == 0 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1573  return 1;
1574 }
1575 
1576 
1577 long
1578 GNEApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void*) {
1579  sender->handle(this, myNet == 0 || !OptionsCont::getOptions().isSet("sumo-net-file") ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1580  return 1;
1581 }
1582 
1583 
1584 long
1585 GNEApplicationWindow::onCmdSaveNetwork(FXObject*, FXSelector, void*) {
1587  // function onCmdSaveAsNetwork must be executed if this is the first save
1588  if (oc.getString("output-file") == "") {
1589  return onCmdSaveAsNetwork(0, 0, 0);
1590  } else {
1591  getApp()->beginWaitCursor();
1592  try {
1593  myNet->save(oc);
1594  myUndoList->unmark();
1595  myUndoList->mark();
1596  } catch (IOError& e) {
1597  // write warning if netedit is running in testing mode
1598  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1599  WRITE_WARNING("Opening FXMessageBox 'error saving network'");
1600  }
1601  // open error message box
1602  FXMessageBox::error(this, MBOX_OK, "Saving Network failed!", "%s", e.what());
1603  // write warning if netedit is running in testing mode
1604  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1605  WRITE_WARNING("Closed FXMessageBox 'error saving network' with 'OK'");
1606  }
1607  }
1608  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Network saved in " + oc.getString("output-file") + ".\n");
1610  getApp()->endWaitCursor();
1611  return 1;
1612  }
1613 }
1614 
1615 
1616 long
1617 GNEApplicationWindow::onCmdSaveAdditionals(FXObject*, FXSelector, void*) {
1618  // check if save additional menu is enabled
1619  if(mySaveAdditionalsMenuCommand->isEnabled()) {
1620  // Check if additionals file was already set at start of netedit or with a previous save
1621  if (myAdditionalsFile == "") {
1622  FXString file = MFXUtils::getFilename2Write(this,
1623  "Select name of the additional file", ".xml",
1625  gCurrentFolder);
1626  if (file == "") {
1627  // None additionals file was selected, then stop function
1628  return 0;
1629  } else {
1630  myAdditionalsFile = file.text();
1631  }
1632  }
1633  // Start saving additionals
1634  getApp()->beginWaitCursor();
1635  try {
1637  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Additionals saved in " + myAdditionalsFile + ".\n");
1638  mySaveAdditionalsMenuCommand->disable();
1639  } catch (IOError& e) {
1640  // write warning if netedit is running in testing mode
1641  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1642  WRITE_WARNING("Opening FXMessageBox 'error saving additionals'");
1643  }
1644  // open error message box
1645  FXMessageBox::error(this, MBOX_OK, "Saving additionals failed!", "%s", e.what());
1646  // write warning if netedit is running in testing mode
1647  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1648  WRITE_WARNING("Closed FXMessageBox 'error saving additionals' with 'OK'");
1649  }
1650  }
1652  getApp()->endWaitCursor();
1653  return 1;
1654  } else {
1655  return 0;
1656  }
1657 }
1658 
1659 
1660 long
1661 GNEApplicationWindow::onCmdSaveAdditionalsAs(FXObject*, FXSelector, void*) {
1662  // Open window to select additionasl file
1663  FXString file = MFXUtils::getFilename2Write(this,
1664  "Select name of the additional file", ".xml",
1666  gCurrentFolder);
1667  if (file != "") {
1668  // Set new additional file
1669  myAdditionalsFile = file.text();
1670  // save additionals
1671  return onCmdSaveAdditionals(0, 0, 0);
1672  } else {
1673  return 1;
1674  }
1675 }
1676 
1677 
1678 long
1679 GNEApplicationWindow::onUpdSaveNetwork(FXObject* sender, FXSelector, void*) {
1681  bool enable = myNet != 0 && oc.isSet("output-file");
1682  sender->handle(this, FXSEL(SEL_COMMAND, enable ? ID_ENABLE : ID_DISABLE), 0);
1683  if (enable) {
1684  FXString caption = ("Save " + oc.getString("output-file")).c_str();
1685  sender->handle(this, FXSEL(SEL_COMMAND, FXMenuCaption::ID_SETSTRINGVALUE), (void*)&caption);
1686  }
1687  return 1;
1688 }
1689 
1690 
1691 GNEViewNet*
1693  if (mySubWindows.size() != 0) {
1694  return (GNEViewNet*)(((GUIGlChildWindow*)mySubWindows[0])->getView());
1695  } else {
1696  return 0;
1697  }
1698 }
1699 
1700 
1701 bool
1703  FXuint answer = 0;
1704  if (myUndoList->canUndo() && !myUndoList->marked()) {
1705  // write warning if netedit is running in testing mode
1706  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1707  WRITE_WARNING("Opening FXMessageBox 'Confirm closing network'");
1708  }
1709  // open question box
1710  answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
1711  "Confirm closing Network", "%s",
1712  "You have unsaved changes in the network. Do you wish to quit and discard all changes?");
1713  // restore focus to view net
1714  getView()->setFocus();
1715  // if user close dialog box, check additionasl and shapes
1716  if (answer == MBOX_CLICKED_QUIT) {
1717  // write warning if netedit is running in testing mode
1718  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1719  WRITE_WARNING("Closed FXMessageBox 'Confirm closing network' with 'Quit'");
1720  }
1722  // clear undo list and return true to continue with closing/reload
1723  myUndoList->p_clear();
1724  return true;
1725  } else {
1726  return false;
1727  }
1728  } else if (answer == MBOX_CLICKED_SAVE) {
1729  // save newtork
1730  onCmdSaveNetwork(0, 0, 0);
1731  if (!myUndoList->marked()) {
1732  // saving failed
1733  return false;
1734  }
1736  // clear undo list and return true to continue with closing/reload
1737  myUndoList->p_clear();
1738  return true;
1739  } else {
1740  return false;
1741  }
1742  } else {
1743  // write warning if netedit is running in testing mode
1744  if (answer == 2 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1745  WRITE_WARNING("Closed FXMessageBox 'Confirm closing network' with 'No'");
1746  } else if (answer == 4 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1747  WRITE_WARNING("Closed FXMessageBox 'Confirm closing network' with 'ESC'");
1748  }
1749  // return false to stop closing/reloading
1750  return false;
1751  }
1752  } else {
1754  // clear undo list and return true to continue with closing/reload
1755  myUndoList->p_clear(); //only ask once
1756  return true;
1757  } else {
1758  // return false to stop closing/reloading
1759  return false;
1760  }
1761  }
1762 }
1763 
1764 
1765 bool
1767  // Check if there are non saved additionals
1768  if (mySaveAdditionalsMenuCommand->isEnabled()) {
1769  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1770  WRITE_WARNING("Opening FXMessageBox 'Save additionals before exit'");
1771  }
1772  // open question box
1773  FXuint answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
1774  "Save additionals before exit", "%s",
1775  "You have unsaved additionals. Do you wish to quit and discard all changes?");
1776  // restore focus to view net
1777  getView()->setFocus();
1778  // if answer was affirmative, but there was an error during saving additional, return false to stop closing/reloading
1779  if (answer == MBOX_CLICKED_QUIT) {
1780  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1781  WRITE_WARNING("Closed FXMessageBox 'Save additionals before exit' with 'Quit'");
1782  }
1783  // nothing to save, return true
1784  return true;
1785  } else if (answer == MBOX_CLICKED_SAVE) {
1786  // write warning if netedit is running in testing mode
1787  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1788  WRITE_WARNING("Closed FXMessageBox 'Save additionals before exit' with 'Yes'");
1789  }
1790  if (onCmdSaveAdditionals(0, 0, 0) == 1) {
1791  // additionals sucesfully saved
1792  return true;
1793  } else {
1794  // error saving additionals, abort saving
1795  return false;
1796  }
1797  } else {
1798  // write warning if netedit is running in testing mode
1799  if (answer == 2 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1800  WRITE_WARNING("Closed FXMessageBox 'Save additionals before exit' with 'No'");
1801  } else if (answer == 4 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1802  WRITE_WARNING("Closed FXMessageBox 'Save additionals before exit' with 'ESC'");
1803  }
1804  // abort saving
1805  return false;
1806  }
1807  } else {
1808  // nothing to save, return true
1809  return true;
1810  }
1811 }
1812 
1813 
1814 bool
1816  // Check if there are non saved additionals
1817  if (mySaveShapesMenuCommand->isEnabled()) {
1818  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1819  WRITE_WARNING("Opening FXMessageBox 'Save shapes before exit'");
1820  }
1821  // open question box
1822  FXuint answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
1823  "Save shapes before exit", "%s",
1824  "You have unsaved shapes. Do you wish to quit and discard all changes?");
1825  // restore focus to view net
1826  getView()->setFocus();
1827  // if answer was affirmative, but there was an error during saving additional, return false to stop closing/reloading
1828  if (answer == MBOX_CLICKED_QUIT) {
1829  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1830  WRITE_WARNING("Closed FXMessageBox 'Save shapes before exit' with 'Quit'");
1831  }
1832  return true;
1833  } else if (answer == MBOX_CLICKED_SAVE) {
1834  // write warning if netedit is running in testing mode
1835  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
1836  WRITE_WARNING("Closed FXMessageBox 'Save shapes before exit' with 'Yes'");
1837  }
1838  if (onCmdSaveShapes(0, 0, 0) == 1) {
1839  // shapes sucesfully saved
1840  return true;
1841  } else {
1842  // error saving shapes, abort saving
1843  return false;
1844  }
1845  } else {
1846  // write warning if netedit is running in testing mode
1847  if (answer == 2 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1848  WRITE_WARNING("Closed FXMessageBox 'Save shapes before exit' with 'No'");
1849  } else if (answer == 4 && OptionsCont::getOptions().getBool("gui-testing-debug")) {
1850  WRITE_WARNING("Closed FXMessageBox 'Save shapes before exit' with 'ESC'");
1851  }
1852  // abort saving
1853  return false;
1854  }
1855  } else {
1856  // nothing to save, then return true
1857  return true;
1858  }
1859 }
1860 
1861 
1862 void
1864  GNEViewNet* view = getView();
1865  if (view != 0) {
1866  view->updateControls();
1867  }
1868 }
1869 
1870 
1871 long
1872 GNEApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* eventData) {
1873  const long handled = FXMainWindow::onKeyPress(o, sel, eventData);
1874  if (handled == 0 && myMDIClient->numChildren() > 0) {
1875  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1876  if (w != 0) {
1877  w->onKeyPress(0, sel, eventData);
1878  }
1879  }
1880  return 0;
1881 }
1882 
1883 
1884 long
1885 GNEApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* eventData) {
1886  const long handled = FXMainWindow::onKeyRelease(o, sel, eventData);
1887  if (handled == 0 && myMDIClient->numChildren() > 0) {
1888  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1889  if (w != 0) {
1890  w->onKeyRelease(0, sel, eventData);
1891  }
1892  }
1893  return 0;
1894 }
1895 
1896 // ---------------------------------------------------------------------------
1897 // GNEApplicationWindow::GNEShapeHandler - methods
1898 // ---------------------------------------------------------------------------
1899 
1901  ShapeHandler(file, *net),
1902  myNet(net) {}
1903 
1904 
1906 
1907 
1908 Position
1909 GNEApplicationWindow::GNEShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat) {
1910  std::string edgeID;
1911  int laneIndex;
1912  NIImporter_SUMO::interpretLaneID(laneID, edgeID, laneIndex);
1913  NBEdge* edge = myNet->retrieveEdge(edgeID)->getNBEdge();
1914  if (edge == 0 || laneIndex < 0 || edge->getNumLanes() <= laneIndex) {
1915  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1916  return Position::INVALID;
1917  }
1918  if (lanePos < 0) {
1919  lanePos = edge->getLength() + lanePos;
1920  }
1921  if (lanePos < 0 || lanePos > edge->getLength()) {
1922  WRITE_WARNING("lane position " + toString(lanePos) + " for poi '" + poiID + "' is not valid.");
1923  }
1924  return edge->getLanes()[laneIndex].shape.positionAtOffset(lanePos, -lanePosLat);
1925 }
1926 
1927 /****************************************************************************/
std::vector< FXMainWindow * > myTrackerWindows
std::string myConfigPattern
Input file pattern.
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
hot key <DEL>
Definition: GUIAppEnum.h:423
FXMenuBar * myMenuBar
The application menu bar.
FXMenuCommand * mySaveShapesMenuCommand
FXMenuCommand for enable or disable save shapes.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
GUICompleteSchemeStorage gSchemeStorage
Main window closes.
Definition: GUIAppEnum.h:55
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NWFrame.cpp:121
void pop()
Definition: MFXEventQue.h:53
void enableSaveAdditionalsMenu()
enable save additionals
long onKeyPress(FXObject *o, FXSelector sel, void *data)
Called when user press a key.
static std::string clipped
Definition: GUIUserIO.h:64
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:899
long onCmdNewNetwork(FXObject *, FXSelector, void *)
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
mode for inspecting object attributes
Definition: GUIAppEnum.h:442
void setAdditionalsFile(const std::string &additionalsFile)
set additionals file
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NBFrame.cpp:459
void abortOperation(bool clearSelection=true)
abort current edition operation
void setStatusBarText(const std::string &statusBarText)
set text of the statusBar
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
MFXEventQue< GUIEvent * > myEvents
List of got requests.
void resetWritable()
Resets all options to be writeable.
GNEUndoList * getUndoList()
get pointer to undoList
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
long onCmdReload(FXObject *, FXSelector, void *)
called when the command/FXCall reload is executed
void create()
Creates the widget.
void closeAllWindows()
this method closes all windows and deletes the current simulation */
virtual void setViewportFromTo(const Position &lookFrom, const Position &lookAt)
applies the given viewport settings
send when a message occured
Definition: GUIEvent.h:50
FXRecentFiles myRecentConfigs
List of recent config files.
long onCmdSaveAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals is executed
bool empty()
Definition: MFXEventQue.h:72
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
void enableSaveShapesMenu()
enable save shapes
The main window of the Netedit.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
std::string myShapesFile
filename for load/save shapes
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:294
Locate TLS - button.
Definition: GUIAppEnum.h:181
void hotkeyFocusFrame()
handle focus frame keypress
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
called when the command/FXCall clear message windows is executed
void loadConfigOrNet(const std::string &file, bool isNet, bool useStartupOptions, bool newNet=false)
begins the loading of a netconvert configuration or a a network
Loads a file previously loaded.
Definition: GUIAppEnum.h:83
const std::string & getMsg() const
Returns the message.
virtual void create()
Creates the main window (required by FOX)
long onCmdJoinJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->join junctions
void unSet(const std::string &name, bool failOnNonExistant=true) const
Marks the option as unset.
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:571
bool hadDependentBuild
check if had dependent build
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:71
Load additional file with additional elements.
Definition: GUIAppEnum.h:79
double getTrackerInterval() const
get current tracker interval (pure virtual but we don&#39;t need it)
static void initIcons(FXApp *a)
Initiate GUIIconSubSys.
GNEUndoList * myUndoList
the one and only undo list
long onCmdComputeJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->compute junctions
static void resetTextures()
Reset textures.
void registerMsgHandlers()
register and unregister message handlers
long onCmdSetMode(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits an edit-mode hotkey
void handleEvent_NetworkLoaded(GUIEvent *e)
handle event of type Network loaded
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:263
bool continueWithUnsavedAdditionalChanges()
warns about unsaved changes in additionals and gives the user the option to abort ...
void loadConfigOrNet(const std::string file, bool isNet, bool isReload=false, bool useStartupOptions=false, bool newNet=false)
starts to load a netimport configuration or a network */
void setWindowSizeAndPos()
perform initial window positioning and sizing according to user options / previous call ...
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
Definition: GUIDesigns.h:266
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
called when a key is released
#define GUIDesignSplitter
Definition: GUIDesigns.h:291
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
Called when user releases a key.
void saveAdditionals(const std::string &filename, bool volatileOptionsEnabled=false)
save additional elements of the network
Definition: GNENet.cpp:813
Editor for the list of chosen objects.
mode for moving things
Definition: GUIAppEnum.h:438
bool continueWithUnsavedChanges()
warns about unsaved changes and gives the user the option to abort
FXGLVisual * myGLVisual
The gl-visual used.
long onCmdOpenForeign(FXObject *, FXSelector, void *)
called when the command/FXCall open foreign is executed
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
long onCmdSaveNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall save network is executed
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:85
Main window-ID.
Definition: GUIAppEnum.h:53
long onCmdAbout(FXObject *, FXSelector, void *)
called when the command/FXCall show about dialog is executed
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
bool cleanInvalidCrossings(GNEUndoList *undoList)
clear invalid crossings
Definition: GNENet.cpp:1387
FXString gCurrentFolder
The folder used as last.
long onCmdSaveShapes(FXObject *, FXSelector, void *)
called when the command/FXCall save shapes is executed
long onUpdNeedsNetwork(FXObject *, FXSelector, void *)
called when the upadte/FXCall needs network is executed
void saveViewport(const double x, const double y, const double z)
Makes the given viewport the default.
long onCmdCleanInvalidCrossings(FXObject *, FXSelector, void *)
called if the user selects Processing->clear invalid crossings
std::string myFile
the name of the loaded file
long onLoadThreadEvent(FXObject *, FXSelector, void *)
called when the command/FXCall load thread is executed
static void resetLoaded()
resets loaded location elements
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
void set(double x, double y)
set positions x and y
Definition: Position.h:93
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:81
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:110
void updateControls()
update control contents after undo/redo or recompute
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:91
Open network - ID.
Definition: GUIAppEnum.h:75
virtual FXGLCanvas * getBuildGLCanvas() const
long onCmdEditChosen(FXObject *, FXSelector, void *)
called when the command/FXCall edit chosen is executed
void updateControls()
update control contents after undo/redo or recompute
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
void addDecals(const std::vector< Decal > &decals)
add decals
GUISUMOAbstractView * openNewView()
opens a new simulation display
GNENet * myNet
the loaded net
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of additionals of the net.
Definition: GNENet.cpp:1715
long onUpdReload(FXObject *, FXSelector, void *)
called when the update/FXCall reload is executed
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:73
save network
Definition: GUIAppEnum.h:565
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
long onCmdHelp(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Documentation
The application&#39;s "About" - dialog.
void addSeparator()
Adds a a separator to this log window.
void p_clear()
clears the undo list (implies abort)
Definition: GNEUndoList.cpp:99
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
called when the command/FXCall clipboard request is executed
mode for adding edges
Definition: GUIAppEnum.h:436
The XML-Handler for network loading.
Definition: ShapeHandler.h:56
static void setDefaultOptions(OptionsCont &oc)
sets required options for proper functioning
Open configuration - ID.
Definition: GUIAppEnum.h:73
FXHorizontalFrame * myCartesianFrame
FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[]
long onCmdSaveAdditionalsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals as is executed
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
long onCmdEditViewport(FXObject *, FXSelector, void *)
called if the user press key v to open zoom editor
std::vector< FXMDIChild * > mySubWindows
long onCmdOptions(FXObject *, FXSelector, void *)
called if the user selects Processing->Configure Options
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:84
mode for editing additional
Definition: GUIAppEnum.h:450
static void close()
close GUITextureSubSys
GNEApplicationWindow()
FOX needs this for static members.
FXSplitter * myMainSplitter
The splitter that divides the main window into view and the log window.
mode for creating polygons
Definition: GUIAppEnum.h:454
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
hot key <ENTER>
Definition: GUIAppEnum.h:425
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
long onCmdOpenRecent(FXObject *, FXSelector, void *)
called when the command/FXCall open recent is executed
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall open network is executed
SUMOTime getCurrentSimTime() const
get current simulation time (pure virtual but we don&#39;t need it)
int myViewNumber
The current view number.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:92
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)
get lane position
bool joinSelectedJunctions(GNEUndoList *undoList)
join selected junctions
Definition: GNENet.cpp:1280
Locate edge - button.
Definition: GUIAppEnum.h:175
virtual void fillMenuBar()
Builds the menu bar.
bool continueWithUnsavedShapeChanges()
warns about unsaved changes in shapes and gives the user the option to abort
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
Save shapes.
Definition: GUIAppEnum.h:570
long onCmdSaveAsPlainXML(FXObject *, FXSelector, void *)
called when the command/FXCall save as plain xml is executed
long onCmdSaveShapesAs(FXObject *, FXSelector, void *)
called when the command/FXCall save shapes as is executed
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:804
Locate junction - button.
Definition: GUIAppEnum.h:173
mode for selecting objects
Definition: GUIAppEnum.h:444
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
called when the command/FXCall open configuration is executed
static bool checkOptions()
checks shared options and sets StdDefs
mode for editing crossing
Definition: GUIAppEnum.h:452
std::string mySettingsFile
the name of the settings file to load
long onCmdOpenAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall open additionals is executed
send when a error occured
Definition: GUIEvent.h:56
#define VERSION_STRING
Definition: version.h:1
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NIFrame.cpp:291
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:77
long onCmdLocate(FXObject *, FXSelector, void *)
called when the command/FXCall locate is executed
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:137
Clear simulation output.
Definition: GUIAppEnum.h:156
FXCursor * getDefaultCursor()
get default cursor
long onCmdCleanJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->clean junctions
GNEShapeHandler(const std::string &file, GNENet *net)
Constructor.
virtual ~GNEApplicationWindow()
Destructor.
long onUpdOpen(FXObject *, FXSelector, void *)
called when the command/FXCall on update open executed
GNELoadThread * myLoadThread
the thread that loads the network
FXStatusBar * myStatusbar
The status bar.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
abort current edit operation
Definition: GUIAppEnum.h:419
long onCmdOpenShapes(FXObject *, FXSelector, void *)
called when the command/FXCall open shapes is executed
void unlock()
release mutex lock
Definition: MFXMutex.cpp:94
long onCmdEnter(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits enter
virtual void showViewportEditor()
show viewport editor
#define GUIDesignBar
Definition: GUIDesigns.h:260
bool myViewportFromRegistry
whether loading viewport from registry
long onCmdFocusFrame(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits f
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:482
static void interpretLaneID(const std::string &lane_id, std::string &edge_id, int &index)
parses edge-id and index from lane-id
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
virtual void detach()
detaches the tool/menu bar
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
About SUMO - ID.
Definition: GUIAppEnum.h:87
void setViewport(GUISUMOAbstractView *view)
Sets the default viewport.
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
focus upper element of current frame
Definition: GUIAppEnum.h:421
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:147
The loading thread.
Definition: GUIAppEnum.h:117
long onCmdDel(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits del
FXRecentFiles myRecentNets
List of recent nets.
void loadOptionOnStartup()
load net on startup
mode for editing tls
Definition: GUIAppEnum.h:448
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition: GNENet.cpp:1443
static void close()
close GUIIconSubSys
FXToolBarShell * myMenuBarDrag
FXHorizontalFrame * myGeoFrame
FXDockSite * myTopDock
A storage for options typed value containers)
Definition: OptionsCont.h:99
FXMenuCommand * mySaveAdditionalsMenuCommand
FXMenuCommand for enable or disable save additionals.
long onCmdClose(FXObject *, FXSelector, void *)
called when the command/FXCall close is executed
void computeEverything(GNEApplicationWindow *window, bool force=false, bool volatileOptions=false, std::string additionalPath="", std::string shapePath="")
trigger full netbuild computation param[in] window The window to inform about delay param[in] force W...
Definition: GNENet.cpp:1167
void clear()
Clears the list of selected objects.
std::string myAdditionalsFile
filename for load/save additionals
void lock()
lock mutex
Definition: MFXMutex.cpp:84
FXMDIClient * myMDIClient
The multi view panel.
send when a simulation has been loaded
Definition: GUIEvent.h:44
void handleEvent_Message(GUIEvent *e)
hanlde event of type message
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:872
FXGLCanvas * getBuildGLCanvas() const
get build OpenGL Canvas
send when a warning occured
Definition: GUIEvent.h:53
#define GUIDesignHorizontalFrameStatusBar
Horizontal frame used in status bar.
Definition: GUIDesigns.h:213
mode for deleting things
Definition: GUIAppEnum.h:440
long onCmdAbort(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits esc
long onCmdSaveJoined(FXObject *, FXSelector, void *)
called when the command/FXCall save joined is executed
An XML-handler for visualisation schemes.
const FXString myTitlePrefix
the prefix for the window title
long long int SUMOTime
Definition: TraCIDefs.h:52
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:69
Close simulation - ID.
Definition: GUIAppEnum.h:85
GNENet * myNet
we are responsible for the net
#define GUIDesignToolBarShell3
Definition: GUIDesigns.h:274
Open viewport editor - button.
Definition: GUIAppEnum.h:193
void dependentBuild()
build dependent
void clear()
Clears the window.
processing menu messages
Definition: GUIAppEnum.h:524
help button
Definition: GUIAppEnum.h:404
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:306
long onCmdComputeJunctionsVolatile(FXObject *, FXSelector, void *)
called if the user selects Processing->compute junctions with volatile options
void hotkeyDel()
handle del keypress
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
int getNumberOfShapes() const
get number of shapes
Definition: GNENet.cpp:2071
static void initTextures(FXApp *a)
Initiate GUITextureSubSys for textures.
GUISelectedStorage gSelected
A global holder of selected objects.
void hotkeyEnter()
handle enter keypress
long onCmdSaveAsNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall save network as is executed
GNEViewNet * getView()
convenience method
A logging window for the gui.
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1519
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
misc messages
Definition: GUIAppEnum.h:559
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:864
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
FXMenuPane * myFileMenu
the submenus
long onKeyPress(FXObject *o, FXSelector sel, void *data)
called when a key is pressed
long onUpdSaveNetwork(FXObject *, FXSelector, void *)
called when the update/FXCall save network is executed
mode for connecting lanes
Definition: GUIAppEnum.h:446
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:278
void saveShapes(const std::string &filename)
save shapes elements of the network
Definition: GNENet.cpp:2042
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void setShapesFile(const std::string &shapesFile)
set shapes file
Save additionals.
Definition: GUIAppEnum.h:573