Eclipse 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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Functions from main window of NETEDIT
19 /****************************************************************************/
20 #include <netbuild/NBFrame.h>
21 #include <netbuild/NBNetBuilder.h>
34 #include <netimport/NIFrame.h>
36 #include <netimport/NITypeLoader.h>
37 #include <netwrite/NWFrame.h>
41 #include <utils/gui/div/GLHelper.h>
56 #include <utils/xml/XMLSubSys.h>
57 
58 #include "GNEApplicationWindow.h"
59 #include "GNEEvent_NetworkLoaded.h"
60 #include "GNELoadThread.h"
61 #include "GNENet.h"
62 #include "GNEViewNet.h"
63 #include "GNEUndoList.h"
64 #include "GNEViewParent.h"
65 
66 #ifdef HAVE_VERSION_H
67 #include <version.h>
68 #endif
69 
70 // ===========================================================================
71 // FOX-declarations
72 // ===========================================================================
73 
74 FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[] = {
75  // quit calls
79  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GNEApplicationWindow::onCmdQuit),
80 
81  // toolbar file
85  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GNEApplicationWindow::onUpdOpen),
87  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GNEApplicationWindow::onUpdOpen),
91  FXMAPFUNC(SEL_UPDATE, MID_RECENTFILE, GNEApplicationWindow::onUpdOpen),
94  // network
103  // TLS
108  // edge types
115  // additionals
122  // demand elements
129  // data elements
136  // other
141 
142  // Toolbar supermode
146 
147  // Toolbar edit
179  FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_CTRL_X_CUT, GNEApplicationWindow::onCmdCut),
182 
183  // Toolbar processing
195 
196  // Toolbar locate
197  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GNEApplicationWindow::onCmdLocate),
199  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GNEApplicationWindow::onCmdLocate),
201  FXMAPFUNC(SEL_COMMAND, MID_LOCATEVEHICLE, GNEApplicationWindow::onCmdLocate),
203  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPERSON, GNEApplicationWindow::onCmdLocate),
205  FXMAPFUNC(SEL_COMMAND, MID_LOCATEROUTE, GNEApplicationWindow::onCmdLocate),
207  FXMAPFUNC(SEL_COMMAND, MID_LOCATESTOP, GNEApplicationWindow::onCmdLocate),
209  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GNEApplicationWindow::onCmdLocate),
211  FXMAPFUNC(SEL_COMMAND, MID_LOCATEADD, GNEApplicationWindow::onCmdLocate),
213  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOI, GNEApplicationWindow::onCmdLocate),
215  FXMAPFUNC(SEL_COMMAND, MID_LOCATEPOLY, GNEApplicationWindow::onCmdLocate),
217 
218  // toolbar windows
220 
221  // toolbar help
224 
225  // alt + <number>
246 
247  // key events
248  FXMAPFUNC(SEL_KEYPRESS, 0, GNEApplicationWindow::onKeyPress),
249  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEApplicationWindow::onKeyRelease),
250  FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_ESC, GNEApplicationWindow::onCmdAbort),
251  FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_DEL, GNEApplicationWindow::onCmdDel),
252  FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_ENTER, GNEApplicationWindow::onCmdEnter),
254 
255  // threads events
258 
259  // Edge template functions
263 
264  // Other
265  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNEApplicationWindow::onClipboardRequest),
271 };
272 
273 // Object implementation
274 FXIMPLEMENT(GNEApplicationWindow, FXMainWindow, GNEApplicationWindowMap, ARRAYNUMBER(GNEApplicationWindowMap))
275 
276 
277 // ===========================================================================
278 // GNEApplicationWindow method definitions
279 // ===========================================================================
280 
281 GNEApplicationWindow::GNEApplicationWindow(FXApp* a, const std::string& configPattern) :
282  GUIMainWindow(a),
283  myLoadThread(nullptr),
284  myAmLoading(false),
285  myFileMenu(nullptr),
286  myFileMenuTLS(nullptr),
287  myFileMenuEdgeTypes(nullptr),
288  myFileMenuAdditionals(nullptr),
289  myFileMenuDemandElements(nullptr),
290  myFileMenuDataElements(nullptr),
291  myEditMenu(nullptr),
292  myProcessingMenu(nullptr),
293  myLocatorMenu(nullptr),
294  myWindowsMenu(nullptr),
295  myHelpMenu(nullptr),
296  myMessageWindow(nullptr),
297  myMainSplitter(nullptr),
298  hadDependentBuild(false),
299  myNet(nullptr),
300  myUndoList(new GNEUndoList(this)),
301  myConfigPattern(configPattern),
302  myToolbarsGrip(this),
303  myMenuBarFile(this),
304  myFileMenuCommands(this),
305  myEditMenuCommands(this),
306  myProcessingMenuCommands(this),
307  myLocateMenuCommands(this),
308  myWindowsMenuCommands(this),
309  mySupermodeCommands(this),
310  myViewNet(nullptr),
311  myTitlePrefix("NETEDIT " VERSION_STRING),
312  myMDIMenu(nullptr)
313 
314 {
315  // init icons
317  // init Textures
319  // init cursors
321 }
322 
323 
324 void
326  // do this not twice
327  if (hadDependentBuild) {
328  WRITE_ERROR("DEBUG: GNEApplicationWindow::dependentBuild called twice");
329  return;
330  }
331  hadDependentBuild = true;
332  setTarget(this);
333  setSelector(MID_WINDOW);
334  // build toolbar menu
336  // build the thread - io
338  // build the status bar
339  myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
340  {
341  myGeoFrame =
342  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
343  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in netconvert)", nullptr, LAYOUT_CENTER_Y);
345  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
346  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", nullptr, LAYOUT_CENTER_Y);
347  }
348  // make the window a mdi-window
349  myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
350  myMDIClient = new FXMDIClient(myMainSplitter, GUIDesignSplitterMDI);
351  myMDIMenu = new FXMDIMenu(this, myMDIClient);
352  // build the message window
354  myMainSplitter->setSplit(1, 65);
355  // fill menu and tool bar
356  fillMenuBar();
357  // build additional threads
358  myLoadThread = new GNELoadThread(getApp(), this, myEvents, myLoadThreadEvent);
359  // set the status bar
360  myStatusbar->getStatusLine()->setText("Ready.");
361  // set the caption
362  setTitle(myTitlePrefix);
363  // set Netedit ICON
366  // build NETEDIT Accelerators (hotkeys)
368 }
369 
370 
371 void
374  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
375  FXMainWindow::create();
376  myFileMenu->create();
377  myEditMenu->create();
378  myFileMenuTLS->create();
379  myFileMenuEdgeTypes->create();
380  myFileMenuAdditionals->create();
381  myFileMenuDemandElements->create();
382  myFileMenuDataElements->create();
383  //mySettingsMenu->create();
384  myWindowsMenu->create();
385  myHelpMenu->create();
386 
387  FXint textWidth = getApp()->getNormalFont()->getTextWidth("8", 1) * 22;
388  myCartesianFrame->setWidth(textWidth);
389  myGeoFrame->setWidth(textWidth);
390 
391  show(PLACEMENT_DEFAULT);
392  if (!OptionsCont::getOptions().isSet("window-size")) {
393  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
394  maximize();
395  }
396  }
397 
398 }
399 
400 
402  closeAllWindows();
403  // Close icons
405  // Close gifs (Textures)
407  // delete visuals
408  delete myGLVisual;
409  // must delete menus to avoid segfault on removing accelerators
410  // (http://www.fox-toolkit.net/faq#TOC-What-happens-when-the-application-s)
411  delete myFileMenuTLS;
412  delete myFileMenuEdgeTypes;
413  delete myFileMenuAdditionals;
415  delete myFileMenuDataElements;
416  delete myFileMenu;
417  delete myEditMenu;
418  delete myLocatorMenu;
419  delete myProcessingMenu;
420  delete myWindowsMenu;
421  delete myHelpMenu;
422  // Delete load thread
423  delete myLoadThread;
424  // drop all events
425  while (!myEvents.empty()) {
426  // get the next event
427  GUIEvent* e = myEvents.top();
428  myEvents.pop();
429  delete e;
430  }
431  // delte undo list
432  delete myUndoList;
433 }
434 
435 
436 long
437 GNEApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
438  if (continueWithUnsavedChanges("quit")) {
440  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
441  if (isMaximized()) {
442  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 1);
443  } else {
444  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 0);
445  }
446  getApp()->exit(0);
447  }
448  return 1;
449 }
450 
451 
452 long
453 GNEApplicationWindow::onCmdEditChosen(FXObject*, FXSelector, void*) {
454  GUIDialog_GLChosenEditor* chooser =
456  chooser->create();
457  chooser->show();
458  return 1;
459 }
460 
461 
462 long
463 GNEApplicationWindow::onCmdNewNetwork(FXObject*, FXSelector, void*) {
464  // first check that current edited Net can be closed (und therefore the undo-list cleared, see #5753)
465  if (myViewNet && !onCmdClose(0, 0, 0)) {
466  return 1;
467  } else {
471  loadConfigOrNet("", true, false, true, true);
472  return 1;
473  }
474 }
475 
476 
477 long
478 GNEApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
479  // first check that current edited Net can be closed (und therefore the undo-list cleared, see #5753)
480  if (myViewNet && !onCmdClose(0, 0, 0)) {
481  return 1;
482  } else {
483  // get the new file name
484  FXFileDialog opendialog(this, "Open Netconvert Configuration");
485  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_CONFIG));
486  opendialog.setSelectMode(SELECTFILE_EXISTING);
487  opendialog.setPatternList(myConfigPattern.c_str());
488  if (gCurrentFolder.length() != 0) {
489  opendialog.setDirectory(gCurrentFolder);
490  }
491  if (opendialog.execute()) {
492  gCurrentFolder = opendialog.getDirectory();
493  std::string file = opendialog.getFilename().text();
494  loadConfigOrNet(file, false);
495  // add it into recent configs
496  myMenuBarFile.myRecentConfigs.appendFile(file.c_str());
497  }
498  return 1;
499  }
500 }
501 
502 
503 long
504 GNEApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
505  // first check that current edited Net can be closed (und therefore the undo-list cleared, see #5753)
506  if (myViewNet && !onCmdClose(0, 0, 0)) {
507  return 1;
508  } else {
509  // get the new file name
510  FXFileDialog opendialog(this, "Open Network");
511  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_NET));
512  opendialog.setSelectMode(SELECTFILE_EXISTING);
513  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
514  if (gCurrentFolder.length() != 0) {
515  opendialog.setDirectory(gCurrentFolder);
516  }
517  if (opendialog.execute()) {
518  gCurrentFolder = opendialog.getDirectory();
519  std::string file = opendialog.getFilename().text();
520  loadConfigOrNet(file, true);
521  // add it into recent nets
522  myMenuBarFile.myRecentNets.appendFile(file.c_str());
523  // when a net is loaded, save additionals and TLSPrograms are disabled
526  }
527  return 1;
528  }
529 }
530 
531 
532 long
533 GNEApplicationWindow::onCmdOpenForeign(FXObject*, FXSelector, void*) {
534  // first check that current edited Net can be closed (und therefore the undo-list cleared, see #5753)
535  if (myViewNet && !onCmdClose(0, 0, 0)) {
536  return 1;
537  } else {
538  // get the new file name
539  FXFileDialog opendialog(this, "Import Foreign Network");
540  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN_NET));
541  opendialog.setSelectMode(SELECTFILE_EXISTING);
542  FXString osmPattern("OSM net (*.osm.xml,*.osm)");
543  opendialog.setPatternText(0, osmPattern);
544  if (gCurrentFolder.length() != 0) {
545  opendialog.setDirectory(gCurrentFolder);
546  }
547  if (opendialog.execute()) {
548  gCurrentFolder = opendialog.getDirectory();
549  std::string file = opendialog.getFilename().text();
550 
553  if (osmPattern.contains(opendialog.getPattern())) {
554  // recommended osm options
555  // https://sumo.dlr.de/wiki/Networks/Import/OpenStreetMap#Recommended_NETCONVERT_Options
556  oc.set("osm-files", file);
557  oc.set("geometry.remove", "true");
558  oc.set("ramps.guess", "true");
559  oc.set("junctions.join", "true");
560  oc.set("tls.guess-signals", "true");
561  oc.set("tls.discard-simple", "true");
562  } else {
563  throw ProcessError("Attempted to import unknown file format '" + file + "'.");
564  }
565 
566  GUIDialog_Options* wizard =
567  new GUIDialog_Options(this, "Select Import Options", getWidth(), getHeight());
568 
569  if (wizard->execute()) {
570  NIFrame::checkOptions(); // needed to set projection parameters
571  loadConfigOrNet("", false, false, false);
572  }
573  }
574  return 1;
575  }
576 }
577 
578 
579 long
580 GNEApplicationWindow::onCmdOpenAdditionals(FXObject*, FXSelector, void*) {
581  // write debug information
582  WRITE_DEBUG("Open additional dialog");
583  // get the Additional file name
584  FXFileDialog opendialog(this, "Open Additionals file");
585  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::MODEADDITIONAL));
586  opendialog.setSelectMode(SELECTFILE_EXISTING);
587  opendialog.setPatternList("Additional files (*.add.xml)\nAll files (*)");
588  if (gCurrentFolder.length() != 0) {
589  opendialog.setDirectory(gCurrentFolder);
590  }
591  if (opendialog.execute()) {
592  // close additional dialog
593  WRITE_DEBUG("Close additional dialog");
594  // udpate current folder
595  gCurrentFolder = opendialog.getDirectory();
596  std::string file = opendialog.getFilename().text();
597  // disable validation for additionals
598  XMLSubSys::setValidation("never", "auto", "auto");
599  // Create additional handler
600  GNEAdditionalHandler additionalHandler(file, myNet);
601  // begin undoList operation
602  myUndoList->p_begin("Loading additionals from '" + file + "'");
603  // Run parser for additionals
604  if (!XMLSubSys::runParser(additionalHandler, file, false)) {
605  WRITE_ERROR("Loading of " + file + " failed.");
606  }
607  // end undoList operation and update view
608  myUndoList->p_end();
609  update();
610  // restore validation for additionals
611  XMLSubSys::setValidation("auto", "auto", "auto");
612  } else {
613  // write debug information
614  WRITE_DEBUG("Cancel additional dialog");
615  }
616  return 1;
617 }
618 
619 
620 long
621 GNEApplicationWindow::onCmdOpenTLSPrograms(FXObject*, FXSelector, void*) {
622  // write debug information
623  WRITE_DEBUG("Open TLSProgram dialog");
624  // get the shape file name
625  FXFileDialog opendialog(this, "Open TLSPrograms file");
626  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::MODETLS));
627  opendialog.setSelectMode(SELECTFILE_EXISTING);
628  opendialog.setPatternList("TLSProgram files (*.xml)\nAll files (*)");
629  if (gCurrentFolder.length() != 0) {
630  opendialog.setDirectory(gCurrentFolder);
631  }
632  if (opendialog.execute()) {
633  // close additional dialog
634  WRITE_DEBUG("Close TLSProgram dialog");
635  gCurrentFolder = opendialog.getDirectory();
636  std::string file = opendialog.getFilename().text();
637  // Run parser
638  myUndoList->p_begin("Loading TLS Programs from '" + file + "'");
639  myNet->computeNetwork(this);
640  if (myNet->getViewNet()->getViewParent()->getTLSEditorFrame()->parseTLSPrograms(file) == false) {
641  // Abort undo/redo
642  myUndoList->abort();
643  } else {
644  // commit undo/redo operation
645  myUndoList->p_end();
646  update();
647  }
648  } else {
649  // write debug information
650  WRITE_DEBUG("Cancel TLSProgram dialog");
651  }
652  return 1;
653 }
654 
655 
656 long
657 GNEApplicationWindow::onCmdOpenEdgeTypes(FXObject*, FXSelector, void*) {
658  // open dialog
659  FXFileDialog opendialog(this, "Load edgeType file");
660  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::MODECREATEEDGE));
661  opendialog.setSelectMode(SELECTFILE_EXISTING);
662  opendialog.setPatternList("*.xml");
663  if (gCurrentFolder.length() != 0) {
664  opendialog.setDirectory(gCurrentFolder);
665  }
666  if (opendialog.execute()) {
667  // declare type container
668  NBTypeCont typeContainerAux;
669  // declare type handler
670  NIXMLTypesHandler* handler = new NIXMLTypesHandler(typeContainerAux);
671  // load edge types
672  NITypeLoader::load(handler, {opendialog.getFilename().text()}, "types");
673  // write information
674  WRITE_MESSAGE("Loaded " + toString(typeContainerAux.size()) + " edge types");
675  // now create GNETypes based on typeContainerAux
676  myViewNet->getUndoList()->p_begin("load edgeTypes");
677  // iterate over typeContainerAux
678  for (const auto &auxEdgeType : typeContainerAux) {
679  // create new edge type
680  GNEEdgeType* edgeType = new GNEEdgeType(myNet, auxEdgeType.first, auxEdgeType.second);
681  // add it using undoList
682  myViewNet->getUndoList()->add(new GNEChange_EdgeType(edgeType, true), true);
683  // iterate over lanes auxType
684  for (const auto &auxLaneType : auxEdgeType.second->laneTypeDefinitions) {
685  // also create a new laneType
686  GNELaneType* laneType = new GNELaneType(edgeType, auxLaneType);
687  // add it using undoList
688  myViewNet->getUndoList()->add(new GNEChange_LaneType(laneType, (int)edgeType->getLaneTypes().size(), true), true);
689  }
690  }
691  // end undo list
693  // refresh edge type selector
695  }
696  return 0;
697 }
698 
699 
700 long
701 GNEApplicationWindow::onCmdOpenDemandElements(FXObject*, FXSelector, void*) {
702  // write debug information
703  WRITE_DEBUG("Open demand element dialog");
704  // get the demand element file name
705  FXFileDialog opendialog(this, "Open demand element file");
707  opendialog.setSelectMode(SELECTFILE_EXISTING);
708  opendialog.setPatternList("Demand element files (*.rou.xml)\nAll files (*)");
709  if (gCurrentFolder.length() != 0) {
710  opendialog.setDirectory(gCurrentFolder);
711  }
712  if (opendialog.execute()) {
713  // close additional dialog
714  WRITE_DEBUG("Close demand element dialog");
715  // udpate current folder
716  gCurrentFolder = opendialog.getDirectory();
717  std::string file = opendialog.getFilename().text();
718  // disable validation for additionals
719  XMLSubSys::setValidation("never", "auto", "auto");
720  // Create additional handler
721  GNERouteHandler demandHandler(file, myNet);
722  // begin undoList operation
723  myUndoList->p_begin("Loading demand elements from '" + file + "'");
724  // Run parser for additionals
725  if (!XMLSubSys::runParser(demandHandler, file, false)) {
726  WRITE_ERROR("Loading of " + file + " failed.");
727  }
728  // end undoList operation and update view
729  myUndoList->p_end();
730  update();
731  // restore validation for demand
732  XMLSubSys::setValidation("auto", "auto", "auto");
733  } else {
734  // write debug information
735  WRITE_DEBUG("Cancel demand element dialog");
736  }
737  return 1;
738 }
739 
740 
741 long
742 GNEApplicationWindow::onCmdOpenDataElements(FXObject*, FXSelector, void*) {
743  // write debug information
744  WRITE_DEBUG("Open data element dialog");
745  // get the data element file name
746  FXFileDialog opendialog(this, "Open data element file");
747  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::SUPERMODEDATA));
748  opendialog.setSelectMode(SELECTFILE_EXISTING);
749  opendialog.setPatternList("Data element files (*.xml)\nAll files (*)");
750  if (gCurrentFolder.length() != 0) {
751  opendialog.setDirectory(gCurrentFolder);
752  }
753  if (opendialog.execute()) {
754  // close additional dialog
755  WRITE_DEBUG("Close data element dialog");
756  // udpate current folder
757  gCurrentFolder = opendialog.getDirectory();
758  std::string file = opendialog.getFilename().text();
759  // disable interval bar update
761  // disable update data
763  // disable validation for additionals
764  XMLSubSys::setValidation("never", "auto", "auto");
765  // Create additional handler
766  GNEDataHandler dataHandler(file, myNet);
767  // begin undoList operation
768  myUndoList->p_begin("Loading data elements from '" + file + "'");
769  // Run parser for additionals
770  if (!XMLSubSys::runParser(dataHandler, file, false)) {
771  WRITE_ERROR("Loading of " + file + " failed.");
772  }
773  // restore validation for data
774  XMLSubSys::setValidation("auto", "auto", "auto");
775  // end undoList operation and update view
776  myUndoList->p_end();
777  // enable update data
779  // enable interval bar update
781  // update
782  update();
783  } else {
784  // write debug information
785  WRITE_DEBUG("Cancel data element dialog");
786  }
787  return 1;
788 }
789 
790 
791 long
792 GNEApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* fileData) {
793  // first check that current edited Net can be closed (und therefore the undo-list cleared, see #5753)
794  if (myViewNet && !onCmdClose(0, 0, 0)) {
795  return 1;
796  } else if (myAmLoading) {
797  myStatusbar->getStatusLine()->setText("Already loading!");
798  return 1;
799  } else {
800  std::string file((const char*)fileData);
801  loadConfigOrNet(file, sender == &myMenuBarFile.myRecentNets);
802  return 1;
803  }
804 }
805 
806 
807 long
808 GNEApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
809  // first check that current edited Net can be closed (und therefore the undo-list cleared, see #5753)
810  if (myViewNet) {
811  // check if current network can be closed
812  if (continueWithUnsavedChanges("reload")) {
813  closeAllWindows();
814  // disable save additionals and TLS menu
817  // hide all Supermode, Network and demand commands
821  } else {
822  // abort reloading (because "cancel button" was pressed)
823  return 1;
824  }
825  }
826  // @note. If another network has been load during this session, it might not be desirable to set useStartupOptions
827  loadConfigOrNet(OptionsCont::getOptions().getString("sumo-net-file"), true, true);
828  return 1;
829 }
830 
831 
832 long
833 GNEApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
834  if (continueWithUnsavedChanges("close")) {
835  closeAllWindows();
836  // disable save additionals and TLS menu
839  // hide all Supermode, Network and demand commands
843  }
844  return 1;
845 }
846 
847 
848 long
849 GNEApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
850  if (myMDIClient->numChildren() > 0) {
851  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
852  if (w != nullptr) {
853  w->onCmdLocate(nullptr, sel, nullptr);
854  }
855  }
856  return 1;
857 }
858 
859 long
860 GNEApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void*) {
861  sender->handle(this, myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
862  return 1;
863 }
864 
865 
866 long
867 GNEApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
869  return 1;
870 }
871 
872 
873 long
875  // write warning if netedit is running in testing mode
876  WRITE_DEBUG("Toogle load additionals in sumo-gui");
877  return 1;
878 }
879 
880 
881 long
882 GNEApplicationWindow::onCmdLoadDemandInSUMOGUI(FXObject*, FXSelector, void*) {
883  // write warning if netedit is running in testing mode
884  WRITE_DEBUG("Toogle load demand in sumo-gui");
885  return 1;
886 }
887 
888 
889 long
890 GNEApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
891  // write warning if netedit is running in testing mode
892  WRITE_DEBUG("Opening about dialog");
893  // create and open about dialog
894  GNEAbout* about = new GNEAbout(this);
895  about->create();
896  about->show(PLACEMENT_OWNER);
897  // write warning if netedit is running in testing mode
898  WRITE_DEBUG("Closed about dialog");
899  return 1;
900 }
901 
902 
903 long GNEApplicationWindow::onClipboardRequest(FXObject*, FXSelector, void* ptr) {
904  FXEvent* event = (FXEvent*)ptr;
905  FXString string = GUIUserIO::clipped.c_str();
906  setDNDData(FROM_CLIPBOARD, event->target, string);
907  return 1;
908 }
909 
910 
911 long
912 GNEApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
913  eventOccurred();
914  return 1;
915 }
916 
917 
918 void
920  while (!myEvents.empty()) {
921  // get the next event
922  GUIEvent* e = myEvents.top();
923  myEvents.pop();
924  // process
925  switch (e->getOwnType()) {
928  break;
935  break;
936  default:
937  break;
938  }
939  delete e;
940  }
941 }
942 
943 
944 void
947  myAmLoading = false;
948  GNEEvent_NetworkLoaded* ec = static_cast<GNEEvent_NetworkLoaded*>(e);
949  // check whether the loading was successfull
950  if (ec->myNet == nullptr) {
951  // report failure
952  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
953  } else {
954  // set new Net
955  myNet = ec->myNet;
956  // report success
957  setStatusBarText("'" + ec->myFile + "' loaded.");
959  // build viewparent toolbar grips before creating view parent
961  // initialise NETEDIT View
962  GNEViewParent* viewParent = new GNEViewParent(myMDIClient, myMDIMenu, "NETEDIT VIEW", this, nullptr, myNet, myUndoList, nullptr, MDI_TRACKING, 10, 10, 300, 200);
963  // create it maximized
964  viewParent->maximize();
965  // mark it as Active child
966  myMDIClient->setActiveChild(viewParent);
967  // cast pointer myViewNet
968  myViewNet = dynamic_cast<GNEViewNet*>(viewParent->getView());
969  // set settings in view
970  if (viewParent->getView() && ec->mySettingsFile != "") {
971  GUISettingsHandler settings(ec->mySettingsFile, true, true);
972  std::string settingsName = settings.addSettings(viewParent->getView());
973  viewParent->getView()->addDecals(settings.getDecals());
974  settings.applyViewport(viewParent->getView());
975  settings.setSnapshots(viewParent->getView());
976  }
977  // set network name on the caption
978  setTitle(MFXUtils::getTitleText(myTitlePrefix, ec->myFile.c_str()));
979  // force supermode network
980  if (myViewNet) {
982  }
983  if (myViewNet && ec->myViewportFromRegistry) {
984  Position off;
985  off.set(getApp()->reg().readRealEntry("viewport", "x"), getApp()->reg().readRealEntry("viewport", "y"), getApp()->reg().readRealEntry("viewport", "z"));
986  Position p(off.x(), off.y(), 0);
987  myViewNet->setViewportFromToRot(off, p, 0);
988  }
989  }
990  getApp()->endWaitCursor();
992  // check if additionals/shapes has to be loaded at start
993  if (oc.isSet("additional-files") && !oc.getString("additional-files").empty() && myNet) {
994  // obtain vector of additional files
995  std::vector<std::string> additionalFiles = oc.getStringVector("additional-files");
996  // begin undolist
997  myUndoList->p_begin("Loading additionals and shapes from '" + toString(additionalFiles) + "'");
998  // iterate over every additional file
999  for (const auto& additionalFile : additionalFiles) {
1000  WRITE_MESSAGE("Loading additionals and shapes from '" + additionalFile + "'");
1001  GNEAdditionalHandler additionalHandler(additionalFile, myNet);
1002  // disable validation for additionals
1003  XMLSubSys::setValidation("never", "auto", "auto");
1004  // Run parser
1005  if (!XMLSubSys::runParser(additionalHandler, additionalFile, false)) {
1006  WRITE_ERROR("Loading of " + additionalFile + " failed.");
1007  }
1008  // disable validation for additionals
1009  XMLSubSys::setValidation("auto", "auto", "auto");
1010  }
1011  // end undo list
1012  myUndoList->p_end();
1013  // disable save additionals (because additionals were loaded through console)
1014  myNet->requireSaveAdditionals(false);
1015  }
1016  // check if demand elements has to be loaded at start
1017  if (oc.isSet("route-files") && !oc.getString("route-files").empty() && myNet) {
1018  // obtain vector of route files
1019  std::vector<std::string> demandElementsFiles = oc.getStringVector("route-files");
1020  // begin undolist
1021  myUndoList->p_begin("Loading demand elements from '" + toString(demandElementsFiles) + "'");
1022  // iterate over every route file
1023  for (const auto& demandElementsFile : demandElementsFiles) {
1024  WRITE_MESSAGE("Loading demand elements from '" + demandElementsFile + "'");
1025  GNERouteHandler routeHandler(demandElementsFile, myNet);
1026  // disable validation for demand elements
1027  XMLSubSys::setValidation("never", "auto", "auto");
1028  if (!XMLSubSys::runParser(routeHandler, demandElementsFile, false)) {
1029  WRITE_ERROR("Loading of " + demandElementsFile + " failed.");
1030  }
1031  // disable validation for demand elements
1032  XMLSubSys::setValidation("auto", "auto", "auto");
1033  }
1034  // end undo list
1035  myUndoList->p_end();
1036  // disable save demand elements (because demand elements were loaded through console)
1038  }
1039  // check if data elements has to be loaded at start
1040  if (oc.isSet("data-files") && !oc.getString("data-files").empty() && myNet) {
1041  // obtain vector of data files
1042  std::vector<std::string> dataElementsFiles = oc.getStringVector("data-files");
1043  // disable interval bar update
1045  // disable update data
1047  // begin undolist
1048  myUndoList->p_begin("Loading data elements from '" + toString(dataElementsFiles) + "'");
1049  // iterate over every data file
1050  for (const auto& dataElementsFile : dataElementsFiles) {
1051  WRITE_MESSAGE("Loading data elements from '" + dataElementsFile + "'");
1052  GNEDataHandler dataHandler(dataElementsFile, myNet);
1053  // disable validation for data elements
1054  XMLSubSys::setValidation("never", "auto", "auto");
1055  if (!XMLSubSys::runParser(dataHandler, dataElementsFile, false)) {
1056  WRITE_ERROR("Loading of " + dataElementsFile + " failed.");
1057  }
1058  // disable validation for data elements
1059  XMLSubSys::setValidation("auto", "auto", "auto");
1060  }
1061  // end undolist
1062  myUndoList->p_end();
1063  // disable save data elements (because data elements were loaded through console)
1065  // enable update data
1067  // enable interval bar update
1069  }
1070  // check if additionals output must be changed
1071  if (oc.isSet("additionals-output")) {
1072  // overwrite "additional-files" with value "additionals-output"
1073  oc.resetWritable();
1074  oc.set("additional-files", oc.getString("additionals-output"));
1075  }
1076  // check if demand elements output must be changed
1077  if (oc.isSet("demandelements-output")) {
1078  // overwrite "route-files" with value "demandelements-output"
1079  oc.resetWritable();
1080  oc.set("route-files", oc.getString("demandelements-output"));
1081  }
1082  // check if data elements output must be changed
1083  if (oc.isSet("dataelements-output")) {
1084  // overwrite "data-files" with value "dataelements-output"
1085  oc.resetWritable();
1086  oc.set("data-files", oc.getString("dataelements-output"));
1087  }
1088  // after loading net shouldn't be saved
1089  if (myNet) {
1090  myNet->requireSaveNet(false);
1091  }
1092  // update app
1093  update();
1094 }
1095 
1096 
1097 void
1099  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
1100  myMessageWindow->appendMsg(ec->getOwnType(), ec->getMsg());
1101 }
1102 
1103 // ---------------------------------------------------------------------------
1104 // private methods
1105 // ---------------------------------------------------------------------------
1106 
1107 void
1109  // build file menu
1110  myFileMenu = new FXMenuPane(this, LAYOUT_FIX_HEIGHT);
1112  myFileMenuTLS = new FXMenuPane(this);
1113  myFileMenuEdgeTypes = new FXMenuPane(this);
1114  myFileMenuAdditionals = new FXMenuPane(this);
1115  myFileMenuDemandElements = new FXMenuPane(this);
1116  myFileMenuDataElements = new FXMenuPane(this);
1118  // build recent files
1120  new FXMenuSeparator(myFileMenu);
1122  "&Quit", "Ctrl+Q", "Quit the Application.",
1123  nullptr, this, MID_HOTKEY_CTRL_Q_CLOSE);
1124  // build edit menu
1125  myEditMenu = new FXMenuPane(this);
1127  // build undo/redo command
1129  "&Undo", "Ctrl+Z", "Undo the last change.",
1132  "&Redo", "Ctrl+Y", "Redo the last change.",
1134  // build separator
1135  new FXMenuSeparator(myEditMenu);
1136  // build Supermode commands and hide it
1140  // build processing menu (trigger netbuild computations)
1141  myProcessingMenu = new FXMenuPane(this);
1144  // build locate menu
1145  myLocatorMenu = new FXMenuPane(this);
1148  // build windows menu
1149  myWindowsMenu = new FXMenuPane(this);
1152  // build help menu
1153  myHelpMenu = new FXMenuPane(this);
1155  // build help menu commands
1157  "&Online Documentation", "F1", "Open Online documentation.",
1158  nullptr, this, MID_HOTKEY_F1_ONLINEDOCUMENTATION);
1160  "&About", "F12", "About netedit.",
1162 }
1163 
1164 
1165 void
1166 GNEApplicationWindow::loadConfigOrNet(const std::string file, bool isNet, bool isReload, bool useStartupOptions, bool newNet) {
1168  getApp()->beginWaitCursor();
1169  myAmLoading = true;
1170  closeAllWindows();
1171  if (isReload) {
1172  myLoadThread->start();
1173  setStatusBarText("Reloading.");
1174  } else {
1175  gSchemeStorage.saveViewport(0, 0, -1, 0); // recenter view
1176  myLoadThread->loadConfigOrNet(file, isNet, useStartupOptions, newNet);
1177  setStatusBarText("Loading '" + file + "'.");
1178  }
1179  // show supermode commands menu
1181  // show Network command menus (because Network is the default supermode)
1183  // update window
1184  update();
1185 }
1186 
1187 
1188 FXGLCanvas*
1190  // NETEDIT uses only a single View, then return nullptr
1191  return nullptr;
1192 }
1193 
1194 
1195 SUMOTime
1197  return 0;
1198 }
1199 
1200 
1201 double
1203  return 1;
1204 }
1205 
1206 
1207 GNEUndoList*
1209  return myUndoList;
1210 }
1211 
1212 
1213 GNEViewNet*
1215  return myViewNet;
1216 }
1217 
1218 
1221  return myToolbarsGrip;
1222 }
1223 
1224 
1225 void
1227  // check if view has to be saved
1228  if (myViewNet) {
1230  }
1231  // lock tracker
1232  myTrackerLock.lock();
1233  // remove trackers and other external windows
1234  while (!myGLWindows.empty()) {
1235  delete myGLWindows.front();
1236  }
1237  myViewNet = nullptr;
1238  for (FXMainWindow* const window : myTrackerWindows) {
1239  window->destroy();
1240  delete window;
1241  }
1242  myTrackerWindows.clear();
1243  // reset the caption
1244  setTitle(myTitlePrefix);
1245  // add a separator to the log
1247  // unlock tracker
1248  myTrackerLock.unlock();
1249  // remove coordinate information
1250  myGeoCoordinate->setText("N/A");
1251  myCartesianCoordinate->setText("N/A");
1252  // check if net can be deleted
1253  if (myNet != nullptr) {
1254  delete myNet;
1255  myNet = nullptr;
1257  }
1259  // Reset textures
1261  // reset fonts
1263  // disable saving commmand
1265 }
1266 
1267 
1268 FXCursor*
1270  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1271 }
1272 
1273 
1274 void
1277  // Disable normalization preserve the given network as far as possible
1278  oc.set("offset.disable-normalization", "true");
1279  loadConfigOrNet("", true, false, true, oc.getBool("new"));
1280 }
1281 
1282 
1283 void
1284 GNEApplicationWindow::setStatusBarText(const std::string& statusBarText) {
1285  myStatusbar->getStatusLine()->setText(statusBarText.c_str());
1286  myStatusbar->getStatusLine()->setNormalText(statusBarText.c_str());
1287 }
1288 
1289 
1290 long
1292  // obtain option container
1294  // declare variable to save FXMessageBox outputs.
1295  FXuint answer = 0;
1296  // declare string to save paths in wich additionals, shapes demand and data elements will be saved
1297  std::string additionalsSavePath = oc.getString("additional-files");
1298  std::string demandElementsSavePath = oc.getString("route-files");
1299  std::string dataElementsSavePath = oc.getString("data-files");
1300  // write warning if netedit is running in testing mode
1301  WRITE_DEBUG("Opening FXMessageBox 'Volatile Recomputing'");
1302  // open question dialog box
1303  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Recompute with volatile options",
1304  "Changes produced in the net due a recomputing with volatile options cannot be undone. Continue?");
1305  if (answer != 1) { //1:yes, 2:no, 4:esc
1306  // write warning if netedit is running in testing mode
1307  if (answer == 2) {
1308  WRITE_DEBUG("Closed FXMessageBox 'Volatile Recomputing' with 'No'");
1309  } else if (answer == 4) {
1310  WRITE_DEBUG("Closed FXMessageBox 'Volatile Recomputing' with 'ESC'");
1311  }
1312  // abort recompute with volatile options
1313  return 0;
1314  } else {
1315  // write warning if netedit is running in testing mode
1316  WRITE_DEBUG("Closed FXMessageBox 'Volatile Recomputing' with 'Yes'");
1317  // Check if there are additionals in our net
1318  if (myNet->getNumberOfAdditionals() > 0) {
1319  // ask user if want to save additionals if weren't saved previously
1320  if (oc.getString("additional-files") == "") {
1321  // write warning if netedit is running in testing mode
1322  WRITE_DEBUG("Opening FXMessageBox 'Save additionals before recomputing'");
1323  // open question dialog box
1324  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Save additionals before recomputing with volatile options",
1325  "Would you like to save additionals before recomputing?");
1326  if (answer != 1) { //1:yes, 2:no, 4:esc
1327  // write warning if netedit is running in testing mode
1328  if (answer == 2) {
1329  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before recomputing' with 'No'");
1330  } else if (answer == 4) {
1331  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before recomputing' with 'ESC'");
1332  }
1333  } else {
1334  // write warning if netedit is running in testing mode
1335  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before recomputing' with 'Yes'");
1336  // Open a dialog to set filename output
1337  FXString file = MFXUtils::getFilename2Write(this,
1338  "Select name of the demand element file", ".xml",
1340  gCurrentFolder).text();
1341  // add xml extension
1342  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".rou.xml");
1343  // check that file is valid
1344  if (fileWithExtension != "") {
1345  // update additional files
1346  oc.resetWritable();
1347  oc.set("additional-files", fileWithExtension);
1348  // set obtanied filename output into additionalsSavePath (can be "")
1349  additionalsSavePath = oc.getString("additional-files");
1350  }
1351  }
1352  }
1353  // Check if additional must be saved in a temporal directory, if user didn't define a directory for additionals
1354  if (oc.getString("additional-files") == "") {
1355  // Obtain temporal directory provided by FXSystem::getCurrentDirectory()
1356  additionalsSavePath = FXSystem::getTempDirectory().text() + std::string("/tmpAdditionalsNetedit.xml");
1357  }
1358  // Start saving additionals
1359  getApp()->beginWaitCursor();
1360  try {
1361  myNet->saveAdditionals(additionalsSavePath);
1362  } catch (IOError& e) {
1363  // write warning if netedit is running in testing mode
1364  WRITE_DEBUG("Opening FXMessageBox 'Error saving additionals before recomputing'");
1365  // open error message box
1366  FXMessageBox::error(this, MBOX_OK, "Saving additionals in temporal folder failed!", "%s", e.what());
1367  // write warning if netedit is running in testing mode
1368  WRITE_DEBUG("Closed FXMessageBox 'Error saving additionals before recomputing' with 'OK'");
1369  }
1370  // end saving additionals
1372  getApp()->endWaitCursor();
1373  } else {
1374  // clear additional path
1375  additionalsSavePath = "";
1376  }
1377  // Check if there are demand elements in our net
1378  if (myNet->getNumberOfDemandElements() > 0) {
1379  // ask user if want to save demand elements if weren't saved previously
1380  if (oc.getString("route-files") == "") {
1381  // write warning if netedit is running in testing mode
1382  WRITE_DEBUG("Opening FXMessageBox 'Save demand elements before recomputing'");
1383  // open question dialog box
1384  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Save demand elements before recomputing with volatile options",
1385  "Would you like to save demand elements before recomputing?");
1386  if (answer != 1) { //1:yes, 2:no, 4:esc
1387  // write warning if netedit is running in testing mode
1388  if (answer == 2) {
1389  WRITE_DEBUG("Closed FXMessageBox 'Save demand elements before recomputing' with 'No'");
1390  } else if (answer == 4) {
1391  WRITE_DEBUG("Closed FXMessageBox 'Save demand elements before recomputing' with 'ESC'");
1392  }
1393  } else {
1394  // write warning if netedit is running in testing mode
1395  WRITE_DEBUG("Closed FXMessageBox 'Save demand elements before recomputing' with 'Yes'");
1396  // Open a dialog to set filename output
1397  FXString file = MFXUtils::getFilename2Write(this,
1398  "Select name of the demand element file", ".rou.xml",
1400  gCurrentFolder).text();
1401  // add xml extension
1402  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".rou.xml");
1403  // check that file is valid
1404  if (fileWithExtension != "") {
1405  // update route files
1406  oc.resetWritable();
1407  oc.set("route-files", fileWithExtension);
1408  // set obtanied filename output into demand elementSavePath (can be "")
1409  demandElementsSavePath = oc.getString("route-files");
1410  }
1411  }
1412  }
1413  // Check if demand element must be saved in a temporal directory, if user didn't define a directory for demand elements
1414  if (oc.getString("route-files") == "") {
1415  // Obtain temporal directory provided by FXSystem::getCurrentDirectory()
1416  demandElementsSavePath = FXSystem::getTempDirectory().text() + std::string("/tmpDemandElementsNetedit.xml");
1417  }
1418  // Start saving demand elements
1419  getApp()->beginWaitCursor();
1420  try {
1421  myNet->saveDemandElements(demandElementsSavePath);
1422  } catch (IOError& e) {
1423  // write warning if netedit is running in testing mode
1424  WRITE_DEBUG("Opening FXMessageBox 'Error saving demand elements before recomputing'");
1425  // open error message box
1426  FXMessageBox::error(this, MBOX_OK, "Saving demand elements in temporal folder failed!", "%s", e.what());
1427  // write warning if netedit is running in testing mode
1428  WRITE_DEBUG("Closed FXMessageBox 'Error saving demand elements before recomputing' with 'OK'");
1429  }
1430  // end saving demand elements
1432  getApp()->endWaitCursor();
1433  } else {
1434  // clear demand element path
1435  demandElementsSavePath = "";
1436  }
1437  // Check if there are data elements in our net
1438  if (myNet->getNumberOfDataSets() > 0) {
1439  // ask user if want to save data elements if weren't saved previously
1440  if (oc.getString("data-files") == "") {
1441  // write warning if netedit is running in testing mode
1442  WRITE_DEBUG("Opening FXMessageBox 'Save data elements before recomputing'");
1443  // open question dialog box
1444  answer = FXMessageBox::question(myNet->getViewNet()->getApp(), MBOX_YES_NO, "Save data elements before recomputing with volatile options",
1445  "Would you like to save data elements before recomputing?");
1446  if (answer != 1) { //1:yes, 2:no, 4:esc
1447  // write warning if netedit is running in testing mode
1448  if (answer == 2) {
1449  WRITE_DEBUG("Closed FXMessageBox 'Save data elements before recomputing' with 'No'");
1450  } else if (answer == 4) {
1451  WRITE_DEBUG("Closed FXMessageBox 'Save data elements before recomputing' with 'ESC'");
1452  }
1453  } else {
1454  // write warning if netedit is running in testing mode
1455  WRITE_DEBUG("Closed FXMessageBox 'Save data elements before recomputing' with 'Yes'");
1456  // Open a dialog to set filename output
1457  FXString file = MFXUtils::getFilename2Write(this,
1458  "Select name of the data element file", ".rou.xml",
1460  gCurrentFolder).text();
1461  // add xml extension
1462  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".rou.xml");
1463  // check that file is valid
1464  if (fileWithExtension != "") {
1465  // update data files
1466  oc.resetWritable();
1467  oc.set("data-files", fileWithExtension);
1468  // set obtanied filename output into data elementSavePath (can be "")
1469  dataElementsSavePath = oc.getString("data-files");
1470  }
1471  }
1472  }
1473  // Check if data element must be saved in a temporal directory, if user didn't define a directory for data elements
1474  if (oc.getString("data-files") == "") {
1475  // Obtain temporal directory provided by FXSystem::getCurrentDirectory()
1476  dataElementsSavePath = FXSystem::getTempDirectory().text() + std::string("/tmpDataElementsNetedit.xml");
1477  }
1478  // Start saving data elements
1479  getApp()->beginWaitCursor();
1480  try {
1481  myNet->saveDataElements(dataElementsSavePath);
1482  } catch (IOError& e) {
1483  // write warning if netedit is running in testing mode
1484  WRITE_DEBUG("Opening FXMessageBox 'Error saving data elements before recomputing'");
1485  // open error message box
1486  FXMessageBox::error(this, MBOX_OK, "Saving data elements in temporal folder failed!", "%s", e.what());
1487  // write warning if netedit is running in testing mode
1488  WRITE_DEBUG("Closed FXMessageBox 'Error saving data elements before recomputing' with 'OK'");
1489  }
1490  // end saving data elements
1492  getApp()->endWaitCursor();
1493  } else {
1494  // clear data element path
1495  dataElementsSavePath = "";
1496  }
1497  // compute with volatile options
1498  myNet->computeNetwork(this, true, true, additionalsSavePath, demandElementsSavePath, dataElementsSavePath);
1499  updateControls();
1500  return 1;
1501  }
1502 }
1503 
1504 
1505 void
1508 }
1509 
1510 
1511 void
1515 }
1516 
1517 
1518 void
1522 }
1523 
1524 
1525 void
1529 }
1530 
1531 
1532 void
1536 }
1537 
1538 
1539 void
1543 }
1544 
1545 
1546 void
1550 }
1551 
1552 
1553 long
1554 GNEApplicationWindow::onCmdSetSuperMode(FXObject* sender, FXSelector sel, void* ptr) {
1555  // check that currently there is a View
1556  if (myViewNet) {
1557  myViewNet->onCmdSetSupermode(sender, sel, ptr);
1558  }
1559  return 1;
1560 }
1561 
1562 
1563 long
1564 GNEApplicationWindow::onCmdSetMode(FXObject* sender, FXSelector sel, void* ptr) {
1565  // check that currently there is a View
1566  if (myViewNet) {
1567  myViewNet->onCmdSetMode(sender, sel, ptr);
1568  }
1569  return 1;
1570 }
1571 
1572 
1573 long
1574 GNEApplicationWindow::onCmdProcessButton(FXObject*, FXSelector sel, void*) {
1575  // first check if there is a view
1576  if (myViewNet) {
1577  // process depending of supermode
1579  // check what FXMenuCommand was called
1580  switch (FXSELID(sel)) {
1582  // show extra information for tests
1583  WRITE_DEBUG("Key F5 (Compute) pressed");
1584  myNet->computeNetwork(this, true, false);
1585  updateControls();
1586  break;
1588  // show extra information for tests
1589  WRITE_DEBUG("Keys Shift + F5 (Compute with volatile options) pressed");
1591  break;
1593  // show extra information for tests
1594  WRITE_DEBUG("Key F6 (Clean junction) pressed");
1596  break;
1598  // show extra information for tests
1599  WRITE_DEBUG("Key F7 (Join junctions) pressed");
1601  break;
1603  // show extra information for tests
1604  WRITE_DEBUG("Key F8 (Clean invalid crossings) pressed");
1606  break;
1607  default:
1608  break;
1609  }
1610  } else {
1611  // check what FXMenuCommand was called
1612  switch (FXSELID(sel)) {
1614  // show extra information for tests
1615  WRITE_DEBUG("Key F5 (Compute) pressed");
1617  updateControls();
1618  break;
1620  // show extra information for tests
1621  WRITE_DEBUG("Key F6 (RemoveUnusedRoutes) pressed");
1623  break;
1625  // show extra information for tests
1626  WRITE_DEBUG("Key F7 (JoinRoutes) pressed");
1628  break;
1630  // show extra information for tests
1631  WRITE_DEBUG("Key F8 (CleanInvalidDemandElements) pressed");
1633  break;
1634  default:
1635  break;
1636  }
1637  }
1638  }
1639  return 1;
1640 }
1641 
1642 
1643 long
1644 GNEApplicationWindow::onCmdOpenSUMOGUI(FXObject*, FXSelector, void*) {
1645  // check that currently there is a View
1646  if (myViewNet) {
1647  // first check if network is saved
1648  if (!myViewNet->getNet()->isNetSaved()) {
1649  // save network
1650  onCmdSaveNetwork(nullptr, 0, nullptr);
1651  if (!myViewNet->getNet()->isNetSaved()) {
1652  return 0;
1653  }
1654  }
1655  // now check if additionals must be loaded and are saved
1656  if ((myEditMenuCommands.loadAdditionalsInSUMOGUI->getCheck() == TRUE) &&
1657  (myViewNet->getNet()->getNumberOfAdditionals() > 0) &&
1658  (myViewNet->getNet()->isAdditionalsSaved() == false)) {
1659  // save additionals
1660  onCmdSaveAdditionals(nullptr, 0, nullptr);
1661  // check if additionals were sucesfully saved. If not, abort
1662  if (!myViewNet->getNet()->isAdditionalsSaved()) {
1663  return 0;
1664  }
1665  }
1666  // finally check if demand elements must be loaded and are saved
1667  if ((myEditMenuCommands.loadDemandInSUMOGUI->getCheck() == TRUE) &&
1669  (myViewNet->getNet()->isDemandElementsSaved() == false)) {
1670  // save additionals
1671  onCmdSaveDemandElements(nullptr, 0, nullptr);
1672  // check if demand elements were sucesfully saved. If not, abort
1673  if (!myViewNet->getNet()->isDemandElementsSaved()) {
1674  return 0;
1675  }
1676  }
1677  // obtain viewport
1678  FXRegistry reg("SUMO GUI", "Eclipse");
1679  reg.read();
1680  reg.writeRealEntry("viewport", "x", myViewNet->getChanger().getXPos());
1681  reg.writeRealEntry("viewport", "y", myViewNet->getChanger().getYPos());
1682  reg.writeRealEntry("viewport", "z", myViewNet->getChanger().getZPos());
1683  reg.write();
1684  std::string sumogui = "sumo-gui";
1685  const char* sumoPath = getenv("SUMO_HOME");
1686  if (sumoPath != nullptr) {
1687  std::string newPath = std::string(sumoPath) + "/bin/sumo-gui";
1688  if (FileHelpers::isReadable(newPath) || FileHelpers::isReadable(newPath + ".exe")) {
1689  sumogui = "\"" + newPath + "\"";
1690  }
1691  }
1692  std::string cmd = sumogui + " --registry-viewport" + " -n " + "\"" + OptionsCont::getOptions().getString("output-file") + "\"";
1693  // obtainer options container
1695  // if load additionals is enabled, add it to command
1696  if ((myEditMenuCommands.loadAdditionalsInSUMOGUI->getCheck() == TRUE) && (oc.getString("additional-files").size() > 0)) {
1697  cmd += " -a \"" + oc.getString("additional-files") + "\"";
1698  }
1699  // if load demand is enabled, add it to command
1700  if ((myEditMenuCommands.loadDemandInSUMOGUI->getCheck() == TRUE) && (oc.getString("route-files").size() > 0)) {
1701  cmd += " -r \"" + oc.getString("route-files") + "\"";
1702  }
1703  // start in background
1704 #ifndef WIN32
1705  cmd = cmd + " &";
1706 #else
1707  // see "help start" for the parameters
1708  cmd = "start /B \"\" " + cmd;
1709 #endif
1710  WRITE_MESSAGE("Running " + cmd + ".");
1711  // yay! fun with dangerous commands... Never use this over the internet
1713  }
1714  return 1;
1715 }
1716 
1717 
1718 long
1719 GNEApplicationWindow::onCmdAbort(FXObject*, FXSelector, void*) {
1720  // check that view exists
1721  if (myViewNet) {
1722  // show extra information for tests
1723  WRITE_DEBUG("Key ESC (abort) pressed");
1724  // first check if we're selecting a subset of edges in TAZ Frame
1726  // show extra information for tests
1727  WRITE_DEBUG("Cleaning current selected edges");
1728  // clear current selection
1730  } else if (myViewNet->getViewParent()->getInspectorFrame()->shown()) {
1731  // show extra information for tests
1732  WRITE_DEBUG("Cleaning inspected elements");
1733  // clear inspected elements
1735  } else {
1736  // abort current operation
1738  }
1739  }
1740  return 1;
1741 }
1742 
1743 
1744 long
1745 GNEApplicationWindow::onCmdDel(FXObject*, FXSelector, void*) {
1746  // check that view exists
1747  if (myViewNet) {
1748  // show extra information for tests
1749  WRITE_DEBUG("Key DEL (delete) pressed");
1750  myViewNet->hotkeyDel();
1751  }
1752  return 1;
1753 }
1754 
1755 
1756 long
1757 GNEApplicationWindow::onCmdEnter(FXObject*, FXSelector, void*) {
1758  // check that view exists
1759  if (myViewNet) {
1760  // show extra information for tests
1761  WRITE_DEBUG("Key ENTER pressed");
1763  }
1764  return 1;
1765 }
1766 
1767 
1768 long
1769 GNEApplicationWindow::onCmdBackspace(FXObject*, FXSelector, void*) {
1770  // check that view exists
1771  if (myViewNet) {
1772  // show extra information for tests
1773  WRITE_DEBUG("Key BACKSPACE pressed");
1775  }
1776  return 1;
1777 }
1778 
1779 long
1780 GNEApplicationWindow::onCmdForceSaveNetwork(FXObject* /*sender*/, FXSelector /*sel*/, void* /*ptr*/) {
1781  // check that view exists
1782  if (myViewNet) {
1783  myViewNet->getNet()->requireSaveNet(true);
1784  myViewNet->update();
1785  }
1786  return 1;
1787 }
1788 
1789 
1790 long
1791 GNEApplicationWindow::onCmdForceSaveAdditionals(FXObject* /*sender*/, FXSelector /*sel*/, void* /*ptr*/) {
1792  // check that view exists
1793  if (myViewNet) {
1795  update();
1796  }
1797  return 1;
1798 }
1799 
1800 
1801 long
1802 GNEApplicationWindow::onCmdForceSaveDemandElements(FXObject* /*sender*/, FXSelector /*sel*/, void* /*ptr*/) {
1803  // check that view exists
1804  if (myViewNet) {
1806  update();
1807  }
1808  return 1;
1809 }
1810 
1811 
1812 long
1813 GNEApplicationWindow::onCmdForceSaveDataElements(FXObject* /*sender*/, FXSelector /*sel*/, void* /*ptr*/) {
1814  // check that view exists
1815  if (myViewNet) {
1817  update();
1818  }
1819  return 1;
1820 }
1821 
1822 
1823 long
1824 GNEApplicationWindow::onCmdFocusFrame(FXObject*, FXSelector, void*) {
1825  // check that view exists
1826  if (myViewNet) {
1828  }
1829  return 1;
1830 }
1831 
1832 
1833 long
1834 GNEApplicationWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
1835  // check that view exists
1836  if (myViewNet) {
1838  }
1839  return 1;
1840 }
1841 
1842 
1843 long
1844 GNEApplicationWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
1845  // check that view exists
1846  if (myViewNet) {
1848  }
1849  return 1;
1850 }
1851 
1852 
1853 long
1854 GNEApplicationWindow::onCmdToogleGrid(FXObject* obj, FXSelector sel, void* ptr) {
1855  // check that view exists
1856  if (myViewNet) {
1857  // Toogle getMenuCheckShowGrid of GNEViewNet
1859  // show extra information for tests
1860  WRITE_DEBUG("Disabled grid throught Ctrl+g hotkey");
1861  } else {
1862  // show extra information for tests
1863  WRITE_DEBUG("Enabled grid throught Ctrl+g hotkey");
1864  }
1865  // Call manually toogle grid function
1866  myViewNet->onCmdToogleShowGrid(obj, sel, ptr);
1867  }
1868  return 1;
1869 }
1870 
1871 
1872 long
1873 GNEApplicationWindow::onCmdSetFrontElement(FXObject* /*obj*/, FXSelector /*sel*/, void* /*ptr*/) {
1874  if (myViewNet) {
1875  if (myViewNet->getViewParent()->getInspectorFrame()->shown()) {
1876  // get inspected AC
1877  const GNEAttributeCarrier* inspectedAC = (myViewNet->getInspectedAttributeCarriers().size() == 1) ? myViewNet->getInspectedAttributeCarriers().front() : nullptr;
1878  // set or clear front attribute
1879  if (myViewNet->getFrontAttributeCarrier() == inspectedAC) {
1881  } else {
1882  myViewNet->setFrontAttributeCarrier(inspectedAC);
1883  }
1885  } else {
1887  }
1888  }
1889  return 1;
1890 }
1891 
1892 
1893 long
1894 GNEApplicationWindow::onCmdToogleEditOptions(FXObject* obj, FXSelector sel, void* /* ptr */) {
1895  // first check that we have a ViewNet
1896  if (myViewNet) {
1897  // first check what selector was called
1898  int numericalKeyPressed = sel - FXSEL(SEL_COMMAND, MID_HOTKEY_ALT_0_TOOGLEEDITOPTION) - 1;
1899  // check that numericalKeyPressed is valid
1900  if ((numericalKeyPressed < 0) || (numericalKeyPressed > 10)) {
1901  return 1;
1902  }
1903  // declare a vector in which save visible menu commands
1904  std::vector<MFXCheckableButton*> visibleMenuCommands;
1905  // get common, network and demand visible menu commands
1909  // now check that numericalKeyPressed isn't greather than visible view options
1910  if (numericalKeyPressed >= (int)visibleMenuCommands.size()) {
1911  return 1;
1912  }
1913  // toogle edit options
1915  visibleMenuCommands.at(numericalKeyPressed), numericalKeyPressed, obj, sel)) {
1916  return 1;
1918  visibleMenuCommands.at(numericalKeyPressed), numericalKeyPressed, obj, sel)) {
1919  return 1;
1921  visibleMenuCommands.at(numericalKeyPressed), numericalKeyPressed, obj, sel)) {
1922  return 1;
1923  }
1924  }
1925  return 1;
1926 }
1927 
1928 
1929 long
1930 GNEApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
1931  FXLinkLabel::fxexecute("https://sumo.dlr.de/docs/netedit.html");
1932  return 1;
1933 }
1934 
1935 
1936 long
1937 GNEApplicationWindow::onCmdOptions(FXObject*, FXSelector, void*) {
1938  GUIDialog_Options* wizard =
1939  new GUIDialog_Options(this, "Configure Options", getWidth(), getHeight());
1940 
1941  if (wizard->execute()) {
1942  NIFrame::checkOptions(); // needed to set projection parameters
1945  SystemFrame::checkOptions(); // needed to set precision
1946  }
1947  return 1;
1948 }
1949 
1950 
1951 long
1952 GNEApplicationWindow::onCmdUndo(FXObject*, FXSelector, void*) {
1953  WRITE_DEBUG("Keys Ctrl+Z (Undo) pressed");
1954  // Undo needs a viewnet and a enabled undoLastChange menu command
1955  if (myViewNet && myEditMenuCommands.undoLastChange->isEnabled()) {
1956  myViewNet->getUndoList()->undo();
1957  // update current show frame after undo
1960  }
1961  // update manually undo/redo menu commands (see #6005)
1964  // update toolbar undo-redo buttons
1966  }
1967  return 1;
1968 }
1969 
1970 
1971 long
1972 GNEApplicationWindow::onCmdRedo(FXObject*, FXSelector, void*) {
1973  WRITE_DEBUG("Keys Ctrl+Y (Redo) pressed");
1974  // redo needs a viewnet and a enabled redoLastChange menu command
1975  if (myViewNet && myEditMenuCommands.redoLastChange->isEnabled()) {
1976  myViewNet->getUndoList()->redo();
1977  // update current show frame after redo
1980  }
1981  // update manually undo/redo menu commands (see #6005)
1984  // update toolbar undo-redo buttons
1986  }
1987  return 1;
1988 }
1989 
1990 
1991 
1992 long
1993 GNEApplicationWindow::onCmdCut(FXObject*, FXSelector, void*) {
1994  WRITE_DEBUG("Key Ctrl+X (Cut) pressed");
1995  // Prepared for #6042
1996  return 1;
1997 }
1998 
1999 
2000 long
2001 GNEApplicationWindow::onCmdCopy(FXObject*, FXSelector, void*) {
2002  WRITE_DEBUG("Key Ctrl+C (Copy) pressed");
2003  // Prepared for #6042
2004  return 1;
2005 }
2006 
2007 
2008 long
2009 GNEApplicationWindow::onCmdPaste(FXObject*, FXSelector, void*) {
2010  WRITE_DEBUG("Key Ctrl+V (Paste) pressed");
2011  // Prepared for #6042
2012  return 1;
2013 }
2014 
2015 
2016 long
2017 GNEApplicationWindow::onCmdSetTemplate(FXObject*, FXSelector, void*) {
2018  WRITE_DEBUG("Key Ctrl+F1 (Set Template) pressed");
2019  // first check if myViewNet exist
2020  if (myViewNet) {
2021  // call set template in inspector frame
2023  }
2024  return 1;
2025 }
2026 
2027 
2028 long
2029 GNEApplicationWindow::onCmdCopyTemplate(FXObject*, FXSelector, void*) {
2030  WRITE_DEBUG("Key Ctrl+F2 (Copy Template) pressed");
2031  // first check if myViewNet exist
2032  if (myViewNet) {
2033  // call copy template in inspector frame
2035  }
2036  return 1;
2037 }
2038 
2039 
2040 long
2041 GNEApplicationWindow::onCmdClearTemplate(FXObject*, FXSelector, void*) {
2042  WRITE_DEBUG("Key Ctrl+F3 (Clear Template) pressed");
2043  // first check if myViewNet exist
2044  if (myViewNet) {
2045  // call clear template in inspector frame
2047  }
2048  return 1;
2049 }
2050 
2051 
2052 long
2053 GNEApplicationWindow::onCmdSaveAsNetwork(FXObject*, FXSelector, void*) {
2054  FXString file = MFXUtils::getFilename2Write(this,
2055  "Save Network as", ".net.xml",
2057  gCurrentFolder);
2058  // add xml extension
2059  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".net.xml");
2060  // check that file with extension is valid
2061  if (fileWithExtension != "") {
2063  oc.resetWritable();
2064  oc.set("output-file", fileWithExtension);
2065  setTitle(MFXUtils::getTitleText(myTitlePrefix, fileWithExtension.c_str()));
2066  onCmdSaveNetwork(nullptr, 0, nullptr);
2067  }
2068  return 1;
2069 }
2070 
2071 
2072 long
2073 GNEApplicationWindow::onCmdSaveAsPlainXML(FXObject*, FXSelector, void*) {
2074  FXString file = MFXUtils::getFilename2Write(this,
2075  "Select name of the plain-xml edge-file (other names will be deduced from this)", "",
2077  gCurrentFolder);
2078  // check that file is valid (note: in this case we don't need to use function FileHelpers::addExtension)
2079  if (file != "") {
2081  bool wasSet = oc.isSet("plain-output-prefix");
2082  std::string oldPrefix = oc.getString("plain-output-prefix");
2083  std::string prefix = file.text();
2084  // if the name of an edg.xml file was given, remove the suffix
2085  if (StringUtils::endsWith(prefix, ".edg.xml")) {
2086  prefix = prefix.substr(0, prefix.size() - 8);
2087  }
2088  if (StringUtils::endsWith(prefix, ".")) {
2089  prefix = prefix.substr(0, prefix.size() - 1);
2090  }
2091  oc.resetWritable();
2092  oc.set("plain-output-prefix", prefix);
2093  getApp()->beginWaitCursor();
2094  try {
2095  myNet->savePlain(oc);
2096  myUndoList->unmark();
2097  myUndoList->mark();
2098  } catch (IOError& e) {
2099  // write warning if netedit is running in testing mode
2100  WRITE_DEBUG("Opening FXMessageBox 'Error saving plainXML'");
2101  // open message box
2102  FXMessageBox::error(this, MBOX_OK, "Saving plain xml failed!", "%s", e.what());
2103  // write warning if netedit is running in testing mode
2104  WRITE_DEBUG("Closed FXMessageBox 'Error saving plainXML' with 'OK'");
2105  }
2106  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Plain XML saved with prefix '" + prefix + "'.\n");
2108  if (wasSet) {
2109  oc.resetWritable();
2110  oc.set("plain-output-prefix", oldPrefix);
2111  } else {
2112  oc.unSet("plain-output-prefix");
2113  }
2114  getApp()->endWaitCursor();
2115  }
2116  return 1;
2117 }
2118 
2119 
2120 long
2121 GNEApplicationWindow::onCmdSaveJoined(FXObject*, FXSelector, void*) {
2122  FXString file = MFXUtils::getFilename2Write(this,
2123  "Select name of the joined-junctions file", ".nod.xml",
2125  gCurrentFolder);
2126  // add xml extension
2127  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".xml");
2128  // check that file with extension is valid
2129  if (fileWithExtension != "") {
2131  bool wasSet = oc.isSet("junctions.join-output");
2132  std::string oldFile = oc.getString("junctions.join-output");
2133  oc.resetWritable();
2134  oc.set("junctions.join-output", fileWithExtension);
2135  getApp()->beginWaitCursor();
2136  try {
2137  myNet->saveJoined(oc);
2138  } catch (IOError& e) {
2139  // write warning if netedit is running in testing mode
2140  WRITE_DEBUG("Opening FXMessageBox 'error saving joined'");
2141  // opening error message
2142  FXMessageBox::error(this, MBOX_OK, "Saving joined junctions failed!", "%s", e.what());
2143  // write warning if netedit is running in testing mode
2144  WRITE_DEBUG("Closed FXMessageBox 'error saving joined' with 'OK'");
2145  }
2146  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Joined junctions saved to '" + fileWithExtension + "'.\n");
2148  if (wasSet) {
2149  oc.resetWritable();
2150  oc.set("junctions.join-output", oldFile);
2151  } else {
2152  oc.unSet("junctions.join-output");
2153  }
2154  getApp()->endWaitCursor();
2155  }
2156  return 1;
2157 }
2158 
2159 
2160 long
2161 GNEApplicationWindow::onUpdNeedsNetwork(FXObject* sender, FXSelector, void*) {
2162  // check if net exist
2163  if (myNet) {
2164  sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
2165  } else {
2166  sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
2167  }
2168  return 1;
2169 }
2170 
2171 
2172 long
2173 GNEApplicationWindow::onUpdNeedsFrontElement(FXObject* sender, FXSelector, void*) {
2174  // check if net, viewnet and front attribute exist
2176  sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
2177  } else {
2178  sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
2179  }
2180  return 1;
2181 }
2182 
2183 
2184 long
2185 GNEApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void*) {
2186  sender->handle(this, ((myNet == nullptr) || !OptionsCont::getOptions().isSet("sumo-net-file")) ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
2187  return 1;
2188 }
2189 
2190 
2191 long
2192 GNEApplicationWindow::onUpdSaveNetwork(FXObject* sender, FXSelector, void*) {
2193  sender->handle(this, ((myNet == nullptr) || myNet->isNetSaved()) ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
2194  return 1;
2195 }
2196 
2197 
2198 long
2199 GNEApplicationWindow::onUpdSaveAdditionals(FXObject* sender, FXSelector, void*) {
2200  sender->handle(this, ((myNet == nullptr) || myNet->isAdditionalsSaved()) ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
2201  return 1;
2202 }
2203 
2204 
2205 long
2206 GNEApplicationWindow::onUpdSaveDemandElements(FXObject* sender, FXSelector, void*) {
2207  sender->handle(this, ((myNet == nullptr) || myNet->isDemandElementsSaved()) ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
2208  return 1;
2209 }
2210 
2211 
2212 long
2213 GNEApplicationWindow::onUpdSaveDataElements(FXObject* sender, FXSelector, void*) {
2214  sender->handle(this, ((myNet == nullptr) || myNet->isDataElementsSaved()) ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
2215  return 1;
2216 }
2217 
2218 
2219 long
2220 GNEApplicationWindow::onUpdUndo(FXObject* obj, FXSelector sel, void* ptr) {
2221  return myUndoList->p_onUpdUndo(obj, sel, ptr);
2222 }
2223 
2224 
2225 long
2226 GNEApplicationWindow::onUpdRedo(FXObject* obj, FXSelector sel, void* ptr) {
2227  return myUndoList->p_onUpdRedo(obj, sel, ptr);
2228 }
2229 
2230 
2231 long
2232 GNEApplicationWindow::onCmdSaveNetwork(FXObject*, FXSelector, void*) {
2234  // function onCmdSaveAsNetwork must be executed if this is the first save
2235  if (oc.getString("output-file") == "" || oc.isDefault("output-file")) {
2236  return onCmdSaveAsNetwork(nullptr, 0, nullptr);
2237  } else {
2238  getApp()->beginWaitCursor();
2239  try {
2240  myNet->save(oc);
2241  myUndoList->unmark();
2242  myUndoList->mark();
2243  } catch (IOError& e) {
2244  // write warning if netedit is running in testing mode
2245  WRITE_DEBUG("Opening FXMessageBox 'error saving network'");
2246  // open error message box
2247  FXMessageBox::error(this, MBOX_OK, "Saving Network failed!", "%s", e.what());
2248  // write warning if netedit is running in testing mode
2249  WRITE_DEBUG("Closed FXMessageBox 'error saving network' with 'OK'");
2250  }
2251  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Network saved in " + oc.getString("output-file") + ".\n");
2252  // After saveing a net sucesfully, add it into Recent Nets list.
2253  myMenuBarFile.myRecentNets.appendFile(oc.getString("output-file").c_str());
2255  getApp()->endWaitCursor();
2256  return 1;
2257  }
2258 }
2259 
2260 
2261 long
2262 GNEApplicationWindow::onCmdSaveTLSPrograms(FXObject*, FXSelector, void*) {
2263  // obtain option container
2265  // check if save additional menu is enabled
2266  if (myFileMenuCommands.saveTLSPrograms->isEnabled()) {
2267  // Check if TLS Programs file was already set at start of netedit or with a previous save
2268  if (oc.getString("TLSPrograms-output").empty()) {
2269  FXString file = MFXUtils::getFilename2Write(this,
2270  "Select name of the TLS file", ".xml",
2272  gCurrentFolder);
2273  // add xml extension
2274  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".xml");
2275  // check tat file is valid
2276  if (file == "") {
2277  // None TLS Programs file was selected, then stop function
2278  return 0;
2279  } else {
2280  // change value of "TLSPrograms-output"
2281  oc.resetWritable();
2282  oc.set("TLSPrograms-output", fileWithExtension);
2283  }
2284  }
2285  // Start saving TLS Programs
2286  getApp()->beginWaitCursor();
2287  try {
2288  myNet->saveTLSPrograms(oc.getString("TLSPrograms-output"));
2289  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "TLS Programs saved in " + oc.getString("TLSPrograms-output") + ".\n");
2291  } catch (IOError& e) {
2292  // write warning if netedit is running in testing mode
2293  WRITE_DEBUG("Opening FXMessageBox 'error saving TLS Programs'");
2294  // open error message box
2295  FXMessageBox::error(this, MBOX_OK, "Saving TLS Programs failed!", "%s", e.what());
2296  // write warning if netedit is running in testing mode
2297  WRITE_DEBUG("Closed FXMessageBox 'error saving TLS Programs' with 'OK'");
2298  }
2300  getApp()->endWaitCursor();
2301  return 1;
2302  } else {
2303  return 0;
2304  }
2305 }
2306 
2307 
2308 long
2309 GNEApplicationWindow::onCmdSaveEdgeTypes(FXObject*, FXSelector, void*) {
2310  // obtain option container
2312  // check if save additional menu is enabled
2313  if (myFileMenuCommands.saveEdgeTypes->isEnabled()) {
2314  // Check if edgeType file was already set at start of netedit or with a previous save
2315  if (oc.getString("edgeTypes-output").empty()) {
2316  FXString file = MFXUtils::getFilename2Write(this,
2317  "Select name of the edgeType file", ".xml",
2319  gCurrentFolder);
2320  // add xml extension
2321  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".xml");
2322  // check tat file is valid
2323  if (file == "") {
2324  // None edgeType Programs file was selected, then stop function
2325  return 0;
2326  } else {
2327  // change value of "edgeTypes-output"
2328  oc.resetWritable();
2329  oc.set("edgeTypes-output", fileWithExtension);
2330  }
2331  }
2332  // Start saving edgeTypes
2333  getApp()->beginWaitCursor();
2334  try {
2335  myNet->saveEdgeTypes(oc.getString("edgeTypes-output"));
2336  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "EdgeType saved in " + oc.getString("edgeTypes-output") + ".\n");
2337  myFileMenuCommands.saveEdgeTypes->disable();
2338  } catch (IOError& e) {
2339  // write warning if netedit is running in testing mode
2340  WRITE_DEBUG("Opening FXMessageBox 'error saving edgeTypes'");
2341  // open error message box
2342  FXMessageBox::error(this, MBOX_OK, "Saving edgeTypes failed!", "%s", e.what());
2343  // write warning if netedit is running in testing mode
2344  WRITE_DEBUG("Closed FXMessageBox 'error saving edgeTypes' with 'OK'");
2345  }
2347  getApp()->endWaitCursor();
2348  return 1;
2349  } else {
2350  return 0;
2351  }
2352 }
2353 
2354 
2355 long
2356 GNEApplicationWindow::onCmdSaveTLSProgramsAs(FXObject*, FXSelector, void*) {
2357  // Open window to select TLS Programs file
2358  FXString file = MFXUtils::getFilename2Write(this,
2359  "Select name of the TLS Program file", ".xml",
2361  gCurrentFolder);
2362  // add xml extension
2363  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".xml");
2364  // check tat file is valid
2365  if (fileWithExtension != "") {
2366  // change value of "TLSPrograms-files"
2367  OptionsCont::getOptions().set("TLSPrograms-output", fileWithExtension);
2368  // save TLS Programs
2369  return onCmdSaveTLSPrograms(nullptr, 0, nullptr);
2370  } else {
2371  return 1;
2372  }
2373 }
2374 
2375 
2376 long
2377 GNEApplicationWindow::onCmdSaveEdgeTypesAs(FXObject*, FXSelector, void*) {
2378  // Open window to select edgeType file
2379  FXString file = MFXUtils::getFilename2Write(this,
2380  "Select name of the edgeType file", ".xml",
2382  gCurrentFolder);
2383  // add xml extension
2384  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".xml");
2385  // check tat file is valid
2386  if (fileWithExtension != "") {
2387  // change value of "edgeTypes-files"
2388  OptionsCont::getOptions().set("edgeTypes-output", fileWithExtension);
2389  // save edgeTypes
2390  return onCmdSaveEdgeTypes(nullptr, 0, nullptr);
2391  } else {
2392  return 1;
2393  }
2394 }
2395 
2396 
2397 long
2398 GNEApplicationWindow::onCmdSaveAdditionals(FXObject*, FXSelector, void*) {
2399  // obtain option container
2401  // check if save additional menu is enabled
2402  if (myFileMenuCommands.saveAdditionals->isEnabled()) {
2403  // Check if additionals file was already set at start of netedit or with a previous save
2404  if (oc.getString("additional-files").empty()) {
2405  FXString file = MFXUtils::getFilename2Write(this,
2406  "Select name of the additional file", ".add.xml",
2408  gCurrentFolder);
2409  // add xml extension
2410  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".add.xml");
2411  // check tat file is valid
2412  if (fileWithExtension != "") {
2413  // change value of "additional-files"
2414  oc.resetWritable();
2415  oc.set("additional-files", fileWithExtension);
2416  } else {
2417  // None additionals file was selected, then stop function
2418  return 0;
2419  }
2420  }
2421  // Start saving additionals
2422  getApp()->beginWaitCursor();
2423  try {
2424  myNet->saveAdditionals(oc.getString("additional-files"));
2425  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Additionals saved in " + oc.getString("additional-files") + ".\n");
2427  } catch (IOError& e) {
2428  // write warning if netedit is running in testing mode
2429  WRITE_DEBUG("Opening FXMessageBox 'error saving additionals'");
2430  // open error message box
2431  FXMessageBox::error(this, MBOX_OK, "Saving additionals failed!", "%s", e.what());
2432  // write warning if netedit is running in testing mode
2433  WRITE_DEBUG("Closed FXMessageBox 'error saving additionals' with 'OK'");
2434  }
2436  getApp()->endWaitCursor();
2437  return 1;
2438  } else {
2439  return 0;
2440  }
2441 }
2442 
2443 
2444 long
2445 GNEApplicationWindow::onCmdSaveAdditionalsAs(FXObject*, FXSelector, void*) {
2446  // Open window to select additional file
2447  FXString file = MFXUtils::getFilename2Write(this,
2448  "Select name of the additional file", ".add.xml",
2450  gCurrentFolder);
2451  // add xml extension
2452  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".add.xml");
2453  // check tat file is valid
2454  if (fileWithExtension != "") {
2455  // reset writtable flag
2457  // change value of "additional-files"
2458  OptionsCont::getOptions().set("additional-files", fileWithExtension);
2459  // change flag of menu command for save additionals
2461  // save additionals
2462  return onCmdSaveAdditionals(nullptr, 0, nullptr);
2463  } else {
2464  return 1;
2465  }
2466 }
2467 
2468 
2469 long
2470 GNEApplicationWindow::onCmdSaveDemandElements(FXObject*, FXSelector, void*) {
2471  // obtain option container
2473  // check if save demand element menu is enabled
2474  if (myFileMenuCommands.saveDemandElements->isEnabled()) {
2475  // Check if demand elements file was already set at start of netedit or with a previous save
2476  if (oc.getString("route-files").empty()) {
2477  FXString file = MFXUtils::getFilename2Write(this,
2478  "Select name of the demand element file", ".rou.xml",
2480  gCurrentFolder);
2481  // add xml extension
2482  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".rou.xml");
2483  // check tat file is valid
2484  if (fileWithExtension != "") {
2485  // change value of "route-files"
2486  oc.resetWritable();
2487  oc.set("route-files", fileWithExtension);
2488  } else {
2489  // None demand elements file was selected, then stop function
2490  return 0;
2491  }
2492  }
2493  // Start saving demand elements
2494  getApp()->beginWaitCursor();
2495  try {
2496  myNet->saveDemandElements(oc.getString("route-files"));
2497  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Demand elements saved in " + oc.getString("route-files") + ".\n");
2499  } catch (IOError& e) {
2500  // write warning if netedit is running in testing mode
2501  WRITE_DEBUG("Opening FXMessageBox 'error saving demand elements'");
2502  // open error message box
2503  FXMessageBox::error(this, MBOX_OK, "Saving demand elements failed!", "%s", e.what());
2504  // write warning if netedit is running in testing mode
2505  WRITE_DEBUG("Closed FXMessageBox 'error saving demand elements' with 'OK'");
2506  }
2508  getApp()->endWaitCursor();
2509  return 1;
2510  } else {
2511  return 0;
2512  }
2513 }
2514 
2515 
2516 long
2518  // Open window to select additionasl file
2519  FXString file = MFXUtils::getFilename2Write(this,
2520  "Select name of the demand element file", ".rou.xml",
2522  gCurrentFolder);
2523  // add xml extension
2524  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".rou.xml");
2525  // check that file is correct
2526  if (fileWithExtension != "") {
2527  // reset writtable flag
2529  // change value of "route-files"
2530  OptionsCont::getOptions().set("route-files", fileWithExtension);
2531  // change flag of menu command for save demand elements
2533  // save demand elements
2534  return onCmdSaveDemandElements(nullptr, 0, nullptr);
2535  } else {
2536  return 1;
2537  }
2538 }
2539 
2540 
2541 long
2542 GNEApplicationWindow::onCmdSaveDataElements(FXObject*, FXSelector, void*) {
2543  // obtain option container
2545  // check if save data element menu is enabled
2546  if (myFileMenuCommands.saveDataElements->isEnabled()) {
2547  // Check if data elements file was already set at start of netedit or with a previous save
2548  if (oc.getString("data-files").empty()) {
2549  FXString file = MFXUtils::getFilename2Write(this,
2550  "Select name of the data element file", ".xml",
2552  gCurrentFolder);
2553  // add xml extension
2554  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".xml");
2555  // check tat file is valid
2556  if (fileWithExtension != "") {
2557  // change value of "data-files"
2558  oc.resetWritable();
2559  oc.set("data-files", fileWithExtension);
2560  } else {
2561  // None data elements file was selected, then stop function
2562  return 0;
2563  }
2564  }
2565  // Start saving data elements
2566  getApp()->beginWaitCursor();
2567  try {
2568  myNet->saveDataElements(oc.getString("data-files"));
2569  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURRED, "Data elements saved in " + oc.getString("data-files") + ".\n");
2571  } catch (IOError& e) {
2572  // write warning if netedit is running in testing mode
2573  WRITE_DEBUG("Opening FXMessageBox 'error saving data elements'");
2574  // open error message box
2575  FXMessageBox::error(this, MBOX_OK, "Saving data elements failed!", "%s", e.what());
2576  // write warning if netedit is running in testing mode
2577  WRITE_DEBUG("Closed FXMessageBox 'error saving data elements' with 'OK'");
2578  }
2580  getApp()->endWaitCursor();
2581  return 1;
2582  } else {
2583  return 0;
2584  }
2585 }
2586 
2587 
2588 long
2589 GNEApplicationWindow::onCmdSaveDataElementsAs(FXObject*, FXSelector, void*) {
2590  // Open window to select additionasl file
2591  FXString file = MFXUtils::getFilename2Write(this,
2592  "Select name of the data element file", ".xml",
2594  gCurrentFolder);
2595  // add xml extension
2596  std::string fileWithExtension = FileHelpers::addExtension(file.text(), ".xml");
2597  // check that file is correct
2598  if (fileWithExtension != "") {
2599  // reset writtable flag
2601  // change value of "data-files"
2602  OptionsCont::getOptions().set("data-files", fileWithExtension);
2603  // change flag of menu command for save data elements
2605  // save data elements
2606  return onCmdSaveDataElements(nullptr, 0, nullptr);
2607  } else {
2608  return 1;
2609  }
2610 }
2611 
2612 
2613 bool
2615  FXuint answer = 0;
2616  if (myViewNet && myNet && !myNet->isNetSaved()) {
2617  // write warning if netedit is running in testing mode
2618  WRITE_DEBUG("Opening FXMessageBox 'Confirm " + operation + " network'");
2619  // open question box
2620  answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
2621  ("Confirm " + operation + " Network").c_str(), "%s",
2622  ("You have unsaved changes in the network. Do you wish to " + operation + " and discard all changes?").c_str());
2623  // restore focus to view net
2624  myViewNet->setFocus();
2625  // if user close dialog box, check additionals and demand elements
2626  if (answer == MBOX_CLICKED_QUIT) {
2627  // write warning if netedit is running in testing mode
2628  WRITE_DEBUG("Closed FXMessageBox 'Confirm " + operation + " network' with 'Quit'");
2630  // clear undo list and return true to continue with closing/reload
2631  myUndoList->p_clear();
2632  return true;
2633  } else {
2634  return false;
2635  }
2636  } else if (answer == MBOX_CLICKED_SAVE) {
2637  // save newtork
2638  onCmdSaveNetwork(nullptr, 0, nullptr);
2639  if (!myUndoList->marked()) {
2640  // saving failed
2641  return false;
2642  }
2644  // clear undo list and return true to continue with closing/reload
2645  myUndoList->p_clear();
2646  return true;
2647  } else {
2648  return false;
2649  }
2650  } else {
2651  // write warning if netedit is running in testing mode
2652  if (answer == 2) {
2653  WRITE_DEBUG("Closed FXMessageBox 'Confirm " + operation + " network' with 'No'");
2654  } else if (answer == 4) {
2655  WRITE_DEBUG("Closed FXMessageBox 'Confirm " + operation + " network' with 'ESC'");
2656  }
2657  // return false to stop closing/reloading
2658  return false;
2659  }
2660  } else {
2662  // clear undo list and return true to continue with closing/reload
2663  myUndoList->p_clear(); //only ask once
2664  return true;
2665  } else {
2666  // return false to stop closing/reloading
2667  return false;
2668  }
2669  }
2670 }
2671 
2672 
2673 bool
2675  // Check if there are non saved additionals
2676  if (myViewNet && myFileMenuCommands.saveAdditionals->isEnabled()) {
2677  WRITE_DEBUG("Opening FXMessageBox 'Save additionals before " + operation + "'");
2678  // open question box
2679  FXuint answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
2680  ("Save additionals before " + operation).c_str(), "%s",
2681  ("You have unsaved additionals. Do you wish to " + operation + " and discard all changes?").c_str());
2682  // restore focus to view net
2683  myViewNet->setFocus();
2684  // if answer was affirmative, but there was an error during saving additionals, return false to stop closing/reloading
2685  if (answer == MBOX_CLICKED_QUIT) {
2686  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before " + operation + "' with 'Quit'");
2687  // nothing to save, return true
2688  return true;
2689  } else if (answer == MBOX_CLICKED_SAVE) {
2690  // write warning if netedit is running in testing mode
2691  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before " + operation + "' with 'Yes'");
2692  if (onCmdSaveAdditionals(nullptr, 0, nullptr) == 1) {
2693  // additionals sucesfully saved
2694  return true;
2695  } else {
2696  // error saving additionals, abort saving
2697  return false;
2698  }
2699  } else {
2700  // write warning if netedit is running in testing mode
2701  if (answer == 2) {
2702  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before " + operation + "' with 'No'");
2703  } else if (answer == 4) {
2704  WRITE_DEBUG("Closed FXMessageBox 'Save additionals before " + operation + "' with 'ESC'");
2705  }
2706  // abort saving
2707  return false;
2708  }
2709  } else {
2710  // nothing to save, return true
2711  return true;
2712  }
2713 }
2714 
2715 
2716 bool
2718  // Check if there are non saved demand elements
2719  if (myViewNet && myFileMenuCommands.saveDemandElements->isEnabled()) {
2720  WRITE_DEBUG("Opening FXMessageBox 'Save demand elements before " + operation + "'");
2721  // open question box
2722  FXuint answer = FXMessageBox::question(getApp(), MBOX_QUIT_SAVE_CANCEL,
2723  ("Save demand elements before " + operation).c_str(), "%s",
2724  ("You have unsaved demand elements. Do you wish to " + operation + " and discard all changes?").c_str());
2725  // restore focus to view net
2726  myViewNet->setFocus();
2727  // if answer was affirmative, but there was an error during saving demand elements, return false to stop closing/reloading
2728  if (answer == MBOX_CLICKED_QUIT) {
2729  WRITE_DEBUG("Closed FXMessageBox 'Save demand elements before " + operation + "' with 'Quit'");
2730  // nothing to save, return true
2731  return true;
2732  } else if (answer == MBOX_CLICKED_SAVE) {
2733  // write warning if netedit is running in testing mode
2734  WRITE_DEBUG("Closed FXMessageBox 'Save demand elements before " + operation + "' with 'Yes'");
2735  if (onCmdSaveDemandElements(nullptr, 0, nullptr) == 1) {
2736  // demand elements sucesfully saved
2737  return true;
2738  } else {
2739  // error saving demand elements, abort saving
2740  return false;
2741  }
2742  } else {
2743  // write warning if netedit is running in testing mode
2744  if (answer == 2) {
2745  WRITE_DEBUG("Closed FXMessageBox 'Save demand elements before " + operation + "' with 'No'");
2746  } else if (answer == 4) {
2747  WRITE_DEBUG("Closed FXMessageBox 'Save demand elements before " + operation + "' with 'ESC'");
2748  }
2749  // abort saving
2750  return false;
2751  }
2752  } else {
2753  // nothing to save, return true
2754  return true;
2755  }
2756 }
2757 
2758 
2759 void
2761  // check that view exists
2762  if (myViewNet) {
2764  }
2765 }
2766 
2767 
2768 void
2770  if (supermode == Supermode::NETWORK) {
2771  // menu commands
2775  // processing
2779  } else if (supermode == Supermode::DEMAND) {
2780  // menu commands
2784  // processing
2788  } else if (supermode == Supermode::DATA) {
2789  // menu commands
2793  // processing
2797  } else {
2798  // menu commands
2802  // processing
2806  }
2807 }
2808 
2809 
2810 void
2811 GNEApplicationWindow::disableUndoRedo(const std::string& reason) {
2812  myUndoRedoListEnabled = reason;
2813 }
2814 
2815 
2816 void
2818  myUndoRedoListEnabled.clear();
2819 }
2820 
2821 
2822 const std::string&
2824  return myUndoRedoListEnabled;
2825 }
2826 
2827 // ---------------------------------------------------------------------------
2828 // GNEApplicationWindow - protected methods
2829 // ---------------------------------------------------------------------------
2830 
2832  myLoadThread(nullptr),
2833  myAmLoading(false),
2834  myFileMenu(nullptr),
2835  myFileMenuTLS(nullptr),
2836  myFileMenuAdditionals(nullptr),
2837  myFileMenuDemandElements(nullptr),
2838  myFileMenuDataElements(nullptr),
2839  myEditMenu(nullptr),
2840  myProcessingMenu(nullptr),
2841  myLocatorMenu(nullptr),
2842  myWindowsMenu(nullptr),
2843  myHelpMenu(nullptr),
2844  myMessageWindow(nullptr),
2845  myMainSplitter(nullptr),
2846  hadDependentBuild(false),
2847  myNet(nullptr),
2848  myUndoList(nullptr),
2849  myToolbarsGrip(this),
2850  myMenuBarFile(this),
2851  myFileMenuCommands(this),
2852  myEditMenuCommands(this),
2853  myProcessingMenuCommands(this),
2854  myLocateMenuCommands(this),
2855  myWindowsMenuCommands(this),
2856  mySupermodeCommands(this),
2857  myViewNet(nullptr),
2858  myMDIMenu(nullptr)
2859 { }
2860 
2861 
2862 long
2863 GNEApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* eventData) {
2864  const long handled = FXMainWindow::onKeyPress(o, sel, eventData);
2865  if (handled == 0 && myMDIClient->numChildren() > 0) {
2866  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
2867  if (w != nullptr) {
2868  w->onKeyPress(nullptr, sel, eventData);
2869  }
2870  }
2871  return 0;
2872 }
2873 
2874 
2875 long
2876 GNEApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* eventData) {
2877  const long handled = FXMainWindow::onKeyRelease(o, sel, eventData);
2878  if (handled == 0 && myMDIClient->numChildren() > 0) {
2879  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
2880  if (w != nullptr) {
2881  w->onKeyRelease(nullptr, sel, eventData);
2882  }
2883  }
2884  return 0;
2885 }
2886 
2887 
2888 /****************************************************************************/
FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[]
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
@ DATA
Data mode (edgeData, LaneData etc..)
@ DEMAND
Demand mode (Routes, Vehicles etc..)
@ MID_GNE_TOOLBAREDIT_LOADADDITIONALS
load additionals in SUMO-GUI after press ctrl+T
Definition: GUIAppEnum.h:614
@ MID_HOTKEY_CTRL_Q_CLOSE
Main window closes.
Definition: GUIAppEnum.h:99
@ MID_HOTKEY_SHIFT_F5_COMPUTEJUNCTIONS_VOLATILE
compute junctions with volatile options
Definition: GUIAppEnum.h:214
@ MID_HOTKEY_CTRL_SHIFT_B_SAVEDATAELEMENTS
save Data Elements
Definition: GUIAppEnum.h:155
@ MID_HOTKEY_F3_SUPERMODE_DEMAND
select demand supermode in NETEDIT
Definition: GUIAppEnum.h:181
@ MID_HOTKEY_ALT_6_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:135
@ MID_LOCATEPERSON
Locate person - button.
Definition: GUIAppEnum.h:349
@ MID_HOTKEY_T_MODES_TLS_VTYPE
hotkey for mode editing TLS AND Vehicle Types
Definition: GUIAppEnum.h:61
@ MID_HOTKEY_CTRL_Y_REDO
Undo.
Definition: GUIAppEnum.h:113
@ MID_HOTKEY_CTRL_SHIFT_H_SAVEEDGETYPES
save Edge Types
Definition: GUIAppEnum.h:153
@ MID_HOTKEY_S_MODES_SELECT
hotkey for mode selecting objects
Definition: GUIAppEnum.h:57
@ MID_LOCATEJUNCTION
Locate junction - button.
Definition: GUIAppEnum.h:339
@ MID_GNE_TOOLBAREDIT_LOADDEMAND
load demand in SUMO-GUI after press ctrl+T
Definition: GUIAppEnum.h:616
@ MID_OPEN_CONFIG
Open configuration - ID.
Definition: GUIAppEnum.h:254
@ MID_HOTKEY_CTRL_W_CLOSESIMULATION
Close simulation - ID.
Definition: GUIAppEnum.h:109
@ MID_HOTKEY_F7_JOIN_SELECTEDJUNCTIONS_ROUTES
join selected junctions in network mode and normalice demand element ids in demand mode
Definition: GUIAppEnum.h:189
@ MID_HOTKEY_CTRL_D_SINGLESIMULATIONSTEP_OPENDEMANDELEMENTS
Perform a single simulation step in SUMO and open Demand Elements in NETEDIT.
Definition: GUIAppEnum.h:81
@ MID_HOTKEY_F5_COMPUTE_NETWORK_DEMAND
compute Network in network mode and Demand elements in demand mode
Definition: GUIAppEnum.h:185
@ MID_HOTKEY_V_MODES_VEHICLE
hotkey for mode create vehicles
Definition: GUIAppEnum.h:63
@ MID_HOTKEY_F9_EDIT_VIEWSCHEME
open edit scheme menu
Definition: GUIAppEnum.h:193
@ MID_HOTKEY_E_MODES_EDGE_EDGEDATA
hotkey for mode adding edges AND edgeDatas
Definition: GUIAppEnum.h:49
@ MID_LOCATEPOLY
Locate polygons - button.
Definition: GUIAppEnum.h:359
@ MID_HOTKEY_DEL
hot key delete selections or elements
Definition: GUIAppEnum.h:225
@ MID_HOTKEY_ALT_1_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:125
@ MID_HOTKEY_CTRL_N_NEWNETWORK
create new empty newtork
Definition: GUIAppEnum.h:97
@ MID_HOTKEY_ALT_0_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:123
@ MID_HOTKEY_CTRL_SHIFT_S_SAVENETWORK_AS
save network as
Definition: GUIAppEnum.h:161
@ MID_GNE_TOOLBARFILE_OPENFOREIGN
open foreign network
Definition: GUIAppEnum.h:596
@ MID_HOTKEY_CTRL_B_EDITBREAKPOINT_OPENDATAELEMENTS
Edit simulation breakpoints in SUMO and open Data Elements in NETEDIT.
Definition: GUIAppEnum.h:77
@ MID_HOTKEY_ALT_7_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:137
@ MID_HOTKEY_F1_ONLINEDOCUMENTATION
open online documentation
Definition: GUIAppEnum.h:177
@ MID_HOTKEY_CTRL_SHIFT_D_SAVEDEMANDELEMENTS
Save Demand Elements.
Definition: GUIAppEnum.h:157
@ MID_HOTKEY_CTRL_R_RELOAD
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:103
@ MID_HOTKEY_CTRL_SHIFT_V_FORCESAVEDEMANDELEMENTS
Force save demand elements (flag)
Definition: GUIAppEnum.h:167
@ MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK
Stop the simulation in SUMO and save network in NETEDIT.
Definition: GUIAppEnum.h:101
@ MID_HOTKEY_W_MODES_PROHIBITION_PERSONTYPE
hotkey for mode editing connection prohibitions AND person types
Definition: GUIAppEnum.h:65
@ MID_HOTKEY_ESC
hot key <ESC> abort current edit operation
Definition: GUIAppEnum.h:223
@ MID_GNE_TOOLBARFILE_SAVEDATA_AS
save data elements as
Definition: GUIAppEnum.h:606
@ MID_HOTKEY_F10_OPTIONSMENU
open options menu
Definition: GUIAppEnum.h:195
@ MID_HOTKEY_F11_FRONTELEMENT
set/clear front element
Definition: GUIAppEnum.h:197
@ MID_HOTKEY_R_MODES_CROSSING_ROUTE_EDGERELDATA
hotkey for mode editing crossing, routes and edge rel datas
Definition: GUIAppEnum.h:59
@ MID_HOTKEY_F8_CLEANINVALID_CROSSINGS_DEMANDELEMENTS
clean invalid crossings in network mode and demand elements in demand mode
Definition: GUIAppEnum.h:191
@ MID_HOTKEY_I_MODES_INSPECT
hotkey for mode inspecting object attributes
Definition: GUIAppEnum.h:51
@ MID_LOCATEADD
Locate addtional structure - button.
Definition: GUIAppEnum.h:355
@ MID_LOCATEPOI
Locate poi - button.
Definition: GUIAppEnum.h:357
@ MID_HOTKEY_CTRL_SHIFT_W_FORCESAVEDATAELEMENTS
Force save data elements (flag)
Definition: GUIAppEnum.h:169
@ MID_HOTKEY_P_MODES_POLYGON_PERSON
hotkey for mode creating polygons
Definition: GUIAppEnum.h:55
@ MID_HOTKEY_ALT_4_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:131
@ MID_OPEN_NETWORK
Open network - ID.
Definition: GUIAppEnum.h:256
@ MID_HOTKEY_CTRL_SHIFT_U_FORCESAVEADDITIONALS
Force save additionals (flag)
Definition: GUIAppEnum.h:165
@ MID_GNE_TOOLBARFILE_SAVETLSPROGRAMS_AS
save TLS Programs as
Definition: GUIAppEnum.h:600
@ MID_HOTKEY_Z_MODES_TAZ_TAZREL
hotkey for mode editing TAZ and TAZRel
Definition: GUIAppEnum.h:67
@ MID_HOTKEY_M_MODES_MOVE
hotkey for mode moving element
Definition: GUIAppEnum.h:53
@ MID_HOTKEY_CTRL_I_EDITVIEWPORT
Open viewport editor.
Definition: GUIAppEnum.h:87
@ MID_RECENTFILE
Loads a file previously loaded.
Definition: GUIAppEnum.h:262
@ MID_HOTKEY_CTRL_J_SAVEJOINEDJUNCTIONS
save joined junctions
Definition: GUIAppEnum.h:91
@ MID_HOTKEY_F4_SUPERMODE_DATA
select data supermode in NETEDIT
Definition: GUIAppEnum.h:183
@ MID_HOTKEY_F6_CLEAN_SOLITARYJUNCTIONS_UNUSEDROUTES
clean junctions without edges in network mode and unused routes in demand mode
Definition: GUIAppEnum.h:187
@ MID_LOCATESTOP
Locate stop - button.
Definition: GUIAppEnum.h:347
@ MID_HOTKEY_CTRL_K_OPENTLSPROGRAMS
Load file with TLS Programs.
Definition: GUIAppEnum.h:93
@ MID_HOTKEY_CTRL_V_PASTE
paste the current selection / element
Definition: GUIAppEnum.h:107
@ MID_CLEARMESSAGEWINDOW
Clear simulation output.
Definition: GUIAppEnum.h:321
@ MID_HOTKEY_ALT_3_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:129
@ ID_LOADTHREAD_EVENT
The loading thread.
Definition: GUIAppEnum.h:288
@ MID_HOTKEY_ALT_5_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:133
@ MID_HOTKEY_A_MODES_ADDITIONAL_STOP
hotkey for mode editing additionals AND stops
Definition: GUIAppEnum.h:43
@ MID_HOTKEY_CTRL_C_COPY
Copy the current selection / element.
Definition: GUIAppEnum.h:79
@ MID_GNE_TOOLBARFILE_SAVEADDITIONALS_AS
save additionals as
Definition: GUIAppEnum.h:598
@ MID_GNE_TOOLBARFILE_SAVEEDGETYPES_AS
save edgeTypes as
Definition: GUIAppEnum.h:602
@ MID_HOTKEY_ALT_8_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:139
@ MID_HOTKEY_C_MODES_CONNECT_PERSONPLAN
hotkey for mode connecting lanes
Definition: GUIAppEnum.h:45
@ MID_HOTKEY_ALT_F4_CLOSE
Main window closes.
Definition: GUIAppEnum.h:143
@ MID_HOTKEY_CTRL_SHIFT_A_SAVEADDITIONALS
Save Additional Elements.
Definition: GUIAppEnum.h:151
@ MID_LOCATEEDGE
Locate edge - button.
Definition: GUIAppEnum.h:341
@ MID_HOTKEY_SHIFT_F2_TEMPLATE_COPY
copy template
Definition: GUIAppEnum.h:210
@ MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALS
Start the simulation in SUMO and open Additionals Elemements in NETEDIT.
Definition: GUIAppEnum.h:75
@ MID_LOCATEVEHICLE
Locate vehicle - button.
Definition: GUIAppEnum.h:343
@ MID_LOCATETLS
Locate TLS - button.
Definition: GUIAppEnum.h:353
@ MID_GNE_TOOLBARFILE_SAVEDEMAND_AS
save demand elements as
Definition: GUIAppEnum.h:604
@ MID_HOTKEY_CTRL_Z_UNDO
Redo.
Definition: GUIAppEnum.h:115
@ MID_HOTKEY_ALT_2_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:127
@ MID_HOTKEY_CTRL_SHIFT_T_FORCESAVENETEWORK
Force save network (flag)
Definition: GUIAppEnum.h:163
@ MID_HOTKEY_BACKSPACE
hot key <Backspace> remove last sub-operation
Definition: GUIAppEnum.h:229
@ MID_HOTKEY_F12_ABOUT
open about dialog
Definition: GUIAppEnum.h:201
@ MID_HOTKEY_ENTER
hot key <ENTER> accept current operation
Definition: GUIAppEnum.h:227
@ MID_HOTKEY_CTRL_SHIFT_K_SAVETLS
save TLS Programs
Definition: GUIAppEnum.h:159
@ MID_HOTKEY_SHIFT_F1_TEMPLATE_SET
set template
Definition: GUIAppEnum.h:208
@ MID_HOTKEY_F2_SUPERMODE_NETWORK
select network supermode in NETEDIT
Definition: GUIAppEnum.h:179
@ MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT
focus upper element of current frame (only used in NETEDIT)
Definition: GUIAppEnum.h:216
@ MID_HOTKEY_D_MODES_DELETE
hotkey for mode deleting things
Definition: GUIAppEnum.h:47
@ MID_HOTKEY_SHIFT_F3_TEMPLATE_CLEAR
clear template
Definition: GUIAppEnum.h:212
@ MID_HOTKEY_CTRL_H_OPENEDGETYPES
open edge type files
Definition: GUIAppEnum.h:85
@ MID_HOTKEY_CTRL_G_GAMINGMODE_TOOGLEGRID
Toogle Gaming mode in SUMO and grid in NETEDIT.
Definition: GUIAppEnum.h:83
@ MID_LOCATEROUTE
Locate route - button.
Definition: GUIAppEnum.h:345
@ MID_HOTKEY_ALT_9_TOOGLEEDITOPTION
toogle edit option
Definition: GUIAppEnum.h:141
@ MID_HOTKEY_CTRL_L_SAVEASPLAINXML
save network as plain XML
Definition: GUIAppEnum.h:95
@ MID_HOTKEY_CTRL_X_CUT
cut the current selection / element
Definition: GUIAppEnum.h:111
@ MID_HOTKEY_CTRL_T_OPENSUMONETEDIT
Open current network in SUMO or in NETEDIT.
Definition: GUIAppEnum.h:105
@ MID_WINDOW
Main window-ID.
Definition: GUIAppEnum.h:237
GUICompleteSchemeStorage gSchemeStorage
#define GUIDesignHorizontalFrameStatusBar
Horizontal frame used in status bar.
Definition: GUIDesigns.h:272
#define GUIDesignSplitter
Definition: GUIDesigns.h:373
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:376
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:345
@ EVENT_GLDEBUG_OCCURRED
send when a gldebug occured
Definition: GUIEvent.h:52
@ EVENT_ERROR_OCCURRED
send when a error occured
Definition: GUIEvent.h:46
@ EVENT_SIMULATION_LOADED
send when a simulation has been loaded
Definition: GUIEvent.h:34
@ EVENT_DEBUG_OCCURRED
send when a debug occured
Definition: GUIEvent.h:49
@ EVENT_MESSAGE_OCCURRED
send when a message occured
Definition: GUIEvent.h:40
@ EVENT_WARNING_OCCURRED
send when a warning occured
Definition: GUIEvent.h:43
GUISelectedStorage gSelected
A global holder of selected objects.
FXString gCurrentFolder
The folder used as last.
@ MODEADDITIONAL
@ SUPERMODEDEMAND
@ NETEDIT_MINI
@ MODECREATEEDGE
@ SAVENETWORKELEMENTS
@ SUPERMODEDATA
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
long long int SUMOTime
Definition: SUMOTime.h:31
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:128
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:138
bool empty()
Definition: FXSynchQue.h:128
void pop()
Definition: FXSynchQue.h:65
static std::string addExtension(const std::string &path, const std::string &extension)
Add an extension to the given file path.
Definition: FileHelpers.cpp:85
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:48
static void resetFont()
to be called when the font context is invalidated
Definition: GLHelper.cpp:463
The application's "About" - dialog.
Definition: GNEAbout.h:33
void create()
Creates the widget.
Definition: GNEAbout.cpp:85
Builds additional objects for GNENet (busStops, chargingStations, detectors, etc.....
The main window of the Netedit.
long onCmdSaveAsNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall save network as is executed
long onCmdSaveAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals is executed
GNEApplicationWindowHelper::SupermodeCommands mySupermodeCommands
Supermode Commands.
long onCmdSaveTLSProgramsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save TLSPrograms as is executed
void create()
Creates the main window (required by FOX)
GNEApplicationWindowHelper::WindowsMenuCommands myWindowsMenuCommands
Windows Menu Commands.
GNELoadThread * myLoadThread
the thread that loads the network
GNENet * myNet
we are responsible for the net
long onCmdSaveEdgeTypes(FXObject *, FXSelector, void *)
called when the command/FXCall save edge types is executed
void handleEvent_Message(GUIEvent *e)
hanlde event of type message
bool continueWithUnsavedDemandElementChanges(const std::string &operation)
warns about unsaved changes in demand elements and gives the user the option to abort
long onCmdLoadAdditionalsInSUMOGUI(FXObject *, FXSelector, void *)
called when user toogle windows checkbox "load additionals"
long onCmdOpenTLSPrograms(FXObject *, FXSelector, void *)
called when the command/FXCall open TLS programs is executed
void updateControls()
update control contents after undo/redo or recompute
long computeJunctionWithVolatileOptions()
called if the user selects Processing->compute junctions with volatile options
long onCmdNewNetwork(FXObject *, FXSelector, void *)
long onCmdToogleGrid(FXObject *, FXSelector, void *)
called if the user press key combination Ctrl + G to toogle grid
GNEApplicationWindow()
FOX needs this for static members.
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
called when the command/FXCall clipboard request is executed
FXMenuPane * myFileMenuAdditionals
long onUpdSaveNetwork(FXObject *, FXSelector, void *)
called when the update/FXCall save network is executed
std::string myUndoRedoListEnabled
string to check if undo/redo list is enabled (a String is used to keep the disabling reason)
std::string myConfigPattern
Input file pattern.
long onCmdClose(FXObject *, FXSelector, void *)
called when the command/FXCall close is executed
long onCmdEditViewport(FXObject *, FXSelector, void *)
Called on menu Edit->Viewport.
void enableSaveAdditionalsMenu()
enable save additionals
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
GNEApplicationWindowHelper::MenuBarFile myMenuBarFile
MenuBarFile.
long onCmdOpenAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall open additionals is executed
long onCmdForceSaveDataElements(FXObject *sender, FXSelector sel, void *ptr)
force save data elements (flag)
long onCmdForceSaveAdditionals(FXObject *sender, FXSelector sel, void *ptr)
force save additionals (flag)
long onUpdRedo(FXObject *obj, FXSelector sel, void *ptr)
called when the update/FXCall redo is executed
long onUpdReload(FXObject *, FXSelector, void *)
called when the update/FXCall reload is executed
GNEApplicationWindowHelper::ProcessingMenuCommands myProcessingMenuCommands
Edit Menu Commands.
void setStatusBarText(const std::string &statusBarText)
set text of the statusBar
GNEUndoList * myUndoList
the one and only undo list
long onUpdSaveDataElements(FXObject *, FXSelector, void *)
called when the update/FXCall save data elements is executed
long onCmdPaste(FXObject *, FXSelector, void *)
long onCmdSaveAsPlainXML(FXObject *, FXSelector, void *)
called when the command/FXCall save as plain xml is executed
void disableSaveDemandElementsMenu()
disable save demand elements
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall open network is executed
void closeAllWindows()
this method closes all windows and deletes the current simulation *‍/
long onCmdForceSaveNetwork(FXObject *sender, FXSelector sel, void *ptr)
force save network (flag)
long onCmdCopyTemplate(FXObject *, FXSelector, void *)
void enableSaveDataElementsMenu()
enable save data elements
long onLoadThreadEvent(FXObject *, FXSelector, void *)
called when the command/FXCall load thread is executed
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
long onUpdSaveDemandElements(FXObject *, FXSelector, void *)
called when the update/FXCall save demand elements is executed
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 *‍/
SUMOTime getCurrentSimTime() const
get current simulation time (pure virtual but we don't need it)
long onCmdOptions(FXObject *, FXSelector, void *)
called if the user selects Processing->Configure Options
long onKeyPress(FXObject *o, FXSelector sel, void *data)
called when a key is pressed
void disableSaveAdditionalsMenu()
disable save additionals
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
long onCmdSaveEdgeTypesAs(FXObject *, FXSelector, void *)
called when the command/FXCall save edgeTypes as is executed
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
called when the command/FXCall clear message windows is executed
long onCmdClearTemplate(FXObject *, FXSelector, void *)
GNEUndoList * getUndoList()
get pointer to undoList
long onUpdNeedsFrontElement(FXObject *, FXSelector, void *)
called when the update/FXCall needs front element is executed
long onCmdProcessButton(FXObject *, FXSelector sel, void *)
called when user press a process button (or a shortcut)
void loadOptionOnStartup()
load net on startup
GNEViewNet * getViewNet()
get pointer to viewNet
long onCmdSaveAdditionalsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals as is executed
bool hadDependentBuild
check if had dependent build
GNEApplicationWindowHelper::LocateMenuCommands myLocateMenuCommands
Locate Menu Commands.
bool continueWithUnsavedChanges(const std::string &operation)
warns about unsaved changes and gives the user the option to abort
long onCmdUndo(FXObject *, FXSelector, void *)
called when user press Ctrl+Z
long onCmdAbout(FXObject *, FXSelector, void *)
called when the command/FXCall show about dialog is executed
void dependentBuild()
build dependent
FXMenuPane * myFileMenuDemandElements
long onCmdEditChosen(FXObject *, FXSelector, void *)
called when the command/FXCall edit chosen is executed
GNEApplicationWindowHelper::EditMenuCommands myEditMenuCommands
Edit Menu Commands.
long onCmdForceSaveDemandElements(FXObject *sender, FXSelector sel, void *ptr)
force save demand elements (flag)
long onCmdSetSuperMode(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits an edit-supermode hotkey
long onCmdAbort(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits esc
GNEViewNet * myViewNet
pointer to current view net
const FXString myTitlePrefix
the prefix for the window title
void enableSaveTLSProgramsMenu()
enable save TLS Programs
double getTrackerInterval() const
get current tracker interval (pure virtual but we don't need it)
long onCmdReload(FXObject *, FXSelector, void *)
called when the command/FXCall reload is executed
void disableSaveDataElementsMenu()
disable save data elements
void fillMenuBar()
Builds the menu bar.
long onCmdFocusFrame(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits f
long onCmdToogleEditOptions(FXObject *, FXSelector, void *)
called if the user press key combination Alt + <0-9>
long onCmdHelp(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Documentation
long onCmdSaveDemandElements(FXObject *, FXSelector, void *)
called when the command/FXCall save demand elements is executed
long onCmdCut(FXObject *, FXSelector, void *)
called when user press Ctrl+Z
long onCmdOpenEdgeTypes(FXObject *, FXSelector, void *)
called when the command/FXCall open edgeType is executed
void enableSaveDemandElementsMenu()
enable save demand elements
long onCmdLoadDemandInSUMOGUI(FXObject *, FXSelector, void *)
called when user toogle windows checkbox "load demand"
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
called when the command/FXCall open configuration is executed
long onUpdSaveAdditionals(FXObject *, FXSelector, void *)
called when the update/FXCall save additionals is executed
long onCmdSaveDemandElementsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save demand elements as is executed
long onCmdSaveDataElementsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save data elements as is executed
GNEApplicationWindowHelper::FileMenuCommands myFileMenuCommands
File Menu Commands.
long onCmdOpenRecent(FXObject *, FXSelector, void *)
called when the command/FXCall open recent is executed
long onUpdOpen(FXObject *, FXSelector, void *)
called when the command/FXCall on update open executed
long onCmdSetMode(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits an edit-mode hotkey
long onCmdBackspace(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits backspace
void handleEvent_NetworkLoaded(GUIEvent *e)
handle event of type Network loaded
long onCmdCopy(FXObject *, FXSelector, void *)
long onCmdOpenSUMOGUI(FXObject *sender, FXSelector sel, void *ptr)
called if the user hints ctrl + T
void disableUndoRedo(const std::string &reason)
disable undo-redo giving a string with the reason
long onCmdOpenDemandElements(FXObject *, FXSelector, void *)
called when the command/FXCall open demand is executed
FXSynchQue< GUIEvent * > myEvents
List of got requests.
void enableUndoRedo()
disable undo-redo
bool continueWithUnsavedAdditionalChanges(const std::string &operation)
warns about unsaved changes in additionals and gives the user the option to abort
const std::string & isUndoRedoEnabled() const
check if undo-redo is enabled
long onUpdNeedsNetwork(FXObject *, FXSelector, void *)
called when the update/FXCall needs network is executed
GNEApplicationWindowHelper::ToolbarsGrip & getToolbarsGrip()
get ToolbarsGrip
long onCmdSaveDataElements(FXObject *, FXSelector, void *)
called when the command/FXCall save data elements is executed
long onCmdLocate(FXObject *, FXSelector, void *)
called when the command/FXCall locate is executed
long onCmdDel(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits del
long onCmdOpenDataElements(FXObject *, FXSelector, void *)
called when the command/FXCall open data is executed
void updateSuperModeMenuCommands(const Supermode supermode)
update FXMenuCommands depending of supermode
long onCmdSetFrontElement(FXObject *, FXSelector, void *)
called if the user call set front element
long onCmdEnter(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits enter
FXCursor * getDefaultCursor()
get default cursor
long onCmdSetTemplate(FXObject *, FXSelector, void *)
long onCmdRedo(FXObject *, FXSelector, void *)
long onUpdUndo(FXObject *obj, FXSelector sel, void *ptr)
called when the update/FXCall undo is executed
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
FXSplitter * myMainSplitter
The splitter that divides the main window into view and the log window.
long onCmdSaveTLSPrograms(FXObject *, FXSelector, void *)
called when the command/FXCall save TLSPrograms is executed
long onCmdSaveJoined(FXObject *, FXSelector, void *)
called when the command/FXCall save joined is executed
long onCmdSaveNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall save network is executed
FXMenuPane * myFileMenu
the submenus
GNEApplicationWindowHelper::ToolbarsGrip myToolbarsGrip
Toolbars Grip.
FXMenuPane * myFileMenuDataElements
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
called when a key is released
FXGLCanvas * getBuildGLCanvas() const
get build GL Canvas (must be implemented in all children)
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
Called on menu Edit->Visualization.
long onCmdOpenForeign(FXObject *, FXSelector, void *)
called when the command/FXCall open foreign is executed
void refreshEdgeTypeSelector()
refresh edge type selector
EdgeTypeSelector * getEdgeTypeSelector() const
getcustom edge selector
Builds data objects for GNENet (busStops, chargingStations, detectors, etc..)
const std::vector< GNELaneType * > & getLaneTypes() const
get laneTypes
Definition: GNEEdgeType.cpp:87
std::string mySettingsFile
the name of the settings file to load
bool myViewportFromRegistry
whether loading viewport from registry
std::string myFile
the name of the loaded file
GNENet * myNet
the loaded net
virtual void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame (can be reimplemented in frame children)
Definition: GNEFrame.cpp:151
void refreshNeteditAttributesEditor(bool forceRefresh)
refresh netedit attributes
void clearTemplate()
clear template (used by shortcut)
void setTemplate()
set template (used by shortcut)
void copyTemplate()
copy template (used by shortcut)
void inspectSingleElement(GNEAttributeCarrier *AC)
Inspect a single element.
TemplateEditor * getTemplateEditor() const
get template editor
GNEInspectorFrame::NeteditAttributesEditor * getNeteditAttributesEditor() const
get Netedit Attributes editor
void loadConfigOrNet(const std::string &file, bool isNet, bool useStartupOptions, bool newNet=false)
begins the loading of a netconvert configuration or a a network
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
static void setDefaultOptions(OptionsCont &oc)
sets required options for proper functioning
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition: GNENet.cpp:1933
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of additionals of the net.
Definition: GNENet.cpp:2349
bool joinSelectedJunctions(GNEUndoList *undoList)
join selected junctions
Definition: GNENet.cpp:1744
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:1059
void saveDemandElements(const std::string &filename)
save demand element elements of the network
Definition: GNENet.cpp:2487
void saveTLSPrograms(const std::string &filename)
save TLS Programs elements of the network
Definition: GNENet.cpp:3060
int getNumberOfDemandElements(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of demand elements of the net.
Definition: GNENet.cpp:2462
bool isNetSaved() const
return if net has to be saved
Definition: GNENet.cpp:1053
void enableUpdateData()
Definition: GNENet.cpp:3127
void requireSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:1047
void saveEdgeTypes(const std::string &filename)
save edgeTypes elements of the network
Definition: GNENet.cpp:3081
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:1082
void requireSaveAdditionals(bool value)
inform that additionals has to be saved
Definition: GNENet.cpp:2361
void cleanInvalidDemandElements(GNEUndoList *undoList)
clean invalid demand elements
Definition: GNENet.cpp:2040
void cleanUnusedRoutes(GNEUndoList *undoList)
clean unused routes
Definition: GNENet.cpp:1950
void computeNetwork(GNEApplicationWindow *window, bool force=false, bool volatileOptions=false, std::string additionalPath="", std::string demandPath="", std::string dataPath="")
trigger full netbuild computation param[in] window The window to inform about delay param[in] force W...
Definition: GNENet.cpp:1603
bool isAdditionalsSaved() const
check if additionals are saved
Definition: GNENet.cpp:2419
void disableUpdateData()
disable update data elements after inserting or removing an element in net
Definition: GNENet.cpp:3140
int getNumberOfDataSets() const
Returns the number of data sets of the net.
Definition: GNENet.cpp:2639
bool cleanInvalidCrossings(GNEUndoList *undoList)
clear invalid crossings
Definition: GNENet.cpp:1881
void joinRoutes(GNEUndoList *undoList)
join routes
Definition: GNENet.cpp:1976
void requireSaveDemandElements(bool value)
inform that demand elements has to be saved
Definition: GNENet.cpp:2474
void requireSaveDataElements(bool value)
inform that data sets has to be saved
Definition: GNENet.cpp:2645
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:1090
void saveDataElements(const std::string &filename)
save data set elements of the network
Definition: GNENet.cpp:2658
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:2374
bool isDataElementsSaved() const
check if data sets are saved
Definition: GNENet.cpp:2671
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
void computeDemandElements(GNEApplicationWindow *window)
compute demand elements param[in] window The window to inform about delay
Definition: GNENet.cpp:1659
bool isDemandElementsSaved() const
check if demand elements are saved
Definition: GNENet.cpp:2533
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
const std::vector< TAZCurrent::TAZEdge > & getEdgeAndTAZChildrenSelected() const
get map with edge and TAZChildren
void clearSelectedEdges()
clear current TAZ children
TAZSelectionStatistics * getTAZSelectionStatisticsModul() const
get TAZ Selection Statistics modul
bool parseTLSPrograms(const std::string &file)
parse TLS Programs from a file
void undo()
undo the last command group
void p_clear()
clears the undo list (implies abort)
Definition: GNEUndoList.cpp:89
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:71
void redo()
redo the last command group
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:78
long p_onUpdUndo(FXObject *, FXSelector, void *)
long p_onUpdRedo(FXObject *, FXSelector, void *)
event after Redo
void enableIntervalBarUpdate()
enable interval bar update
void disableIntervalBarUpdate()
enable interval bar update
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:491
GNENet * getNet() const
get the net object
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
void hotkeyBackSpace()
handle backspace keypress
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:467
void abortOperation(bool clearSelection=true)
abort current edition operation
Definition: GNEViewNet.cpp:998
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:479
void hotkeyFocusFrame()
handle focus frame keypress
GNEViewNetHelper::IntervalBar & getIntervalBar()
get interval bar
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
void saveVisualizationSettings() const
Definition: GNEViewNet.cpp:439
long onCmdSetSupermode(FXObject *, FXSelector sel, void *)
long onCmdSetMode(FXObject *, FXSelector sel, void *)
called when user press a mode button (Network or demand)
void hotkeyEnter()
handle enter keypress
void forceSupermodeNetwork()
set supermode Network (used after load/create new network)
Definition: GNEViewNet.cpp:325
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
long onCmdToogleShowGrid(FXObject *, FXSelector, void *)
toogle show grid
void updateControls()
update control contents after undo/redo or recompute
void hotkeyDel()
handle del keypress
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:485
void setFrontAttributeCarrier(const GNEAttributeCarrier *AC)
set front attributeCarrier
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:81
void updateUndoRedoButtons()
update toolbar undo/redo buttons (called when user press Ctrl+Z/Y)
long onKeyPress(FXObject *o, FXSelector sel, void *data)
Called when user press a key.
GNETAZFrame * getTAZFrame() const
get frame for NETWORK_TAZ
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for NETWORK_TLS
GNEInspectorFrame * getInspectorFrame() const
get frame for inspect elements
GNECreateEdgeFrame * getCreateEdgeFrame() const
get frame for NETWORK_CREATEEDGE
GNEFrame * getCurrentShownFrame() const
get current frame (note: it can be null)
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
Called when user releases a key.
void saveViewport(const double x, const double y, const double z, const double rot)
Makes the given viewport the default.
static void initCursors(FXApp *a)
Initiate GUICursorSubSys.
static FXMenuTitle * buildFXMenuTitle(FXComposite *p, const std::string &text, FXIcon *icon, FXMenuPane *menuPane)
build menu title
Definition: GUIDesigns.cpp:29
static FXMenuCommand * buildFXMenuCommandShortcut(FXComposite *p, const std::string &text, const std::string &shortcut, const std::string &info, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:51
Editor for the list of chosen objects.
const std::string & getMsg() const
Returns the message.
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:77
GUISUMOAbstractView * getView() const
return GUISUMOAbstractView
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static void initIcons(FXApp *a)
Initiate GUIIconSubSys.
static void close()
close GUIIconSubSys
void setWindowSizeAndPos()
perform initial window positioning and sizing according to user options / previous call
std::vector< FXMainWindow * > myTrackerWindows
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
FXMDIClient * myMDIClient
The multi view panel.
FXHorizontalFrame * myGeoFrame
FXLabel * myGeoCoordinate
FXHorizontalFrame * myCartesianFrame
FXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
void storeWindowSizeAndPos()
record window position and size in registry
FXStatusBar * myStatusbar
The status bar.
FXGLVisual * myGLVisual
The gl-visual used.
std::vector< GUIGlChildWindow * > myGLWindows
A logging window for the gui.
void addSeparator()
Adds a a separator to this log window.
void unregisterMsgHandlers()
unregister message handlers
void clear()
Clears the window.
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
void registerMsgHandlers()
register message handlers
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
void addDecals(const std::vector< Decal > &decals)
add decals
void showViewschemeEditor()
show viewsscheme editor
GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings
virtual void showViewportEditor()
show viewport editor
GUIPerspectiveChanger & getChanger() const
get changer
virtual void setViewportFromToRot(const Position &lookFrom, const Position &lookAt, double rotation)
applies the given viewport settings
An XML-handler for visualisation schemes.
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
static void buildNETEDITAccelerators(GNEApplicationWindow *GNEApp)
build NETEDIT Accelerators
static void close()
close GUITextureSubSys
static void resetTextures()
Reset textures.
static void initTextures(FXApp *a)
Initiate GUITextureSubSys for textures.
static std::string clipped
Definition: GUIUserIO.h:58
bool showGrid
Information whether a grid shall be shown.
static void resetLoaded()
resets loaded location elements
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:82
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:60
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NBFrame.cpp:647
A storage for available edgeTypes of edges.
Definition: NBTypeCont.h:52
int size() const
Returns the number of known edgeTypes.
Definition: NBTypeCont.cpp:223
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NIFrame.cpp:346
static bool load(SUMOSAXHandler *handler, const std::vector< std::string > &files, const std::string &type, const bool stringParse=false)
Importer for edge type information stored in XML.
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NWFrame.cpp:125
A storage for options typed value containers)
Definition: OptionsCont.h:89
void unSet(const std::string &name, bool failOnNonExistant=true) const
Marks the option as unset.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
void resetWritable()
Resets all options to be writeable.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
void set(double x, double y)
set positions x and y
Definition: Position.h:84
double x() const
Returns the x-position.
Definition: Position.h:54
double y() const
Returns the y-position.
Definition: Position.h:59
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static unsigned long runHiddenCommand(const std::string &cmd)
run a shell command without popping up any windows (particuarly on win32)
Definition: SysUtils.cpp:64
static bool checkOptions()
checks shared options and sets StdDefs
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:65
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:148
@ SEL_THREAD_EVENT
Definition: fxexdefs.h:187
@ SEL_THREAD
Definition: fxexdefs.h:169
DataMenuCommands dataMenuCommands
Data Menu Commands.
void buildEditMenuCommands(FXMenuPane *editMenu)
build edit menu commands
DemandMenuCommands demandMenuCommands
Demand Menu Commands.
FXMenuCheck * loadAdditionalsInSUMOGUI
menu check for load additionals in SUMO GUI
FXMenuCommand * undoLastChange
FXMenuCommand for undo last change.
FXMenuCheck * loadDemandInSUMOGUI
menu check for load demand in SUMO GUI
FXMenuCommand * redoLastChange
FXMenuCommand for redo last change.
NetworkMenuCommands networkMenuCommands
Network Menu Commands.
FXMenuCommand * saveTLSPrograms
FXMenuCommand for enable or disable save additionals.
FXMenuCommand * saveEdgeTypes
FXMenuCommand for enable or disable save edgeTypes.
FXMenuCommand * saveDemandElementsAs
FXMenuCommand for enable or disable save demand elements as.
FXMenuCommand * saveDataElementsAs
FXMenuCommand for enable or disable save data elements as.
FXMenuCommand * saveAdditionals
FXMenuCommand for enable or disable save additionals.
FXMenuCommand * saveDemandElements
FXMenuCommand for enable or disable save demand elements.
FXMenuCommand * saveDataElements
FXMenuCommand for enable or disable save data elements.
void buildFileMenuCommands(FXMenuPane *fileMenu, FXMenuPane *fileMenuTLS, FXMenuPane *fileMenuEdgeTypes, FXMenuPane *fileMenuAdditionals, FXMenuPane *fileMenuDemandElements, FXMenuPane *fileMenuDataElements)
build menu commands
FXMenuCommand * saveAdditionalsAs
FXMenuCommand for enable or disable save additionals As.
void buildLocateMenuCommands(FXMenuPane *locateMenu)
build menu commands
void buildRecentFiles(FXMenuPane *fileMenu)
build recent files
FXRecentFiles myRecentConfigs
List of recent config files.
FXRecentFiles myRecentNets
List of recent nets.
void showDataProcessingMenuCommands()
show data processing menu commands
void showDemandProcessingMenuCommands()
show demand processing menu commands
void hideDemandProcessingMenuCommands()
show demand processing menu commands
void hideDataProcessingMenuCommands()
show data processing menu commands
void showNetworkProcessingMenuCommands()
show network processing menu commands
void buildProcessingMenuCommands(FXMenuPane *editMenu)
build menu commands
void hideNetworkProcessingMenuCommands()
show network processing menu commands
void buildSupermodeCommands(FXMenuPane *editMenu)
build menu commands
void buildMenuToolbarsGrip()
build menu toolbar grips
FXMenuBar * menu
The application menu bar (for file, edit, processing...)
void buildWindowsMenuCommands(FXMenuPane *windowsMenu, FXStatusBar *statusbar, GUIMessageWindow *messageWindow)
build menu commands
static bool toogleEditOptionsNetwork(GNEViewNet *viewNet, const MFXCheckableButton *menuCheck, const int numericalKeyPressed, FXObject *obj, FXSelector sel)
toogle edit options Network menu commands (called in GNEApplicationWindow::onCmdToogleEditOptions)
static bool toogleEditOptionsData(GNEViewNet *viewNet, const MFXCheckableButton *menuCheck, const int numericalKeyPressed, FXObject *obj, FXSelector sel)
toogle edit options Data menu commands (called in GNEApplicationWindow::onCmdToogleEditOptions)
static bool toogleEditOptionsDemand(GNEViewNet *viewNet, const MFXCheckableButton *menuCheck, const int numericalKeyPressed, FXObject *obj, FXSelector sel)
toogle edit options Demand menu commands (called in GNEApplicationWindow::onCmdToogleEditOptions)
void getVisibleDataMenuCommands(std::vector< MFXCheckableButton * > &commands) const
get visible demand menu commands
void getVisibleDemandMenuCommands(std::vector< MFXCheckableButton * > &commands) const
get visible demand menu commands
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
void getVisibleNetworkMenuCommands(std::vector< MFXCheckableButton * > &commands) const
get visible network menu commands