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-2016 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>
58 #include <netimport/NIFrame.h>
59 
60 #include "GNEApplicationWindow.h"
61 #include "GNELoadThread.h"
62 #include "GNEEvent_NetworkLoaded.h"
63 #include "GNEViewParent.h"
64 #include "GNEViewNet.h"
65 #include "GNEDialog_About.h"
66 #include "GNEDialog_Wizard.h"
67 #include "GNENet.h"
68 #include "GNEEdge.h"
69 #include "GNEJunction.h"
70 #include "GNEUndoList.h"
71 #include "GNEPOI.h"
72 #include "GNEAdditionalHandler.h"
73 
74 
75 #ifdef CHECK_MEMORY_LEAKS
76 #include <foreign/nvwa/debug_new.h>
77 #endif
78 
79 
80 // ===========================================================================
81 // FOX-declarations
82 // ===========================================================================
83 FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[] = {
84  //________Message_Type____________ID________________________Message_Handler________
85  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GNEApplicationWindow::onCmdQuit),
86  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GNEApplicationWindow::onCmdQuit),
87  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GNEApplicationWindow::onCmdQuit),
88 
96  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GNEApplicationWindow::onCmdReload),
97  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GNEApplicationWindow::onCmdClose),
98  FXMAPFUNC(SEL_UPDATE, MID_CLOSE, GNEApplicationWindow::onUpdNeedsNetwork),
99 
100  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GNEApplicationWindow::onCmdAbout),
102 
104  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GNEApplicationWindow::onUpdOpen),
105  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GNEApplicationWindow::onUpdOpen),
109  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GNEApplicationWindow::onUpdReload),
110  FXMAPFUNC(SEL_UPDATE, MID_RECENTFILE, GNEApplicationWindow::onUpdOpen),
111  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNEApplicationWindow::onClipboardRequest),
112 
113  // forward requests to the active view
114  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GNEApplicationWindow::onCmdLocate),
115  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GNEApplicationWindow::onCmdLocate),
116  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GNEApplicationWindow::onCmdLocate),
120  FXMAPFUNC(SEL_KEYPRESS, 0, GNEApplicationWindow::onKeyPress),
121  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEApplicationWindow::onKeyRelease),
122 
125 
127  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_MOVE, GNEApplicationWindow::onCmdSetMode),
132  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_TLS, GNEApplicationWindow::onCmdSetMode),
134 
140  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_PLAIN_XML, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
142  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_JOINED, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
144  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_POIS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
146  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_ADDITIONALS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
148  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_ADDITIONALS_AS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
149 
150  FXMAPFUNC(SEL_COMMAND, MID_GNE_ABORT, GNEApplicationWindow::onCmdAbort),
151  FXMAPFUNC(SEL_COMMAND, MID_GNE_HOTKEY_DEL, GNEApplicationWindow::onCmdDel),
153  FXMAPFUNC(SEL_COMMAND, MID_HELP, GNEApplicationWindow::onCmdHelp),
160  FXMAPFUNC(SEL_COMMAND, MID_GNE_OPTIONS, GNEApplicationWindow::onCmdOptions),
161 };
162 
163 // Object implementation
164 FXIMPLEMENT(GNEApplicationWindow, FXMainWindow, GNEApplicationWindowMap, ARRAYNUMBER(GNEApplicationWindowMap))
165 
166 // ===========================================================================
167 // member method definitions
168 // ===========================================================================
169 #ifdef _MSC_VER
170 #pragma warning(disable: 4355)
171 #endif
172 GNEApplicationWindow::GNEApplicationWindow(FXApp* a, const std::string& configPattern) :
173  GUIMainWindow(a),
174  myLoadThread(0),
175  myAmLoading(false),
176  myRecentNets(a, "nets"),
177  myConfigPattern(configPattern),
178  hadDependentBuild(false),
179  myNet(0),
180  myUndoList(new GNEUndoList(this)),
181  myTitlePrefix("NETEDIT " VERSION_STRING) {
182  // Load icons
184  // Load Gifs (Textures)
186 }
187 #ifdef _MSC_VER
188 #pragma warning(default: 4355)
189 #endif
190 
191 
192 void
194  // do this not twice
195  if (hadDependentBuild) {
196  WRITE_ERROR("DEBUG: GNEApplicationWindow::dependentBuild called twice");
197  return;
198  }
199  hadDependentBuild = true;
200 
201  setTarget(this);
202  setSelector(MID_WINDOW);
203 
204  // build menu bar
205  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
206  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
207  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
208  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
209  TOOLBARGRIP_DOUBLE);
210  // build the thread - io
213 
214  // build the status bar
215  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
216  {
217  myGeoFrame =
218  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
219  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
220  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
222  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
223  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
224  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
225  }
226  // make the window a mdi-window
227  myMainSplitter = new FXSplitter(this,
228  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
229  myMDIClient = new FXMDIClient(myMainSplitter,
230  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
231  myMDIMenu = new FXMDIMenu(this, myMDIClient);
232  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
233  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
234  new FXMDIDeleteButton(myMenuBar, myMDIClient,
235  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
236  new FXMDIRestoreButton(myMenuBar, myMDIClient,
237  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
238  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
239  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
240 
241  // build the message window
243  myMainSplitter->setSplit(1, 65);
244  // fill menu and tool bar
245  fillMenuBar();
246  // build additional threads
247  myLoadThread = new GNELoadThread(getApp(), this, myEvents, myLoadThreadEvent);
248  // set the status bar
249  myStatusbar->getStatusLine()->setText("Ready.");
250  // set the caption
251  setTitle(myTitlePrefix);
252 
254 
255  //initialize some hotkeys
256  getAccelTable()->addAccel(parseAccel("e"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CREATE_EDGE));
257  getAccelTable()->addAccel(parseAccel("m"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_MOVE));
258  getAccelTable()->addAccel(parseAccel("d"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_DELETE));
259  getAccelTable()->addAccel(parseAccel("i"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_INSPECT));
260  getAccelTable()->addAccel(parseAccel("s"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_SELECT));
261  getAccelTable()->addAccel(parseAccel("c"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CONNECT));
262  getAccelTable()->addAccel(parseAccel("t"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_TLS));
263  getAccelTable()->addAccel(parseAccel("a"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_ADDITIONAL));
264  getAccelTable()->addAccel(parseAccel("Esc"), this, FXSEL(SEL_COMMAND, MID_GNE_ABORT));
265  getAccelTable()->addAccel(parseAccel("Del"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_DEL));
266  getAccelTable()->addAccel(parseAccel("Enter"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_ENTER));
267 }
268 
269 void
271  int windowWidth = getApp()->reg().readIntEntry("SETTINGS", "width", 600);
272  int windowHeight = getApp()->reg().readIntEntry("SETTINGS", "height", 400);
273  const OptionsCont& oc = OptionsCont::getOptions();
274  if (oc.isSet("window-size")) {
275  std::vector<std::string> windowSize = oc.getStringVector("window-size");
276  if (windowSize.size() != 2
277  || !TplCheck::_str2int(windowSize[0])
278  || !TplCheck::_str2int(windowSize[1])) {
279  WRITE_ERROR("option window-size requires INT,INT");
280  } else {
281  windowWidth = TplConvert::_str2int(windowSize[0]);
282  windowHeight = TplConvert::_str2int(windowSize[1]);
283  }
284  }
285  if (oc.isSet("window-size") || getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
286  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
287  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
288  setWidth(windowWidth);
289  setHeight(windowHeight);
290  }
291  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
292  FXMainWindow::create();
293  myMenuBarDrag->create();
294  myFileMenu->create();
295  myEditMenu->create();
296  //mySettingsMenu->create();
297  myWindowsMenu->create();
298  myHelpMenu->create();
299 
300  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 22;
301  myCartesianFrame->setWidth(width);
302  myGeoFrame->setWidth(width);
303 
304  show(PLACEMENT_SCREEN);
305  if (!OptionsCont::getOptions().isSet("window-size")) {
306  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
307  maximize();
308  }
309  }
310 }
311 
312 
314  closeAllWindows();
315  // Close icons
317  // Close gifs (Textures)
319  delete myGLVisual;
320  // must delete menus to avoid segfault on removing accelerators
321  // (http://www.fox-toolkit.net/faq#TOC-What-happens-when-the-application-s)
322  delete myFileMenu;
323  delete myEditMenu;
324  delete myProcessingMenu;
325  delete myWindowsMenu;
326  delete myHelpMenu;
327 
328  delete myLoadThread;
329 
330  while (!myEvents.empty()) {
331  // get the next event
332  GUIEvent* e = myEvents.top();
333  myEvents.pop();
334  delete e;
335  }
336  delete myUndoList;
337 }
338 
339 
340 void
342  FXMainWindow::detach();
343  myMenuBarDrag->detach();
344 }
345 
346 
347 void
349  // build file menu
350  myFileMenu = new FXMenuPane(this);
351  new FXMenuTitle(myMenuBar, "&File", 0, myFileMenu);
352  new FXMenuCommand(myFileMenu,
353  "&New Network...\tCtrl+A\tCreate a new network.",
355  new FXMenuCommand(myFileMenu,
356  "&Open Network...\tCtrl+N\tOpen a SUMO network.",
358  new FXMenuCommand(myFileMenu,
359  "Open &Configuration...\tCtrl+O\tOpen a NETCONVERT configuration file.",
361  new FXMenuCommand(myFileMenu,
362  "Import &Foreign Network...\t\tImport a foreign network such as OSM.",
364  new FXMenuCommand(myFileMenu,
365  "Load S&hapes...\tCtrl+P\tLoad shapes into the network view.",
367  new FXMenuCommand(myFileMenu,
368  "&Load Additionals...\tCtrl+D\tLoad additional elements.",
370  new FXMenuCommand(myFileMenu,
371  "&Reload\tCtrl+R\tReloads the network.",
373  new FXMenuCommand(myFileMenu,
374  "&Save Network...\tCtrl+S\tSave the network.",
376  new FXMenuCommand(myFileMenu,
377  "Save Net&work As...\tCtrl+Shift-S\tSave the network.",
379  new FXMenuCommand(myFileMenu,
380  "Save plain &xml...\t\tSave plain xml representation the network.",
382  new FXMenuCommand(myFileMenu,
383  "Save &joined junctions...\t\tSave log of joined junctions (allows reproduction of joins).",
385  new FXMenuCommand(myFileMenu,
386  "Save &POIs As ...\t\tSave the POIs.",
388  new FXMenuCommand(myFileMenu,
389  "Save &additionals\t\tSave additional elements.",
391  new FXMenuCommand(myFileMenu,
392  "Save a&dditionals As...\t\tSave additional elements.",
394  new FXMenuSeparator(myFileMenu);
395  new FXMenuCommand(myFileMenu,
396  "Close\tCtrl+W\tClose &the network.",
398  // Recent files
399  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
400  sep1->setTarget(&myRecentConfigs);
401  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
402  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
403  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
404  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
405  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
406  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
407  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
408  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
409  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
410  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
411  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
412  new FXMenuCommand(myFileMenu, "Clear Recent Configurat&ions", 0, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
413  myRecentConfigs.setTarget(this);
414  myRecentConfigs.setSelector(MID_RECENTFILE);
415  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
416  sep2->setTarget(&myRecentNets);
417  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
418  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
419  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
420  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
421  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
422  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
423  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
424  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
425  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
426  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
427  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
428  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", 0, &myRecentNets, FXRecentFiles::ID_CLEAR);
429  myRecentNets.setTarget(this);
430  myRecentNets.setSelector(MID_RECENTFILE);
431  new FXMenuSeparator(myFileMenu);
432  new FXMenuCommand(myFileMenu,
433  "&Quit\tCtrl+Q\tQuit the Application.",
434  0, this, MID_QUIT, 0);
435 
436  // build edit menu
437  myEditMenu = new FXMenuPane(this);
438  new FXMenuTitle(myMenuBar, "&Edit", 0, myEditMenu);
439  new FXMenuCommand(myEditMenu,
440  "&Undo\tCtrl+Z\tUndo the last change.",
441  GUIIconSubSys::getIcon(ICON_UNDO), myUndoList, FXUndoList::ID_UNDO);
442  new FXMenuCommand(myEditMenu,
443  "&Redo\tCtrl+Y\tRedo the last change.",
444  GUIIconSubSys::getIcon(ICON_REDO), myUndoList, FXUndoList::ID_REDO);
445 
446 
447  /*
448  new FXMenuSeparator(myEditMenu);
449  new FXMenuCommand(myEditMenu,
450  "Edit Breakpoints...\t\tOpens a Dialog for editing breakpoints.",
451  0, this, MID_EDIT_BREAKPOINTS);
452  */
453 
454  // processing menu (trigger netbuild computations)
455  myProcessingMenu = new FXMenuPane(this);
456  new FXMenuTitle(myMenuBar, "&Processing", 0, myProcessingMenu);
457  new FXMenuCommand(myProcessingMenu,
458  "&Compute Junctions\tF5\tComputes junction shape and logic.",
459  0, this, MID_GNE_COMPUTE_JUNCTIONS);
460  new FXMenuCommand(myProcessingMenu,
461  "Clean &Junctions\tF6\tRemoves solitary junctions.",
462  0, this, MID_GNE_CLEAN_JUNCTIONS);
463  new FXMenuCommand(myProcessingMenu,
464  "Join &Selected Junctions\tF7\tJoins selected junctions into a single junction.",
465  0, this, MID_GNE_JOIN_JUNCTIONS);
466  new FXMenuCommand(myProcessingMenu,
467  "&Options\t\tConfigure Processing Options.",
468  0, this, MID_GNE_OPTIONS);
469 
470  // build settings menu
471  /*
472  mySettingsMenu = new FXMenuPane(this);
473  new FXMenuTitle(myMenuBar,"&Settings",0,mySettingsMenu);
474  new FXMenuCheck(mySettingsMenu,
475  "Gaming Mode\t\tToggle gaming mode on/off.",
476  this,MID_GAMING);
477  */
478  // build Locate menu
479  myLocatorMenu = new FXMenuPane(this);
480  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
481  new FXMenuCommand(myLocatorMenu,
482  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
484  new FXMenuCommand(myLocatorMenu,
485  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
487  new FXMenuCommand(myLocatorMenu,
488  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
490 
491  // build windows menu
492  myWindowsMenu = new FXMenuPane(this);
493  new FXMenuTitle(myMenuBar, "&Windows", 0, myWindowsMenu);
494  new FXMenuCheck(myWindowsMenu,
495  "&Show Status Line\t\tToggle this Status Bar on/off.",
496  myStatusbar, FXWindow::ID_TOGGLESHOWN);
497  new FXMenuCheck(myWindowsMenu,
498  "Show &Message Window\t\tToggle the Message Window on/off.",
499  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
500  /*
501  new FXMenuSeparator(myWindowsMenu);
502  new FXMenuCommand(myWindowsMenu,"Tile &Horizontally",
503  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_HORI),
504  myMDIClient,FXMDIClient::ID_MDI_TILEHORIZONTAL);
505  new FXMenuCommand(myWindowsMenu,"Tile &Vertically",
506  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_VERT),
507  myMDIClient,FXMDIClient::ID_MDI_TILEVERTICAL);
508  new FXMenuCommand(myWindowsMenu,"C&ascade",
509  GUIIconSubSys::getIcon(ICON_WINDOWS_CASCADE),
510  myMDIClient,FXMDIClient::ID_MDI_CASCADE);
511  new FXMenuCommand(myWindowsMenu,"&Close",0,
512  myMDIClient,FXMDIClient::ID_MDI_CLOSE);
513  sep1=new FXMenuSeparator(myWindowsMenu);
514  sep1->setTarget(myMDIClient);
515  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
516  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_1);
517  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_2);
518  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_3);
519  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_4);
520  new FXMenuCommand(myWindowsMenu,"&Others...",0,myMDIClient,FXMDIClient::ID_MDI_OVER_5);
521  new FXMenuSeparator(myWindowsMenu);
522  */
523  new FXMenuCommand(myWindowsMenu,
524  "&Clear Message Window\t\tClear the message window.",
525  0, this, MID_CLEARMESSAGEWINDOW);
526 
527  // build help menu
528  myHelpMenu = new FXMenuPane(this);
529  new FXMenuTitle(myMenuBar, "&Help", 0, myHelpMenu);
530  new FXMenuCommand(myHelpMenu, "&Online Documentation", 0, this, MID_HELP);
531  new FXMenuCommand(myHelpMenu, "&About", 0, this, MID_ABOUT);
532 }
533 
534 
535 long
536 GNEApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
538  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
539  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
540  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
541  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
542  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
543  if (isMaximized()) {
544  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 1);
545  } else {
546  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 0);
547  }
548  getApp()->exit(0);
549  }
550  return 1;
551 }
552 
553 
554 long
555 GNEApplicationWindow::onCmdEditChosen(FXObject*, FXSelector, void*) {
556  GUIDialog_GLChosenEditor* chooser =
558  chooser->create();
559  chooser->show();
560  return 1;
561 }
562 
563 
564 long
565 GNEApplicationWindow::onCmdNewNetwork(FXObject*, FXSelector, void*) {
566  // ask before we clobber options
568  return 1;
569  }
573  loadConfigOrNet("", true, false, true, true);
574  return 1;
575 }
576 
577 
578 long
579 GNEApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
580  // get the new file name
581  FXFileDialog opendialog(this, "Open Netconvert Configuration");
582  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
583  opendialog.setSelectMode(SELECTFILE_EXISTING);
584  opendialog.setPatternList(myConfigPattern.c_str());
585  if (gCurrentFolder.length() != 0) {
586  opendialog.setDirectory(gCurrentFolder);
587  }
588  if (opendialog.execute()) {
589  gCurrentFolder = opendialog.getDirectory();
590  std::string file = opendialog.getFilename().text();
591  loadConfigOrNet(file, false);
592  myRecentConfigs.appendFile(file.c_str());
593  }
594  return 1;
595 }
596 
597 
598 long
599 GNEApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
600  // get the new file name
601  FXFileDialog opendialog(this, "Open Network");
602  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
603  opendialog.setSelectMode(SELECTFILE_EXISTING);
604  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
605  if (gCurrentFolder.length() != 0) {
606  opendialog.setDirectory(gCurrentFolder);
607  }
608  if (opendialog.execute()) {
609  gCurrentFolder = opendialog.getDirectory();
610  std::string file = opendialog.getFilename().text();
611  loadConfigOrNet(file, true);
612  myRecentNets.appendFile(file.c_str());
613  }
614  return 1;
615 }
616 
617 
618 long
619 GNEApplicationWindow::onCmdOpenForeign(FXObject*, FXSelector, void*) {
620  // ask before we clobber options
622  return 1;
623  }
624  // get the new file name
625  FXFileDialog opendialog(this, "Import Foreign Network");
626  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
627  opendialog.setSelectMode(SELECTFILE_EXISTING);
628  FXString osmPattern("OSM net (*.osm.xml,*.osm)");
629  opendialog.setPatternText(0, osmPattern);
630  if (gCurrentFolder.length() != 0) {
631  opendialog.setDirectory(gCurrentFolder);
632  }
633  if (opendialog.execute()) {
634  gCurrentFolder = opendialog.getDirectory();
635  std::string file = opendialog.getFilename().text();
636 
639  if (osmPattern.contains(opendialog.getPattern())) {
640  oc.set("osm-files", file);
641  oc.set("ramps.guess", "true");
642  oc.set("tls.guess", "true");
643  } else {
644  throw ProcessError("Attempted to import unknown file format '" + file + "'.");
645  }
646 
647  GNEDialog_Wizard* wizard =
648  new GNEDialog_Wizard(this, "Select Import Options", getWidth(), getHeight());
649 
650  if (wizard->execute()) {
651  NIFrame::checkOptions(); // needed to set projection parameters
652  loadConfigOrNet(file, false, false, false);
653  }
654  }
655  return 1;
656 }
657 
658 
659 long
660 GNEApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
661  // get the shape file name
662  FXFileDialog opendialog(this, "Open Shapes");
663  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
664  opendialog.setSelectMode(SELECTFILE_EXISTING);
665  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
666  if (gCurrentFolder.length() != 0) {
667  opendialog.setDirectory(gCurrentFolder);
668  }
669  if (opendialog.execute()) {
670  gCurrentFolder = opendialog.getDirectory();
671  std::string file = opendialog.getFilename().text();
672  GNEShapeHandler handler(file, myNet, myNet->getShapeContainer());
673  if (!XMLSubSys::runParser(handler, file, false)) {
674  WRITE_MESSAGE("Loading of " + file + " failed.");
675  }
676  update();
677  }
678  return 1;
679 }
680 
681 
682 long
683 GNEApplicationWindow::onCmdOpenAdditionals(FXObject*, FXSelector, void*) {
684  // get the shape file name
685  FXFileDialog opendialog(this, "Open Additional");
686  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
687  opendialog.setSelectMode(SELECTFILE_EXISTING);
688  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
689  if (gCurrentFolder.length() != 0) {
690  opendialog.setDirectory(gCurrentFolder);
691  }
692  if (opendialog.execute()) {
693  gCurrentFolder = opendialog.getDirectory();
694  std::string file = opendialog.getFilename().text();
695  // Start operation for undo/redo
696  myUndoList->p_begin("load additionals");
697  // Create additional handler
698  GNEAdditionalHandler additionalHandler(file, getView());
699  // Run parser
700  if (!XMLSubSys::runParser(additionalHandler, file, false)) {
701  WRITE_MESSAGE("Loading of " + file + " failed.");
702  // Abort undo/redo
703  myUndoList->abort();
704  } else {
705  // commit undo/redo operation
706  myUndoList->p_end();
707  update();
708  }
709  }
710  return 1;
711 }
712 
713 
714 long
715 GNEApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
716  if (myAmLoading) {
717  myStatusbar->getStatusLine()->setText("Already loading!");
718  return 1;
719  }
720  std::string file((const char*)data);
721  loadConfigOrNet(file, sender == &myRecentNets);
722  return 1;
723 }
724 
725 
726 long
727 GNEApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
728  // @note. If another network has been load during this session, it might not be desirable to set useStartupOptions
729  loadConfigOrNet(OptionsCont::getOptions().getString("sumo-net-file"), true, true);
730  return 1;
731 }
732 
733 
734 long
735 GNEApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
737  closeAllWindows();
738  }
739  return 1;
740 }
741 
742 
743 long
744 GNEApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
745  if (myMDIClient->numChildren() > 0) {
746  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
747  if (w != 0) {
748  w->onCmdLocate(0, sel, 0);
749  }
750  }
751  return 1;
752 }
753 
754 long
755 GNEApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void*) {
756  sender->handle(this, myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
757  return 1;
758 }
759 
760 
761 long
762 GNEApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
764  return 1;
765 }
766 
767 
768 long
769 GNEApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
770  GNEDialog_About* about =
771  new GNEDialog_About(this);
772  about->create();
773  about->show(PLACEMENT_OWNER);
774  return 1;
775 }
776 
777 
778 long GNEApplicationWindow::onClipboardRequest(FXObject*, FXSelector, void* ptr) {
779  FXEvent* event = (FXEvent*)ptr;
780  FXString string = GUIUserIO::clipped.c_str();
781  setDNDData(FROM_CLIPBOARD, event->target, string);
782  return 1;
783 }
784 
785 
786 long
787 GNEApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
788  eventOccured();
789  return 1;
790 }
791 
792 
793 void
795  while (!myEvents.empty()) {
796  // get the next event
797  GUIEvent* e = myEvents.top();
798  myEvents.pop();
799  // process
800  switch (e->getOwnType()) {
803  break;
806  case EVENT_ERROR_OCCURED:
808  break;
809  default:
810  break;
811  }
812  delete e;
813  }
814 }
815 
816 
817 void
819  myAmLoading = false;
820  GNEEvent_NetworkLoaded* ec = static_cast<GNEEvent_NetworkLoaded*>(e);
821  // check whether the loading was successfull
822  if (ec->myNet == 0) {
823  // report failure
824  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
825  } else {
826  myNet = ec->myNet;
827  // report success
828  setStatusBarText("'" + ec->myFile + "' loaded.");
829  // initialise views
830  myViewNumber = 0;
832  if (view && ec->mySettingsFile != "") {
833  GUISettingsHandler settings(ec->mySettingsFile);
834  std::string settingsName = settings.addSettings(view);
835  view->addDecals(settings.getDecals());
836  settings.applyViewport(view);
837  settings.setSnapshots(view);
838  }
839  // set network name on the caption
840  setTitle(MFXUtils::getTitleText(myTitlePrefix, ec->myFile.c_str()));
842  gSchemeStorage.setViewport(getView()); // refit the network to accomodate mode specific panel
843  if (ec->myViewportFromRegistry) {
844  Position off, p;
845  off.set(getApp()->reg().readRealEntry("viewport", "x"), getApp()->reg().readRealEntry("viewport", "y"), getApp()->reg().readRealEntry("viewport", "z"));
846  getView()->setViewportFromTo(off, p);
847  }
848  }
849  getApp()->endWaitCursor();
851  if (OptionsCont::getOptions().isSet("sumo-additionals-file")) {
852  std::string additionalFile = OptionsCont::getOptions().getString("sumo-additionals-file");
853  WRITE_MESSAGE("Loading additionals from '" + additionalFile + "'");
854  GNEAdditionalHandler additionalHandler(additionalFile, myNet->getViewNet());
855  // Run parser
856  if (!XMLSubSys::runParser(additionalHandler, additionalFile, false)) {
857  WRITE_ERROR("Loading of " + additionalFile + " failed.");
858  }
859  }
860  update();
861 }
862 
863 
864 void
866  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
868 }
869 
870 
871 void
872 GNEApplicationWindow::loadConfigOrNet(const std::string file, bool isNet, bool isReload, bool useStartupOptions, bool newNet) {
874  return;
875  }
876  getApp()->beginWaitCursor();
877  myAmLoading = true;
878  closeAllWindows();
879  if (isReload) {
880  myLoadThread->start();
881  setStatusBarText("Reloading.");
882  } else {
883  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
884  myLoadThread->loadConfigOrNet(file, isNet, useStartupOptions, newNet);
885  setStatusBarText("Loading '" + file + "'.");
886  }
887  update();
888 }
889 
890 
891 
894  std::string caption = "View #" + toString(myViewNumber++);
895  FXuint opts = MDI_TRACKING;
897  myMDIMenu, FXString(caption.c_str()), this,
900  opts, 10, 10, 300, 200);
901  if (myMDIClient->numChildren() == 1) {
902  w->maximize();
903  } else {
904  myMDIClient->vertical(true);
905  }
906  myMDIClient->setActiveChild(w);
907  //v->grabKeyboard();
908  return w->getView();
909 }
910 
911 
912 FXGLCanvas*
914  if (myMDIClient->numChildren() == 0) {
915  return 0;
916  }
917  GNEViewParent* share_tmp1 =
918  static_cast<GNEViewParent*>(myMDIClient->childAtIndex(0));
919  return share_tmp1->getBuildGLCanvas();
920 }
921 
922 
923 SUMOTime
925  return 0;
926 }
927 
928 
931  return myUndoList;
932 }
933 
934 
935 void
938  // remove trackers and other external windows
939  for (int i = 0; i < (int)mySubWindows.size(); ++i) {
940  mySubWindows[i]->destroy();
941  }
942  for (int i = 0; i < (int)myTrackerWindows.size(); ++i) {
943  myTrackerWindows[i]->destroy();
944  }
945  // reset the caption
946  setTitle(myTitlePrefix);
947  // delete other children
948  while (myTrackerWindows.size() != 0) {
949  delete myTrackerWindows[0];
950  }
951  while (mySubWindows.size() != 0) {
952  delete mySubWindows[0];
953  }
954  mySubWindows.clear();
955  // clear selected items
956  gSelected.clear();
957  // add a separator to the log
960  // remove coordinate information
961  myGeoCoordinate->setText("N/A");
962  myCartesianCoordinate->setText("N/A");
963 
964  myUndoList->p_clear();
965  if (myNet != 0) {
966  delete myNet;
967  myNet = 0;
969  }
971  // Reset textures
973 }
974 
975 
976 FXCursor*
978  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
979 }
980 
981 
982 void
984  const OptionsCont& oc = OptionsCont::getOptions();
985  loadConfigOrNet("", true, false, true, oc.getBool("new"));
986 }
987 
988 
989 void
990 GNEApplicationWindow::setStatusBarText(const std::string& text) {
991  myStatusbar->getStatusLine()->setText(text.c_str());
992  myStatusbar->getStatusLine()->setNormalText(text.c_str());
993 }
994 
995 
996 long
997 GNEApplicationWindow::onCmdSetMode(FXObject*, FXSelector sel, void*) {
998  if (getView()) {
999  getView()->setEditModeFromHotkey(FXSELID(sel));
1000  }
1001  return 1;
1002 }
1003 
1004 
1005 long
1006 GNEApplicationWindow::onCmdAbort(FXObject*, FXSelector, void*) {
1007  if (getView()) {
1008  getView()->abortOperation();
1009  getView()->update();
1010  }
1011  return 1;
1012 }
1013 
1014 
1015 long
1016 GNEApplicationWindow::onCmdDel(FXObject*, FXSelector, void*) {
1017  if (getView()) {
1018  getView()->hotkeyDel();
1019  }
1020  return 1;
1021 }
1022 
1023 
1024 long
1025 GNEApplicationWindow::onCmdEnter(FXObject*, FXSelector, void*) {
1026  if (getView()) {
1027  getView()->hotkeyEnter();
1028  }
1029  return 1;
1030 }
1031 
1032 
1033 long
1034 GNEApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
1035  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/NETEDIT");
1036  return 1;
1037 }
1038 
1039 
1040 long
1041 GNEApplicationWindow::onCmdComputeJunctions(FXObject*, FXSelector, void*) {
1042  myNet->computeEverything(this, true);
1043  updateControls();
1044  return 1;
1045 }
1046 
1047 
1048 long
1049 GNEApplicationWindow::onCmdCleanJunctions(FXObject*, FXSelector, void*) {
1051  return 1;
1052 }
1053 
1054 
1055 long
1056 GNEApplicationWindow::onCmdJoinJunctions(FXObject*, FXSelector, void*) {
1058  return 1;
1059 }
1060 
1061 
1062 long
1063 GNEApplicationWindow::onCmdOptions(FXObject*, FXSelector, void*) {
1064  GNEDialog_Wizard* wizard =
1065  new GNEDialog_Wizard(this, "Configure Options", getWidth(), getHeight());
1066 
1067  if (wizard->execute()) {
1068  NIFrame::checkOptions(); // needed to set projection parameters
1069  }
1070  return 1;
1071 }
1072 
1073 
1074 long
1075 GNEApplicationWindow::onCmdSaveAsNetwork(FXObject*, FXSelector, void*) {
1076  FXString file = MFXUtils::getFilename2Write(this,
1077  "Save Network as", ".net.xml",
1079  gCurrentFolder);
1080  if (file == "") {
1081  return 1;
1082  }
1084  oc.resetWritable();
1085  oc.set("output-file", file.text());
1086  setTitle(MFXUtils::getTitleText(myTitlePrefix, file));
1087  onCmdSaveNetwork(0, 0, 0);
1088  return 1;
1089 }
1090 
1091 
1092 long
1093 GNEApplicationWindow::onCmdSaveAsPlainXML(FXObject*, FXSelector, void*) {
1094  FXString file = MFXUtils::getFilename2Write(this,
1095  "Select name of the plain-xml edge-file (other names will be deduced from this)", ".edg.xml",
1097  gCurrentFolder);
1098  if (file == "") {
1099  return 1;
1100  }
1102  bool wasSet = oc.isSet("plain-output-prefix");
1103  std::string oldPrefix = oc.getString("plain-output-prefix");
1104  oc.resetWritable();
1105  std::string prefix = file.text();
1106  prefix = prefix.substr(0, prefix.size() - 8);
1107  oc.set("plain-output-prefix", prefix);
1108  getApp()->beginWaitCursor();
1109  try {
1110  myNet->savePlain(oc);
1111  myUndoList->unmark();
1112  myUndoList->mark();
1113  } catch (IOError& e) {
1114  FXMessageBox::error(this, MBOX_OK, "Saving plain xml failed!", "%s", e.what());
1115  }
1116  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Plain XML saved with prefix '" + prefix + "'.\n");
1118  if (wasSet) {
1119  oc.resetWritable();
1120  oc.set("plain-output-prefix", oldPrefix);
1121  } else {
1122  oc.unSet("plain-output-prefix");
1123  }
1124  getApp()->endWaitCursor();
1125  return 1;
1126 }
1127 
1128 
1129 long
1130 GNEApplicationWindow::onCmdSaveJoined(FXObject*, FXSelector, void*) {
1131  FXString file = MFXUtils::getFilename2Write(this,
1132  "Select name of the joined-junctions file", ".nod.xml",
1134  gCurrentFolder);
1135  if (file == "") {
1136  return 1;
1137  }
1139  bool wasSet = oc.isSet("junctions.join-output");
1140  std::string oldFile = oc.getString("junctions.join-output");
1141  oc.resetWritable();
1142  std::string filename = file.text();
1143  oc.set("junctions.join-output", filename);
1144  getApp()->beginWaitCursor();
1145  try {
1146  myNet->saveJoined(oc);
1147  } catch (IOError& e) {
1148  FXMessageBox::error(this, MBOX_OK, "Saving joined junctions failed!", "%s", e.what());
1149  }
1150  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Joined junctions saved to '" + filename + "'.\n");
1152  if (wasSet) {
1153  oc.resetWritable();
1154  oc.set("junctions.join-output", oldFile);
1155  } else {
1156  oc.unSet("junctions.join-output");
1157  }
1158  getApp()->endWaitCursor();
1159  return 1;
1160 }
1161 
1162 
1163 long
1164 GNEApplicationWindow::onCmdSavePois(FXObject*, FXSelector, void*) {
1165  FXString file = MFXUtils::getFilename2Write(this,
1166  "Select name of the POI file", ".xml",
1168  gCurrentFolder);
1169  if (file == "") {
1170  return 1;
1171  }
1172  std::string filename = file.text();
1173  // XXX Not yet implemented
1174  getApp()->beginWaitCursor();
1175  try {
1176  GNEPOI::saveToFile(filename);
1177  } catch (IOError& e) {
1178  FXMessageBox::error(this, MBOX_OK, "Saving POIs failed!", "%s", e.what());
1179  }
1181  getApp()->endWaitCursor();
1182  return 1;
1183 }
1184 
1185 
1186 long
1187 GNEApplicationWindow::onUpdNeedsNetwork(FXObject* sender, FXSelector, void*) {
1188  sender->handle(this, myNet == 0 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1189  return 1;
1190 }
1191 
1192 
1193 long
1194 GNEApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void*) {
1195  sender->handle(this, myNet == 0 || !OptionsCont::getOptions().isSet("sumo-net-file") ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1196  return 1;
1197 }
1198 
1199 
1200 long
1201 GNEApplicationWindow::onCmdSaveNetwork(FXObject*, FXSelector, void*) {
1202  getApp()->beginWaitCursor();
1203  try {
1205  myNet->save(oc);
1206  myUndoList->unmark();
1207  myUndoList->mark();
1208  } catch (IOError& e) {
1209  FXMessageBox::error(this, MBOX_OK, "Saving Network failed!", "%s", e.what());
1210  }
1211  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Network saved.\n");
1213  getApp()->endWaitCursor();
1214  return 1;
1215 }
1216 
1217 
1218 long
1219 GNEApplicationWindow::onCmdSaveAdditionals(FXObject*, FXSelector, void*) {
1221  std::string filename;
1222  if (!oc.isSet("additionals-output")) {
1223  FXString file = MFXUtils::getFilename2Write(this,
1224  "Select name of the additional file", ".xml",
1226  gCurrentFolder);
1227  if (file == "") {
1228  return 1;
1229  } else {
1230  oc.set("additionals-output", file.text());
1231  filename = file.text();
1232  }
1233  } else {
1234  filename = oc.getString("additionals-output");
1235  }
1236  getApp()->beginWaitCursor();
1237  try {
1238  myNet->saveAdditionals(filename);
1239  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Additionals saved.\n");
1240  } catch (IOError& e) {
1241  FXMessageBox::error(this, MBOX_OK, "Saving additionals failed!", "%s", e.what());
1242  }
1244  getApp()->endWaitCursor();
1245  return 1;
1246 }
1247 
1248 
1249 long
1250 GNEApplicationWindow::onCmdSaveAdditionalsAs(FXObject*, FXSelector, void*) {
1251  FXString file = MFXUtils::getFilename2Write(this,
1252  "Select name of the additional file", ".xml",
1254  gCurrentFolder);
1255  if (file != "") {
1257  oc.set("additionals-output", file.text());
1258  std::string filename = file.text();
1259  getApp()->beginWaitCursor();
1260  try {
1261  myNet->saveAdditionals(filename);
1262  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Additionals saved.\n");
1263  } catch (IOError& e) {
1264  FXMessageBox::error(this, MBOX_OK, "Saving additionals failed!", "%s", e.what());
1265  }
1267  getApp()->endWaitCursor();
1268  }
1269  return 1;
1270 }
1271 
1272 
1273 long
1274 GNEApplicationWindow::onUpdSaveNetwork(FXObject* sender, FXSelector, void*) {
1276  bool enable = myNet != 0 && oc.isSet("output-file");
1277  sender->handle(this, FXSEL(SEL_COMMAND, enable ? ID_ENABLE : ID_DISABLE), 0);
1278  if (enable) {
1279  FXString caption = ("Save " + oc.getString("output-file")).c_str();
1280  sender->handle(this, FXSEL(SEL_COMMAND, FXMenuCaption::ID_SETSTRINGVALUE), (void*)&caption);
1281  }
1282  return 1;
1283 }
1284 
1285 
1286 GNEViewNet*
1288  if (mySubWindows.size() != 0) {
1289  return (GNEViewNet*)(((GUIGlChildWindow*)mySubWindows[0])->getView());
1290  } else {
1291  return 0;
1292  }
1293 }
1294 
1295 
1296 bool
1298  if (myUndoList->canUndo() && !myUndoList->marked()) {
1299  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
1300  "Confirm Closing Network", "%s",
1301  "You have unsaved changes. Do you wish to close the network and discard all changes?");
1302  if (answer == 1) { //1:yes, 2:no, 4:esc
1303  myUndoList->p_clear(); // only ask once
1304  return true;
1305  } else {
1306  return false;
1307  }
1308  } else {
1309  return true;
1310  }
1311 }
1312 
1313 
1315  ShapeHandler(file, sc),
1316  myNet(net) {}
1317 
1318 
1320 
1321 
1322 Position
1323 GNEApplicationWindow::GNEShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, SUMOReal lanePos) {
1324  std::string edgeID = laneID;
1325  int lane = 0;
1326  const std::string::size_type underscore = laneID.rfind('_');
1327 
1328  if (underscore != std::string::npos) {
1329  edgeID = laneID.substr(0, underscore);
1330  lane = TplConvert::_2intSec(laneID.substr(underscore).c_str(), 0);
1331  }
1332  NBEdge* edge = myNet->retrieveEdge(edgeID)->getNBEdge();
1333  if (edge == 0 || edge->getNumLanes() <= lane) {
1334  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1335  return Position::INVALID;
1336  }
1337  if (lanePos < 0) {
1338  lanePos = edge->getLength() + lanePos;
1339  }
1340  return edge->getLanes()[lane].shape.positionAtOffset(lanePos);
1341 }
1342 
1343 
1344 void
1346  GNEViewNet* view = getView();
1347  if (view != 0) {
1348  view->updateControls();
1349  }
1350 }
1351 
1352 
1353 long
1354 GNEApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1355  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1356  if (handled == 0 && myMDIClient->numChildren() > 0) {
1357  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1358  if (w != 0) {
1359  w->onKeyPress(0, sel, data);
1360  }
1361  }
1362  return 0;
1363 }
1364 
1365 
1366 long
1367 GNEApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1368  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1369  if (handled == 0 && myMDIClient->numChildren() > 0) {
1370  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1371  if (w != 0) {
1372  w->onKeyRelease(0, sel, data);
1373  }
1374  }
1375  return 0;
1376 }
1377 
1378 /****************************************************************************/
std::vector< FXMainWindow * > myTrackerWindows
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
std::string myConfigPattern
Input file pattern.
FXLabel * myGeoCoordinate
static bool _str2int(const std::string &data)
check if a String can be parsed into a int check overflows
Definition: TplCheck.h:48
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1169
FXMenuBar * myMenuBar
The application menu bar.
GUISUMOAbstractView * getView() const
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
SUMOTime getCurrentSimTime() const
get current simulation time (pure virtual but we don&#39;t need it)
GUICompleteSchemeStorage gSchemeStorage
Main window closes.
Definition: GUIAppEnum.h:55
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:702
long long int SUMOTime
Definition: SUMOTime.h:43
long onCmdNewNetwork(FXObject *, FXSelector, void *)
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
void abortOperation(bool clearSelection=true)
abort current edition operation
Definition: GNEViewNet.cpp:807
void appendMsg(GUIEventType eType, const std::string &msg)
Adds new text to the window.
MFXEventQue< GUIEvent * > myEvents
List of got requests.
void resetWritable()
Resets all options to be writeable.
GNEUndoList * getUndoList()
get pointer to undoList
long onCmdReload(FXObject *, FXSelector, void *)
called when the command/FXCall reload is executed
void create()
Creates the widget (and the icons)
void closeAllWindows()
this method closes all windows and deletes the current simulation */
virtual FXGLCanvas * getBuildGLCanvas() const
virtual void setViewportFromTo(const Position &lookFrom, const Position &lookAt)
applies the given viewport settings
void joinSelectedJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:975
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.
Locate TLS - button.
Definition: GUIAppEnum.h:179
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
called when the command/FXCall clear message windows is executed
void loadConfigOrNet(const std::string &file, bool isNet, bool useStartupOptions, bool newNet=false)
begins the loading of a netconvert configuration or a a network
Loads a file previously loaded.
Definition: GUIAppEnum.h:83
virtual void create()
Creates the main window (required by FOX)
long onCmdJoinJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->join junctions
bool hadDependentBuild
check if had dependent build
The representation of a single edge during network building.
Definition: NBEdge.h:71
Load additional file with additional elements.
Definition: GUIAppEnum.h:79
GNEUndoList * myUndoList
the one and only undo list
long onCmdComputeJunctions(FXObject *, FXSelector, void *)
called if the user selects Processing->compute junctions
void registerMsgHandlers()
register and unregister message handlers
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:911
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
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 */
long onCmdLocate(FXObject *, FXSelector, void *)
locator-callback
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
called when a key is released
long onKeyRelease(FXObject *o, FXSelector sel, void *data)
Called when user releases a key.
Editor for the list of chosen objects.
bool continueWithUnsavedChanges()
warns about unsaved changes and gives the user the option to abort
FXGLVisual * myGLVisual
The gl-visual used.
long 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
Main window-ID.
Definition: GUIAppEnum.h:53
long onCmdAbout(FXObject *, FXSelector, void *)
called when the command/FXCall show about dialog is executed
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
Definition: GNEViewNet.cpp:865
FXString gCurrentFolder
The folder used as last.
Storage for geometrical objects.
long onUpdNeedsNetwork(FXObject *, FXSelector, void *)
called when the upadte/FXCall needs network is executed
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
std::string myFile
the name of the loaded file
long onLoadThreadEvent(FXObject *, FXSelector, void *)
called when the command/FXCall load thread is executed
static void resetLoaded()
resets loaded location elements
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
Reload the previously loaded simulation.
Definition: GUIAppEnum.h:81
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:114
void updateControls()
update control contents after undo/redo or recompute
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:95
Open network - ID.
Definition: GUIAppEnum.h:75
long onCmdEditChosen(FXObject *, FXSelector, void *)
called when the command/FXCall edit chosen is executed
void updateControls()
update control contents after undo/redo or recompute
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
void addDecals(const std::vector< Decal > &decals)
add decals
GUISUMOAbstractView * openNewView()
opens a new simulation display */
GNENet * myNet
the loaded net
long onUpdReload(FXObject *, FXSelector, void *)
called when the update/FXCall reload is executed
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:69
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
Open configuration - ID.
Definition: GUIAppEnum.h:73
FXHorizontalFrame * myCartesianFrame
FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[]
long onCmdSaveAdditionalsAs(FXObject *, FXSelector, void *)
called when the command/FXCall save additionals as is executed
const std::string & getMsg() const
Returns the message.
#define new
Definition: debug_new.h:121
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
std::vector< FXMDIChild * > mySubWindows
long onCmdOptions(FXObject *, FXSelector, void *)
called if the user selects Processing->Configure Options
static void close()
close GUITextureSubSys
GNEApplicationWindow()
FOX needs this for static members.
FXSplitter * myMainSplitter
The splitter that divides the main window into view and the log window.
long onCmdOpenRecent(FXObject *, FXSelector, void *)
called when the command/FXCall open recent is executed
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall open network is executed
FXGLCanvas * getBuildGLCanvas() const
get build OpenGL Canvas
int myViewNumber
The current view number.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h: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
Locate edge - button.
Definition: GUIAppEnum.h:173
virtual void fillMenuBar()
Builds the menu bar.
static void init(FXApp *a)
Initiate GUIIconSubSys.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static void saveToFile(const std::string &file)
save POIs to file
Definition: GNEPOI.cpp:183
static int _str2int(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
Definition: TplConvert.h:160
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
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:643
Locate junction - button.
Definition: GUIAppEnum.h:171
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
long onCmdOpenAdditionals(FXObject *, FXSelector, void *)
called when the command/FXCall open additionals is executed
send when a error occured
Definition: GUIEvent.h:56
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid.
Definition: NIFrame.cpp:277
Load additional file with poi and polygons.
Definition: GUIAppEnum.h:77
long onCmdLocate(FXObject *, FXSelector, void *)
called when the command/FXCall locate is executed
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:137
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
Clear simulation output.
Definition: GUIAppEnum.h:154
FXCursor * getDefaultCursor()
get default cursor
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
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
static void reset()
Reset textures.
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
#define VERSION_STRING
Definition: config.h:225
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.
long onCmdOpenShapes(FXObject *, FXSelector, void *)
called when the command/FXCall open shapes is executed
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
long onCmdEnter(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits enter
bool myViewportFromRegistry
whether loading viewport from registry
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
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.
About SUMO - ID.
Definition: GUIAppEnum.h:87
void setViewport(GUISUMOAbstractView *view)
Sets the default viewport.
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:147
The loading thread.
Definition: GUIAppEnum.h:117
void unSet(const std::string &name, bool failOnNonExistant=true) const
Marks the option as unset.
long onCmdDel(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits del
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
FXRecentFiles myRecentNets
List of recent nets.
void loadOptionOnStartup()
load net on startup
void removeSolitaryJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:1025
static void close()
close GUIIconSubSys
FXToolBarShell * myMenuBarDrag
FXHorizontalFrame * myGeoFrame
static void init(FXApp *a)
Initiate GUITextureSubSys for textures.
FXDockSite * myTopDock
A storage for options typed value containers)
Definition: OptionsCont.h:99
void set(SUMOReal x, SUMOReal y)
Definition: Position.h:78
long onCmdClose(FXObject *, FXSelector, void *)
called when the command/FXCall close is executed
void clear()
Clears the list of selected objects.
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:676
send when a warning occured
Definition: GUIEvent.h:53
long onCmdAbort(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits esc
#define SUMOReal
Definition: config.h:213
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
GUIEventType getOwnType() const
returns the event type
Definition: GUIEvent.h:84
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.
Close simulation - ID.
Definition: GUIAppEnum.h:85
GNENet * myNet
we are responsible for the net
void dependentBuild()
build dependent
void clear()
Clears the window.
processing menu messages
Definition: GUIAppEnum.h:458
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:261
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:829
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
GUISelectedStorage gSelected
A global holder of selected objects.
void hotkeyEnter()
handle enter keypress
Definition: GNEViewNet.cpp:842
long onCmdSaveAsNetwork(FXObject *, FXSelector, void *)
called when the command/FXCall save network as is executed
GNEViewNet * getView()
convenience method
A logging window for the gui.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void setStatusBarText(const std::string &)
set text of the statusBar
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:650
misc messages
Definition: GUIAppEnum.h:480
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:669
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
Definition: Position.h:261
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1082