SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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 // main function
65 // ===========================================================================
66 int
67 main(int argc, char** argv) {
68  // make the output aware of threading
69  MFXMutex lock;
71  // get the options
73  // give some application descriptions
74  oc.setApplicationDescription("Graphical editor for SUMO networks.");
75  oc.setApplicationName("netedit.exe", "Netedit Version " VERSION_STRING);
76  int ret = 0;
77 #ifndef _DEBUG
78  try {
79 #else
80  {
81 #endif
82  // initialise subsystems
85  OptionsIO::setArgs(argc, argv);
87  if (oc.processMetaOptions(false)) {
89  return 0;
90  }
91  // Make application
92  FXApp application("Netedit", "DLR");
93  // Open display
94  application.init(argc, argv);
95  int minor, major;
96  if (!FXGLVisual::supported(&application, major, minor)) {
97  throw ProcessError("This system has no OpenGL support. Exiting.");
98  }
99  // build the main window
100  GNEApplicationWindow* window =
101  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
102  gSchemeStorage.init(&application);
103  window->dependentBuild();
104  // Create app
105  application.addSignal(SIGINT, window, MID_QUIT);
106  application.create();
107  // Load configuration given on command line
108  if (argc > 1) {
109  // Set default options
110  OptionsIO::setArgs(argc, argv);
111  // load options
112  window->loadOptionOnStartup();
113  }
114  // Run
115  ret = application.run();
116 #ifndef _DEBUG
117  } catch (const std::exception& e) {
118  if (std::string(e.what()) != std::string("")) {
119  WRITE_ERROR(e.what());
120  }
121  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
122  ret = 1;
123  } catch (...) {
124  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
125  ret = 1;
126 #endif
127  }
129  return ret;
130 }
131 
132 
133 
134 /****************************************************************************/
135 
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
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:72
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: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:65
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
#define VERSION_STRING
Definition: config.h:226
#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:89
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.