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-2015 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 // methods
65 // ===========================================================================
66 
67 
68 /* -------------------------------------------------------------------------
69  * main
70  * ----------------------------------------------------------------------- */
71 int
72 main(int argc, char** argv) {
73  // make the output aware of threading
74  MFXMutex lock;
76  // get the options
78  // give some application descriptions
79  oc.setApplicationDescription("Graphical editor for SUMO networks.");
80  oc.setApplicationName("netedit.exe", "Netedit Version " + getBuildName(VERSION_STRING));
81  int ret = 0;
82 #ifndef _DEBUG
83  try {
84 #else
85  {
86 #endif
87  // initialise subsystems
91  OptionsIO::setArgs(argc, argv);
93  if (oc.processMetaOptions(false)) {
95  return 0;
96  }
97  XMLSubSys::setValidation(oc.getString("xml-validation"), oc.getString("xml-validation.net"));
98  // within gui-based applications, nothing is reported to the console
99  /*
100  MsgHandler::getErrorInstance()->report2cout(false);
101  MsgHandler::getErrorInstance()->report2cerr(false);
102  MsgHandler::getWarningInstance()->report2cout(false);
103  MsgHandler::getWarningInstance()->report2cerr(false);
104  MsgHandler::getMessageInstance()->report2cout(false);
105  MsgHandler::getMessageInstance()->report2cerr(false);
106  */
107  // Make application
108  FXApp application("Netedit", "DLR");
109  // Open display
110  application.init(argc, argv);
111  int minor, major;
112  if (!FXGLVisual::supported(&application, major, minor)) {
113  throw ProcessError("This system has no OpenGL support. Exiting.");
114  }
115  // initialise global settings
116  GUITexturesHelper::allowTextures(!oc.getBool("disable-textures"));
117 
118  // build the main window
119  GNEApplicationWindow* window =
120  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
121  window->dependentBuild();
122  gSchemeStorage.init(&application);
123  // init simulation and visualization structures
124  // initGuiShapeNames();
125  // Create app
126  application.addSignal(SIGINT, window, MID_QUIT);
127  application.create();
128  // Load configuration given on command line
129  if (oc.isSet("configuration-file") || oc.isSet("sumo-net-file")) {
130  window->loadOnStartup();
131  }
132  // Run
133  ret = application.run();
134 #ifndef _DEBUG
135  } catch (const std::exception& e) {
136  if (std::string(e.what()) != std::string("")) {
137  WRITE_ERROR(e.what());
138  }
139  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
140  ret = 1;
141  } catch (...) {
142  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
143  ret = 1;
144 #endif
145  }
147  return ret;
148 }
149 
150 
151 
152 /****************************************************************************/
153 
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
Main window closes.
Definition: GUIAppEnum.h:55
The main window of the Netedit.
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:69
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
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:64
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
const std::string getBuildName(const std::string &version)
attach some build flags to the version string
Definition: StdDefs.cpp:91
#define VERSION_STRING
Definition: config.h:226
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
static void getOptions()
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:71
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.
static void allowTextures(const bool val)
switch texture drawing on and off
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.