SUMO - Simulation of Urban MObility
netedit_main.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Main for NETEDIT (adapted from guisim_main)
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 <ctime>
36 #include <signal.h>
37 #include <iostream>
38 #include <utils/options/Option.h>
46 #include <utils/xml/XMLSubSys.h>
51 #include <netimport/NIFrame.h>
52 #include <netbuild/NBFrame.h>
53 #include <netwrite/NWFrame.h>
54 
55 #include "GNEApplicationWindow.h"
56 #include "GNELoadThread.h"
57 
58 #ifdef CHECK_MEMORY_LEAKS
59 #include <foreign/nvwa/debug_new.h>
60 #endif
61 
62 
63 // ===========================================================================
64 // main function
65 // ===========================================================================
66 int
67 main(int argc, char** argv) {
68  // make the output aware of threading
69  MFXMutex lock;
71  // get the options
73  // give some application descriptions
74  oc.setApplicationDescription("Graphical editor for SUMO networks.");
75  oc.setApplicationName("netedit.exe", "Netedit Version " VERSION_STRING);
76  int ret = 0;
77 #ifndef _DEBUG
78  try {
79 #else
80  {
81 #endif
82  // initialise subsystems
84  // Make application
85  FXApp application("Netedit", "DLR");
86  // Open display
87  application.init(argc, argv);
88  int minor, major;
89  if (!FXGLVisual::supported(&application, major, minor)) {
90  throw ProcessError("This system has no OpenGL support. Exiting.");
91  }
92  // build the main window
93  GNEApplicationWindow* window =
94  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
95  gSchemeStorage.init(&application);
96  window->dependentBuild();
97  // Create app
98  application.addSignal(SIGINT, window, MID_QUIT);
99  application.create();
100  // Load configuration given on command line
101  if (argc > 1) {
102  OptionsIO::setArgs(argc, argv);
103  window->loadOnStartup();
104  }
105  // Run
106  ret = application.run();
107 #ifndef _DEBUG
108  } catch (const std::exception& e) {
109  if (std::string(e.what()) != std::string("")) {
110  WRITE_ERROR(e.what());
111  }
112  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
113  ret = 1;
114  } catch (...) {
115  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
116  ret = 1;
117 #endif
118  }
120  return ret;
121 }
122 
123 
124 
125 /****************************************************************************/
126 
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:58
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
GUICompleteSchemeStorage gSchemeStorage
The main window of the Netedit.
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
static void assignLock(AbstractMutex *lock)
Sets the lock to use The lock will not be deleted.
Definition: MsgHandler.cpp:279
static void close()
Closes all of an applications subsystems.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:65
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
Main window closes.
Definition: GUIAppEnum.h:55
#define VERSION_STRING
Definition: version.h:1
void loadOnStartup()
load net on startup
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
int main(int argc, char **argv)
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:89
A storage for options typed value containers)
Definition: OptionsCont.h:108
void init(FXApp *app)
Initialises the storage with some default settings.
void dependentBuild()
build dependent
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.