SUMO - Simulation of Urban MObility
GNEApplicationWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The main window of Netedit (adapted from GUIApplicationWindow)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #ifdef HAVE_VERSION_H
32 #include <version.h>
33 #endif
34 
35 #include <string>
36 #include <sstream>
37 #include <algorithm>
38 
40 #include <utils/common/TplCheck.h>
41 #include <utils/common/ToString.h>
44 #include <utils/xml/XMLSubSys.h>
60 #include <netimport/NIFrame.h>
61 
62 #include "GNEApplicationWindow.h"
63 #include "GNELoadThread.h"
64 #include "GNEEvent_NetworkLoaded.h"
65 #include "GNEViewParent.h"
66 #include "GNEViewNet.h"
67 #include "GNEDialog_About.h"
68 #include "GNEDialog_Wizard.h"
69 #include "GNENet.h"
70 #include "GNEEdge.h"
71 #include "GNEJunction.h"
72 #include "GNEUndoList.h"
73 #include "GNEPOI.h"
74 #include "GNEAdditionalHandler.h"
75 
76 
77 #ifdef CHECK_MEMORY_LEAKS
78 #include <foreign/nvwa/debug_new.h>
79 #endif
80 
81 
82 // ===========================================================================
83 // FOX-declarations
84 // ===========================================================================
85 FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[] = {
86  //________Message_Type____________ID________________________Message_Handler________
87  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GNEApplicationWindow::onCmdQuit),
88  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GNEApplicationWindow::onCmdQuit),
89  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GNEApplicationWindow::onCmdQuit),
90 
98  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GNEApplicationWindow::onCmdReload),
99  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GNEApplicationWindow::onCmdClose),
100  FXMAPFUNC(SEL_UPDATE, MID_CLOSE, GNEApplicationWindow::onUpdNeedsNetwork),
101 
102  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GNEApplicationWindow::onCmdAbout),
104 
106  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GNEApplicationWindow::onUpdOpen),
107  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GNEApplicationWindow::onUpdOpen),
111  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GNEApplicationWindow::onUpdReload),
112  FXMAPFUNC(SEL_UPDATE, MID_RECENTFILE, GNEApplicationWindow::onUpdOpen),
113  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNEApplicationWindow::onClipboardRequest),
114 
115  // forward requests to the active view
116  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GNEApplicationWindow::onCmdLocate),
117  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GNEApplicationWindow::onCmdLocate),
118  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GNEApplicationWindow::onCmdLocate),
122  FXMAPFUNC(SEL_KEYPRESS, 0, GNEApplicationWindow::onKeyPress),
123  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEApplicationWindow::onKeyRelease),
124 
127 
130  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_MOVE, GNEApplicationWindow::onCmdSetMode),
140  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_TLS, GNEApplicationWindow::onCmdSetMode),
146 
152  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_PLAIN_XML, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
154  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_JOINED, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
156  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_POIS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
158  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_ADDITIONALS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
160  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_ADDITIONALS_AS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
161 
162  FXMAPFUNC(SEL_COMMAND, MID_GNE_ABORT, GNEApplicationWindow::onCmdAbort),
163  FXMAPFUNC(SEL_COMMAND, MID_GNE_HOTKEY_DEL, GNEApplicationWindow::onCmdDel),
165  FXMAPFUNC(SEL_COMMAND, MID_HELP, GNEApplicationWindow::onCmdHelp),
172  FXMAPFUNC(SEL_COMMAND, MID_GNE_OPTIONS, GNEApplicationWindow::onCmdOptions),
173 };
174 
175 // Object implementation
176 FXIMPLEMENT(GNEApplicationWindow, FXMainWindow, GNEApplicationWindowMap, ARRAYNUMBER(GNEApplicationWindowMap))
177 
178 // ===========================================================================
179 // member method definitions
180 // ===========================================================================
181 #ifdef _MSC_VER
182 #pragma warning(disable: 4355)
183 #endif
184 GNEApplicationWindow::GNEApplicationWindow(FXApp* a, const std::string& configPattern) :
185  GUIMainWindow(a),
186  myLoadThread(0),
187  myAmLoading(false),
188  myRecentNets(a, "nets"),
189  myConfigPattern(configPattern),
190  hadDependentBuild(false),
191  myNet(0),
192  myUndoList(new GNEUndoList(this)),
193  myTitlePrefix("NETEDIT " VERSION_STRING) {
194  // init icons
196  // init Textures
198 }
199 #ifdef _MSC_VER
200 #pragma warning(default: 4355)
201 #endif
202 
203 
204 void
206  // do this not twice
207  if (hadDependentBuild) {
208  WRITE_ERROR("DEBUG: GNEApplicationWindow::dependentBuild called twice");
209  return;
210  }
211  hadDependentBuild = true;
212 
213  setTarget(this);
214  setSelector(MID_WINDOW);
215 
216  // build menu bar
217  myMenuBarDrag = new FXToolBarShell(this, GUIDesignToolBarShell3);
218  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag, GUIDesignBar);
219  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP, GUIDesignToolBarGrip);
220  // build the thread - io
223 
224  // build the status bar
225  myStatusbar = new FXStatusBar(this, GUIDesignStatusBar);
226  {
227  myGeoFrame =
228  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
229  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
231  new FXHorizontalFrame(myStatusbar, GUIDesignHorizontalFrameStatusBar);
232  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
233  }
234  // make the window a mdi-window
235  myMainSplitter = new FXSplitter(this, GUIDesignSplitter | SPLITTER_VERTICAL | SPLITTER_REVERSED);
236  myMDIClient = new FXMDIClient(myMainSplitter, GUIDesignSplitterMDI);
237  myMDIMenu = new FXMDIMenu(this, myMDIClient);
238  // Due netedit only have a view, this buttons must be disabled (see #2807)
239  //new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient, FXMDIClient::ID_MDI_MENUWINDOW, GUIDesignMDIButtonLeft);
240  //new FXMDIDeleteButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUCLOSE, GUIDesignMDIButtonRight);
241  //new FXMDIRestoreButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENURESTORE, GUIDesignMDIButtonRight);
242  //new FXMDIMinimizeButton(myMenuBar, myMDIClient, FXMDIClient::ID_MDI_MENUMINIMIZE, GUIDesignMDIButtonRight);
243 
244  // build the message window
246  myMainSplitter->setSplit(1, 65);
247  // fill menu and tool bar
248  fillMenuBar();
249  // build additional threads
250  myLoadThread = new GNELoadThread(getApp(), this, myEvents, myLoadThreadEvent);
251  // set the status bar
252  myStatusbar->getStatusLine()->setText("Ready.");
253  // set the caption
254  setTitle(myTitlePrefix);
255 
257 
258  //initialize some hotkeys
259  getAccelTable()->addAccel(parseAccel("e"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CREATE_EDGE));
260  getAccelTable()->addAccel(parseAccel("m"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_MOVE));
261  getAccelTable()->addAccel(parseAccel("d"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_DELETE));
262  getAccelTable()->addAccel(parseAccel("i"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_INSPECT));
263  getAccelTable()->addAccel(parseAccel("s"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_SELECT));
264  getAccelTable()->addAccel(parseAccel("c"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CONNECT));
265  getAccelTable()->addAccel(parseAccel("t"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_TLS));
266  getAccelTable()->addAccel(parseAccel("a"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_ADDITIONAL));
267  getAccelTable()->addAccel(parseAccel("r"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CROSSING));
268  getAccelTable()->addAccel(parseAccel("Esc"), this, FXSEL(SEL_COMMAND, MID_GNE_ABORT));
269  getAccelTable()->addAccel(parseAccel("Del"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_DEL));
270  getAccelTable()->addAccel(parseAccel("Enter"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_ENTER));
271 }
272 
273 void
276  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
277  FXMainWindow::create();
278  myMenuBarDrag->create();
279  myFileMenu->create();
280  myEditMenu->create();
281  //mySettingsMenu->create();
282  myWindowsMenu->create();
283  myHelpMenu->create();
284 
285  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 22;
286  myCartesianFrame->setWidth(width);
287  myGeoFrame->setWidth(width);
288 
289  show(PLACEMENT_DEFAULT);
290  if (!OptionsCont::getOptions().isSet("window-size")) {
291  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
292  maximize();
293  }
294  }
295 
296 }
297 
298 
300  closeAllWindows();
301  // Close icons
303  // Close gifs (Textures)
305  delete myGLVisual;
306  // must delete menus to avoid segfault on removing accelerators
307  // (http://www.fox-toolkit.net/faq#TOC-What-happens-when-the-application-s)
308  delete myFileMenu;
309  delete myEditMenu;
310  delete myLocatorMenu;
311  delete myProcessingMenu;
312  delete myWindowsMenu;
313  delete myHelpMenu;
314 
315  delete myLoadThread;
316 
317  while (!myEvents.empty()) {
318  // get the next event
319  GUIEvent* e = myEvents.top();
320  myEvents.pop();
321  delete e;
322  }
323  delete myUndoList;
324 }
325 
326 
327 void
329  FXMainWindow::detach();
330  myMenuBarDrag->detach();
331 }
332 
333 
334 void
336  // build file menu
337  myFileMenu = new FXMenuPane(this);
338  new FXMenuTitle(myMenuBar, "&File", 0, myFileMenu);
339  new FXMenuCommand(myFileMenu,
340  "&New Network...\tCtrl+N\tCreate a new network.",
342  new FXMenuCommand(myFileMenu,
343  "&Open Network...\tCtrl+O\tOpen a SUMO network.",
345  new FXMenuCommand(myFileMenu,
346  "Open Configura&tion...\tCtrl+T\tOpen a NETCONVERT configuration file.",
348  new FXMenuCommand(myFileMenu,
349  "Import &Foreign Network...\t\tImport a foreign network such as OSM.",
351  new FXMenuCommand(myFileMenu,
352  "Load S&hapes...\tCtrl+P\tLoad shapes into the network view.",
354  new FXMenuCommand(myFileMenu,
355  "Load A&dditionals...\tCtrl+D\tLoad additional elements.",
357  new FXMenuCommand(myFileMenu,
358  "&Reload\tCtrl+R\tReloads the network.",
360  new FXMenuCommand(myFileMenu,
361  "&Save Network...\tCtrl+S\tSave the network.",
363  new FXMenuCommand(myFileMenu,
364  "Save Net&work As...\tCtrl+Shift+S\tSave the network in another file.",
366  new FXMenuCommand(myFileMenu,
367  "Save plain XM&L...\tCtrl+L\tSave plain xml representation the network.",
369  new FXMenuCommand(myFileMenu,
370  "Save &joined junctions...\tCtrl+J\tSave log of joined junctions (allows reproduction of joins).",
372  new FXMenuCommand(myFileMenu,
373  "Save POIs As ...\tCtrl+Shift+P\tSave the POIs.",
375  new FXMenuCommand(myFileMenu,
376  "Save additionals\tCtrl+Shift+D\tSave additional elements.",
378  new FXMenuCommand(myFileMenu,
379  "Save additionals As...\t\tSave additional elements in another file.",
381  new FXMenuSeparator(myFileMenu);
382  new FXMenuCommand(myFileMenu,
383  "Close\tCtrl+W\tClose the net&work.",
385  // Recent files
386  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
387  sep1->setTarget(&myRecentConfigs);
388  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
389  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
390  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
391  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
392  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
393  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
394  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
395  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
396  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
397  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
398  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
399  new FXMenuCommand(myFileMenu, "Clear Recent Configurat&ions", 0, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
400  myRecentConfigs.setTarget(this);
401  myRecentConfigs.setSelector(MID_RECENTFILE);
402  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
403  sep2->setTarget(&myRecentNets);
404  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
405  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
406  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
407  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
408  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
409  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
410  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
411  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
412  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
413  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
414  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
415  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", 0, &myRecentNets, FXRecentFiles::ID_CLEAR);
416  myRecentNets.setTarget(this);
417  myRecentNets.setSelector(MID_RECENTFILE);
418  new FXMenuSeparator(myFileMenu);
419  new FXMenuCommand(myFileMenu,
420  "&Quit\tCtrl+Q\tQuit the Application.",
421  0, this, MID_QUIT, 0);
422 
423  // build edit menu
424  myEditMenu = new FXMenuPane(this);
425  new FXMenuTitle(myMenuBar, "&Edit", 0, myEditMenu);
426 
427  // build undo/redo command
428  new FXMenuCommand(myEditMenu,
429  "&Undo\tCtrl+Z\tUndo the last change.",
430  GUIIconSubSys::getIcon(ICON_UNDO), myUndoList, FXUndoList::ID_UNDO);
431  new FXMenuCommand(myEditMenu,
432  "&Redo\tCtrl+Y\tRedo the last change.",
433  GUIIconSubSys::getIcon(ICON_REDO), myUndoList, FXUndoList::ID_REDO);
434 
435  new FXMenuSeparator(myEditMenu);
436 
437  // build modes command
438  new FXMenuCommand(myEditMenu,
439  "&Edge mode\tE\tCreate junction and edges.",
441  new FXMenuCommand(myEditMenu,
442  "&Move mode\tM\tMove elements.",
444  new FXMenuCommand(myEditMenu,
445  "&Delete mode\tD\tDelete elements.",
447  new FXMenuCommand(myEditMenu,
448  "&Inspect mode\tI\tInspect elements and change their attributes.",
450  new FXMenuCommand(myEditMenu,
451  "&Select mode\tS\tSelect elements.",
453  new FXMenuCommand(myEditMenu,
454  "&Connection mode\tC\tEdit connections between lanes.",
456  new FXMenuCommand(myEditMenu,
457  "&Traffic light mode\tT\tEdit traffic lights over junctions.",
459  new FXMenuCommand(myEditMenu,
460  "&Additional mode\tA\tCreate additional elements.",
462  new FXMenuCommand(myEditMenu,
463  "C&rossing mode\tR\tCreate crossings between edges.",
465 
466  /*
467  new FXMenuSeparator(myEditMenu);
468  new FXMenuCommand(myEditMenu,
469  "Edit Breakpoints...\t\tOpens a Dialog for editing breakpoints.",
470  0, this, MID_EDIT_BREAKPOINTS);
471  */
472 
473  // processing menu (trigger netbuild computations)
474  myProcessingMenu = new FXMenuPane(this);
475  new FXMenuTitle(myMenuBar, "&Processing", 0, myProcessingMenu);
476  new FXMenuCommand(myProcessingMenu,
477  "Compute Junctions\tF5\tComputes junction shape and logic.",
479  new FXMenuCommand(myProcessingMenu,
480  "Clean Junctions\tF6\tRemoves solitary junctions.",
482  new FXMenuCommand(myProcessingMenu,
483  "Join Selected Junctions\tF7\tJoins selected junctions into a single junction.",
485  new FXMenuCommand(myProcessingMenu,
486  "Options\tF10\t\tConfigure Processing Options.",
488  // build settings menu
489  /*
490  mySettingsMenu = new FXMenuPane(this);
491  new FXMenuTitle(myMenuBar,"&Settings",0,mySettingsMenu);
492  new FXMenuCheck(mySettingsMenu,
493  "Gaming Mode\t\tToggle gaming mode on/off.",
494  this,MID_GAMING);
495  */
496  // build Locate menu
497  myLocatorMenu = new FXMenuPane(this);
498  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
499  new FXMenuCommand(myLocatorMenu,
500  "Locate &Junctions\tShift+J\tOpen a Dialog for Locating a Junction.",
502  new FXMenuCommand(myLocatorMenu,
503  "Locate &Edges\tShift+E\tOpen a Dialog for Locating an Edge.",
505  new FXMenuCommand(myLocatorMenu,
506  "Locate &TLS\tShift+T\tOpen a Dialog for Locating a Traffic Light.",
508 
509  // build windows menu
510  myWindowsMenu = new FXMenuPane(this);
511  new FXMenuTitle(myMenuBar, "&Windows", 0, myWindowsMenu);
512  new FXMenuCheck(myWindowsMenu,
513  "&Show Status Line\t\tToggle this Status Bar on/off.",
514  myStatusbar, FXWindow::ID_TOGGLESHOWN);
515  new FXMenuCheck(myWindowsMenu,
516  "Show &Message Window\t\tToggle the Message Window on/off.",
517  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
518  /*
519  new FXMenuSeparator(myWindowsMenu);
520  new FXMenuCommand(myWindowsMenu,"Tile &Horizontally",
521  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_HORI),
522  myMDIClient,FXMDIClient::ID_MDI_TILEHORIZONTAL);
523  new FXMenuCommand(myWindowsMenu,"Tile &Vertically",
524  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_VERT),
525  myMDIClient,FXMDIClient::ID_MDI_TILEVERTICAL);
526  new FXMenuCommand(myWindowsMenu,"C&ascade",
527  GUIIconSubSys::getIcon(ICON_WINDOWS_CASCADE),
528  myMDIClient,FXMDIClient::ID_MDI_CASCADE);
529  new FXMenuCommand(myWindowsMenu,"&Close",0,
530  myMDIClient,FXMDIClient::ID_MDI_CLOSE);
531  sep1=new FXMenuSeparator(myWindowsMenu);
532  sep1->setTarget(myMDIClient);
533  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
534  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_1);
535  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_2);
536  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_3);
537  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_4);
538  new FXMenuCommand(myWindowsMenu,"&Others...",0,myMDIClient,FXMDIClient::ID_MDI_OVER_5);
539  new FXMenuSeparator(myWindowsMenu);
540  */
541  new FXMenuCommand(myWindowsMenu,
542  "&Clear Message Window\t\tClear the message window.",
543  0, this, MID_CLEARMESSAGEWINDOW);
544 
545  // build help menu
546  myHelpMenu = new FXMenuPane(this);
547  new FXMenuTitle(myMenuBar,
548  "&Help",
549  0, myHelpMenu);
550  new FXMenuCommand(myHelpMenu,
551  "&Online Documentation\tF1\tOpen Online documentation.",
552  0, this, MID_HELP);
553  new FXMenuCommand(myHelpMenu,
554  "&About\tF2\tAbout netedit.",
555  0, this, MID_ABOUT);
556 }
557 
558 
559 long
560 GNEApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
562  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
563  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
564  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
565  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
566  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
567  if (isMaximized()) {
568  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 1);
569  } else {
570  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 0);
571  }
572  getApp()->exit(0);
573  }
574  return 1;
575 }
576 
577 
578 long
579 GNEApplicationWindow::onCmdEditChosen(FXObject*, FXSelector, void*) {
580  GUIDialog_GLChosenEditor* chooser =
582  chooser->create();
583  chooser->show();
584  return 1;
585 }
586 
587 
588 long
589 GNEApplicationWindow::onCmdNewNetwork(FXObject*, FXSelector, void*) {
590  // ask before we clobber options
592  return 1;
593  }
597  loadConfigOrNet("", true, false, true, true);
598  return 1;
599 }
600 
601 
602 long
603 GNEApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
604  // get the new file name
605  FXFileDialog opendialog(this, "Open Netconvert Configuration");
606  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
607  opendialog.setSelectMode(SELECTFILE_EXISTING);
608  opendialog.setPatternList(myConfigPattern.c_str());
609  if (gCurrentFolder.length() != 0) {
610  opendialog.setDirectory(gCurrentFolder);
611  }
612  if (opendialog.execute()) {
613  gCurrentFolder = opendialog.getDirectory();
614  std::string file = opendialog.getFilename().text();
615  loadConfigOrNet(file, false);
616  myRecentConfigs.appendFile(file.c_str());
617  }
618  return 1;
619 }
620 
621 
622 long
623 GNEApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
624  // get the new file name
625  FXFileDialog opendialog(this, "Open Network");
626  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
627  opendialog.setSelectMode(SELECTFILE_EXISTING);
628  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
629  if (gCurrentFolder.length() != 0) {
630  opendialog.setDirectory(gCurrentFolder);
631  }
632  if (opendialog.execute()) {
633  gCurrentFolder = opendialog.getDirectory();
634  std::string file = opendialog.getFilename().text();
635  loadConfigOrNet(file, true);
636  myRecentNets.appendFile(file.c_str());
637  }
638  return 1;
639 }
640 
641 
642 long
643 GNEApplicationWindow::onCmdOpenForeign(FXObject*, FXSelector, void*) {
644  // ask before we clobber options
646  return 1;
647  }
648  // get the new file name
649  FXFileDialog opendialog(this, "Import Foreign Network");
650  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
651  opendialog.setSelectMode(SELECTFILE_EXISTING);
652  FXString osmPattern("OSM net (*.osm.xml,*.osm)");
653  opendialog.setPatternText(0, osmPattern);
654  if (gCurrentFolder.length() != 0) {
655  opendialog.setDirectory(gCurrentFolder);
656  }
657  if (opendialog.execute()) {
658  gCurrentFolder = opendialog.getDirectory();
659  std::string file = opendialog.getFilename().text();
660 
663  if (osmPattern.contains(opendialog.getPattern())) {
664  oc.set("osm-files", file);
665  oc.set("ramps.guess", "true");
666  oc.set("tls.guess", "true");
667  } else {
668  throw ProcessError("Attempted to import unknown file format '" + file + "'.");
669  }
670 
671  GNEDialog_Wizard* wizard =
672  new GNEDialog_Wizard(this, "Select Import Options", getWidth(), getHeight());
673 
674  if (wizard->execute()) {
675  NIFrame::checkOptions(); // needed to set projection parameters
676  loadConfigOrNet(file, false, false, false);
677  }
678  }
679  return 1;
680 }
681 
682 
683 long
684 GNEApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
685  // get the shape file name
686  FXFileDialog opendialog(this, "Open Shapes");
687  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
688  opendialog.setSelectMode(SELECTFILE_EXISTING);
689  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
690  if (gCurrentFolder.length() != 0) {
691  opendialog.setDirectory(gCurrentFolder);
692  }
693  if (opendialog.execute()) {
694  gCurrentFolder = opendialog.getDirectory();
695  std::string file = opendialog.getFilename().text();
696  GNEShapeHandler handler(file, myNet, myNet->getShapeContainer());
697  if (!XMLSubSys::runParser(handler, file, false)) {
698  WRITE_MESSAGE("Loading of " + file + " failed.");
699  }
700  update();
701  }
702  return 1;
703 }
704 
705 
706 long
707 GNEApplicationWindow::onCmdOpenAdditionals(FXObject*, FXSelector, void*) {
708  // get the shape file name
709  FXFileDialog opendialog(this, "Open Additional");
710  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
711  opendialog.setSelectMode(SELECTFILE_EXISTING);
712  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
713  if (gCurrentFolder.length() != 0) {
714  opendialog.setDirectory(gCurrentFolder);
715  }
716  if (opendialog.execute()) {
717  gCurrentFolder = opendialog.getDirectory();
718  std::string file = opendialog.getFilename().text();
719  // Start operation for undo/redo
720  myUndoList->p_begin("load additionals");
721  // Create additional handler
722  GNEAdditionalHandler additionalHandler(file, myNet->getViewNet());
723  // Run parser
724  if (!XMLSubSys::runParser(additionalHandler, file, false)) {
725  WRITE_MESSAGE("Loading of " + file + " failed.");
726  // Abort undo/redo
727  myUndoList->abort();
728  } else {
729  // reset last tag (needed if user want to load more additionals)
730  additionalHandler.resetLastTag();
731  // commit undo/redo operation
732  myUndoList->p_end();
733  update();
734  }
735  }
736  return 1;
737 }
738 
739 
740 long
741 GNEApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
742  if (myAmLoading) {
743  myStatusbar->getStatusLine()->setText("Already loading!");
744  return 1;
745  }
746  std::string file((const char*)data);
747  loadConfigOrNet(file, sender == &myRecentNets);
748  return 1;
749 }
750 
751 
752 long
753 GNEApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
754  // @note. If another network has been load during this session, it might not be desirable to set useStartupOptions
755  loadConfigOrNet(OptionsCont::getOptions().getString("sumo-net-file"), true, true);
756  return 1;
757 }
758 
759 
760 long
761 GNEApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
763  closeAllWindows();
764  }
765  return 1;
766 }
767 
768 
769 long
770 GNEApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
771  if (myMDIClient->numChildren() > 0) {
772  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
773  if (w != 0) {
774  w->onCmdLocate(0, sel, 0);
775  }
776  }
777  return 1;
778 }
779 
780 long
781 GNEApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void*) {
782  sender->handle(this, myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
783  return 1;
784 }
785 
786 
787 long
788 GNEApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
790  return 1;
791 }
792 
793 
794 long
795 GNEApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
796  GNEDialog_About* about = new GNEDialog_About(this);
797  about->create();
798  about->show(PLACEMENT_OWNER);
799  return 1;
800 }
801 
802 
803 long GNEApplicationWindow::onClipboardRequest(FXObject*, FXSelector, void* ptr) {
804  FXEvent* event = (FXEvent*)ptr;
805  FXString string = GUIUserIO::clipped.c_str();
806  setDNDData(FROM_CLIPBOARD, event->target, string);
807  return 1;
808 }
809 
810 
811 long
812 GNEApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
813  eventOccured();
814  return 1;
815 }
816 
817 
818 void
820  while (!myEvents.empty()) {
821  // get the next event
822  GUIEvent* e = myEvents.top();
823  myEvents.pop();
824  // process
825  switch (e->getOwnType()) {
828  break;
831  case EVENT_ERROR_OCCURED:
833  break;
834  default:
835  break;
836  }
837  delete e;
838  }
839 }
840 
841 
842 void
844  myAmLoading = false;
845  GNEEvent_NetworkLoaded* ec = static_cast<GNEEvent_NetworkLoaded*>(e);
846  // check whether the loading was successfull
847  if (ec->myNet == 0) {
848  // report failure
849  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
850  } else {
851  myNet = ec->myNet;
852  // report success
853  setStatusBarText("'" + ec->myFile + "' loaded.");
854  // initialise views
855  myViewNumber = 0;
857  if (view && ec->mySettingsFile != "") {
858  GUISettingsHandler settings(ec->mySettingsFile);
859  std::string settingsName = settings.addSettings(view);
860  view->addDecals(settings.getDecals());
861  settings.applyViewport(view);
862  settings.setSnapshots(view);
863  }
864  // set network name on the caption
865  setTitle(MFXUtils::getTitleText(myTitlePrefix, ec->myFile.c_str()));
867  gSchemeStorage.setViewport(getView()); // refit the network to accomodate mode specific panel
868  if (ec->myViewportFromRegistry) {
869  Position off, p;
870  off.set(getApp()->reg().readRealEntry("viewport", "x"), getApp()->reg().readRealEntry("viewport", "y"), getApp()->reg().readRealEntry("viewport", "z"));
871  getView()->setViewportFromTo(off, p);
872  }
873  }
874  getApp()->endWaitCursor();
876  // check if additionals has to be loaded at start
877  if (OptionsCont::getOptions().isSet("sumo-additionals-file") && myNet) {
878  myAdditionalsFile = OptionsCont::getOptions().getString("sumo-additionals-file");
879  WRITE_MESSAGE("Loading additionals from '" + myAdditionalsFile + "'");
881  // Run parser
882  if (!XMLSubSys::runParser(additionalHandler, myAdditionalsFile, false)) {
883  WRITE_ERROR("Loading of " + myAdditionalsFile + " failed.");
884  } else {
885  // reset last tag (needed if user want to load more additionals)
886  additionalHandler.resetLastTag();
887  }
888  }
889  // check if additionals output must be changed
890  if (OptionsCont::getOptions().isSet("additionals-output")) {
891  myAdditionalsFile = OptionsCont::getOptions().getString("additionals-output");
892  }
893 
894  update();
895 }
896 
897 
898 void
900  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
902 }
903 
904 
905 void
906 GNEApplicationWindow::loadConfigOrNet(const std::string file, bool isNet, bool isReload, bool useStartupOptions, bool newNet) {
908  return;
909  }
910  getApp()->beginWaitCursor();
911  myAmLoading = true;
912  closeAllWindows();
913  if (isReload) {
914  myLoadThread->start();
915  setStatusBarText("Reloading.");
916  } else {
917  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
918  myLoadThread->loadConfigOrNet(file, isNet, useStartupOptions, newNet);
919  setStatusBarText("Loading '" + file + "'.");
920  }
921  update();
922 }
923 
924 
925 
928  std::string caption = "View #" + toString(myViewNumber++);
929  FXuint opts = MDI_TRACKING;
930  GNEViewParent* viewParent = new GNEViewParent(myMDIClient, myMDIMenu, FXString(caption.c_str()), this, getBuildGLCanvas(),
931  myNet, myUndoList, NULL, opts, 10, 10, 300, 200);
932  if (myMDIClient->numChildren() == 1) {
933  viewParent->maximize();
934  } else {
935  myMDIClient->vertical(true);
936  }
937  myMDIClient->setActiveChild(viewParent);
938  //v->grabKeyboard();
939  return viewParent->getView();
940 }
941 
942 
943 FXGLCanvas*
945  if (myMDIClient->numChildren() == 0) {
946  return 0;
947  }
948  GNEViewParent* share_tmp1 =
949  static_cast<GNEViewParent*>(myMDIClient->childAtIndex(0));
950  return share_tmp1->getBuildGLCanvas();
951 }
952 
953 
954 SUMOTime
956  return 0;
957 }
958 
959 
962  return myUndoList;
963 }
964 
965 
966 void
969  // remove trackers and other external windows
970  for (int i = 0; i < (int)mySubWindows.size(); ++i) {
971  mySubWindows[i]->destroy();
972  }
973  for (int i = 0; i < (int)myTrackerWindows.size(); ++i) {
974  myTrackerWindows[i]->destroy();
975  }
976  // reset the caption
977  setTitle(myTitlePrefix);
978  // delete other children
979  while (myTrackerWindows.size() != 0) {
980  delete myTrackerWindows[0];
981  }
982  while (mySubWindows.size() != 0) {
983  delete mySubWindows[0];
984  }
985  mySubWindows.clear();
986  // clear selected items
987  gSelected.clear();
988  // add a separator to the log
991  // remove coordinate information
992  myGeoCoordinate->setText("N/A");
993  myCartesianCoordinate->setText("N/A");
994 
995  myUndoList->p_clear();
996  if (myNet != 0) {
997  delete myNet;
998  myNet = 0;
1000  }
1002  // Reset textures
1004 }
1005 
1006 
1007 FXCursor*
1009  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1010 }
1011 
1012 
1013 void
1015  const OptionsCont& oc = OptionsCont::getOptions();
1016  loadConfigOrNet("", true, false, true, oc.getBool("new"));
1017 }
1018 
1019 
1020 void
1021 GNEApplicationWindow::setStatusBarText(const std::string& statusBarText) {
1022  myStatusbar->getStatusLine()->setText(statusBarText.c_str());
1023  myStatusbar->getStatusLine()->setNormalText(statusBarText.c_str());
1024 }
1025 
1026 
1027 void
1028 GNEApplicationWindow::setAdditionalsFile(const std::string& additionalsFile) {
1029  myAdditionalsFile = additionalsFile;
1030 }
1031 
1032 
1033 long
1034 GNEApplicationWindow::onCmdSetMode(FXObject*, FXSelector sel, void*) {
1035  if (getView()) {
1036  getView()->setEditModeFromHotkey(FXSELID(sel));
1037  }
1038  return 1;
1039 }
1040 
1041 
1042 long
1043 GNEApplicationWindow::onCmdAbort(FXObject*, FXSelector, void*) {
1044  if (getView()) {
1045  getView()->abortOperation();
1046  getView()->update();
1047  }
1048  return 1;
1049 }
1050 
1051 
1052 long
1053 GNEApplicationWindow::onCmdDel(FXObject*, FXSelector, void*) {
1054  if (getView()) {
1055  getView()->hotkeyDel();
1056  }
1057  return 1;
1058 }
1059 
1060 
1061 long
1062 GNEApplicationWindow::onCmdEnter(FXObject*, FXSelector, void*) {
1063  if (getView()) {
1064  getView()->hotkeyEnter();
1065  }
1066  return 1;
1067 }
1068 
1069 
1070 long
1071 GNEApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
1072  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/NETEDIT");
1073  return 1;
1074 }
1075 
1076 
1077 long
1078 GNEApplicationWindow::onCmdComputeJunctions(FXObject*, FXSelector, void*) {
1079  myNet->computeEverything(this, true);
1080  updateControls();
1081  return 1;
1082 }
1083 
1084 
1085 long
1086 GNEApplicationWindow::onCmdCleanJunctions(FXObject*, FXSelector, void*) {
1088  return 1;
1089 }
1090 
1091 
1092 long
1093 GNEApplicationWindow::onCmdJoinJunctions(FXObject*, FXSelector, void*) {
1095  return 1;
1096 }
1097 
1098 
1099 long
1100 GNEApplicationWindow::onCmdOptions(FXObject*, FXSelector, void*) {
1101  GNEDialog_Wizard* wizard =
1102  new GNEDialog_Wizard(this, "Configure Options", getWidth(), getHeight());
1103 
1104  if (wizard->execute()) {
1105  NIFrame::checkOptions(); // needed to set projection parameters
1106  }
1107  return 1;
1108 }
1109 
1110 
1111 long
1112 GNEApplicationWindow::onCmdSaveAsNetwork(FXObject*, FXSelector, void*) {
1113  FXString file = MFXUtils::getFilename2Write(this,
1114  "Save Network as", ".net.xml",
1116  gCurrentFolder);
1117  if (file == "") {
1118  return 1;
1119  }
1121  oc.resetWritable();
1122  oc.set("output-file", file.text());
1123  setTitle(MFXUtils::getTitleText(myTitlePrefix, file));
1124  onCmdSaveNetwork(0, 0, 0);
1125  return 1;
1126 }
1127 
1128 
1129 long
1130 GNEApplicationWindow::onCmdSaveAsPlainXML(FXObject*, FXSelector, void*) {
1131  FXString file = MFXUtils::getFilename2Write(this,
1132  "Select name of the plain-xml edge-file (other names will be deduced from this)", "",
1134  gCurrentFolder);
1135  if (file == "") {
1136  return 1;
1137  }
1139  bool wasSet = oc.isSet("plain-output-prefix");
1140  std::string oldPrefix = oc.getString("plain-output-prefix");
1141  oc.resetWritable();
1142  std::string prefix = file.text();
1143  // if last character is a dot, remove it
1144  if (prefix.at(prefix.size() - 1) == '.') {
1145  prefix = prefix.substr(0, prefix.size() - 1);
1146  }
1147  oc.set("plain-output-prefix", prefix);
1148  getApp()->beginWaitCursor();
1149  try {
1150  myNet->savePlain(oc);
1151  myUndoList->unmark();
1152  myUndoList->mark();
1153  } catch (IOError& e) {
1154  FXMessageBox::error(this, MBOX_OK, "Saving plain xml failed!", "%s", e.what());
1155  }
1156  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Plain XML saved with prefix '" + prefix + "'.\n");
1158  if (wasSet) {
1159  oc.resetWritable();
1160  oc.set("plain-output-prefix", oldPrefix);
1161  } else {
1162  oc.unSet("plain-output-prefix");
1163  }
1164  getApp()->endWaitCursor();
1165  return 1;
1166 }
1167 
1168 
1169 long
1170 GNEApplicationWindow::onCmdSaveJoined(FXObject*, FXSelector, void*) {
1171  FXString file = MFXUtils::getFilename2Write(this,
1172  "Select name of the joined-junctions file", ".nod.xml",
1174  gCurrentFolder);
1175  if (file == "") {
1176  return 1;
1177  }
1179  bool wasSet = oc.isSet("junctions.join-output");
1180  std::string oldFile = oc.getString("junctions.join-output");
1181  oc.resetWritable();
1182  std::string filename = file.text();
1183  oc.set("junctions.join-output", filename);
1184  getApp()->beginWaitCursor();
1185  try {
1186  myNet->saveJoined(oc);
1187  } catch (IOError& e) {
1188  FXMessageBox::error(this, MBOX_OK, "Saving joined junctions failed!", "%s", e.what());
1189  }
1190  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Joined junctions saved to '" + filename + "'.\n");
1192  if (wasSet) {
1193  oc.resetWritable();
1194  oc.set("junctions.join-output", oldFile);
1195  } else {
1196  oc.unSet("junctions.join-output");
1197  }
1198  getApp()->endWaitCursor();
1199  return 1;
1200 }
1201 
1202 
1203 long
1204 GNEApplicationWindow::onCmdSavePois(FXObject*, FXSelector, void*) {
1205  FXString file = MFXUtils::getFilename2Write(this,
1206  "Select name of the POI file", ".xml",
1208  gCurrentFolder);
1209  if (file == "") {
1210  return 1;
1211  }
1212  std::string filename = file.text();
1213  // XXX Not yet implemented
1214  getApp()->beginWaitCursor();
1215  try {
1216  GNEPOI::saveToFile(filename);
1217  } catch (IOError& e) {
1218  FXMessageBox::error(this, MBOX_OK, "Saving POIs failed!", "%s", e.what());
1219  }
1221  getApp()->endWaitCursor();
1222  return 1;
1223 }
1224 
1225 
1226 long
1227 GNEApplicationWindow::onUpdNeedsNetwork(FXObject* sender, FXSelector, void*) {
1228  sender->handle(this, myNet == 0 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1229  return 1;
1230 }
1231 
1232 
1233 long
1234 GNEApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void*) {
1235  sender->handle(this, myNet == 0 || !OptionsCont::getOptions().isSet("sumo-net-file") ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1236  return 1;
1237 }
1238 
1239 
1240 long
1241 GNEApplicationWindow::onCmdSaveNetwork(FXObject*, FXSelector, void*) {
1243  // function onCmdSaveAsNetwork must be executed if this is the first save
1244  if (oc.getString("output-file") == "") {
1245  return onCmdSaveAsNetwork(0, 0, 0);
1246  } else {
1247  getApp()->beginWaitCursor();
1248  try {
1249  myNet->save(oc);
1250  myUndoList->unmark();
1251  myUndoList->mark();
1252  } catch (IOError& e) {
1253  FXMessageBox::error(this, MBOX_OK, "Saving Network failed!", "%s", e.what());
1254  }
1255  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Network saved in " + oc.getString("output-file") + ".\n");
1257  getApp()->endWaitCursor();
1258  return 1;
1259  }
1260 }
1261 
1262 
1263 long
1264 GNEApplicationWindow::onCmdSaveAdditionals(FXObject*, FXSelector, void*) {
1265  // Check if additionals file was already set at start of netedit or with a previous save
1266  if (myAdditionalsFile == "") {
1267  FXString file = MFXUtils::getFilename2Write(this,
1268  "Select name of the additional file", ".xml",
1270  gCurrentFolder);
1271  if (file == "") {
1272  // None additionals file was selected, then stop function
1273  return 1;
1274  } else {
1275  myAdditionalsFile = file.text();
1276  }
1277  }
1278  // Start saving additionals
1279  getApp()->beginWaitCursor();
1280  try {
1282  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Additionals saved in " + myAdditionalsFile + ".\n");
1283  } catch (IOError& e) {
1284  FXMessageBox::error(this, MBOX_OK, "Saving additionals failed!", "%s", e.what());
1285  }
1287  getApp()->endWaitCursor();
1288  return 1;
1289 }
1290 
1291 
1292 long
1293 GNEApplicationWindow::onCmdSaveAdditionalsAs(FXObject*, FXSelector, void*) {
1294  // Open window to select additionasl file
1295  FXString file = MFXUtils::getFilename2Write(this,
1296  "Select name of the additional file", ".xml",
1298  gCurrentFolder);
1299  if (file != "") {
1300  // Set new additional file
1301  myAdditionalsFile = file.text();
1302  // save additionals
1303  return onCmdSaveAdditionals(0, 0, 0);
1304  } else {
1305  return 1;
1306  }
1307 }
1308 
1309 
1310 long
1311 GNEApplicationWindow::onUpdSaveNetwork(FXObject* sender, FXSelector, void*) {
1313  bool enable = myNet != 0 && oc.isSet("output-file");
1314  sender->handle(this, FXSEL(SEL_COMMAND, enable ? ID_ENABLE : ID_DISABLE), 0);
1315  if (enable) {
1316  FXString caption = ("Save " + oc.getString("output-file")).c_str();
1317  sender->handle(this, FXSEL(SEL_COMMAND, FXMenuCaption::ID_SETSTRINGVALUE), (void*)&caption);
1318  }
1319  return 1;
1320 }
1321 
1322 
1323 GNEViewNet*
1325  if (mySubWindows.size() != 0) {
1326  return (GNEViewNet*)(((GUIGlChildWindow*)mySubWindows[0])->getView());
1327  } else {
1328  return 0;
1329  }
1330 }
1331 
1332 
1333 bool
1335  if (myUndoList->canUndo() && !myUndoList->marked()) {
1336  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
1337  "Confirm Closing Network", "%s",
1338  "You have unsaved changes. Do you wish to close the network and discard all changes?");
1339  if (answer == 1) { //1:yes, 2:no, 4:esc
1340  myUndoList->p_clear(); // only ask once
1341  return true;
1342  } else {
1343  return false;
1344  }
1345  } else {
1346  return true;
1347  }
1348 }
1349 
1350 
1352  ShapeHandler(file, sc),
1353  myNet(net) {}
1354 
1355 
1357 
1358 
1359 Position
1360 GNEApplicationWindow::GNEShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, SUMOReal lanePos) {
1361  std::string edgeID = laneID;
1362  int lane = 0;
1363  const std::string::size_type underscore = laneID.rfind('_');
1364 
1365  if (underscore != std::string::npos) {
1366  edgeID = laneID.substr(0, underscore);
1367  lane = TplConvert::_2intSec(laneID.substr(underscore).c_str(), 0);
1368  }
1369  NBEdge* edge = myNet->retrieveEdge(edgeID)->getNBEdge();
1370  if (edge == 0 || edge->getNumLanes() <= lane) {
1371  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1372  return Position::INVALID;
1373  }
1374  if (lanePos < 0) {
1375  lanePos = edge->getLength() + lanePos;
1376  }
1377  return edge->getLanes()[lane].shape.positionAtOffset(lanePos);
1378 }
1379 
1380 
1381 void
1383  GNEViewNet* view = getView();
1384  if (view != 0) {
1385  view->updateControls();
1386  }
1387 }
1388 
1389 
1390 long
1391 GNEApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1392  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1393  if (handled == 0 && myMDIClient->numChildren() > 0) {
1394  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1395  if (w != 0) {
1396  w->onKeyPress(0, sel, data);
1397  }
1398  }
1399  return 0;
1400 }
1401 
1402 
1403 long
1404 GNEApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1405  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1406  if (handled == 0 && myMDIClient->numChildren() > 0) {
1407  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1408  if (w != 0) {
1409  w->onKeyRelease(0, sel, data);
1410  }
1411  }
1412  return 0;
1413 }
1414 
1415 /****************************************************************************/
std::vector< FXMainWindow * > myTrackerWindows
std::string myConfigPattern
Input file pattern.
About SUMO - ID.
Definition: GUIAppEnum.h:87
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1201
FXMenuBar * myMenuBar
The application menu bar.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
GUICompleteSchemeStorage gSchemeStorage
void pop()
Definition: MFXEventQue.h:53
long onKeyPress(FXObject *o, FXSelector sel, void *data)
Called when user press a key.
static std::string clipped
Definition: GUIUserIO.h:64
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:732
long long int SUMOTime
Definition: SUMOTime.h:43
long onCmdNewNetwork(FXObject *, FXSelector, void *)
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
void setAdditionalsFile(const std::string &additionalsFile)
set additionals file
void abortOperation(bool clearSelection=true)
abort current edition operation
Definition: GNEViewNet.cpp:889
void setStatusBarText(const std::string &statusBarText)
set text of the statusBar
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
MFXEventQue< GUIEvent * > myEvents
List of got requests.
void resetWritable()
Resets all options to be writeable.
GNEUndoList * getUndoList()
get pointer to undoList
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
long onCmdReload(FXObject *, FXSelector, void *)
called when the command/FXCall reload is executed
void create()
Creates the widget.
void closeAllWindows()
this method closes all windows and deletes the current simulation */
virtual void setViewportFromTo(const Position &lookFrom, const Position &lookAt)
applies the given viewport settings
void joinSelectedJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:1007
send when a message occured
Definition: GUIEvent.h:50
FXRecentFiles myRecentConfigs
List of recent config files.
long onCmdSaveAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals is executed
bool empty()
Definition: MFXEventQue.h:72
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
The main window of the Netedit.
#define GUIDesignSplitterMDI
MDI Splitter.
Definition: GUIDesigns.h:279
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
called when the command/FXCall clear message windows is executed
void loadConfigOrNet(const std::string &file, bool isNet, bool useStartupOptions, bool newNet=false)
begins the loading of a netconvert configuration or a a network
const std::string & getMsg() const
Returns the message.
virtual void create()
Creates the main window (required by FOX)
long onCmdJoinJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->join junctions
void unSet(const std::string &name, bool failOnNonExistant=true) const
Marks the option as unset.
bool hadDependentBuild
check if had dependent build
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:71
static void initIcons(FXApp *a)
Initiate GUIIconSubSys.
GNEUndoList * myUndoList
the one and only undo list
long onCmdComputeJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->compute junctions
static void resetTextures()
Reset textures.
void registerMsgHandlers()
register and unregister message handlers
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:937
long onCmdSetMode(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits an edit-mode hotkey
void handleEvent_NetworkLoaded(GUIEvent *e)
handle event of type Network loaded
#define GUIDesignStatusBar
design used in status bar
Definition: GUIDesigns.h:248
Locate TLS - button.
Definition: GUIAppEnum.h:181
mode for editing crossing
Definition: GUIAppEnum.h:450
void loadConfigOrNet(const std::string file, bool isNet, bool isReload=false, bool useStartupOptions=false, bool newNet=false)
starts to load a netimport configuration or a network */
void setWindowSizeAndPos()
perform initial window positioning and sizing according to user options / previous call ...
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
Definition: GUIDesigns.h:251
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
called when a key is released
#define GUIDesignSplitter
Definition: GUIDesigns.h:276
Load additional file with additional elements.
Definition: GUIAppEnum.h:79
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
Called when user releases a key.
Editor for the list of chosen objects.
bool continueWithUnsavedChanges()
warns about unsaved changes and gives the user the option to abort
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:81
FXGLVisual * myGLVisual
The gl-visual used.
long onCmdOpenForeign(FXObject *, FXSelector, void *)
called when the command/FXCall open foreign is executed
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:87
long onCmdSaveNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall save network is executed
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:86
long onCmdAbout(FXObject *, FXSelector, void *)
called when the command/FXCall show about dialog is executed
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
Definition: GNEViewNet.cpp:940
mode for editing tls
Definition: GUIAppEnum.h:446
FXString gCurrentFolder
The folder used as last.
Open configuration - ID.
Definition: GUIAppEnum.h:73
Storage for geometrical objects.
long onUpdNeedsNetwork(FXObject *, FXSelector, void *)
called when the upadte/FXCall needs network is executed
std::string myFile
the name of the loaded file
long onLoadThreadEvent(FXObject *, FXSelector, void *)
called when the command/FXCall load thread is executed
static void resetLoaded()
resets loaded location elements
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
Close simulation - ID.
Definition: GUIAppEnum.h:85
Loads a file previously loaded.
Definition: GUIAppEnum.h:83
Open network - ID.
Definition: GUIAppEnum.h:75
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:114
void updateControls()
update control contents after undo/redo or recompute
Locate junction - button.
Definition: GUIAppEnum.h:173
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:95
virtual FXGLCanvas * getBuildGLCanvas() const
long onCmdEditChosen(FXObject *, FXSelector, void *)
called when the command/FXCall edit chosen is executed
void updateControls()
update control contents after undo/redo or recompute
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
void addDecals(const std::vector< Decal > &decals)
add decals
GUISUMOAbstractView * openNewView()
opens a new simulation display
GNENet * myNet
the loaded net
long onUpdReload(FXObject *, FXSelector, void *)
called when the update/FXCall reload is executed
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:72
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
long onCmdHelp(FXObject *sender, FXSelector sel, void *ptr)
called if the user selects help->Documentation
The application&#39;s "About" - dialog.
void addSeparator()
Adds a a separator to this log window.
void p_clear()
clears the undo list (implies abort)
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
called when the command/FXCall clipboard request is executed
The XML-Handler for network loading.
Definition: ShapeHandler.h:56
static void setDefaultOptions(OptionsCont &oc)
sets required options for proper functioning
Main window closes.
Definition: GUIAppEnum.h:55
mode for adding edges
Definition: GUIAppEnum.h:434
FXHorizontalFrame * myCartesianFrame
FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[]
long onCmdSaveAdditionalsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals as is executed
#define new
Definition: debug_new.h:121
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
hot key <ENTER>
Definition: GUIAppEnum.h:423
std::vector< FXMDIChild * > mySubWindows
long onCmdOptions(FXObject *, FXSelector, void *)
called if the user selects Processing->Configure Options
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:84
static void close()
close GUITextureSubSys
GNEApplicationWindow()
FOX needs this for static members.
FXSplitter * myMainSplitter
The splitter that divides the main window into view and the log window.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
long onCmdOpenRecent(FXObject *, FXSelector, void *)
called when the command/FXCall open recent is executed
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall open network is executed
SUMOTime getCurrentSimTime() const
get current simulation time (pure virtual but we don&#39;t need it)
mode for inspecting object attributes
Definition: GUIAppEnum.h:440
int myViewNumber
The current view number.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:93
The loading thread.
Definition: GUIAppEnum.h:117
virtual void fillMenuBar()
Builds the menu bar.
static void saveToFile(const std::string &file)
save POIs to file
Definition: GNEPOI.cpp:178
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
Save additionals.
Definition: GUIAppEnum.h:544
Clear simulation output.
Definition: GUIAppEnum.h:156
long onCmdSaveAsPlainXML(FXObject *, FXSelector, void *)
called when the command/FXCall save as plain xml is executed
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:679
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
called when the command/FXCall open configuration is executed
std::string mySettingsFile
the name of the settings file to load
hot key <DEL>
Definition: GUIAppEnum.h:421
long onCmdOpenAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall open additionals is executed
send when a error occured
Definition: GUIEvent.h:56
#define VERSION_STRING
Definition: version.h:1
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NIFrame.cpp:285
mode for moving things
Definition: GUIAppEnum.h:436
long onCmdLocate(FXObject *, FXSelector, void *)
called when the command/FXCall locate is executed
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:137
FXCursor * getDefaultCursor()
get default cursor
Position getLanePos(const std::string &poiID, const std::string &laneID, SUMOReal lanePos)
get lane position
long onCmdCleanJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->clean junctions
mode for connecting lanes
Definition: GUIAppEnum.h:444
The XML-Handler for shapes loading network loading.
virtual ~GNEApplicationWindow()
Destructor.
long onUpdOpen(FXObject *, FXSelector, void *)
called when the command/FXCall on update open executed
GNELoadThread * myLoadThread
the thread that loads the network
FXStatusBar * myStatusbar
The status bar.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
long onCmdOpenShapes(FXObject *, FXSelector, void *)
called when the command/FXCall open shapes is executed
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
long onCmdEnter(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits enter
#define GUIDesignBar
Definition: GUIDesigns.h:245
bool myViewportFromRegistry
whether loading viewport from registry
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
mode for editing additional
Definition: GUIAppEnum.h:448
void saveViewport(const SUMOReal x, const SUMOReal y, const SUMOReal z)
Makes the given viewport the default.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
virtual void detach()
detaches the tool/menu bar
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:77
void setViewport(GUISUMOAbstractView *view)
Sets the default viewport.
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
save network
Definition: GUIAppEnum.h:538
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:147
long onCmdDel(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits del
FXRecentFiles myRecentNets
List of recent nets.
void loadOptionOnStartup()
load net on startup
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition: GNENet.cpp:1057
static void close()
close GUIIconSubSys
FXToolBarShell * myMenuBarDrag
mode for selecting objects
Definition: GUIAppEnum.h:442
FXHorizontalFrame * myGeoFrame
FXDockSite * myTopDock
A storage for options typed value containers)
Definition: OptionsCont.h:99
void set(SUMOReal x, SUMOReal y)
set positions x and y
Definition: Position.h:93
long onCmdClose(FXObject *, FXSelector, void *)
called when the command/FXCall close is executed
void clear()
Clears the list of selected objects.
std::string myAdditionalsFile
filename for load/save additionals
void lock()
lock mutex
Definition: MFXMutex.cpp:86
FXMDIClient * myMDIClient
The multi view panel.
send when a simulation has been loaded
Definition: GUIEvent.h:44
void handleEvent_Message(GUIEvent *e)
hanlde event of type message
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:706
FXGLCanvas * getBuildGLCanvas() const
get build OpenGL Canvas
send when a warning occured
Definition: GUIEvent.h:53
mode for deleting things
Definition: GUIAppEnum.h:438
#define GUIDesignHorizontalFrameStatusBar
Horizontal frame used in status bar.
Definition: GUIDesigns.h:195
long onCmdAbort(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits esc
#define SUMOReal
Definition: config.h:208
help button
Definition: GUIAppEnum.h:404
long onCmdSaveJoined(FXObject *, FXSelector, void *)
called when the command/FXCall save joined is executed
An XML-handler for visualisation schemes.
const FXString myTitlePrefix
the prefix for the window title
processing menu messages
Definition: GUIAppEnum.h:501
misc messages
Definition: GUIAppEnum.h:532
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
Definition: MFXUtils.cpp:73
GNEShapeHandler(const std::string &file, GNENet *net, ShapeContainer &sc)
Constructor.
abort current edit operation
Definition: GUIAppEnum.h:419
Locate edge - button.
Definition: GUIAppEnum.h:175
GNENet * myNet
we are responsible for the net
#define GUIDesignToolBarShell3
Definition: GUIDesigns.h:259
void dependentBuild()
build dependent
void clear()
Clears the window.
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:258
Main window-ID.
Definition: GUIAppEnum.h:53
static int _2intSec(const E *const data, int def)
converts a 0-terminated char-type array into the integer value described by it
Definition: TplConvert.h:186
void hotkeyDel()
handle del keypress
Definition: GNEViewNet.cpp:911
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
static void initTextures(FXApp *a)
Initiate GUITextureSubSys for textures.
GUISelectedStorage gSelected
A global holder of selected objects.
void hotkeyEnter()
handle enter keypress
Definition: GNEViewNet.cpp:924
long onCmdSaveAsNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall save network as is executed
GNEViewNet * getView()
convenience method
A logging window for the gui.
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1114
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:688
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:699
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
FXMenuPane * myFileMenu
the submenus
long onKeyPress(FXObject *o, FXSelector sel, void *data)
called when a key is pressed
long onUpdSaveNetwork(FXObject *, FXSelector, void *)
called when the update/FXCall save network is executed
long onCmdSavePois(FXObject *, FXSelector, void *)
called when the command/FXCall save pois is executed
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:278
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.