SUMO - Simulation of Urban MObility
netedit_main.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Main for NETEDIT (adapted from guisim_main)
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #ifdef HAVE_VERSION_H
25 #include <version.h>
26 #endif
27 
28 #include <ctime>
29 #include <signal.h>
30 #include <iostream>
31 #include <utils/options/Option.h>
39 #include <utils/xml/XMLSubSys.h>
44 #include <netimport/NIFrame.h>
45 #include <netbuild/NBFrame.h>
46 #include <netwrite/NWFrame.h>
47 
48 #include "GNEApplicationWindow.h"
49 #include "GNELoadThread.h"
50 
51 
52 // ===========================================================================
53 // main function
54 // ===========================================================================
55 int
56 main(int argc, char** argv) {
57  // make the output aware of threading
58  MFXMutex lock;
60  // get the options
62  // give some application descriptions
63  oc.setApplicationDescription("Graphical editor for SUMO networks.");
64  oc.setApplicationName("netedit", "Eclipse SUMO netedit Version " VERSION_STRING);
65  int ret = 0;
66 #ifndef _DEBUG
67  try {
68 #else
69  {
70 #endif
71  // initialise subsystems
74  OptionsIO::setArgs(argc, argv);
76  if (oc.processMetaOptions(false)) {
78  return 0;
79  }
80  // Make application
81  FXApp application("SUMO netedit", "Eclipse");
82  // Open display
83  application.init(argc, argv);
84  int minor, major;
85  if (!FXGLVisual::supported(&application, major, minor)) {
86  throw ProcessError("This system has no OpenGL support. Exiting.");
87  }
88  // build the main window
89  GNEApplicationWindow* window =
90  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
91  gSchemeStorage.init(&application, true);
92  window->dependentBuild();
93  // Create app
94  application.addSignal(SIGINT, window, MID_QUIT);
95  application.create();
96  // Load configuration given on command line
97  if (argc > 1) {
98  // Set default options
99  OptionsIO::setArgs(argc, argv);
100  // load options
101  window->loadOptionOnStartup();
102  }
103  // Run
104  ret = application.run();
105 #ifndef _DEBUG
106  } catch (const std::exception& e) {
107  if (std::string(e.what()) != std::string("")) {
108  WRITE_ERROR(e.what());
109  }
110  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
111  ret = 1;
112  } catch (...) {
113  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
114  ret = 1;
115 #endif
116  }
118  return ret;
119 }
120 
121 
122 
123 /****************************************************************************/
124 
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:48
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:76
GUICompleteSchemeStorage gSchemeStorage
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:76
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:313
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:55
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
#define VERSION_STRING
Definition: version.h:1
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:248
Main window closes.
Definition: GUIAppEnum.h:48
void loadOptionOnStartup()
load net on startup
int main(int argc, char **argv)
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:113
A storage for options typed value containers)
Definition: OptionsCont.h:92
void dependentBuild()
build dependent
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.