Eclipse 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-2019 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 /****************************************************************************/
14 // Main for NETEDIT (adapted from guisim_main)
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #ifdef HAVE_VERSION_H
24 #include <version.h>
25 #endif
26 
27 #include <signal.h>
34 #include <utils/xml/XMLSubSys.h>
35 
36 #include "GNEApplicationWindow.h"
37 #include "GNELoadThread.h"
38 
39 
40 // ===========================================================================
41 // main function
42 // ===========================================================================
43 int
44 main(int argc, char** argv) {
45  // make the output aware of threading
47  // get the options
49  // give some application descriptions
50  oc.setApplicationDescription("Graphical editor for SUMO networks.");
51  oc.setApplicationName("netedit", "Eclipse SUMO netedit Version " VERSION_STRING);
52  int ret = 0;
53 #ifndef _DEBUG
54  try {
55 #else
56  {
57 #endif
58  // initialise subsystems
61  OptionsIO::setArgs(argc, argv);
63  if (oc.processMetaOptions(false)) {
65  return 0;
66  }
67  // Make application
68  FXApp application("SUMO netedit", "Eclipse");
69  // Open display
70  application.init(argc, argv);
71  int minor, major;
72  if (!FXGLVisual::supported(&application, major, minor)) {
73  throw ProcessError("This system has no OpenGL support. Exiting.");
74  }
75  // build the main window
76  GNEApplicationWindow* window =
77  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
78  gSchemeStorage.init(&application, true);
79  window->dependentBuild();
80  // Create app
81  application.addSignal(SIGINT, window, MID_HOTKEY_CTRL_Q_CLOSE);
82  application.create();
83  // Load configuration given on command line
84  if (argc > 1) {
85  // Set default options
86  OptionsIO::setArgs(argc, argv);
87  // load options
88  window->loadOptionOnStartup();
89  }
90  // focus window at startup
91  window->setFocus();
92  // Run
93  ret = application.run();
94 #ifndef _DEBUG
95  } catch (const std::exception& e) {
96  if (std::string(e.what()) != std::string("")) {
97  WRITE_ERROR(e.what());
98  }
99  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
100  ret = 1;
101  } catch (...) {
102  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
103  ret = 1;
104 #endif
105  }
107  return ret;
108 }
109 
110 
111 
112 /****************************************************************************/
113 
GUICompleteSchemeStorage.h
OptionsCont::processMetaOptions
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
Definition: OptionsCont.cpp:557
SystemFrame::close
static void close()
Closes all of an applications subsystems.
Definition: SystemFrame.cpp:133
GNEApplicationWindow::loadOptionOnStartup
void loadOptionOnStartup()
load net on startup
Definition: GNEApplicationWindow.cpp:1783
OptionsCont.h
MsgHandler::inform
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
GNEApplicationWindow
The main window of the Netedit.
Definition: GNEApplicationWindow.h:58
GUIAppEnum.h
MsgHandlerSynchronized::create
static MsgHandler * create(MsgType type)
Definition: MsgHandlerSynchronized.h:50
MsgHandler::setFactory
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
Definition: MsgHandler.h:63
OptionsCont::setApplicationName
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
Definition: OptionsCont.cpp:481
SystemFrame.h
main
int main(int argc, char **argv)
Definition: netedit_main.cpp:44
ProcessError
Definition: UtilExceptions.h:39
GNEApplicationWindow.h
gSchemeStorage
GUICompleteSchemeStorage gSchemeStorage
Definition: GUICompleteSchemeStorage.cpp:38
XMLSubSys::init
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:47
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
GNEApplicationWindow::dependentBuild
void dependentBuild()
build dependent
Definition: GNEApplicationWindow.cpp:385
GNELoadThread.h
MID_HOTKEY_CTRL_Q_CLOSE
@ MID_HOTKEY_CTRL_Q_CLOSE
Main window closes.
Definition: GUIAppEnum.h:99
OptionsIO::getOptions
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:75
OptionsCont::setApplicationDescription
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
Definition: OptionsCont.cpp:489
MsgHandlerSynchronized.h
OptionsIO::setArgs
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:54
GNELoadThread::fillOptions
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
Definition: GNELoadThread.cpp:200
config.h
GUICompleteSchemeStorage::init
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
Definition: GUICompleteSchemeStorage.cpp:111
MsgHandler::getErrorInstance
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:81
VERSION_STRING
#define VERSION_STRING
Definition: config.h:210
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
OptionsIO.h
XMLSubSys.h