SUMO - Simulation of Urban MObility
GNEApplicationWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // The main window of Netedit (adapted from GUIApplicationWindow)
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #ifdef HAVE_VERSION_H
25 #include <version.h>
26 #endif
27 
28 #include <string>
29 #include <sstream>
30 #include <algorithm>
31 
32 #include <utils/common/ToString.h>
35 #include <utils/xml/XMLSubSys.h>
45 #include <utils/gui/div/GLHelper.h>
52 #include <netimport/NIFrame.h>
53 #include <netbuild/NBFrame.h>
54 #include <netwrite/NWFrame.h>
64 
65 #include "GNEApplicationWindow.h"
66 #include "GNELoadThread.h"
67 #include "GNEEvent_NetworkLoaded.h"
68 #include "GNEViewParent.h"
69 #include "GNEViewNet.h"
70 #include "GNENet.h"
71 #include "GNEUndoList.h"
72 
73 
74 // ===========================================================================
75 // FOX-declarations
76 // ===========================================================================
77 FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[] = {
78  // quit calls
79  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GNEApplicationWindow::onCmdQuit),
80  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GNEApplicationWindow::onCmdQuit),
81  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GNEApplicationWindow::onCmdQuit),
82 
83  // toolbar file
87  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GNEApplicationWindow::onUpdOpen),
89  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GNEApplicationWindow::onUpdOpen),
99  FXMAPFUNC(SEL_UPDATE, MID_RECENTFILE, GNEApplicationWindow::onUpdOpen),
100  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GNEApplicationWindow::onCmdReload),
101  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GNEApplicationWindow::onUpdReload),
118  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GNEApplicationWindow::onCmdClose),
119  FXMAPFUNC(SEL_UPDATE, MID_CLOSE, GNEApplicationWindow::onUpdNeedsNetwork),
120 
121  // Toolbar edit
148  FXMAPFUNC(SEL_COMMAND, MID_SUMOGUI, GNEApplicationWindow::onCmdOpenSUMOGUI),
150 
151  // Toolbar processing
163 
164  // Toolbar locate
165  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GNEApplicationWindow::onCmdLocate),
167  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GNEApplicationWindow::onCmdLocate),
169  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GNEApplicationWindow::onCmdLocate),
171  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GNEApplicationWindow::onCmdLocate),
173  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GNEApplicationWindow::onCmdLocate),
175  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GNEApplicationWindow::onCmdLocate),
177 
178  // toolbar windows
180 
181  // toolbar help
182  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GNEApplicationWindow::onCmdAbout),
183 
184  // key events
185  FXMAPFUNC(SEL_KEYPRESS, 0, GNEApplicationWindow::onKeyPress),
186  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEApplicationWindow::onKeyRelease),
187  FXMAPFUNC(SEL_COMMAND, MID_GNE_HOTKEY_ESC, GNEApplicationWindow::onCmdAbort),
188  FXMAPFUNC(SEL_COMMAND, MID_GNE_HOTKEY_DEL, GNEApplicationWindow::onCmdDel),
190 
191  // threads events
194 
195  // Other
198  FXMAPFUNC(SEL_COMMAND, MID_HELP, GNEApplicationWindow::onCmdHelp),
200  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNEApplicationWindow::onClipboardRequest),
201 };
202 
203 // Object implementation
204 FXIMPLEMENT(GNEApplicationWindow, FXMainWindow, GNEApplicationWindowMap, ARRAYNUMBER(GNEApplicationWindowMap))
205 
206 // ===========================================================================
207 // member method definitions
208 // ===========================================================================
209 #ifdef _MSC_VER
210 #pragma warning(push)
211 #pragma warning(disable: 4355)
212 #endif
213 GNEApplicationWindow::GNEApplicationWindow(FXApp* a, const std::string& configPattern) :
214  GUIMainWindow(a),
215  myLoadThread(0),
216  myAmLoading(false),
217  myRecentNets(a, "nets"),
218  myConfigPattern(configPattern),
219  hadDependentBuild(false),
220  myNet(nullptr),
221  myUndoList(new GNEUndoList(this)),
222  myTitlePrefix("NETEDIT " VERSION_STRING) {
223  // init icons
225  // init Textures
227 }
228 #ifdef _MSC_VER
229 #pragma warning(pop)
230 #endif
231 
232 
233 void
235  // do this not twice
236  if (hadDependentBuild) {
237  WRITE_ERROR("DEBUG: GNEApplicationWindow::dependentBuild called twice");
238  return;
239  }
240  hadDependentBuild = true;
241  setTarget(this);
242  setSelector(MID_WINDOW);
243  // build menu bar
244  myMenuBarDrag = new FXToolBarShell(this, GUIDesignToolBarShell3);
245  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag, GUIDesignBar);
246  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
247  // build the thread - io
249  // build the status bar
250  myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
251  {
252  myGeoFrame =
253  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
254  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
256  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
257  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
258  }
259  // make the window a mdi-window
260  myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
261  myMDIClient = new FXMDIClient(myMainSplitter, GUIDesignSplitterMDI);
262  myMDIMenu = new FXMDIMenu(this, myMDIClient);
263  // Due netedit only have a view, this buttons must be disabled (see #2807)
264  //new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient, FXMDIClient::ID_MDI_MENUWINDOW, GUIDesignMDIButtonLeft);
265  //new FXMDIDeleteButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUCLOSE, GUIDesignMDIButtonRight);
266  //new FXMDIRestoreButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENURESTORE, GUIDesignMDIButtonRight);
267  //new FXMDIMinimizeButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUMINIMIZE, GUIDesignMDIButtonRight);
268  // build the message window
270  myMainSplitter->setSplit(1, 65);
271  // fill menu and tool bar
272  fillMenuBar();
273  // build additional threads
274  myLoadThread = new GNELoadThread(getApp(), this, myEvents, myLoadThreadEvent);
275  // set the status bar
276  myStatusbar->getStatusLine()->setText("Ready.");
277  // set the caption
278  setTitle(myTitlePrefix);
279  // set Netedit ICON
281  // initialize single hotkeys using decimal code (to avoid problems in Linux)
282  getAccelTable()->addAccel(101, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_CREATE_EDGE)); // e
283  getAccelTable()->addAccel(69, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_CREATE_EDGE)); // E
284  getAccelTable()->addAccel(109, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_MOVE)); // m
285  getAccelTable()->addAccel(77, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_MOVE)); // M
286  getAccelTable()->addAccel(100, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_DELETE)); // d
287  getAccelTable()->addAccel(68, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_DELETE)); // D
288  getAccelTable()->addAccel(105, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_INSPECT)); // i
289  getAccelTable()->addAccel(73, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_INSPECT)); // I
290  getAccelTable()->addAccel(115, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_SELECT)); // s
291  getAccelTable()->addAccel(83, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_SELECT)); // S
292  getAccelTable()->addAccel(99, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_CONNECT)); // c
293  getAccelTable()->addAccel(67, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_CONNECT)); // C
294  getAccelTable()->addAccel(119, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_PROHIBITION)); // w
295  getAccelTable()->addAccel(87, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_PROHIBITION)); // W
296  getAccelTable()->addAccel(116, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_TLS)); // t
297  getAccelTable()->addAccel(94, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_TLS)); // T
298  getAccelTable()->addAccel(97, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_ADDITIONAL)); // a
299  getAccelTable()->addAccel(65, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_ADDITIONAL)); // A
300  getAccelTable()->addAccel(114, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_CROSSING)); // r
301  getAccelTable()->addAccel(82, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_CROSSING)); // R
302  getAccelTable()->addAccel(112, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_POLYGON)); // p
303  getAccelTable()->addAccel(80, this, FXSEL(SEL_COMMAND, MID_GNE_SETMODE_POLYGON)); // P
304  getAccelTable()->addAccel(118, this, FXSEL(SEL_COMMAND, MID_EDITVIEWPORT)); // v
305  getAccelTable()->addAccel(86, this, FXSEL(SEL_COMMAND, MID_EDITVIEWPORT)); // V
306  // initialize Ctrl hotkeys with Caps Lock enabled using decimal code (to avoid problems in Linux)
307  getAccelTable()->addAccel(262222, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_NEWNETWORK)); // Ctrl + N
308  getAccelTable()->addAccel(262223, this, FXSEL(SEL_COMMAND, MID_OPEN_NETWORK)); // Ctrl + O
309  getAccelTable()->addAccel(327691, this, FXSEL(SEL_COMMAND, MID_OPEN_CONFIG)); // Ctrl + Shift + O
310  getAccelTable()->addAccel(262226, this, FXSEL(SEL_COMMAND, MID_RELOAD)); // Ctrl + R
311  getAccelTable()->addAccel(262227, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_SAVENETWORK)); // Ctrl + S
312  getAccelTable()->addAccel(327695, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_SAVENETWORK_AS)); // Ctrl + Shift + S
313  getAccelTable()->addAccel(262220, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_SAVEPLAINXML)); // Ctrl + L
314  getAccelTable()->addAccel(262218, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_SAVEJOINED)); // Ctrl + J
315  getAccelTable()->addAccel(262224, this, FXSEL(SEL_COMMAND, MID_OPEN_SHAPES)); // Ctrl + P
316  getAccelTable()->addAccel(327692, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_SAVESHAPES)); // Ctrl + Shift + P
317  getAccelTable()->addAccel(262212, this, FXSEL(SEL_COMMAND, MID_OPEN_ADDITIONALS)); // Ctrl + D
318  getAccelTable()->addAccel(327780, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_SAVEADDITIONALS)); // Ctrl + Shift + D
319  getAccelTable()->addAccel(262219, this, FXSEL(SEL_COMMAND, MID_OPEN_TLSPROGRAMS)); // Ctrl + K
320  getAccelTable()->addAccel(327787, this, FXSEL(SEL_COMMAND, MID_GNE_TOOLBARFILE_SAVETLSPROGRAMS)); // Ctrl + Shift + K
321  getAccelTable()->addAccel(262230, this, FXSEL(SEL_COMMAND, MID_CLOSE)); // Ctrl + W
322  getAccelTable()->addAccel(262225, this, FXSEL(SEL_COMMAND, MID_QUIT)); // Ctrl + Q
323  getAccelTable()->addAccel(262234, this, FXSEL(SEL_COMMAND, FXUndoList::ID_UNDO)); // Ctrl + Z
324  getAccelTable()->addAccel(262233, this, FXSEL(SEL_COMMAND, FXUndoList::ID_REDO)); // Ctrl + Y
325  getAccelTable()->addAccel(262230, this, FXSEL(SEL_COMMAND, MID_EDITVIEWSCHEME)); // Ctrl + V
326  getAccelTable()->addAccel(262217, this, FXSEL(SEL_COMMAND, MID_EDITVIEWPORT)); // Ctrl + I
327  getAccelTable()->addAccel(262215, this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_TOOGLE_GRID)); // Ctrl + G
328  getAccelTable()->addAccel(262228, this, FXSEL(SEL_COMMAND, MID_SUMOGUI)); // Ctrl + S
329  // initialize Shift hotkeys with Caps Lock enabled using decimal code (to avoid problems in Linux)
330  getAccelTable()->addAccel(65642, this, FXSEL(SEL_COMMAND, MID_LOCATEJUNCTION)); // Shift + J
331  getAccelTable()->addAccel(65637, this, FXSEL(SEL_COMMAND, MID_LOCATEEDGE)); // Shift + E
332  getAccelTable()->addAccel(65652, this, FXSEL(SEL_COMMAND, MID_LOCATETLS)); // Shift + T
333  getAccelTable()->addAccel(65633, this, FXSEL(SEL_COMMAND, MID_LOCATEADD)); // Shift + A
334  getAccelTable()->addAccel(65647, this, FXSEL(SEL_COMMAND, MID_LOCATEPOI)); // Shift + O
335  getAccelTable()->addAccel(65644, this, FXSEL(SEL_COMMAND, MID_LOCATEPOLY)); // Shift + L
336  // initialize rest of hotkeys
337  getAccelTable()->addAccel(parseAccel("Esc"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_ESC));
338  getAccelTable()->addAccel(parseAccel("Del"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_DEL));
339  getAccelTable()->addAccel(parseAccel("Enter"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_ENTER));
340  getAccelTable()->addAccel(parseAccel("F12"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_FOCUSFRAME));
341 }
342 
343 
344 void
347  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
348  FXMainWindow::create();
349  myMenuBarDrag->create();
350  myFileMenu->create();
351  myEditMenu->create();
352  myFileMenuShapes->create();
353  myFileMenuAdditionals->create();
354  myFileMenuTLS->create();
355  //mySettingsMenu->create();
356  myWindowsMenu->create();
357  myHelpMenu->create();
358 
359  FXint textWidth = getApp()->getNormalFont()->getTextWidth("8", 1) * 22;
360  myCartesianFrame->setWidth(textWidth);
361  myGeoFrame->setWidth(textWidth);
362 
363  show(PLACEMENT_DEFAULT);
364  if (!OptionsCont::getOptions().isSet("window-size")) {
365  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
366  maximize();
367  }
368  }
369 
370 }
371 
372 
374  closeAllWindows();
375  // Close icons
377  // Close gifs (Textures)
379  // delete visuals
380  delete myGLVisual;
381  // must delete menus to avoid segfault on removing accelerators
382  // (http://www.fox-toolkit.net/faq#TOC-What-happens-when-the-application-s)
383  delete myFileMenuShapes,
384  delete myFileMenuAdditionals,
385  delete myFileMenuTLS,
386  delete myFileMenu;
387  delete myEditMenu;
388  delete myLocatorMenu;
389  delete myProcessingMenu;
390  delete myWindowsMenu;
391  delete myHelpMenu;
392  // Delete load thread
393  delete myLoadThread;
394  // drop all events
395  while (!myEvents.empty()) {
396  // get the next event
397  GUIEvent* e = myEvents.top();
398  myEvents.pop();
399  delete e;
400  }
401  // delte undo list
402  delete myUndoList;
403 }
404 
405 
406 void
408  FXMainWindow::detach();
409  myMenuBarDrag->detach();
410 }
411 
412 
413 void
415  // build file menu
416  myFileMenu = new FXMenuPane(this);
417  new FXMenuTitle(myMenuBar, "&File", 0, myFileMenu);
418  new FXMenuCommand(myFileMenu,
419  "&New Network...\tCtrl+N\tCreate a new network.",
421  new FXMenuCommand(myFileMenu,
422  "&Open Network...\tCtrl+O\tOpen a SUMO network.",
424  new FXMenuCommand(myFileMenu,
425  "Open Configura&tion...\tCtrl+Shift+O\tOpen a NETCONVERT configuration file.",
427  new FXMenuCommand(myFileMenu,
428  "Import &Foreign Network...\t\tImport a foreign network such as OSM.",
430  new FXMenuCommand(myFileMenu,
431  "&Reload\tCtrl+R\tReloads the network.",
433  new FXMenuCommand(myFileMenu,
434  "&Save Network...\tCtrl+S\tSave the network.",
436  new FXMenuCommand(myFileMenu,
437  "Save Net&work As...\tCtrl+Shift+S\tSave the network in another file.",
439  new FXMenuCommand(myFileMenu,
440  "Save plain XM&L...\tCtrl+L\tSave plain xml representation the network.",
442  new FXMenuCommand(myFileMenu,
443  "Save &joined junctions...\tCtrl+J\tSave log of joined junctions (allows reproduction of joins).",
445  // create Shapes menu options
446  myFileMenuShapes = new FXMenuPane(this);
447  new FXMenuCommand(myFileMenuShapes,
448  "Load S&hapes...\tCtrl+P\tLoad shapes into the network view.",
450  mySaveShapesMenuCommand = new FXMenuCommand(myFileMenuShapes,
451  "Save Shapes\tCtrl+Shift+P\tSave shapes elements.",
453  mySaveShapesMenuCommand->disable();
454  mySaveShapesMenuCommandAs = new FXMenuCommand(myFileMenuShapes,
455  "Save Shapes As...\t\tSave shapes elements in another files.",
457  mySaveShapesMenuCommandAs->disable();
458  new FXMenuCascade(myFileMenu, "Shapes", GUIIconSubSys::getIcon(ICON_MODEPOLYGON), myFileMenuShapes);
459  // create Additionals menu options
460  myFileMenuAdditionals = new FXMenuPane(this);
461  new FXMenuCommand(myFileMenuAdditionals,
462  "Load A&dditionals...\tCtrl+D\tLoad additional elements.",
465  "Save Additionals\tCtrl+Shift+D\tSave additional elements.",
467  mySaveAdditionalsMenuCommand->disable();
469  "Save Additionals As...\t\tSave additional elements in another file.",
472  new FXMenuCascade(myFileMenu, "Additionals", GUIIconSubSys::getIcon(ICON_MODEADDITIONAL), myFileMenuAdditionals);
473  // create TLS menu options
474  myFileMenuTLS = new FXMenuPane(this);
475  new FXMenuCommand(myFileMenuTLS,
476  "load TLS Programs...\tCtrl+K\tload TLS Programs in all Traffic Lights of the net.",
478  mySaveTLSProgramsMenuCommand = new FXMenuCommand(myFileMenuTLS,
479  "Save TLS Programs \tCtrl+Shift+K\tSave TLS Programs of all Traffic Lights of the current net.",
481  mySaveTLSProgramsMenuCommand->disable();
482  new FXMenuCommand(myFileMenuTLS,
483  "Save TLS Programs As...\t\tSave TLS Programs of all Traffic Lights of the current net in another file.",
485  new FXMenuCascade(myFileMenu, "Traffic Lights", GUIIconSubSys::getIcon(ICON_MODETLS), myFileMenuTLS);
486  // close network
487  new FXMenuSeparator(myFileMenu);
488  new FXMenuCommand(myFileMenu,
489  "Close\tCtrl+W\tClose the net&work.",
491  // Recent files
492  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
493  sep1->setTarget(&myRecentConfigs);
494  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
495  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
496  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
497  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
498  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
499  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
500  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
501  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
502  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
503  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
504  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
505  new FXMenuCommand(myFileMenu, "Clear Recent Configurat&ions", 0, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
506  myRecentConfigs.setTarget(this);
507  myRecentConfigs.setSelector(MID_RECENTFILE);
508  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
509  sep2->setTarget(&myRecentNets);
510  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
511  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
512  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
513  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
514  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
515  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
516  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
517  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
518  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
519  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
520  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
521  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", 0, &myRecentNets, FXRecentFiles::ID_CLEAR);
522  myRecentNets.setTarget(this);
523  myRecentNets.setSelector(MID_RECENTFILE);
524  new FXMenuSeparator(myFileMenu);
525  new FXMenuCommand(myFileMenu,
526  "&Quit\tCtrl+Q\tQuit the Application.",
527  0, this, MID_QUIT, 0);
528 
529  // build edit menu
530  myEditMenu = new FXMenuPane(this);
531  new FXMenuTitle(myMenuBar, "&Edit", 0, myEditMenu);
532 
533  // build undo/redo command
534  new FXMenuCommand(myEditMenu,
535  "&Undo\tCtrl+Z\tUndo the last change.",
536  GUIIconSubSys::getIcon(ICON_UNDO), myUndoList, FXUndoList::ID_UNDO);
537  new FXMenuCommand(myEditMenu,
538  "&Redo\tCtrl+Y\tRedo the last change.",
539  GUIIconSubSys::getIcon(ICON_REDO), myUndoList, FXUndoList::ID_REDO);
540 
541  new FXMenuSeparator(myEditMenu);
542 
543  // build modes command
544  new FXMenuCommand(myEditMenu,
545  "&Edge mode\tE\tCreate junction and edges.",
547  new FXMenuCommand(myEditMenu,
548  "&Move mode\tM\tMove elements.",
550  new FXMenuCommand(myEditMenu,
551  "&Delete mode\tD\tDelete elements.",
553  new FXMenuCommand(myEditMenu,
554  "&Inspect mode\tI\tInspect elements and change their attributes.",
556  new FXMenuCommand(myEditMenu,
557  "&Select mode\tS\tSelect elements.",
559  new FXMenuCommand(myEditMenu,
560  "&Connection mode\tC\tEdit connections between lanes.",
562  new FXMenuCommand(myEditMenu,
563  "Pro&hibition mode\tW\tEdit connection prohibitions.",
565  new FXMenuCommand(myEditMenu,
566  "&Traffic light mode\tT\tEdit traffic lights over junctions.",
568  new FXMenuCommand(myEditMenu,
569  "&Additional mode\tA\tCreate additional elements.",
571  new FXMenuCommand(myEditMenu,
572  "C&rossing mode\tR\tCreate crossings between edges.",
574  new FXMenuCommand(myEditMenu,
575  "&POI-Poly mode\tP\tCreate Points-Of-Interest and polygons.",
577 
578  new FXMenuSeparator(myEditMenu);
579  new FXMenuCommand(myEditMenu,
580  "Edit Visualisation ...\tCtrl+V\tOpens a dialog for editing visualization settings.",
581  0, this, MID_EDITVIEWSCHEME);
582  new FXMenuCommand(myEditMenu,
583  "Edit Viewport...\tCtrl+I\tOpens a dialog for editing viewing are, zoom and rotation.",
584  0, this, MID_EDITVIEWPORT);
585  new FXMenuCommand(myEditMenu,
586  "Toggle Grid...\tCtrl+G\tToggles background grid (and snap-to-grid functionality).",
587  0, this, MID_GNE_HOTKEY_TOOGLE_GRID);
588  new FXMenuSeparator(myEditMenu);
589  new FXMenuCommand(myEditMenu,
590  "Open in SUMO GUI...\tCtrl+T\tOpens the SUMO GUI application with the current network.",
592 
593  // processing menu (trigger netbuild computations)
594  myProcessingMenu = new FXMenuPane(this);
595  new FXMenuTitle(myMenuBar, "&Processing", 0, myProcessingMenu);
596  new FXMenuCommand(myProcessingMenu,
597  "Compute Junctions\tF5\tComputes junction shape and logic.",
599  new FXMenuCommand(myProcessingMenu,
600  "Compute Junctions with volatile options\tShift+F5\tComputes junction shape and logic using volatile junctions.",
602  new FXMenuCommand(myProcessingMenu,
603  "Clean Junctions\tF6\tRemoves solitary junctions.",
605  new FXMenuCommand(myProcessingMenu,
606  "Join Selected Junctions\tF7\tJoins selected junctions into a single junction.",
608  new FXMenuCommand(myProcessingMenu,
609  "Clean invalid crossings\tF8\tClear invalid crossings.",
611  new FXMenuCommand(myProcessingMenu,
612  "Options\tF10\t\tConfigure Processing Options.",
614  // build settings menu
615  /*
616  mySettingsMenu = new FXMenuPane(this);
617  new FXMenuTitle(myMenuBar,"&Settings",0,mySettingsMenu);
618  new FXMenuCheck(mySettingsMenu,
619  "Gaming Mode\t\tToggle gaming mode on/off.",
620  this,MID_GAMING);
621  */
622  // build Locate menu
623  myLocatorMenu = new FXMenuPane(this);
624  new FXMenuTitle(myMenuBar, "&Locate", nullptr, myLocatorMenu);
625  new FXMenuCommand(myLocatorMenu,
626  "Locate &Junctions\tShift+J\tOpen a Dialog for Locating a Junction.",
628  new FXMenuCommand(myLocatorMenu,
629  "Locate &Edges\tShift+E\tOpen a Dialog for Locating an Edge.",
631  new FXMenuCommand(myLocatorMenu,
632  "Locate &TLS\tShift+T\tOpen a Dialog for Locating a Traffic Light.",
634  new FXMenuCommand(myLocatorMenu,
635  "Locate &Additional\tShift+A\tOpen a Dialog for Locating an Additional Structure.",
637  new FXMenuCommand(myLocatorMenu,
638  "Locate P&oI\tShift+O\tOpen a Dialog for Locating a Point of Intereset.",
640  new FXMenuCommand(myLocatorMenu,
641  "Locate Po&lygon\tShift+L\tOpen a Dialog for Locating a Polygon.",
643  // build windows menu
644  myWindowsMenu = new FXMenuPane(this);
645  new FXMenuTitle(myMenuBar, "&Windows", 0, myWindowsMenu);
646  new FXMenuCheck(myWindowsMenu,
647  "&Show Status Line\t\tToggle this Status Bar on/off.",
648  myStatusbar, FXWindow::ID_TOGGLESHOWN);
649  new FXMenuCheck(myWindowsMenu,
650  "Show &Message Window\t\tToggle the Message Window on/off.",
651  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
652  /*
653  new FXMenuSeparator(myWindowsMenu);
654  new FXMenuCommand(myWindowsMenu,"Tile &Horizontally",
655  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_HORI),
656  myMDIClient,FXMDIClient::ID_MDI_TILEHORIZONTAL);
657  new FXMenuCommand(myWindowsMenu,"Tile &Vertically",
658  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_VERT),
659  myMDIClient,FXMDIClient::ID_MDI_TILEVERTICAL);
660  new FXMenuCommand(myWindowsMenu,"C&ascade",
661  GUIIconSubSys::getIcon(ICON_WINDOWS_CASCADE),
662  myMDIClient,FXMDIClient::ID_MDI_CASCADE);
663  new FXMenuCommand(myWindowsMenu,"&Close",0,
664  myMDIClient,FXMDIClient::ID_MDI_CLOSE);
665  sep1=new FXMenuSeparator(myWindowsMenu);
666  sep1->setTarget(myMDIClient);
667  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
668  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_1);
669  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_2);
670  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_3);
671  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_4);
672  new FXMenuCommand(myWindowsMenu,"&Others...",0,myMDIClient,FXMDIClient::ID_MDI_OVER_5);
673  new FXMenuSeparator(myWindowsMenu);
674  */
675  new FXMenuCommand(myWindowsMenu,
676  "&Clear Message Window\t\tClear the message window.",
677  0, this, MID_CLEARMESSAGEWINDOW);
678 
679  // build help menu
680  myHelpMenu = new FXMenuPane(this);
681  new FXMenuTitle(myMenuBar, "&Help", 0, myHelpMenu);
682  new FXMenuCommand(myHelpMenu,
683  "&Online Documentation\tF1\tOpen Online documentation.",
684  0, this, MID_HELP);
685  new FXMenuCommand(myHelpMenu,
686  "&About\tF2\tAbout netedit.",
687  0, this, MID_ABOUT);
688 }
689 
690 
691 long
692 GNEApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
695  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
696  if (isMaximized()) {
697  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 1);
698  } else {
699  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 0);
700  }
701  getApp()->exit(0);
702  }
703  return 1;
704 }
705 
706 
707 long
708 GNEApplicationWindow::onCmdEditChosen(FXObject*, FXSelector, void*) {
709  GUIDialog_GLChosenEditor* chooser =
711  chooser->create();
712  chooser->show();
713  return 1;
714 }
715 
716 
717 long
718 GNEApplicationWindow::onCmdNewNetwork(FXObject*, FXSelector, void*) {
719  // ask before we clobber options
721  return 1;
722  }
726  loadConfigOrNet("", true, false, true, true);
727  return 1;
728 }
729 
730 
731 long
732 GNEApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
733  // get the new file name
734  FXFileDialog opendialog(this, "Open Netconvert Configuration");
735  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_MODECREATEEDGE));
736  opendialog.setSelectMode(SELECTFILE_EXISTING);
737  opendialog.setPatternList(myConfigPattern.c_str());
738  if (gCurrentFolder.length() != 0) {
739  opendialog.setDirectory(gCurrentFolder);
740  }
741  if (opendialog.execute()) {
742  gCurrentFolder = opendialog.getDirectory();
743  std::string file = opendialog.getFilename().text();
744  loadConfigOrNet(file, false);
745  myRecentConfigs.appendFile(file.c_str());
746  }
747  return 1;
748 }
749 
750 
751 long
752 GNEApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
753  // get the new file name
754  FXFileDialog opendialog(this, "Open Network");
755  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_MODECREATEEDGE));
756  opendialog.setSelectMode(SELECTFILE_EXISTING);
757  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
758  if (gCurrentFolder.length() != 0) {
759  opendialog.setDirectory(gCurrentFolder);
760  }
761  if (opendialog.execute()) {
762  gCurrentFolder = opendialog.getDirectory();
763  std::string file = opendialog.getFilename().text();
764  loadConfigOrNet(file, true);
765  myRecentNets.appendFile(file.c_str());
766  // when a net is loaded, save additional, shapes an TLSPrograms are disabled
769  mySaveTLSProgramsMenuCommand->disable();
770  }
771  return 1;
772 }
773 
774 
775 long
776 GNEApplicationWindow::onCmdOpenForeign(FXObject*, FXSelector, void*) {
777  // ask before we clobber options
779  return 1;
780  }
781  // get the new file name
782  FXFileDialog opendialog(this, "Import Foreign Network");
783  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_MODECREATEEDGE));
784  opendialog.setSelectMode(SELECTFILE_EXISTING);
785  FXString osmPattern("OSM net (*.osm.xml,*.osm)");
786  opendialog.setPatternText(0, osmPattern);
787  if (gCurrentFolder.length() != 0) {
788  opendialog.setDirectory(gCurrentFolder);
789  }
790  if (opendialog.execute()) {
791  gCurrentFolder = opendialog.getDirectory();
792  std::string file = opendialog.getFilename().text();
793 
796  if (osmPattern.contains(opendialog.getPattern())) {
797  oc.set("osm-files", file);
798  oc.set("ramps.guess", "true");
799  oc.set("tls.guess", "true");
800  } else {
801  throw ProcessError("Attempted to import unknown file format '" + file + "'.");
802  }
803 
804  GUIDialog_Options* wizard =
805  new GUIDialog_Options(this, "Select Import Options", getWidth(), getHeight());
806 
807  if (wizard->execute()) {
808  NIFrame::checkOptions(); // needed to set projection parameters
809  loadConfigOrNet(file, false, false, false);
810  }
811  }
812  return 1;
813 }
814 
815 
816 long
817 GNEApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
818  // get the shape file name
819  FXFileDialog opendialog(this, "Open Shapes file");
820  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_MODEPOLYGON));
821  opendialog.setSelectMode(SELECTFILE_EXISTING);
822  opendialog.setPatternList("Shape files (*.xml)\nAll files (*)");
823  if (gCurrentFolder.length() != 0) {
824  opendialog.setDirectory(gCurrentFolder);
825  }
826  if (opendialog.execute()) {
827  gCurrentFolder = opendialog.getDirectory();
828  std::string file = opendialog.getFilename().text();
829  GNEShapeHandler handler(file, myNet);
830  // disable validation for shapes
831  XMLSubSys::setValidation("never", "auto");
832  // begin undo operation
833  myUndoList->p_begin("Loading shapes from '" + file + "'");
834  // run parser for shapes
835  if (!XMLSubSys::runParser(handler, file, false)) {
836  WRITE_MESSAGE("Loading of shapes failed.");
837  }
838  // end undoList operation and update view
839  myUndoList->p_end();
840  update();
841  // enable validation for shapes
842  XMLSubSys::setValidation("auto", "auto");
843  update();
844  }
845  return 1;
846 }
847 
848 
849 long
850 GNEApplicationWindow::onCmdOpenAdditionals(FXObject*, FXSelector, void*) {
851  // get the Additional file name
852  FXFileDialog opendialog(this, "Open Additionals file");
853  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_MODEADDITIONAL));
854  opendialog.setSelectMode(SELECTFILE_EXISTING);
855  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
856  if (gCurrentFolder.length() != 0) {
857  opendialog.setDirectory(gCurrentFolder);
858  }
859  if (opendialog.execute()) {
860  gCurrentFolder = opendialog.getDirectory();
861  std::string file = opendialog.getFilename().text();
862  // disable validation for additionals
863  XMLSubSys::setValidation("never", "auto");
864  // Create additional handler
865  GNEAdditionalHandler additionalHandler(file, myNet->getViewNet());
866  // begin undoList operation
867  myUndoList->p_begin("Loading additionals from '" + file + "'");
868  // Run parser for additionals
869  if (!XMLSubSys::runParser(additionalHandler, file, false)) {
870  WRITE_MESSAGE("Loading of " + file + " failed.");
871  }
872  // end undoList operation and update view
873  myUndoList->p_end();
874  update();
875  // restore validation for additionals
876  XMLSubSys::setValidation("auto", "auto");
877  }
878  return 1;
879 }
880 
881 
882 long
883 GNEApplicationWindow::onCmdOpenTLSPrograms(FXObject*, FXSelector, void*) {
884  // get the shape file name
885  FXFileDialog opendialog(this, "Open TLSPrograms file");
886  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_MODETLS));
887  opendialog.setSelectMode(SELECTFILE_EXISTING);
888  opendialog.setPatternList("TLSProgram files (*.xml)\nAll files (*)");
889  if (gCurrentFolder.length() != 0) {
890  opendialog.setDirectory(gCurrentFolder);
891  }
892  if (opendialog.execute()) {
893  gCurrentFolder = opendialog.getDirectory();
894  std::string file = opendialog.getFilename().text();
895  // Run parser
896  myUndoList->p_begin("Loading TLS Programs from '" + file + "'");
897  if (myNet->getViewNet()->getViewParent()->getTLSEditorFrame()->parseTLSPrograms(file) == false) {
898  // Abort undo/redo
899  myUndoList->abort();
900  } else {
901  // commit undo/redo operation
902  myUndoList->p_end();
903  update();
904  }
905  }
906  return 1;
907 }
908 
909 
910 long
911 GNEApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* fileData) {
912  if (myAmLoading) {
913  myStatusbar->getStatusLine()->setText("Already loading!");
914  return 1;
915  }
916  std::string file((const char*)fileData);
917  loadConfigOrNet(file, sender == &myRecentNets);
918  return 1;
919 }
920 
921 
922 long
923 GNEApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
924  // @note. If another network has been load during this session, it might not be desirable to set useStartupOptions
925  loadConfigOrNet(OptionsCont::getOptions().getString("sumo-net-file"), true, true);
926  return 1;
927 }
928 
929 
930 long
931 GNEApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
933  closeAllWindows();
934  // disable save additionals, shapes and TLS menu
937  mySaveTLSProgramsMenuCommand->disable();
938  }
939  return 1;
940 }
941 
942 
943 long
944 GNEApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
945  if (myMDIClient->numChildren() > 0) {
946  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
947  if (w != 0) {
948  w->onCmdLocate(0, sel, 0);
949  }
950  }
951  return 1;
952 }
953 
954 long
955 GNEApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void*) {
956  sender->handle(this, myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
957  return 1;
958 }
959 
960 
961 long
962 GNEApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
964  return 1;
965 }
966 
967 
968 long
969 GNEApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
970  // write warning if netedit is running in testing mode
971  WRITE_DEBUG("Opening about dialog");
972  // create and open about dialog
973  GNEDialog_About* about = new GNEDialog_About(this);
974  about->create();
975  about->show(PLACEMENT_OWNER);
976  // write warning if netedit is running in testing mode
977  WRITE_DEBUG("Closed about dialog");
978  return 1;
979 }
980 
981 
982 long GNEApplicationWindow::onClipboardRequest(FXObject*, FXSelector, void* ptr) {
983  FXEvent* event = (FXEvent*)ptr;
984  FXString string = GUIUserIO::clipped.c_str();
985  setDNDData(FROM_CLIPBOARD, event->target, string);
986  return 1;
987 }
988 
989 
990 long
991 GNEApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
992  eventOccurred();
993  return 1;
994 }
995 
996 
997 void
999  while (!myEvents.empty()) {
1000  // get the next event
1001  GUIEvent* e = myEvents.top();
1002  myEvents.pop();
1003  // process
1004  switch (e->getOwnType()) {
1007  break;
1010  case EVENT_ERROR_OCCURRED:
1011  case EVENT_DEBUG_OCCURRED:
1014  break;
1015  default:
1016  break;
1017  }
1018  delete e;
1019  }
1020 }
1021 
1022 
1023 void
1026  myAmLoading = false;
1027  GNEEvent_NetworkLoaded* ec = static_cast<GNEEvent_NetworkLoaded*>(e);
1028  // check whether the loading was successfull
1029  if (ec->myNet == nullptr) {
1030  // report failure
1031  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
1032  } else {
1033  // set new Net
1034  myNet = ec->myNet;
1035  // report success
1036  setStatusBarText("'" + ec->myFile + "' loaded.");
1038  // initialise views
1039  myViewNumber = 0;
1040  GUISUMOAbstractView* view = openNewView();
1041  if (view && ec->mySettingsFile != "") {
1042  GUISettingsHandler settings(ec->mySettingsFile, true, true);
1043  std::string settingsName = settings.addSettings(view);
1044  view->addDecals(settings.getDecals());
1045  settings.applyViewport(view);
1046  settings.setSnapshots(view);
1047  }
1048  // set network name on the caption
1049  setTitle(MFXUtils::getTitleText(myTitlePrefix, ec->myFile.c_str()));
1051  if (ec->myViewportFromRegistry) {
1052  Position off;
1053  off.set(getApp()->reg().readRealEntry("viewport", "x"), getApp()->reg().readRealEntry("viewport", "y"), getApp()->reg().readRealEntry("viewport", "z"));
1054  Position p(off.x(), off.y(), 0);
1055  getView()->setViewportFromToRot(off, p, 0);
1056  }
1057  }
1058  getApp()->endWaitCursor();
1060  // check if additionals has to be loaded at start
1061  if (oc.isSet("sumo-additionals-file") && !oc.getString("sumo-additionals-file").empty() && myNet) {
1062  myAdditionalsFile = oc.getString("sumo-additionals-file");
1063  WRITE_MESSAGE("Loading additionals from '" + myAdditionalsFile + "'");
1064  GNEAdditionalHandler additionalHandler(myAdditionalsFile, myNet->getViewNet());
1065  // disable validation for additionals
1066  XMLSubSys::setValidation("never", "auto");
1067  // Run parser
1068  myUndoList->p_begin("Loading additionals from '" + myAdditionalsFile + "'");
1069  if (!XMLSubSys::runParser(additionalHandler, myAdditionalsFile, false)) {
1070  WRITE_ERROR("Loading of " + myAdditionalsFile + " failed.");
1071  }
1072  // disable validation for additionals
1073  XMLSubSys::setValidation("auto", "auto");
1074  myUndoList->p_end();
1075  }
1076  // check if shapes has to be loaded at start
1077  if (oc.isSet("sumo-shapes-file") && !oc.getString("sumo-shapes-file").empty() && myNet) {
1078  myShapesFile = oc.getString("sumo-shapes-file");
1079  WRITE_MESSAGE("Loading shapes");
1080  GNEShapeHandler shapeHandler(myShapesFile, myNet);
1081  // disable validation for shapes
1082  XMLSubSys::setValidation("never", "auto");
1083  // Run parser
1084  myUndoList->p_begin("Loading shapes from '" + myShapesFile + "'");
1085  if (!XMLSubSys::runParser(shapeHandler, myShapesFile, false)) {
1086  WRITE_ERROR("Loading of shapes failed.");
1087  }
1088  // enable validation for shapes
1089  XMLSubSys::setValidation("auto", "auto");
1090  myUndoList->p_end();
1091  }
1092  // check if additionals output must be changed
1093  if (oc.isSet("additionals-output")) {
1094  myAdditionalsFile = oc.getString("additionals-output");
1095  }
1096  // check if shapes output must be changed
1097  if (oc.isSet("shapes-output")) {
1098  myShapesFile = oc.getString("shapes-output");
1099  }
1100  // check if TLSPrograms output must be changed
1101  if (oc.isSet("TLSPrograms-output")) {
1102  myTLSProgramsFile = oc.getString("TLSPrograms-output");
1103  }
1104  // after loading net shouldn't be saved
1105  if (myNet) {
1106  myNet->requiereSaveNet(false);
1107  }
1108  update();
1109 }
1110 
1111 
1112 void
1114  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1115  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1116 }
1117 
1118 
1119 void
1120 GNEApplicationWindow::loadConfigOrNet(const std::string file, bool isNet, bool isReload, bool useStartupOptions, bool newNet) {
1121  if (!continueWithUnsavedChanges()) {
1122  return;
1123  }
1125  getApp()->beginWaitCursor();
1126  myAmLoading = true;
1127  closeAllWindows();
1128  if (isReload) {
1129  myLoadThread->start();
1130  setStatusBarText("Reloading.");
1131  } else {
1132  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
1133  myLoadThread->loadConfigOrNet(file, isNet, useStartupOptions, newNet);
1134  setStatusBarText("Loading '" + file + "'.");
1135  }
1136  update();
1137 }
1138 
1139 
1140 
1143  std::string caption = "View #" + toString(myViewNumber++);
1144  FXuint opts = MDI_TRACKING;
1145  // create view parent
1146  GNEViewParent* viewParent = new GNEViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()), this, getBuildGLCanvas(), myNet, myUndoList, nullptr, opts, 10, 10, 300, 200);
1147  if (myMDIClient->numChildren() == 1) {
1148  viewParent->maximize();
1149  } else {
1150  myMDIClient->vertical(true);
1151  }
1152  myMDIClient->setActiveChild(viewParent);
1153  //v->grabKeyboard();
1154  return viewParent->getView();
1155 }
1156 
1157 
1158 FXGLCanvas*
1160  if (myMDIClient->numChildren() == 0) {
1161  return 0;
1162  }
1163  GNEViewParent* share_tmp1 =
1164  static_cast<GNEViewParent*>(myMDIClient->childAtIndex(0));
1165  return share_tmp1->getBuildGLCanvas();
1166 }
1167 
1168 
1169 SUMOTime
1171  return 0;
1172 }
1173 
1174 
1175 double
1177  return 1;
1178 }
1179 
1180 
1181 GNEUndoList*
1183  return myUndoList;
1184 }
1185 
1186 
1187 void
1189  myTrackerLock.lock();
1190  // remove trackers and other external windows
1191  for (int i = 0; i < (int)mySubWindows.size(); ++i) {
1192  mySubWindows[i]->destroy();
1193  }
1194  for (int i = 0; i < (int)myTrackerWindows.size(); ++i) {
1195  myTrackerWindows[i]->destroy();
1196  }
1197  // reset the caption
1198  setTitle(myTitlePrefix);
1199  // delete other children
1200  while (myTrackerWindows.size() != 0) {
1201  delete myTrackerWindows[0];
1202  }
1203  while (mySubWindows.size() != 0) {
1204  delete mySubWindows[0];
1205  }
1206  mySubWindows.clear();
1207  // add a separator to the log
1210  // remove coordinate information
1211  myGeoCoordinate->setText("N/A");
1212  myCartesianCoordinate->setText("N/A");
1213 
1214  myUndoList->p_clear();
1215  // check if net can be deleted
1216  if (myNet != nullptr) {
1217  delete myNet;
1218  myNet = nullptr;
1220  }
1222  // Reset textures
1224  // reset fonts
1226  // disable saving commmand
1229 }
1230 
1231 
1232 FXCursor*
1234  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1235 }
1236 
1237 
1238 void
1240  const OptionsCont& oc = OptionsCont::getOptions();
1241  loadConfigOrNet("", true, false, true, oc.getBool("new"));
1242 }
1243 
1244 
1245 void
1246 GNEApplicationWindow::setStatusBarText(const std::string& statusBarText) {
1247  myStatusbar->getStatusLine()->setText(statusBarText.c_str());
1248  myStatusbar->getStatusLine()->setNormalText(statusBarText.c_str());
1249 }
1250 
1251 
1252 void
1253 GNEApplicationWindow::setAdditionalsFile(const std::string& additionalsFile) {
1254  myAdditionalsFile = additionalsFile;
1255 }
1256 
1257 
1258 void
1259 GNEApplicationWindow::setShapesFile(const std::string& shapesFile) {
1260  myShapesFile = shapesFile;
1261 }
1262 
1263 
1264 void
1265 GNEApplicationWindow::setTLSProgramsFile(const std::string& TLSProgramsFile) {
1266  myTLSProgramsFile = TLSProgramsFile;
1267 }
1268 
1269 
1270 void
1272  mySaveAdditionalsMenuCommand->enable();
1274 }
1275 
1276 
1277 void
1279  mySaveAdditionalsMenuCommand->disable();
1280  mySaveAdditionalsMenuCommandAs->disable();
1281 }
1282 
1283 
1284 void
1286  mySaveShapesMenuCommand->enable();
1287  mySaveShapesMenuCommandAs->enable();
1288 }
1289 
1290 
1291 void
1293  mySaveShapesMenuCommand->disable();
1294  mySaveShapesMenuCommandAs->disable();
1295 }
1296 
1297 
1298 void
1300  mySaveTLSProgramsMenuCommand->enable();
1301 }
1302 
1303 
1304 long
1305 GNEApplicationWindow::onCmdSetMode(FXObject*, FXSelector sel, void*) {
1306  if (getView()) {
1307  getView()->setEditModeFromHotkey(FXSELID(sel));
1308  }
1309  return 1;
1310 }
1311 
1312 
1313 long
1314 GNEApplicationWindow::onCmdOpenSUMOGUI(FXObject*, FXSelector, void*) {
1315  if (mySubWindows.empty()) {
1316  return 1;
1317  }
1318  std::string sumogui = "sumo-gui";
1319  const char* sumoPath = getenv("SUMO_HOME");
1320  if (sumoPath != 0) {
1321  std::string newPath = std::string(sumoPath) + "/bin/sumo-gui";
1322  if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
1323  sumogui = "\"" + newPath + "\"";
1324  }
1325  }
1326  std::string cmd = sumogui + " -n " + OptionsCont::getOptions().getString("output-file");
1327  // start in background
1328 #ifndef WIN32
1329  cmd = cmd + " &";
1330 #else
1331  // see "help start" for the parameters
1332  cmd = "start /B \"\" " + cmd;
1333 #endif
1334  WRITE_MESSAGE("Running " + cmd + ".");
1335  // yay! fun with dangerous commands... Never use this over the internet
1337  return 1;
1338 }
1339 
1340 
1341 long
1342 GNEApplicationWindow::onCmdAbort(FXObject*, FXSelector, void*) {
1343  if (getView()) {
1344  // show extra information for tests
1345  WRITE_DEBUG("Key ESC (abort) pressed");
1346  // abort current operation
1347  getView()->abortOperation();
1348  getView()->update();
1349  }
1350  return 1;
1351 }
1352 
1353 
1354 long
1355 GNEApplicationWindow::onCmdDel(FXObject*, FXSelector, void*) {
1356  if (getView()) {
1357  // show extra information for tests
1358  WRITE_DEBUG("Key DEL (delete) pressed");
1359  getView()->hotkeyDel();
1360  }
1361  return 1;
1362 }
1363 
1364 
1365 long
1366 GNEApplicationWindow::onCmdEnter(FXObject*, FXSelector, void*) {
1367  if (getView()) {
1368  // show extra information for tests
1369  WRITE_DEBUG("Key ENTER pressed");
1370  getView()->hotkeyEnter();
1371  }
1372  return 1;
1373 }
1374 
1375 
1376 long
1377 GNEApplicationWindow::onCmdFocusFrame(FXObject*, FXSelector, void*) {
1378  if (getView()) {
1380  }
1381  return 1;
1382 }
1383 
1384 
1385 long
1386 GNEApplicationWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
1387  if (getView()) {
1389  }
1390  return 1;
1391 }
1392 
1393 
1394 long
1395 GNEApplicationWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
1396  if (getView()) {
1398  }
1399  return 1;
1400 }
1401 
1402 
1403 long
1404 GNEApplicationWindow::onCmdToogleGrid(FXObject*, FXSelector, void*) {
1405  // only toogle grid if there is a GNEViewNet
1406  if (getView() != nullptr) {
1407  // Toogle getMenuCheckShowGrid of GNEViewNet
1408  if (getView()->getMenuCheckShowGrid()->getCheck() == 1) {
1409  getView()->getMenuCheckShowGrid()->setCheck(0);
1410  // show extra information for tests
1411  WRITE_DEBUG("Disabled grid throught Ctrl+g hotkey");
1412  } else {
1413  getView()->getMenuCheckShowGrid()->setCheck(1);
1414  // show extra information for tests
1415  WRITE_WARNING("Enabled grid throught Ctrl+g hotkey");
1416  }
1417  // Call manually show grid function
1418  getView()->onCmdShowGrid(0, 0, 0);
1419  }
1420  return 1;
1421 }
1422 
1423 
1424 long
1425 GNEApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
1426  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/NETEDIT");
1427  return 1;
1428 }
1429 
1430 
1431 long
1432 GNEApplicationWindow::onCmdComputeJunctions(FXObject*, FXSelector, void*) {
1433  // show extra information for tests
1434  WRITE_DEBUG("Key F5 (Compute) pressed");
1435  myNet->computeEverything(this, true, false);
1436  updateControls();
1437  return 1;
1438 }
1439 
1440 
1441 long
1443  // declare variable to save FXMessageBox outputs.
1444  FXuint answer = 0;
1445  // declare string to save paths in wich additionals and shapes will be saved
1446  std::string additionalSavePath = myAdditionalsFile;
1447  std::string shapeSavePath = myShapesFile;
1448  // write warning if netedit is running in testing mode
1449  WRITE_DEBUG("Keys Shift + F5 (Compute with volatile options) pressed");
1450  WRITE_DEBUG("Opening FXMessageBox 'Volatile Recomputing'");
1451  // open question dialog box
1452  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Recompute with volatile options",
1453  "Changes produced in the net due a recomputing with volatile options cannot be undone. Continue?");
1454  if (answer != 1) { //1:yes, 2:no, 4:esc
1455  // write warning if netedit is running in testing mode
1456  if (answer == 2) {
1457  WRITE_DEBUG("Closed FXMessageBox 'Volatile Recomputing' with 'No'");
1458  } else if (answer == 4) {
1459  WRITE_DEBUG("Closed FXMessageBox 'Volatile Recomputing' with 'ESC'");
1460  }
1461  // abort recompute with volatile options
1462  return 0;
1463  } else {
1464  // write warning if netedit is running in testing mode
1465  WRITE_DEBUG("Closed FXMessageBox 'Volatile Recomputing' with 'Yes'");
1466  // Check if there are additionals in our net
1467  if (myNet->getNumberOfAdditionals() > 0) {
1468  // ask user if want to save additionals if weren't saved previously
1469  if (myAdditionalsFile == "") {
1470  // write warning if netedit is running in testing mode
1471  WRITE_DEBUG("Opening FXMessageBox 'Save additionals before recomputing'");
1472  // open question dialog box
1473  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Save additionals before recomputing with volatile options",
1474  "Would you like to save additionals before recomputing?");
1475  if (answer != 1) { //1:yes, 2:no, 4:esc
1476  // write warning if netedit is running in testing mode
1477  if (answer == 2) {
1478  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before recomputing' with 'No'");
1479  } else if (answer == 4) {
1480  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before recomputing' with 'ESC'");
1481  }
1482  } else {
1483  // write warning if netedit is running in testing mode
1484  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before recomputing' with 'Yes'");
1485  // Open a dialog to set filename output
1487  "Select name of the additional file", ".xml",
1489  gCurrentFolder).text();
1490  // set obtanied filename output into additionalSavePath (can be "")
1491  additionalSavePath = myAdditionalsFile;
1492  }
1493  }
1494  // Check if additional must be saved in a temporal directory, if user didn't define a directory for additionals
1495  if (myAdditionalsFile == "") {
1496  // Obtain temporal directory provided by FXSystem::getCurrentDirectory()
1497  additionalSavePath = FXSystem::getTempDirectory().text() + std::string("/tmpAdditionalsNetedit.xml");
1498  }
1499  // Start saving additionals
1500  getApp()->beginWaitCursor();
1501  try {
1502  myNet->saveAdditionals(additionalSavePath);
1503  } catch (IOError& e) {
1504  // write warning if netedit is running in testing mode
1505  WRITE_DEBUG("Opening FXMessageBox 'Error saving additionals before recomputing'");
1506  // open error message box
1507  FXMessageBox::error(this, MBOX_OK, "Saving additionals in temporal folder failed!", "%s", e.what());
1508  // write warning if netedit is running in testing mode
1509  WRITE_DEBUG("Closed FXMessageBox 'Error saving additionals before recomputing' with 'OK'");
1510  }
1511  // end saving additionals
1513  getApp()->endWaitCursor();
1514  } else {
1515  // clear additional path
1516  additionalSavePath = "";
1517  }
1518  // Check if there are shapes in our net
1519  if (myNet->getNumberOfShapes() > 0) {
1520  // ask user if want to save shapes if weren't saved previously
1521  if (myShapesFile == "") {
1522  // write warning if netedit is running in testing mode
1523  WRITE_DEBUG("Opening FXMessageBox 'Save shapes before recomputing'");
1524  // open question dialog box
1525  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Save shapes before recomputing with volatile options",
1526  "Would you like to save shapes before recomputing?");
1527  if (answer != 1) { //1:yes, 2:no, 4:esc
1528  // write warning if netedit is running in testing mode
1529  if (answer == 2) {
1530  WRITE_DEBUG("Closed FXMessageBox 'Save shapes before recomputing' with 'No'");
1531  } else if (answer == 4) {
1532  WRITE_DEBUG("Closed FXMessageBox 'Save shapes before recomputing' with 'ESC'");
1533  }
1534  } else {
1535  // write warning if netedit is running in testing mode
1536  WRITE_DEBUG("Closed FXMessageBox 'Save shapes before recomputing' with 'Yes'");
1537  // Open a dialog to set filename output
1539  "Select name of the shape file", ".xml",
1541  gCurrentFolder).text();
1542  // set obtanied filename output into shapeSavePath (can be "")
1543  shapeSavePath = myShapesFile;
1544  }
1545  }
1546  // Check if shape must be saved in a temporal directory, if user didn't define a directory for shapes
1547  if (myShapesFile == "") {
1548  // Obtain temporal directory provided by FXSystem::getCurrentDirectory()
1549  shapeSavePath = FXSystem::getTempDirectory().text() + std::string("/tmpShapesNetedit.xml");
1550  }
1551  // Start saving shapes
1552  getApp()->beginWaitCursor();
1553  try {
1554  myNet->saveShapes(shapeSavePath);
1555  } catch (IOError& e) {
1556  // write warning if netedit is running in testing mode
1557  WRITE_DEBUG("Opening FXMessageBox 'Error saving shapes before recomputing'");
1558  // open error message box
1559  FXMessageBox::error(this, MBOX_OK, "Saving shapes in temporal folder failed!", "%s", e.what());
1560  // write warning if netedit is running in testing mode
1561  WRITE_DEBUG("Closed FXMessageBox 'Error saving shapes before recomputing' with 'OK'");
1562  }
1563  // end saving shapes
1565  getApp()->endWaitCursor();
1566  } else {
1567  // clear save path
1568  shapeSavePath = "";
1569  }
1570  // compute with volatile options
1571  myNet->computeEverything(this, true, true, additionalSavePath, shapeSavePath);
1572  updateControls();
1573  return 1;
1574  }
1575 }
1576 
1577 
1578 long
1579 GNEApplicationWindow::onCmdCleanJunctions(FXObject*, FXSelector, void*) {
1580  // show extra information for tests
1581  WRITE_DEBUG("Key F6 (Clean junction) pressed");
1583  return 1;
1584 }
1585 
1586 
1587 long
1588 GNEApplicationWindow::onCmdJoinJunctions(FXObject*, FXSelector, void*) {
1589  // show extra information for tests
1590  WRITE_DEBUG("Key F7 (Join junctions) pressed");
1592  return 1;
1593 }
1594 
1595 
1596 long
1598  // show extra information for tests
1599  WRITE_DEBUG("Key F8 (Clean invalid crossings) pressed");
1601  return 1;
1602 }
1603 
1604 
1605 long
1606 GNEApplicationWindow::onCmdOptions(FXObject*, FXSelector, void*) {
1607  GUIDialog_Options* wizard =
1608  new GUIDialog_Options(this, "Configure Options", getWidth(), getHeight());
1609 
1610  if (wizard->execute()) {
1611  NIFrame::checkOptions(); // needed to set projection parameters
1614  SystemFrame::checkOptions(); // needed to set precision
1615  }
1616  return 1;
1617 }
1618 
1619 
1620 long
1621 GNEApplicationWindow::onCmdSaveAsNetwork(FXObject*, FXSelector, void*) {
1622  FXString file = MFXUtils::getFilename2Write(this,
1623  "Save Network as", ".net.xml",
1625  gCurrentFolder);
1626  if (file == "") {
1627  return 1;
1628  }
1630  oc.resetWritable();
1631  oc.set("output-file", file.text());
1632  setTitle(MFXUtils::getTitleText(myTitlePrefix, file));
1633  onCmdSaveNetwork(0, 0, 0);
1634  return 1;
1635 }
1636 
1637 
1638 long
1639 GNEApplicationWindow::onCmdSaveAsPlainXML(FXObject*, FXSelector, void*) {
1640  FXString file = MFXUtils::getFilename2Write(this,
1641  "Select name of the plain-xml edge-file (other names will be deduced from this)", "",
1643  gCurrentFolder);
1644  if (file == "") {
1645  return 1;
1646  }
1648  bool wasSet = oc.isSet("plain-output-prefix");
1649  std::string oldPrefix = oc.getString("plain-output-prefix");
1650  oc.resetWritable();
1651  std::string prefix = file.text();
1652  // if the name of an edg.xml file was given, remove the suffix
1653  if (StringUtils::endsWith(prefix, ".edg.xml")) {
1654  prefix = prefix.substr(0, prefix.size() - 8);
1655  }
1656  if (StringUtils::endsWith(prefix, ".")) {
1657  prefix = prefix.substr(0, prefix.size() - 1);
1658  }
1659  oc.set("plain-output-prefix", prefix);
1660  getApp()->beginWaitCursor();
1661  try {
1662  myNet->savePlain(oc);
1663  myUndoList->unmark();
1664  myUndoList->mark();
1665  } catch (IOError& e) {
1666  // write warning if netedit is running in testing mode
1667  WRITE_DEBUG("Opening FXMessageBox 'Error saving plainXML'");
1668  // open message box
1669  FXMessageBox::error(this, MBOX_OK, "Saving plain xml failed!", "%s", e.what());
1670  // write warning if netedit is running in testing mode
1671  WRITE_DEBUG("Closed FXMessageBox 'Error saving plainXML' with 'OK'");
1672  }
1673  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Plain XML saved with prefix '" + prefix + "'.\n");
1675  if (wasSet) {
1676  oc.resetWritable();
1677  oc.set("plain-output-prefix", oldPrefix);
1678  } else {
1679  oc.unSet("plain-output-prefix");
1680  }
1681  getApp()->endWaitCursor();
1682  return 1;
1683 }
1684 
1685 
1686 long
1687 GNEApplicationWindow::onCmdSaveJoined(FXObject*, FXSelector, void*) {
1688  FXString file = MFXUtils::getFilename2Write(this,
1689  "Select name of the joined-junctions file", ".nod.xml",
1691  gCurrentFolder);
1692  if (file == "") {
1693  return 1;
1694  }
1696  bool wasSet = oc.isSet("junctions.join-output");
1697  std::string oldFile = oc.getString("junctions.join-output");
1698  oc.resetWritable();
1699  std::string filename = file.text();
1700  oc.set("junctions.join-output", filename);
1701  getApp()->beginWaitCursor();
1702  try {
1703  myNet->saveJoined(oc);
1704  } catch (IOError& e) {
1705  // write warning if netedit is running in testing mode
1706  WRITE_DEBUG("Opening FXMessageBox 'error saving joined'");
1707  // opening error message
1708  FXMessageBox::error(this, MBOX_OK, "Saving joined junctions failed!", "%s", e.what());
1709  // write warning if netedit is running in testing mode
1710  WRITE_DEBUG("Closed FXMessageBox 'error saving joined' with 'OK'");
1711  }
1712  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Joined junctions saved to '" + filename + "'.\n");
1714  if (wasSet) {
1715  oc.resetWritable();
1716  oc.set("junctions.join-output", oldFile);
1717  } else {
1718  oc.unSet("junctions.join-output");
1719  }
1720  getApp()->endWaitCursor();
1721  return 1;
1722 }
1723 
1724 
1725 long
1726 GNEApplicationWindow::onCmdSaveShapes(FXObject*, FXSelector, void*) {
1727  // check if save shapes menu is enabled
1728  if (mySaveShapesMenuCommand->isEnabled()) {
1729  // Check if shapes file was already set at start of netedit or with a previous save
1730  if (myShapesFile == "") {
1731  FXString file = MFXUtils::getFilename2Write(this,
1732  "Select name of the shape file", ".xml",
1734  gCurrentFolder);
1735  if (file == "") {
1736  // None shapes file was selected, then stop function
1737  return 0;
1738  } else {
1739  myShapesFile = file.text();
1740  }
1741  }
1742  getApp()->beginWaitCursor();
1743  try {
1745  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Shapes saved in " + myShapesFile + ".\n");
1746  mySaveShapesMenuCommand->disable();
1747  } catch (IOError& e) {
1748  // write warning if netedit is running in testing mode
1749  WRITE_DEBUG("Opening FXMessageBox 'Error saving shapes'");
1750  // open error dialog box
1751  FXMessageBox::error(this, MBOX_OK, "Saving POIs failed!", "%s", e.what());
1752  // write warning if netedit is running in testing mode
1753  WRITE_DEBUG("Closed FXMessageBox 'Error saving shapes' with 'OK'");
1754  }
1756  getApp()->endWaitCursor();
1757  return 1;
1758  } else {
1759  return 0;
1760  }
1761 }
1762 
1763 
1764 long GNEApplicationWindow::onCmdSaveShapesAs(FXObject*, FXSelector, void*) {
1765  // Open window to select shape file
1766  FXString file = MFXUtils::getFilename2Write(this,
1767  "Select name of the shape file", ".xml",
1769  gCurrentFolder);
1770  if (file != "") {
1771  // Set new shape file
1772  myShapesFile = file.text();
1773  // save shapes
1774  return onCmdSaveShapes(0, 0, 0);
1775  } else {
1776  return 1;
1777  }
1778 }
1779 
1780 
1781 long
1782 GNEApplicationWindow::onUpdNeedsNetwork(FXObject* sender, FXSelector, void*) {
1783  sender->handle(this, myNet == 0 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1784  return 1;
1785 }
1786 
1787 
1788 long
1789 GNEApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void*) {
1790  sender->handle(this, myNet == 0 || !OptionsCont::getOptions().isSet("sumo-net-file") ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1791  return 1;
1792 }
1793 
1794 
1795 long
1796 GNEApplicationWindow::onCmdSaveNetwork(FXObject*, FXSelector, void*) {
1798  // function onCmdSaveAsNetwork must be executed if this is the first save
1799  if (oc.getString("output-file") == "") {
1800  return onCmdSaveAsNetwork(0, 0, 0);
1801  } else {
1802  getApp()->beginWaitCursor();
1803  try {
1804  myNet->save(oc);
1805  myUndoList->unmark();
1806  myUndoList->mark();
1807  } catch (IOError& e) {
1808  // write warning if netedit is running in testing mode
1809  WRITE_DEBUG("Opening FXMessageBox 'error saving network'");
1810  // open error message box
1811  FXMessageBox::error(this, MBOX_OK, "Saving Network failed!", "%s", e.what());
1812  // write warning if netedit is running in testing mode
1813  WRITE_DEBUG("Closed FXMessageBox 'error saving network' with 'OK'");
1814  }
1815  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Network saved in " + oc.getString("output-file") + ".\n");
1816  // After saveing a net sucesfully, add it into Recent Nets list.
1817  myRecentNets.appendFile(oc.getString("output-file").c_str());
1819  getApp()->endWaitCursor();
1820  return 1;
1821  }
1822 }
1823 
1824 
1825 long
1826 GNEApplicationWindow::onCmdSaveAdditionals(FXObject*, FXSelector, void*) {
1827  // check if save additional menu is enabled
1828  if (mySaveAdditionalsMenuCommand->isEnabled()) {
1829  // Check if additionals file was already set at start of netedit or with a previous save
1830  if (myAdditionalsFile == "") {
1831  FXString file = MFXUtils::getFilename2Write(this,
1832  "Select name of the additional file", ".xml",
1834  gCurrentFolder);
1835  if (file == "") {
1836  // None additionals file was selected, then stop function
1837  return 0;
1838  } else {
1839  myAdditionalsFile = file.text();
1840  }
1841  }
1842  // Start saving additionals
1843  getApp()->beginWaitCursor();
1844  try {
1846  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Additionals saved in " + myAdditionalsFile + ".\n");
1847  mySaveAdditionalsMenuCommand->disable();
1848  } catch (IOError& e) {
1849  // write warning if netedit is running in testing mode
1850  WRITE_DEBUG("Opening FXMessageBox 'error saving additionals'");
1851  // open error message box
1852  FXMessageBox::error(this, MBOX_OK, "Saving additionals failed!", "%s", e.what());
1853  // write warning if netedit is running in testing mode
1854  WRITE_DEBUG("Closed FXMessageBox 'error saving additionals' with 'OK'");
1855  }
1857  getApp()->endWaitCursor();
1858  return 1;
1859  } else {
1860  return 0;
1861  }
1862 }
1863 
1864 
1865 long
1866 GNEApplicationWindow::onCmdSaveAdditionalsAs(FXObject*, FXSelector, void*) {
1867  // Open window to select additionasl file
1868  FXString file = MFXUtils::getFilename2Write(this,
1869  "Select name of the additional file", ".xml",
1871  gCurrentFolder);
1872  if (file != "") {
1873  // Set new additional file
1874  myAdditionalsFile = file.text();
1875  // save additionals
1876  return onCmdSaveAdditionals(0, 0, 0);
1877  } else {
1878  return 1;
1879  }
1880 }
1881 
1882 
1883 long
1884 GNEApplicationWindow::onCmdSaveTLSPrograms(FXObject*, FXSelector, void*) {
1885  // check if save additional menu is enabled
1886  if (mySaveTLSProgramsMenuCommand->isEnabled()) {
1887  // Check if TLS Programs file was already set at start of netedit or with a previous save
1888  if (myTLSProgramsFile == "") {
1889  FXString file = MFXUtils::getFilename2Write(this,
1890  "Select name of the additional file", ".xml",
1892  gCurrentFolder);
1893  if (file == "") {
1894  // None TLS Programs file was selected, then stop function
1895  return 0;
1896  } else {
1897  myTLSProgramsFile = file.text();
1898  }
1899  }
1900  // Start saving TLS Programs
1901  getApp()->beginWaitCursor();
1902  try {
1904  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "TLS Programs saved in " + myTLSProgramsFile + ".\n");
1905  mySaveTLSProgramsMenuCommand->disable();
1906  } catch (IOError& e) {
1907  // write warning if netedit is running in testing mode
1908  WRITE_DEBUG("Opening FXMessageBox 'error saving TLS Programs'");
1909  // open error message box
1910  FXMessageBox::error(this, MBOX_OK, "Saving TLS Programs failed!", "%s", e.what());
1911  // write warning if netedit is running in testing mode
1912  WRITE_DEBUG("Closed FXMessageBox 'error saving TLS Programs' with 'OK'");
1913  }
1915  getApp()->endWaitCursor();
1916  return 1;
1917  } else {
1918  return 0;
1919  }
1920 }
1921 
1922 
1923 long
1924 GNEApplicationWindow::onCmdSaveTLSProgramsAs(FXObject*, FXSelector, void*) {
1925  // Open window to select TLS Programs file
1926  FXString file = MFXUtils::getFilename2Write(this,
1927  "Select name of the TLS Progarm file", ".xml",
1929  gCurrentFolder);
1930  if (file != "") {
1931  // Set new TLS Program file
1932  myTLSProgramsFile = file.text();
1933  // save TLS Programs
1934  return onCmdSaveTLSPrograms(0, 0, 0);
1935  } else {
1936  return 1;
1937  }
1938 }
1939 
1940 
1941 long
1942 GNEApplicationWindow::onUpdSaveNetwork(FXObject* sender, FXSelector, void*) {
1944  bool enable = myNet != 0 && oc.isSet("output-file");
1945  sender->handle(this, FXSEL(SEL_COMMAND, enable ? ID_ENABLE : ID_DISABLE), 0);
1946  if (enable) {
1947  FXString caption = ("Save " + oc.getString("output-file")).c_str();
1948  sender->handle(this, FXSEL(SEL_COMMAND, FXMenuCaption::ID_SETSTRINGVALUE), (void*)&caption);
1949  }
1950  return 1;
1951 }
1952 
1953 
1954 GNEViewNet*
1956  if (mySubWindows.size() != 0) {
1957  GUIGlChildWindow* childWindows = dynamic_cast<GUIGlChildWindow*>(mySubWindows[0]);
1958  if (childWindows != nullptr) {
1959  return dynamic_cast<GNEViewNet*>(childWindows->getView());
1960  } else {
1961  return nullptr;
1962  }
1963  } else {
1964  return nullptr;
1965  }
1966 }
1967 
1968 
1969 bool
1971  FXuint answer = 0;
1972  if (myNet && !myNet->isNetSaved()) {
1973  // write warning if netedit is running in testing mode
1974  WRITE_DEBUG("Opening FXMessageBox 'Confirm closing network'");
1975  // open question box
1976  answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
1977  "Confirm closing Network", "%s",
1978  "You have unsaved changes in the network. Do you wish to quit and discard all changes?");
1979  // restore focus to view net
1980  getView()->setFocus();
1981  // if user close dialog box, check additionasl and shapes
1982  if (answer == MBOX_CLICKED_QUIT) {
1983  // write warning if netedit is running in testing mode
1984  WRITE_DEBUG("Closed FXMessageBox 'Confirm closing network' with 'Quit'");
1986  // clear undo list and return true to continue with closing/reload
1987  myUndoList->p_clear();
1988  return true;
1989  } else {
1990  return false;
1991  }
1992  } else if (answer == MBOX_CLICKED_SAVE) {
1993  // save newtork
1994  onCmdSaveNetwork(0, 0, 0);
1995  if (!myUndoList->marked()) {
1996  // saving failed
1997  return false;
1998  }
2000  // clear undo list and return true to continue with closing/reload
2001  myUndoList->p_clear();
2002  return true;
2003  } else {
2004  return false;
2005  }
2006  } else {
2007  // write warning if netedit is running in testing mode
2008  if (answer == 2) {
2009  WRITE_DEBUG("Closed FXMessageBox 'Confirm closing network' with 'No'");
2010  } else if (answer == 4) {
2011  WRITE_DEBUG("Closed FXMessageBox 'Confirm closing network' with 'ESC'");
2012  }
2013  // return false to stop closing/reloading
2014  return false;
2015  }
2016  } else {
2018  // clear undo list and return true to continue with closing/reload
2019  myUndoList->p_clear(); //only ask once
2020  return true;
2021  } else {
2022  // return false to stop closing/reloading
2023  return false;
2024  }
2025  }
2026 }
2027 
2028 
2029 bool
2031  // Check if there are non saved additionals
2032  if (mySaveAdditionalsMenuCommand->isEnabled()) {
2033  WRITE_DEBUG("Opening FXMessageBox 'Save additionals before exit'");
2034  // open question box
2035  FXuint answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
2036  "Save additionals before exit", "%s",
2037  "You have unsaved additionals. Do you wish to quit and discard all changes?");
2038  // restore focus to view net
2039  getView()->setFocus();
2040  // if answer was affirmative, but there was an error during saving additional, return false to stop closing/reloading
2041  if (answer == MBOX_CLICKED_QUIT) {
2042  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before exit' with 'Quit'");
2043  // nothing to save, return true
2044  return true;
2045  } else if (answer == MBOX_CLICKED_SAVE) {
2046  // write warning if netedit is running in testing mode
2047  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before exit' with 'Yes'");
2048  if (onCmdSaveAdditionals(0, 0, 0) == 1) {
2049  // additionals sucesfully saved
2050  return true;
2051  } else {
2052  // error saving additionals, abort saving
2053  return false;
2054  }
2055  } else {
2056  // write warning if netedit is running in testing mode
2057  if (answer == 2) {
2058  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before exit' with 'No'");
2059  } else if (answer == 4) {
2060  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before exit' with 'ESC'");
2061  }
2062  // abort saving
2063  return false;
2064  }
2065  } else {
2066  // nothing to save, return true
2067  return true;
2068  }
2069 }
2070 
2071 
2072 bool
2074  // Check if there are non saved additionals
2075  if (mySaveShapesMenuCommand->isEnabled()) {
2076  WRITE_DEBUG("Opening FXMessageBox 'Save shapes before exit'");
2077  // open question box
2078  FXuint answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
2079  "Save shapes before exit", "%s",
2080  "You have unsaved shapes. Do you wish to quit and discard all changes?");
2081  // restore focus to view net
2082  getView()->setFocus();
2083  // if answer was affirmative, but there was an error during saving additional, return false to stop closing/reloading
2084  if (answer == MBOX_CLICKED_QUIT) {
2085  WRITE_DEBUG("Closed FXMessageBox 'Save shapes before exit' with 'Quit'");
2086  return true;
2087  } else if (answer == MBOX_CLICKED_SAVE) {
2088  // write warning if netedit is running in testing mode
2089  WRITE_DEBUG("Closed FXMessageBox 'Save shapes before exit' with 'Yes'");
2090  if (onCmdSaveShapes(0, 0, 0) == 1) {
2091  // shapes sucesfully saved
2092  return true;
2093  } else {
2094  // error saving shapes, abort saving
2095  return false;
2096  }
2097  } else {
2098  // write warning if netedit is running in testing mode
2099  if (answer == 2) {
2100  WRITE_DEBUG("Closed FXMessageBox 'Save shapes before exit' with 'No'");
2101  } else if (answer == 4) {
2102  WRITE_DEBUG("Closed FXMessageBox 'Save shapes before exit' with 'ESC'");
2103  }
2104  // abort saving
2105  return false;
2106  }
2107  } else {
2108  // nothing to save, then return true
2109  return true;
2110  }
2111 }
2112 
2113 
2114 void
2116  GNEViewNet* view = getView();
2117  if (view != 0) {
2118  view->updateControls();
2119  }
2120 }
2121 
2122 
2123 long
2124 GNEApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* eventData) {
2125  const long handled = FXMainWindow::onKeyPress(o, sel, eventData);
2126  if (handled == 0 && myMDIClient->numChildren() > 0) {
2127  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
2128  if (w != 0) {
2129  w->onKeyPress(0, sel, eventData);
2130  }
2131  }
2132  return 0;
2133 }
2134 
2135 
2136 long
2137 GNEApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* eventData) {
2138  const long handled = FXMainWindow::onKeyRelease(o, sel, eventData);
2139  if (handled == 0 && myMDIClient->numChildren() > 0) {
2140  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
2141  if (w != 0) {
2142  w->onKeyRelease(0, sel, eventData);
2143  }
2144  }
2145  return 0;
2146 }
2147 
2148 // ---------------------------------------------------------------------------
2149 // GNEApplicationWindow::GNEShapeHandler - methods
2150 // ---------------------------------------------------------------------------
2151 
2153  ShapeHandler(file, *net),
2154  myNet(net) {}
2155 
2156 
2158 
2159 
2160 Position
2161 GNEApplicationWindow::GNEShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat) {
2162  std::string edgeID;
2163  int laneIndex;
2164  NBHelpers::interpretLaneID(laneID, edgeID, laneIndex);
2165  NBEdge* edge = myNet->retrieveEdge(edgeID)->getNBEdge();
2166  if (edge == 0 || laneIndex < 0 || edge->getNumLanes() <= laneIndex) {
2167  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
2168  return Position::INVALID;
2169  }
2170  if (lanePos < 0) {
2171  lanePos = edge->getLength() + lanePos;
2172  }
2173  if (lanePos < 0 || lanePos > edge->getLength()) {
2174  WRITE_WARNING("lane position " + toString(lanePos) + " for poi '" + poiID + "' is not valid.");
2175  }
2176  return edge->getLanes()[laneIndex].shape.positionAtOffset(lanePos, -lanePosLat);
2177 }
2178 
2179 /****************************************************************************/
Locate junction - button.
Definition: GUIAppEnum.h:172
Main window-ID.
Definition: GUIAppEnum.h:46
std::vector< FXMainWindow * > myTrackerWindows
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
std::string myConfigPattern
Input file pattern.
FXMenuCheck * getMenuCheckShowGrid() const
get grid button
void enableSaveTLSProgramsMenu()
enable save TLS Programs
FXLabel * myGeoCoordinate
clean junctions without edges
Definition: GUIAppEnum.h:465
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:483
FXMenuBar * myMenuBar
The application menu bar.
FXMenuCommand * mySaveShapesMenuCommand
FXMenuCommand for enable or disable save shapes.
GUISUMOAbstractView * getView() const
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
SUMOTime getCurrentSimTime() const
get current simulation time (pure virtual but we don&#39;t need it)
GUICompleteSchemeStorage gSchemeStorage
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NWFrame.cpp:125
void pop()
Definition: MFXEventQue.h:46
void enableSaveAdditionalsMenu()
enable save additionals
long onKeyPress(FXObject *o, FXSelector sel, void *data)
Called when user press a key.
send when a warning occured
Definition: GUIEvent.h:46
static std::string clipped
Definition: GUIUserIO.h:57
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:907
long long int SUMOTime
Definition: SUMOTime.h:36
long onCmdNewNetwork(FXObject *, FXSelector, void *)
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
void setAdditionalsFile(const std::string &additionalsFile)
set additionals file
static void resetFont()
to be called when the font context is invalidated
Definition: GLHelper.cpp:590
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NBFrame.cpp:524
long onCmdToogleGrid(FXObject *, FXSelector, void *)
called if the user press key combination Ctrl + G to toogle grid
void abortOperation(bool clearSelection=true)
abort current edition operation
bool parseTLSPrograms(const std::string &file)
parse TLS Programs from a file
hot key <F12> focus upper element of current frame
Definition: GUIAppEnum.h:417
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
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 FXGLCanvas * getBuildGLCanvas() const
FXRecentFiles myRecentConfigs
List of recent config files.
long onCmdSaveAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals is executed
FXMenuPane * myFileMenuAdditionals
bool empty()
Definition: MFXEventQue.h:65
mode for editing tls
Definition: GUIAppEnum.h:491
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:47
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
mode for deleting things
Definition: GUIAppEnum.h:483
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:308
Load additional file with additional elements.
Definition: GUIAppEnum.h:74
void hotkeyFocusFrame()
handle focus frame keypress
open foreign network
Definition: GUIAppEnum.h:433
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:59
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
called when the command/FXCall clear message windows is executed
Locate addtional structure - button.
Definition: GUIAppEnum.h:182
void loadConfigOrNet(const std::string &file, bool isNet, bool useStartupOptions, bool newNet=false)
begins the loading of a netconvert configuration or a a network
virtual void create()
Creates the main window (required by FOX)
long onCmdJoinJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->join junctions
bool hadDependentBuild
check if had dependent build
Open configuration - ID.
Definition: GUIAppEnum.h:66
mode for connecting lanes
Definition: GUIAppEnum.h:489
mode for inspecting object attributes
Definition: GUIAppEnum.h:485
GNEViewParent * getViewParent() const
get the net object
double y() const
Returns the y-position.
Definition: Position.h:61
long onCmdSaveTLSPrograms(FXObject *, FXSelector, void *)
called when the command/FXCall save TLSPrograms is executed
The representation of a single edge during network building.
Definition: NBEdge.h:65
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.
long onCmdOpenSUMOGUI(FXObject *sender, FXSelector sel, void *ptr)
called if the user hints ctrl + T
void registerMsgHandlers()
register message handlers
long onCmdSetMode(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits an edit-mode hotkey
save network as plain XML
Definition: GUIAppEnum.h:439
void handleEvent_NetworkLoaded(GUIEvent *e)
handle event of type Network loaded
open options menu
Definition: GUIAppEnum.h:471
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:277
bool continueWithUnsavedAdditionalChanges()
warns about unsaved changes in additionals and gives the user the option to abort ...
double x() const
Returns the x-position.
Definition: Position.h:56
send when a debug occured
Definition: GUIEvent.h:52
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:280
mode for editing additional
Definition: GUIAppEnum.h:493
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:305
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
Called when user releases a key.
Editor for the list of chosen objects.
bool continueWithUnsavedChanges()
warns about unsaved changes and gives the user the option to abort
FXGLVisual * myGLVisual
The gl-visual used.
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
Called on menu Edit->Visualization.
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:80
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:78
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:584
hot key <DEL> delete selections or elements
Definition: GUIAppEnum.h:419
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:1545
FXString gCurrentFolder
The folder used as last.
long onCmdSaveShapes(FXObject *, FXSelector, void *)
called when the command/FXCall save shapes is executed
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of additionals of the net.
Definition: GNENet.cpp:1820
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
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
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 unregisterMsgHandlers()
unregister message handlers
void set(double x, double y)
set positions x and y
Definition: Position.h:86
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:113
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:84
std::string myTLSProgramsFile
filename for load/save TLS Programs
long onCmdEditChosen(FXObject *, FXSelector, void *)
called when the command/FXCall edit chosen is executed
void updateControls()
update control contents after undo/redo or recompute
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
long onUpdReload(FXObject *, FXSelector, void *)
called when the update/FXCall reload is executed
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:242
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:70
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:70
void saveTLSPrograms(const std::string &filename)
save TLS Programs elements of the network
Definition: GNENet.cpp:2111
Loads a file previously loaded.
Definition: GUIAppEnum.h:78
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for GNE_MODE_TLS
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
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:92
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
called when the command/FXCall clipboard request is executed
The XML-Handler for network loading.
Definition: ShapeHandler.h:49
static void setDefaultOptions(OptionsCont &oc)
sets required options for proper functioning
void disableSaveAdditionalsMenu()
disable save additionals
FXHorizontalFrame * myCartesianFrame
FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[]
long onCmdSaveTLSProgramsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save TLSPrograms as is executed
long onCmdSaveAdditionalsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals as is executed
const std::string & getMsg() const
Returns the message.
join selected junctions
Definition: GUIAppEnum.h:467
long onCmdEditViewport(FXObject *, FXSelector, void *)
Called on menu Edit->Viewport.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
std::vector< FXMDIChild * > mySubWindows
long onCmdOptions(FXObject *, FXSelector, void *)
called if the user selects Processing->Configure Options
static void close()
close GUITextureSubSys
mode for editing connection prohibitions
Definition: GUIAppEnum.h:499
Locate polygons - button.
Definition: GUIAppEnum.h:186
GNEApplicationWindow()
FOX needs this for static members.
FXSplitter * myMainSplitter
The splitter that divides the main window into view and the log window.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
static unsigned long runHiddenCommand(const std::string &cmd)
run a shell command without popping up any windows (particuarly on win32)
Definition: SysUtils.cpp:64
help button
Definition: GUIAppEnum.h:400
save joined junctions
Definition: GUIAppEnum.h:441
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
FXGLCanvas * getBuildGLCanvas() const
get build OpenGL Canvas
int myViewNumber
The current view number.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
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:85
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:1405
virtual void fillMenuBar()
Builds the menu bar.
FXMenuCommand * mySaveShapesMenuCommandAs
FXMenuCommand for enable or disable save shapes.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool continueWithUnsavedShapeChanges()
warns about unsaved changes in shapes and gives the user the option to abort
Open viewport editor - button.
Definition: GUIAppEnum.h:188
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:862
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
called when the command/FXCall open configuration is executed
Locate edge - button.
Definition: GUIAppEnum.h:174
static bool checkOptions()
checks shared options and sets StdDefs
std::string mySettingsFile
the name of the settings file to load
mode for creating polygons
Definition: GUIAppEnum.h:497
long onCmdOpenAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall open additionals is executed
double getTrackerInterval() const
get current tracker interval (pure virtual but we don&#39;t need it)
#define VERSION_STRING
Definition: version.h:1
virtual void setViewportFromToRot(const Position &lookFrom, const Position &lookAt, double rotation)
applies the given viewport settings
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NIFrame.cpp:320
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:249
create new empty newtork
Definition: GUIAppEnum.h:431
long onCmdLocate(FXObject *, FXSelector, void *)
called when the command/FXCall locate is executed
Clear simulation output.
Definition: GUIAppEnum.h:155
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:130
FXCursor * getDefaultCursor()
get default cursor
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
mode for editing crossing
Definition: GUIAppEnum.h:495
long onCmdCleanJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->clean junctions
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
GNEShapeHandler(const std::string &file, GNENet *net)
Constructor.
Open view editor - button.
Definition: GUIAppEnum.h:190
hot key <ENTER> accept current operation
Definition: GUIAppEnum.h:421
compute junctions with volatile options
Definition: GUIAppEnum.h:463
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.
long onCmdOpenShapes(FXObject *, FXSelector, void *)
called when the command/FXCall open shapes is executed
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:248
void unlock()
release mutex lock
Definition: MFXMutex.cpp:87
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:274
bool myViewportFromRegistry
whether loading viewport from registry
FXMenuCommand * mySaveAdditionalsMenuCommandAs
FXMenuCommand for enable or disable save additionals As.
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.
void setTLSProgramsFile(const std::string &TLSProgramsFile)
set TLS Programs file
About SUMO - ID.
Definition: GUIAppEnum.h:82
Locate TLS - button.
Definition: GUIAppEnum.h:180
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.
send when a gldebug occured
Definition: GUIEvent.h:55
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
mode for adding edges
Definition: GUIAppEnum.h:479
Main window closes.
Definition: GUIAppEnum.h:48
Open network - ID.
Definition: GUIAppEnum.h:68
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:140
The loading thread.
Definition: GUIAppEnum.h:114
void unSet(const std::string &name, bool failOnNonExistant=true) const
Marks the option as unset.
long onCmdDel(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits del
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
FXRecentFiles myRecentNets
List of recent nets.
void loadOptionOnStartup()
load net on startup
static void interpretLaneID(const std::string &lane_id, std::string &edge_id, int &index)
parses edge-id and index from lane-id
Definition: NBHelpers.cpp:121
send when a message occured
Definition: GUIEvent.h:43
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition: GNENet.cpp:1597
static void close()
close GUIIconSubSys
FXToolBarShell * myMenuBarDrag
void disableSaveShapesMenu()
disable save shapes
mode for moving things
Definition: GUIAppEnum.h:481
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:844
FXHorizontalFrame * myGeoFrame
FXDockSite * myTopDock
A storage for options typed value containers)
Definition: OptionsCont.h:92
FXMenuCommand * mySaveAdditionalsMenuCommand
FXMenuCommand for enable or disable save additionals.
long onCmdClose(FXObject *, FXSelector, void *)
called when the command/FXCall close is executed
long onCmdOpenTLSPrograms(FXObject *, FXSelector, void *)
called when the command/FXCall open additionals 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:1286
int getNumberOfShapes() const
get number of shapes
Definition: GNENet.cpp:2095
send when a error occured
Definition: GUIEvent.h:49
std::string myAdditionalsFile
filename for load/save additionals
void lock()
lock mutex
Definition: MFXMutex.cpp:77
FXMDIClient * myMDIClient
The multi view panel.
send when a simulation has been loaded
Definition: GUIEvent.h:37
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:880
FXMenuCommand * mySaveTLSProgramsMenuCommand
FXMenuCommand for enable or disable save additionals.
#define GUIDesignHorizontalFrameStatusBar
Horizontal frame used in status bar.
Definition: GUIDesigns.h:221
Open in SUMO GUI.
Definition: GUIAppEnum.h:132
long onCmdAbort(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits esc
Load additional file with additional elements.
Definition: GUIAppEnum.h:72
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
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:76
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:85
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:62
GNENet * myNet
we are responsible for the net
#define GUIDesignToolBarShell3
Definition: GUIDesigns.h:288
hot key <ESC> abort current edit operation
Definition: GUIAppEnum.h:415
void dependentBuild()
build dependent
void clear()
Clears the window.
void showViewschemeEditor()
show viewsscheme editor
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:586
mode for selecting objects
Definition: GUIAppEnum.h:487
Locate poi - button.
Definition: GUIAppEnum.h:184
long onCmdComputeJunctionsVolatile(FXObject *, FXSelector, void *)
called if the user selects Processing->compute junctions with volatile options
void storeWindowSizeAndPos()
record window position and size in registry
void hotkeyDel()
handle del keypress
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:243
static void initTextures(FXApp *a)
Initiate GUITextureSubSys for textures.
GUISelectedStorage gSelected
A global holder of selected objects.
hot key <Ctrl + G> for toogle grid
Definition: GUIAppEnum.h:423
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.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:1865
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:872
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
FXMenuPane * myFileMenu
the submenus
bool isNetSaved() const
return if net has to be saved
Definition: GNENet.cpp:856
long onKeyPress(FXObject *o, FXSelector sel, void *data)
called when a key is pressed
long onCmdShowGrid(FXObject *, FXSelector, void *)
toogle show grid
long onUpdSaveNetwork(FXObject *, FXSelector, void *)
called when the update/FXCall save network is executed
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:274
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1737
void saveShapes(const std::string &filename)
save shapes elements of the network
Definition: GNENet.cpp:2074
void setShapesFile(const std::string &shapesFile)
set shapes file
Close simulation - ID.
Definition: GUIAppEnum.h:80