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/ToString.h>
43 #include <utils/xml/XMLSubSys.h>
57 #include <netimport/NIFrame.h>
58 
59 #include "GNEApplicationWindow.h"
60 #include "GNELoadThread.h"
61 #include "GNEEvent_NetworkLoaded.h"
62 #include "GNEViewParent.h"
63 #include "GNEViewNet.h"
64 #include "GNEDialog_About.h"
65 #include "GNEDialog_Wizard.h"
66 #include "GNENet.h"
67 #include "GNEEdge.h"
68 #include "GNEJunction.h"
69 #include "GNEUndoList.h"
70 #include "GNEPOI.h"
71 #include "GNEAdditionalHandler.h"
72 
73 
74 #ifdef CHECK_MEMORY_LEAKS
75 #include <foreign/nvwa/debug_new.h>
76 #endif
77 
78 
79 // ===========================================================================
80 // FOX-declarations
81 // ===========================================================================
82 FXDEFMAP(GNEApplicationWindow) GNEApplicationWindowMap[] = {
83  //________Message_Type____________ID________________________Message_Handler________
84  FXMAPFUNC(SEL_COMMAND, MID_QUIT, GNEApplicationWindow::onCmdQuit),
85  FXMAPFUNC(SEL_SIGNAL, MID_QUIT, GNEApplicationWindow::onCmdQuit),
86  FXMAPFUNC(SEL_CLOSE, MID_WINDOW, GNEApplicationWindow::onCmdQuit),
87 
95  FXMAPFUNC(SEL_COMMAND, MID_RELOAD, GNEApplicationWindow::onCmdReload),
96  FXMAPFUNC(SEL_COMMAND, MID_CLOSE, GNEApplicationWindow::onCmdClose),
97  FXMAPFUNC(SEL_UPDATE, MID_CLOSE, GNEApplicationWindow::onUpdNeedsNetwork),
98 
99  FXMAPFUNC(SEL_COMMAND, MID_ABOUT, GNEApplicationWindow::onCmdAbout),
101 
103  FXMAPFUNC(SEL_UPDATE, MID_OPEN_CONFIG, GNEApplicationWindow::onUpdOpen),
104  FXMAPFUNC(SEL_UPDATE, MID_OPEN_NETWORK, GNEApplicationWindow::onUpdOpen),
108  FXMAPFUNC(SEL_UPDATE, MID_RELOAD, GNEApplicationWindow::onUpdReload),
109  FXMAPFUNC(SEL_UPDATE, MID_RECENTFILE, GNEApplicationWindow::onUpdOpen),
110  FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNEApplicationWindow::onClipboardRequest),
111 
112  // forward requests to the active view
113  FXMAPFUNC(SEL_COMMAND, MID_LOCATEJUNCTION, GNEApplicationWindow::onCmdLocate),
114  FXMAPFUNC(SEL_COMMAND, MID_LOCATEEDGE, GNEApplicationWindow::onCmdLocate),
115  FXMAPFUNC(SEL_COMMAND, MID_LOCATETLS, GNEApplicationWindow::onCmdLocate),
119  FXMAPFUNC(SEL_KEYPRESS, 0, GNEApplicationWindow::onKeyPress),
120  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEApplicationWindow::onKeyRelease),
121 
124 
126  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_MOVE, GNEApplicationWindow::onCmdSetMode),
131  FXMAPFUNC(SEL_COMMAND, MID_GNE_MODE_TLS, GNEApplicationWindow::onCmdSetMode),
133 
139  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_PLAIN_XML, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
141  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_JOINED, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
143  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_POIS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
145  FXMAPFUNC(SEL_UPDATE, MID_GNE_SAVE_ADDITIONALS, GNEApplicationWindow::onUpdNeedsNetwork), // same condition
146 
147  FXMAPFUNC(SEL_COMMAND, MID_GNE_ABORT, GNEApplicationWindow::onCmdAbort),
148  FXMAPFUNC(SEL_COMMAND, MID_GNE_HOTKEY_DEL, GNEApplicationWindow::onCmdDel),
150  FXMAPFUNC(SEL_COMMAND, MID_HELP, GNEApplicationWindow::onCmdHelp),
157  FXMAPFUNC(SEL_COMMAND, MID_GNE_OPTIONS, GNEApplicationWindow::onCmdOptions),
158 };
159 
160 // Object implementation
161 FXIMPLEMENT(GNEApplicationWindow, FXMainWindow, GNEApplicationWindowMap, ARRAYNUMBER(GNEApplicationWindowMap))
162 
163 // ===========================================================================
164 // member method definitions
165 // ===========================================================================
166 #ifdef _MSC_VER
167 #pragma warning(disable: 4355)
168 #endif
169 GNEApplicationWindow::GNEApplicationWindow(FXApp* a, const std::string& configPattern) :
170  GUIMainWindow(a),
171  myLoadThread(0),
172  myAmLoading(false),
173  myRecentNets(a, "nets"),
174  myConfigPattern(configPattern),
175  hadDependentBuild(false),
176  myNet(0),
177  myUndoList(new GNEUndoList(this)),
178  myTitlePrefix("NETEDIT " VERSION_STRING) {
179  // Load icons
181  // Load Gifs (Textures)
183 }
184 #ifdef _MSC_VER
185 #pragma warning(default: 4355)
186 #endif
187 
188 
189 void
191  // do this not twice
192  if (hadDependentBuild) {
193  WRITE_ERROR("DEBUG: GNEApplicationWindow::dependentBuild called twice");
194  return;
195  }
196  hadDependentBuild = true;
197 
198  setTarget(this);
199  setSelector(MID_WINDOW);
200 
201  // build menu bar
202  myMenuBarDrag = new FXToolBarShell(this, FRAME_NORMAL);
203  myMenuBar = new FXMenuBar(myTopDock, myMenuBarDrag,
204  LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
205  new FXToolBarGrip(myMenuBar, myMenuBar, FXMenuBar::ID_TOOLBARGRIP,
206  TOOLBARGRIP_DOUBLE);
207  // build the thread - io
210 
211  // build the status bar
212  myStatusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
213  {
214  myGeoFrame =
215  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
216  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
217  myGeoCoordinate = new FXLabel(myGeoFrame, "N/A\t\tOriginal coordinate (before coordinate transformation in NETCONVERT)", 0, LAYOUT_CENTER_Y);
219  new FXHorizontalFrame(myStatusbar, LAYOUT_FIX_WIDTH | LAYOUT_FILL_Y | LAYOUT_RIGHT | FRAME_SUNKEN,
220  0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
221  myCartesianCoordinate = new FXLabel(myCartesianFrame, "N/A\t\tNetwork coordinate", 0, LAYOUT_CENTER_Y);
222  }
223  // make the window a mdi-window
224  myMainSplitter = new FXSplitter(this,
225  SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
226  myMDIClient = new FXMDIClient(myMainSplitter,
227  LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
228  myMDIMenu = new FXMDIMenu(this, myMDIClient);
229  new FXMDIWindowButton(myMenuBar, myMDIMenu, myMDIClient,
230  FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
231  new FXMDIDeleteButton(myMenuBar, myMDIClient,
232  FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
233  new FXMDIRestoreButton(myMenuBar, myMDIClient,
234  FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
235  new FXMDIMinimizeButton(myMenuBar, myMDIClient,
236  FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
237 
238  // build the message window
240  myMainSplitter->setSplit(1, 65);
241  // fill menu and tool bar
242  fillMenuBar();
243  // build additional threads
244  myLoadThread = new GNELoadThread(getApp(), this, myEvents, myLoadThreadEvent);
245  // set the status bar
246  myStatusbar->getStatusLine()->setText("Ready.");
247  // set the caption
248  setTitle(myTitlePrefix);
249 
251 
252  //initialize some hotkeys
253  getAccelTable()->addAccel(parseAccel("e"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CREATE_EDGE));
254  getAccelTable()->addAccel(parseAccel("m"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_MOVE));
255  getAccelTable()->addAccel(parseAccel("d"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_DELETE));
256  getAccelTable()->addAccel(parseAccel("i"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_INSPECT));
257  getAccelTable()->addAccel(parseAccel("s"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_SELECT));
258  getAccelTable()->addAccel(parseAccel("c"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_CONNECT));
259  getAccelTable()->addAccel(parseAccel("t"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_TLS));
260  getAccelTable()->addAccel(parseAccel("a"), this, FXSEL(SEL_COMMAND, MID_GNE_MODE_ADDITIONAL));
261  getAccelTable()->addAccel(parseAccel("Esc"), this, FXSEL(SEL_COMMAND, MID_GNE_ABORT));
262  getAccelTable()->addAccel(parseAccel("Del"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_DEL));
263  getAccelTable()->addAccel(parseAccel("Enter"), this, FXSEL(SEL_COMMAND, MID_GNE_HOTKEY_ENTER));
264 }
265 
266 void
268  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 0) {
269  setX(getApp()->reg().readIntEntry("SETTINGS", "x", 150));
270  setY(getApp()->reg().readIntEntry("SETTINGS", "y", 150));
271  setWidth(getApp()->reg().readIntEntry("SETTINGS", "width", 600));
272  setHeight(getApp()->reg().readIntEntry("SETTINGS", "height", 400));
273  }
274  gCurrentFolder = getApp()->reg().readStringEntry("SETTINGS", "basedir", "");
275  FXMainWindow::create();
276  myMenuBarDrag->create();
277  myFileMenu->create();
278  myEditMenu->create();
279  //mySettingsMenu->create();
280  myWindowsMenu->create();
281  myHelpMenu->create();
282 
283  FXint width = getApp()->getNormalFont()->getTextWidth("8", 1) * 22;
284  myCartesianFrame->setWidth(width);
285  myGeoFrame->setWidth(width);
286 
287  show(PLACEMENT_SCREEN);
288  if (getApp()->reg().readIntEntry("SETTINGS", "maximized", 0) == 1) {
289  maximize();
290  }
291 }
292 
293 
295  closeAllWindows();
296  // Close icons
298  // Close gifs (Textures)
300  delete myGLVisual;
301  // must delete menus to avoid segfault on removing accelerators
302  // (http://www.fox-toolkit.net/faq#TOC-What-happens-when-the-application-s)
303  delete myFileMenu;
304  delete myEditMenu;
305  delete myProcessingMenu;
306  delete myWindowsMenu;
307  delete myHelpMenu;
308 
309  delete myLoadThread;
310 
311  while (!myEvents.empty()) {
312  // get the next event
313  GUIEvent* e = myEvents.top();
314  myEvents.pop();
315  delete e;
316  }
317  delete myUndoList;
318 }
319 
320 
321 void
323  FXMainWindow::detach();
324  myMenuBarDrag->detach();
325 }
326 
327 
328 void
330  // build file menu
331  myFileMenu = new FXMenuPane(this);
332  new FXMenuTitle(myMenuBar, "&File", 0, myFileMenu);
333  new FXMenuCommand(myFileMenu,
334  "&New Network...\tCtrl+A\tCreate a new network.",
336  new FXMenuCommand(myFileMenu,
337  "Open &Network...\tCtrl+N\tOpen a SUMO network.",
339  new FXMenuCommand(myFileMenu,
340  "&Open Configuration...\tCtrl+O\tOpen a NETCONVERT configuration file.",
342  new FXMenuCommand(myFileMenu,
343  "Import &Foreign Network...\t\tImport a foreign network such as OSM.",
345  new FXMenuCommand(myFileMenu,
346  "Load &Shapes...\tCtrl+P\tLoad shapes into the network view.",
348  new FXMenuCommand(myFileMenu,
349  "Load &Additionals...\tCtrl+D\tLoad additional elements.",
351  new FXMenuCommand(myFileMenu,
352  "&Reload\tCtrl+R\tReloads the network.",
354  new FXMenuCommand(myFileMenu,
355  "&Save Network...\tCtrl+S\tSave the network.",
357  new FXMenuCommand(myFileMenu,
358  "&Save Network As...\tCtrl+Shift-S\tSave the network.",
360  new FXMenuCommand(myFileMenu,
361  "&Save plain xml...\t\tSave plain xml representation the network.",
363  new FXMenuCommand(myFileMenu,
364  "&Save joined junctions...\t\tSave log of joined junctions (allows reproduction of joins).",
366  new FXMenuCommand(myFileMenu,
367  "&Save POIs As ...\t\tSave the POIs.",
369  new FXMenuCommand(myFileMenu,
370  "&Save additionals As...\t\tSave additional elements.",
372  new FXMenuSeparator(myFileMenu);
373  new FXMenuCommand(myFileMenu,
374  "Close\tCtrl+W\tClose the network.",
376  // Recent files
377  FXMenuSeparator* sep1 = new FXMenuSeparator(myFileMenu);
378  sep1->setTarget(&myRecentConfigs);
379  sep1->setSelector(FXRecentFiles::ID_ANYFILES);
380  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_1);
381  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_2);
382  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_3);
383  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_4);
384  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_5);
385  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_6);
386  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_7);
387  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_8);
388  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_9);
389  new FXMenuCommand(myFileMenu, "", 0, &myRecentConfigs, FXRecentFiles::ID_FILE_10);
390  new FXMenuCommand(myFileMenu, "C&lear Recent Configurations", 0, &myRecentConfigs, FXRecentFiles::ID_CLEAR);
391  myRecentConfigs.setTarget(this);
392  myRecentConfigs.setSelector(MID_RECENTFILE);
393  FXMenuSeparator* sep2 = new FXMenuSeparator(myFileMenu);
394  sep2->setTarget(&myRecentNets);
395  sep2->setSelector(FXRecentFiles::ID_ANYFILES);
396  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_1);
397  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_2);
398  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_3);
399  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_4);
400  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_5);
401  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_6);
402  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_7);
403  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_8);
404  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_9);
405  new FXMenuCommand(myFileMenu, "", 0, &myRecentNets, FXRecentFiles::ID_FILE_10);
406  new FXMenuCommand(myFileMenu, "Cl&ear Recent Networks", 0, &myRecentNets, FXRecentFiles::ID_CLEAR);
407  myRecentNets.setTarget(this);
408  myRecentNets.setSelector(MID_RECENTFILE);
409  new FXMenuSeparator(myFileMenu);
410  new FXMenuCommand(myFileMenu,
411  "&Quit\tCtrl+Q\tQuit the Application.",
412  0, this, MID_QUIT, 0);
413 
414  // build edit menu
415  myEditMenu = new FXMenuPane(this);
416  new FXMenuTitle(myMenuBar, "&Edit", 0, myEditMenu);
417  new FXMenuCommand(myEditMenu,
418  "Undo\tCtrl+Z\tUndo the last change.",
419  GUIIconSubSys::getIcon(ICON_UNDO), myUndoList, FXUndoList::ID_UNDO);
420  new FXMenuCommand(myEditMenu,
421  "Redo\tCtrl+Y\tRedo the last change.",
422  GUIIconSubSys::getIcon(ICON_REDO), myUndoList, FXUndoList::ID_REDO);
423 
424 
425  /*
426  new FXMenuSeparator(myEditMenu);
427  new FXMenuCommand(myEditMenu,
428  "Edit Breakpoints...\t\tOpens a Dialog for editing breakpoints.",
429  0, this, MID_EDIT_BREAKPOINTS);
430  */
431 
432  // processing menu (trigger netbuild computations)
433  myProcessingMenu = new FXMenuPane(this);
434  new FXMenuTitle(myMenuBar, "Processing", 0, myProcessingMenu);
435  new FXMenuCommand(myProcessingMenu,
436  "Compute Junctions\tF5\tComputes junction shape and logic.",
437  0, this, MID_GNE_COMPUTE_JUNCTIONS);
438  new FXMenuCommand(myProcessingMenu,
439  "Clean Junctions\tF6\tRemoves solitary junctions.",
440  0, this, MID_GNE_CLEAN_JUNCTIONS);
441  new FXMenuCommand(myProcessingMenu,
442  "Join Selected Junctions\tF7\tJoins selected junctions into a single junction.",
443  0, this, MID_GNE_JOIN_JUNCTIONS);
444  new FXMenuCommand(myProcessingMenu,
445  "Options\t\tConfigure Processing Options.",
446  0, this, MID_GNE_OPTIONS);
447 
448  // build settings menu
449  /*
450  mySettingsMenu = new FXMenuPane(this);
451  new FXMenuTitle(myMenuBar,"&Settings",0,mySettingsMenu);
452  new FXMenuCheck(mySettingsMenu,
453  "Gaming Mode\t\tToggle gaming mode on/off.",
454  this,MID_GAMING);
455  */
456  // build Locate menu
457  myLocatorMenu = new FXMenuPane(this);
458  new FXMenuTitle(myMenuBar, "&Locate", NULL, myLocatorMenu);
459  new FXMenuCommand(myLocatorMenu,
460  "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
462  new FXMenuCommand(myLocatorMenu,
463  "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
465  new FXMenuCommand(myLocatorMenu,
466  "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
468 
469  // build windows menu
470  myWindowsMenu = new FXMenuPane(this);
471  new FXMenuTitle(myMenuBar, "&Windows", 0, myWindowsMenu);
472  new FXMenuCheck(myWindowsMenu,
473  "Show Status Line\t\tToggle this Status Bar on/off.",
474  myStatusbar, FXWindow::ID_TOGGLESHOWN);
475  new FXMenuCheck(myWindowsMenu,
476  "Show Message Window\t\tToggle the Message Window on/off.",
477  myMessageWindow, FXWindow::ID_TOGGLESHOWN);
478  /*
479  new FXMenuSeparator(myWindowsMenu);
480  new FXMenuCommand(myWindowsMenu,"Tile &Horizontally",
481  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_HORI),
482  myMDIClient,FXMDIClient::ID_MDI_TILEHORIZONTAL);
483  new FXMenuCommand(myWindowsMenu,"Tile &Vertically",
484  GUIIconSubSys::getIcon(ICON_WINDOWS_TILE_VERT),
485  myMDIClient,FXMDIClient::ID_MDI_TILEVERTICAL);
486  new FXMenuCommand(myWindowsMenu,"C&ascade",
487  GUIIconSubSys::getIcon(ICON_WINDOWS_CASCADE),
488  myMDIClient,FXMDIClient::ID_MDI_CASCADE);
489  new FXMenuCommand(myWindowsMenu,"&Close",0,
490  myMDIClient,FXMDIClient::ID_MDI_CLOSE);
491  sep1=new FXMenuSeparator(myWindowsMenu);
492  sep1->setTarget(myMDIClient);
493  sep1->setSelector(FXMDIClient::ID_MDI_ANY);
494  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_1);
495  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_2);
496  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_3);
497  new FXMenuCommand(myWindowsMenu,"",0,myMDIClient,FXMDIClient::ID_MDI_4);
498  new FXMenuCommand(myWindowsMenu,"&Others...",0,myMDIClient,FXMDIClient::ID_MDI_OVER_5);
499  new FXMenuSeparator(myWindowsMenu);
500  */
501  new FXMenuCommand(myWindowsMenu,
502  "Clear Message Window\t\tClear the message window.",
503  0, this, MID_CLEARMESSAGEWINDOW);
504 
505  // build help menu
506  myHelpMenu = new FXMenuPane(this);
507  new FXMenuTitle(myMenuBar, "&Help", 0, myHelpMenu);
508  new FXMenuCommand(myHelpMenu, "&Online Documentation", 0, this, MID_HELP);
509  new FXMenuCommand(myHelpMenu, "&About", 0, this, MID_ABOUT);
510 }
511 
512 
513 long
514 GNEApplicationWindow::onCmdQuit(FXObject*, FXSelector, void*) {
516  getApp()->reg().writeIntEntry("SETTINGS", "x", getX());
517  getApp()->reg().writeIntEntry("SETTINGS", "y", getY());
518  getApp()->reg().writeIntEntry("SETTINGS", "width", getWidth());
519  getApp()->reg().writeIntEntry("SETTINGS", "height", getHeight());
520  getApp()->reg().writeStringEntry("SETTINGS", "basedir", gCurrentFolder.text());
521  if (isMaximized()) {
522  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 1);
523  } else {
524  getApp()->reg().writeIntEntry("SETTINGS", "maximized", 0);
525  }
526  getApp()->exit(0);
527  }
528  return 1;
529 }
530 
531 
532 long
533 GNEApplicationWindow::onCmdEditChosen(FXObject*, FXSelector, void*) {
534  GUIDialog_GLChosenEditor* chooser =
536  chooser->create();
537  chooser->show();
538  return 1;
539 }
540 
541 
542 long
543 GNEApplicationWindow::onCmdNewNetwork(FXObject*, FXSelector, void*) {
544  // ask before we clobber options
546  return 1;
547  }
551  loadConfigOrNet("", true, false, true, true);
552  return 1;
553 }
554 
555 
556 long
557 GNEApplicationWindow::onCmdOpenConfiguration(FXObject*, FXSelector, void*) {
558  // get the new file name
559  FXFileDialog opendialog(this, "Open Netconvert Configuration");
560  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
561  opendialog.setSelectMode(SELECTFILE_EXISTING);
562  opendialog.setPatternList(myConfigPattern.c_str());
563  if (gCurrentFolder.length() != 0) {
564  opendialog.setDirectory(gCurrentFolder);
565  }
566  if (opendialog.execute()) {
567  gCurrentFolder = opendialog.getDirectory();
568  std::string file = opendialog.getFilename().text();
569  loadConfigOrNet(file, false);
570  myRecentConfigs.appendFile(file.c_str());
571  }
572  return 1;
573 }
574 
575 
576 long
577 GNEApplicationWindow::onCmdOpenNetwork(FXObject*, FXSelector, void*) {
578  // get the new file name
579  FXFileDialog opendialog(this, "Open Network");
580  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
581  opendialog.setSelectMode(SELECTFILE_EXISTING);
582  opendialog.setPatternList("SUMO nets (*.net.xml)\nAll files (*)");
583  if (gCurrentFolder.length() != 0) {
584  opendialog.setDirectory(gCurrentFolder);
585  }
586  if (opendialog.execute()) {
587  gCurrentFolder = opendialog.getDirectory();
588  std::string file = opendialog.getFilename().text();
589  loadConfigOrNet(file, true);
590  myRecentNets.appendFile(file.c_str());
591  }
592  return 1;
593 }
594 
595 
596 long
597 GNEApplicationWindow::onCmdOpenForeign(FXObject*, FXSelector, void*) {
598  // ask before we clobber options
600  return 1;
601  }
602  // get the new file name
603  FXFileDialog opendialog(this, "Import Foreign Network");
604  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
605  opendialog.setSelectMode(SELECTFILE_EXISTING);
606  FXString osmPattern("OSM net (*.osm.xml,*.osm)");
607  opendialog.setPatternText(0, osmPattern);
608  if (gCurrentFolder.length() != 0) {
609  opendialog.setDirectory(gCurrentFolder);
610  }
611  if (opendialog.execute()) {
612  gCurrentFolder = opendialog.getDirectory();
613  std::string file = opendialog.getFilename().text();
614 
617  if (osmPattern.contains(opendialog.getPattern())) {
618  oc.set("osm-files", file);
619  oc.set("ramps.guess", "true");
620  oc.set("tls.guess", "true");
621  } else {
622  throw ProcessError("Attempted to import unknown file format '" + file + "'.");
623  }
624 
625  GNEDialog_Wizard* wizard =
626  new GNEDialog_Wizard(this, "Select Import Options", getWidth(), getHeight());
627 
628  if (wizard->execute()) {
629  NIFrame::checkOptions(); // needed to set projection parameters
630  loadConfigOrNet(file, false, false, true);
631  }
632  }
633  return 1;
634 }
635 
636 
637 long
638 GNEApplicationWindow::onCmdOpenShapes(FXObject*, FXSelector, void*) {
639  // get the shape file name
640  FXFileDialog opendialog(this, "Open Shapes");
641  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
642  opendialog.setSelectMode(SELECTFILE_EXISTING);
643  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
644  if (gCurrentFolder.length() != 0) {
645  opendialog.setDirectory(gCurrentFolder);
646  }
647  if (opendialog.execute()) {
648  gCurrentFolder = opendialog.getDirectory();
649  std::string file = opendialog.getFilename().text();
650  GNEShapeHandler handler(file, myNet, myNet->getShapeContainer());
651  if (!XMLSubSys::runParser(handler, file, false)) {
652  WRITE_MESSAGE("Loading of " + file + " failed.");
653  }
654  update();
655  }
656  return 1;
657 }
658 
659 
660 long
661 GNEApplicationWindow::onCmdOpenAdditionals(FXObject*, FXSelector, void*) {
662  // get the shape file name
663  FXFileDialog opendialog(this, "Open Additional");
664  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
665  opendialog.setSelectMode(SELECTFILE_EXISTING);
666  opendialog.setPatternList("Additional files (*.xml)\nAll files (*)");
667  if (gCurrentFolder.length() != 0) {
668  opendialog.setDirectory(gCurrentFolder);
669  }
670  if (opendialog.execute()) {
671  gCurrentFolder = opendialog.getDirectory();
672  std::string file = opendialog.getFilename().text();
673  // Start operation for undo/redo
674  myUndoList->p_begin("load additionals");
675  // Create additional handler
676  GNEAdditionalHandler additionalHandler(file, getView());
677  // Run parser
678  if (!XMLSubSys::runParser(additionalHandler, file, false)) {
679  WRITE_MESSAGE("Loading of " + file + " failed.");
680  // Abort undo/redo
681  myUndoList->abort();
682  } else {
683  // commit undo/redo operation
684  myUndoList->p_end();
685  update();
686  }
687  }
688  return 1;
689 }
690 
691 
692 long
693 GNEApplicationWindow::onCmdOpenRecent(FXObject* sender, FXSelector, void* data) {
694  if (myAmLoading) {
695  myStatusbar->getStatusLine()->setText("Already loading!");
696  return 1;
697  }
698  std::string file((const char*)data);
699  loadConfigOrNet(file, sender == &myRecentNets);
700  return 1;
701 }
702 
703 
704 long
705 GNEApplicationWindow::onCmdReload(FXObject*, FXSelector, void*) {
706  loadConfigOrNet(OptionsCont::getOptions().getString("sumo-net-file"), true, true);
707  return 1;
708 }
709 
710 
711 long
712 GNEApplicationWindow::onCmdClose(FXObject*, FXSelector, void*) {
714  closeAllWindows();
715  }
716  return 1;
717 }
718 
719 
720 long
721 GNEApplicationWindow::onCmdLocate(FXObject*, FXSelector sel, void*) {
722  if (myMDIClient->numChildren() > 0) {
723  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
724  if (w != 0) {
725  w->onCmdLocate(0, sel, 0);
726  }
727  }
728  return 1;
729 }
730 
731 long
732 GNEApplicationWindow::onUpdOpen(FXObject* sender, FXSelector, void*) {
733  sender->handle(this, myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
734  return 1;
735 }
736 
737 
738 long
739 GNEApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
741  return 1;
742 }
743 
744 
745 long
746 GNEApplicationWindow::onCmdAbout(FXObject*, FXSelector, void*) {
747  GNEDialog_About* about =
748  new GNEDialog_About(this);
749  about->create();
750  about->show(PLACEMENT_OWNER);
751  return 1;
752 }
753 
754 
755 long GNEApplicationWindow::onClipboardRequest(FXObject*, FXSelector, void* ptr) {
756  FXEvent* event = (FXEvent*)ptr;
757  FXString string = GUIUserIO::clipped.c_str();
758  setDNDData(FROM_CLIPBOARD, event->target, string);
759  return 1;
760 }
761 
762 
763 long
764 GNEApplicationWindow::onLoadThreadEvent(FXObject*, FXSelector, void*) {
765  eventOccured();
766  return 1;
767 }
768 
769 
770 void
772  while (!myEvents.empty()) {
773  // get the next event
774  GUIEvent* e = myEvents.top();
775  myEvents.pop();
776  // process
777  switch (e->getOwnType()) {
780  break;
783  case EVENT_ERROR_OCCURED:
785  break;
786  default:
787  break;
788  }
789  delete e;
790  }
791 }
792 
793 
794 void
796  myAmLoading = false;
797  GNEEvent_NetworkLoaded* ec = static_cast<GNEEvent_NetworkLoaded*>(e);
798  // check whether the loading was successfull
799  if (ec->myNet == 0) {
800  // report failure
801  setStatusBarText("Loading of '" + ec->myFile + "' failed!");
802  } else {
803  myNet = ec->myNet;
804  // report success
805  setStatusBarText("'" + ec->myFile + "' loaded.");
806  // initialise views
807  myViewNumber = 0;
809  if (view && ec->mySettingsFile != "") {
810  GUISettingsHandler settings(ec->mySettingsFile);
811  std::string settingsName = settings.addSettings(view);
812  view->addDecals(settings.getDecals());
813  settings.applyViewport(view);
814  settings.setSnapshots(view);
815  }
816  // set network name on the caption
817  setTitle(MFXUtils::getTitleText(myTitlePrefix, ec->myFile.c_str()));
819  gSchemeStorage.setViewport(getView()); // refit the network to accomodate mode specific panel
820  if (ec->myViewportFromRegistry) {
821  Position off, p;
822  off.set(getApp()->reg().readIntEntry("viewport", "x"), getApp()->reg().readIntEntry("viewport", "y"), getApp()->reg().readIntEntry("viewport", "z"));
823  getView()->setViewportFromTo(off, p);
824  }
825  }
826  getApp()->endWaitCursor();
828  update();
829 }
830 
831 
832 void
834  GUIEvent_Message* ec = static_cast<GUIEvent_Message*>(e);
836 }
837 
838 
839 void
840 GNEApplicationWindow::loadConfigOrNet(const std::string file, bool isNet, bool isReload, bool optionsReady, bool newNet) {
842  return;
843  }
844  getApp()->beginWaitCursor();
845  myAmLoading = true;
846  closeAllWindows();
847  if (isReload) {
848  myLoadThread->start();
849  setStatusBarText("Reloading.");
850  } else {
851  gSchemeStorage.saveViewport(0, 0, -1); // recenter view
852  myLoadThread->loadConfigOrNet(file, isNet, optionsReady, newNet);
853  setStatusBarText("Loading '" + file + "'.");
854  }
855  update();
856 }
857 
858 
859 
862  std::string caption = "View #" + toString(myViewNumber++);
863  FXuint opts = MDI_TRACKING;
865  myMDIMenu, FXString(caption.c_str()), this,
868  opts, 10, 10, 300, 200);
869  if (myMDIClient->numChildren() == 1) {
870  w->maximize();
871  } else {
872  myMDIClient->vertical(true);
873  }
874  myMDIClient->setActiveChild(w);
875  //v->grabKeyboard();
876  return w->getView();
877 }
878 
879 
880 FXGLCanvas*
882  if (myMDIClient->numChildren() == 0) {
883  return 0;
884  }
885  GNEViewParent* share_tmp1 =
886  static_cast<GNEViewParent*>(myMDIClient->childAtIndex(0));
887  return share_tmp1->getBuildGLCanvas();
888 }
889 
890 
891 SUMOTime
893  return 0;
894 }
895 
896 
899  return myUndoList;
900 }
901 
902 
903 void
906  // remove trackers and other external windows
907  for (int i = 0; i < (int)mySubWindows.size(); ++i) {
908  mySubWindows[i]->destroy();
909  }
910  for (int i = 0; i < (int)myTrackerWindows.size(); ++i) {
911  myTrackerWindows[i]->destroy();
912  }
913  // reset the caption
914  setTitle(myTitlePrefix);
915  // delete other children
916  while (myTrackerWindows.size() != 0) {
917  delete myTrackerWindows[0];
918  }
919  while (mySubWindows.size() != 0) {
920  delete mySubWindows[0];
921  }
922  mySubWindows.clear();
923  // clear selected items
924  gSelected.clear();
925  // add a separator to the log
928  // remove coordinate information
929  myGeoCoordinate->setText("N/A");
930  myCartesianCoordinate->setText("N/A");
931 
932  myUndoList->p_clear();
933  if (myNet != 0) {
934  delete myNet;
935  myNet = 0;
937  }
939  // Load Gifs (Textures)
941 }
942 
943 
944 FXCursor*
946  return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
947 }
948 
949 
950 void
952  loadConfigOrNet("", false, false, true);
953 }
954 
955 
956 void
957 GNEApplicationWindow::setStatusBarText(const std::string& text) {
958  myStatusbar->getStatusLine()->setText(text.c_str());
959  myStatusbar->getStatusLine()->setNormalText(text.c_str());
960 }
961 
962 
963 long
964 GNEApplicationWindow::onCmdSetMode(FXObject*, FXSelector sel, void*) {
965  if (getView()) {
966  getView()->setEditModeFromHotkey(FXSELID(sel));
967  }
968  return 1;
969 }
970 
971 
972 long
973 GNEApplicationWindow::onCmdAbort(FXObject*, FXSelector, void*) {
974  if (getView()) {
975  getView()->abortOperation();
976  getView()->update();
977  }
978  return 1;
979 }
980 
981 
982 long
983 GNEApplicationWindow::onCmdDel(FXObject*, FXSelector, void*) {
984  if (getView()) {
985  getView()->hotkeyDel();
986  }
987  return 1;
988 }
989 
990 
991 long
992 GNEApplicationWindow::onCmdEnter(FXObject*, FXSelector, void*) {
993  if (getView()) {
994  getView()->hotkeyEnter();
995  }
996  return 1;
997 }
998 
999 
1000 long
1001 GNEApplicationWindow::onCmdHelp(FXObject*, FXSelector, void*) {
1002  FXLinkLabel::fxexecute("http://sumo.dlr.de/wiki/NETEDIT");
1003  return 1;
1004 }
1005 
1006 
1007 long
1008 GNEApplicationWindow::onCmdComputeJunctions(FXObject*, FXSelector, void*) {
1009  myNet->computeEverything(this, true);
1010  updateControls();
1011  return 1;
1012 }
1013 
1014 
1015 long
1016 GNEApplicationWindow::onCmdCleanJunctions(FXObject*, FXSelector, void*) {
1018  return 1;
1019 }
1020 
1021 
1022 long
1023 GNEApplicationWindow::onCmdJoinJunctions(FXObject*, FXSelector, void*) {
1025  return 1;
1026 }
1027 
1028 
1029 long
1030 GNEApplicationWindow::onCmdOptions(FXObject*, FXSelector, void*) {
1031  GNEDialog_Wizard* wizard =
1032  new GNEDialog_Wizard(this, "Configure Options", getWidth(), getHeight());
1033 
1034  if (wizard->execute()) {
1035  NIFrame::checkOptions(); // needed to set projection parameters
1036  }
1037  return 1;
1038 }
1039 
1040 
1041 long
1042 GNEApplicationWindow::onCmdSaveAsNetwork(FXObject*, FXSelector, void*) {
1043  FXString file = MFXUtils::getFilename2Write(this,
1044  "Save Network as", ".net.xml",
1046  gCurrentFolder);
1047  if (file == "") {
1048  return 1;
1049  }
1051  oc.resetWritable();
1052  oc.set("output-file", file.text());
1053  setTitle(MFXUtils::getTitleText(myTitlePrefix, file));
1054  onCmdSaveNetwork(0, 0, 0);
1055  return 1;
1056 }
1057 
1058 
1059 long
1060 GNEApplicationWindow::onCmdSaveAsPlainXML(FXObject*, FXSelector, void*) {
1061  FXString file = MFXUtils::getFilename2Write(this,
1062  "Select name of the plain-xml edge-file (other names will be deduced from this)", ".edg.xml",
1064  gCurrentFolder);
1065  if (file == "") {
1066  return 1;
1067  }
1069  bool wasSet = oc.isSet("plain-output-prefix");
1070  std::string oldPrefix = oc.getString("plain-output-prefix");
1071  oc.resetWritable();
1072  std::string prefix = file.text();
1073  prefix = prefix.substr(0, prefix.size() - 8);
1074  oc.set("plain-output-prefix", prefix);
1075  getApp()->beginWaitCursor();
1076  try {
1077  myNet->savePlain(oc);
1078  myUndoList->unmark();
1079  myUndoList->mark();
1080  } catch (IOError& e) {
1081  FXMessageBox::error(this, MBOX_OK, "Saving plain xml failed!", "%s", e.what());
1082  }
1083  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Plain XML saved with prefix '" + prefix + "'.\n");
1085  if (wasSet) {
1086  oc.resetWritable();
1087  oc.set("plain-output-prefix", oldPrefix);
1088  } else {
1089  oc.unSet("plain-output-prefix");
1090  }
1091  getApp()->endWaitCursor();
1092  return 1;
1093 }
1094 
1095 
1096 long
1097 GNEApplicationWindow::onCmdSaveJoined(FXObject*, FXSelector, void*) {
1098  FXString file = MFXUtils::getFilename2Write(this,
1099  "Select name of the joined-junctions file", ".nod.xml",
1101  gCurrentFolder);
1102  if (file == "") {
1103  return 1;
1104  }
1106  bool wasSet = oc.isSet("junctions.join-output");
1107  std::string oldFile = oc.getString("junctions.join-output");
1108  oc.resetWritable();
1109  std::string filename = file.text();
1110  oc.set("junctions.join-output", filename);
1111  getApp()->beginWaitCursor();
1112  try {
1113  myNet->saveJoined(oc);
1114  } catch (IOError& e) {
1115  FXMessageBox::error(this, MBOX_OK, "Saving joined junctions failed!", "%s", e.what());
1116  }
1117  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Joined junctions saved to '" + filename + "'.\n");
1119  if (wasSet) {
1120  oc.resetWritable();
1121  oc.set("junctions.join-output", oldFile);
1122  } else {
1123  oc.unSet("junctions.join-output");
1124  }
1125  getApp()->endWaitCursor();
1126  return 1;
1127 }
1128 
1129 
1130 long
1131 GNEApplicationWindow::onCmdSavePois(FXObject*, FXSelector, void*) {
1132  FXString file = MFXUtils::getFilename2Write(this,
1133  "Select name of the POI file", ".xml",
1135  gCurrentFolder);
1136  if (file == "") {
1137  return 1;
1138  }
1139  std::string filename = file.text();
1140  // XXX Not yet implemented
1141  getApp()->beginWaitCursor();
1142  try {
1143  GNEPOI::saveToFile(filename);
1144  } catch (IOError& e) {
1145  FXMessageBox::error(this, MBOX_OK, "Saving POIs failed!", "%s", e.what());
1146  }
1148  getApp()->endWaitCursor();
1149  return 1;
1150 }
1151 
1152 
1153 long
1154 GNEApplicationWindow::onUpdNeedsNetwork(FXObject* sender, FXSelector, void*) {
1155  sender->handle(this, myNet == 0 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1156  return 1;
1157 }
1158 
1159 
1160 long
1161 GNEApplicationWindow::onUpdReload(FXObject* sender, FXSelector, void*) {
1162  sender->handle(this, myNet == 0 || !OptionsCont::getOptions().isSet("sumo-net-file") ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), 0);
1163  return 1;
1164 }
1165 
1166 
1167 long
1168 GNEApplicationWindow::onCmdSaveNetwork(FXObject*, FXSelector, void*) {
1169  getApp()->beginWaitCursor();
1170  try {
1172  myNet->save(oc);
1173  myUndoList->unmark();
1174  myUndoList->mark();
1175  } catch (IOError& e) {
1176  FXMessageBox::error(this, MBOX_OK, "Saving Network failed!", "%s", e.what());
1177  }
1178  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Network saved.\n");
1180  getApp()->endWaitCursor();
1181  return 1;
1182 }
1183 
1184 
1185 
1186 long
1187 GNEApplicationWindow::onCmdSaveAdditionals(FXObject*, FXSelector, void*) {
1188  FXString file = MFXUtils::getFilename2Write(this,
1189  "Select name of the additional file", ".xml",
1191  gCurrentFolder);
1192  if (file == "") {
1193  return 1;
1194  }
1195  std::string filename = file.text();
1196  getApp()->beginWaitCursor();
1197  try {
1198  myNet->saveAdditionals(filename);
1199  myMessageWindow->appendMsg(EVENT_MESSAGE_OCCURED, "Additionals saved.\n");
1200  } catch (IOError& e) {
1201  FXMessageBox::error(this, MBOX_OK, "Saving additionals failed!", "%s", e.what());
1202  }
1204  getApp()->endWaitCursor();
1205  return 1;
1206 }
1207 
1208 
1209 long
1210 GNEApplicationWindow::onUpdSaveNetwork(FXObject* sender, FXSelector, void*) {
1212  bool enable = myNet != 0 && oc.isSet("output-file");
1213  sender->handle(this, FXSEL(SEL_COMMAND, enable ? ID_ENABLE : ID_DISABLE), 0);
1214  if (enable) {
1215  FXString caption = ("Save " + oc.getString("output-file")).c_str();
1216  sender->handle(this, FXSEL(SEL_COMMAND, FXMenuCaption::ID_SETSTRINGVALUE), (void*)&caption);
1217  }
1218  return 1;
1219 }
1220 
1221 
1222 GNEViewNet*
1224  if (mySubWindows.size() != 0) {
1225  return (GNEViewNet*)(((GUIGlChildWindow*)mySubWindows[0])->getView());
1226  } else {
1227  return 0;
1228  }
1229 }
1230 
1231 
1232 bool
1234  if (myUndoList->canUndo() && !myUndoList->marked()) {
1235  FXuint answer = FXMessageBox::question(this, MBOX_YES_NO,
1236  "Confirm Closing Network", "%s",
1237  "You have unsaved changes. Do you wish to close the network and discard all changes?");
1238  if (answer == 1) { //1:yes, 2:no, 4:esc
1239  myUndoList->p_clear(); // only ask once
1240  return true;
1241  } else {
1242  return false;
1243  }
1244  } else {
1245  return true;
1246  }
1247 }
1248 
1249 
1251  ShapeHandler(file, sc),
1252  myNet(net) {}
1253 
1254 
1256 
1257 
1258 Position
1259 GNEApplicationWindow::GNEShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, SUMOReal lanePos) {
1260  std::string edgeID = laneID;
1261  int lane = 0;
1262  const std::string::size_type underscore = laneID.rfind('_');
1263 
1264  if (underscore != std::string::npos) {
1265  edgeID = laneID.substr(0, underscore);
1266  lane = TplConvert::_2intSec(laneID.substr(underscore).c_str(), 0);
1267  }
1268  NBEdge* edge = myNet->retrieveEdge(edgeID)->getNBEdge();
1269  if (edge == 0 || edge->getNumLanes() <= lane) {
1270  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1271  return Position::INVALID;
1272  }
1273  if (lanePos < 0) {
1274  lanePos = edge->getLength() + lanePos;
1275  }
1276  return edge->getLanes()[lane].shape.positionAtOffset(lanePos);
1277 }
1278 
1279 
1280 void
1282  GNEViewNet* view = getView();
1283  if (view != 0) {
1284  view->updateControls();
1285  }
1286 }
1287 
1288 
1289 long
1290 GNEApplicationWindow::onKeyPress(FXObject* o, FXSelector sel, void* data) {
1291  const long handled = FXMainWindow::onKeyPress(o, sel, data);
1292  if (handled == 0 && myMDIClient->numChildren() > 0) {
1293  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1294  if (w != 0) {
1295  w->onKeyPress(0, sel, data);
1296  }
1297  }
1298  return 0;
1299 }
1300 
1301 
1302 long
1303 GNEApplicationWindow::onKeyRelease(FXObject* o, FXSelector sel, void* data) {
1304  const long handled = FXMainWindow::onKeyRelease(o, sel, data);
1305  if (handled == 0 && myMDIClient->numChildren() > 0) {
1306  GNEViewParent* w = dynamic_cast<GNEViewParent*>(myMDIClient->getActiveChild());
1307  if (w != 0) {
1308  w->onKeyRelease(0, sel, data);
1309  }
1310  }
1311  return 0;
1312 }
1313 
1314 /****************************************************************************/
std::vector< FXMainWindow * > myTrackerWindows
std::string myConfigPattern
Input file pattern.
FXLabel * myGeoCoordinate
GUISUMOAbstractView * getView() const
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1040
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
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:616
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:740
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 (and the icons)
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:852
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
Loads a file previously loaded.
Definition: GUIAppEnum.h:83
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
The representation of a single edge during network building.
Definition: NBEdge.h:70
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:799
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
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:86
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:798
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
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
void loadConfigOrNet(const std::string file, bool isNet, bool isReload=false, bool optionsReady=false, bool newNet=false)
starts to load a netimport configuration or a network */
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
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: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[]
#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)
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.
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)
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.
static void saveToFile(const std::string &file)
save POIs to file
Definition: GNEPOI.cpp:183
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
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:557
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
void loadOnStartup()
load net on startup
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
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.
#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 Called either by FileMenu->Quit, the normal close-me...
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
long onCmdDel(FXObject *sender, FXSelector sel, void *ptr)
called if the user hits del
FXRecentFiles myRecentNets
List of recent nets.
void removeSolitaryJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:902
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:590
FXGLCanvas * getBuildGLCanvas() const
get build OpenGL Canvas
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
void loadConfigOrNet(const std::string &file, bool isNet, bool optionsReady=false, bool newNet=false)
begins the loading of a netconvert configuration or a a network
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
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:456
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:225
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:762
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
GUISelectedStorage gSelected
A global holder of selected objects.
void hotkeyEnter()
handle enter keypress
Definition: GNEViewNet.cpp:775
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:564
misc messages
Definition: GUIAppEnum.h:478
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:583
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
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.