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-2017 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 
59 // ===========================================================================
60 // main function
61 // ===========================================================================
62 int
63 main(int argc, char** argv) {
64  // make the output aware of threading
65  MFXMutex lock;
67  // get the options
69  // give some application descriptions
70  oc.setApplicationDescription("Graphical editor for SUMO networks.");
71  oc.setApplicationName("netedit", "Netedit Version " VERSION_STRING);
72  int ret = 0;
73 #ifndef _DEBUG
74  try {
75 #else
76  {
77 #endif
78  // initialise subsystems
81  OptionsIO::setArgs(argc, argv);
83  if (oc.processMetaOptions(false)) {
85  return 0;
86  }
87  // Make application
88  FXApp application("Netedit", "DLR");
89  // Open display
90  application.init(argc, argv);
91  int minor, major;
92  if (!FXGLVisual::supported(&application, major, minor)) {
93  throw ProcessError("This system has no OpenGL support. Exiting.");
94  }
95  // build the main window
96  GNEApplicationWindow* window =
97  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
98  gSchemeStorage.init(&application);
99  window->dependentBuild();
100  // Create app
101  application.addSignal(SIGINT, window, MID_QUIT);
102  application.create();
103  // Load configuration given on command line
104  if (argc > 1) {
105  // Set default options
106  OptionsIO::setArgs(argc, argv);
107  // load options
108  window->loadOptionOnStartup();
109  }
110  // Run
111  ret = application.run();
112 #ifndef _DEBUG
113  } catch (const std::exception& e) {
114  if (std::string(e.what()) != std::string("")) {
115  WRITE_ERROR(e.what());
116  }
117  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
118  ret = 1;
119  } catch (...) {
120  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
121  ret = 1;
122 #endif
123  }
125  return ret;
126 }
127 
128 
129 
130 /****************************************************************************/
131 
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:54
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:82
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:275
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:62
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
Main window closes.
Definition: GUIAppEnum.h:55
#define VERSION_STRING
Definition: config.h:210
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
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:85
A storage for options typed value containers)
Definition: OptionsCont.h:99
void init(FXApp *app)
Initialises the storage with some default settings.
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.