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