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