SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIMainWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <algorithm>
35 #include <fx.h>
36 #include <fx3d.h>
41 #include "GUIAppEnum.h"
42 #include "GUIMainWindow.h"
43 
44 #ifdef CHECK_MEMORY_LEAKS
45 #include <foreign/nvwa/debug_new.h>
46 #endif // CHECK_MEMORY_LEAKS
47 
48 
49 // ===========================================================================
50 // static member definitions
51 // ===========================================================================
53 
54 // ===========================================================================
55 // member method definitions
56 // ===========================================================================
58  : FXMainWindow(a, "SUMO-gui main window", NULL, NULL, DECOR_ALL, 20, 20, 600, 400),
59  myGLVisual(new FXGLVisual(a, VISUAL_DOUBLEBUFFER)),
60  myAmGaming(false), myListInternal(false) {
61 
62  FXFontDesc fdesc;
63  getApp()->getNormalFont()->getFontDesc(fdesc);
64  fdesc.weight = FXFont::Bold;
65  myBoldFont = new FXFont(getApp(), fdesc);
66 
67  myTopDock = new FXDockSite(this, LAYOUT_SIDE_TOP | LAYOUT_FILL_X);
68  myBottomDock = new FXDockSite(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X);
69  myLeftDock = new FXDockSite(this, LAYOUT_SIDE_LEFT | LAYOUT_FILL_Y);
70  myRightDock = new FXDockSite(this, LAYOUT_SIDE_RIGHT | LAYOUT_FILL_Y);
71  if (myInstance != 0) {
72  throw ProcessError("MainWindow initialized twice");
73  }
74  myInstance = this;
75 }
76 
77 
79  delete myBoldFont;
80  delete myTopDock;
81  delete myBottomDock;
82  delete myLeftDock;
83  delete myRightDock;
84 }
85 
86 
87 
88 void
89 GUIMainWindow::addChild(FXMDIChild* child, bool /*updateOnSimStep !!!*/) {
90  mySubWindows.push_back(child);
91 }
92 
93 
94 void
96  std::vector<FXMDIChild*>::iterator i = std::find(mySubWindows.begin(), mySubWindows.end(), child);
97  if (i != mySubWindows.end()) {
98  mySubWindows.erase(i);
99  }
100 }
101 
102 
103 void
104 GUIMainWindow::addChild(FXMainWindow* child, bool /*updateOnSimStep !!!*/) {
106  myTrackerWindows.push_back(child);
108 }
109 
110 
111 void
114  std::vector<FXMainWindow*>::iterator i = std::find(myTrackerWindows.begin(), myTrackerWindows.end(), child);
115  myTrackerWindows.erase(i);
117 }
118 
119 
120 std::vector<std::string>
122  std::vector<std::string> ret;
123  for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
124  ret.push_back((*i)->getTitle().text());
125  }
126  return ret;
127 }
128 
129 
130 FXMDIChild*
131 GUIMainWindow::getViewByID(const std::string& id) const {
132  for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
133  if (std::string((*i)->getTitle().text()) == id) {
134  return *i;
135  }
136  }
137  return 0;
138 }
139 
140 
141 FXFont*
143  return myBoldFont;
144 }
145 
146 
147 void
149  // inform views
150  myMDIClient->forallWindows(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
151  // inform other windows
153  for (size_t i = 0; i < myTrackerWindows.size(); i++) {
154  myTrackerWindows[i]->handle(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
155  }
157 }
158 
159 
160 FXGLVisual*
162  return myGLVisual;
163 }
164 
165 
166 FXLabel&
168  return *myCartesianCoordinate;
169 }
170 
171 
172 FXLabel&
174  return *myGeoCoordinate;
175 }
176 
177 
180  if (myInstance != 0) {
181  return myInstance;
182  }
183  throw ProcessError("A GUIMainWindow instance was not yet constructed.");
184 }
185 
186 
187 /****************************************************************************/
188 
std::vector< FXMainWindow * > myTrackerWindows
Definition: GUIMainWindow.h:90
FXLabel * myGeoCoordinate
FXFont * myBoldFont
Font used for popup-menu titles.
Definition: GUIMainWindow.h:95
FXDockSite * myRightDock
FXGLVisual * myGLVisual
The gl-visual used.
A Simulation step was performed.
Definition: GUIAppEnum.h:263
FXMDIChild * getViewByID(const std::string &id) const
#define new
Definition: debug_new.h:123
FXLabel & getCartesianLabel()
std::vector< FXMDIChild * > mySubWindows
Definition: GUIMainWindow.h:89
void addChild(FXMDIChild *child, bool updateOnSimStep=true)
Adds a further child window to the list.
static GUIMainWindow * getInstance()
FXDockSite * myLeftDock
static GUIMainWindow * myInstance
the singleton window instance
FXFont * getBoldFont()
FXGLVisual * getGLVisual() const
FXLabel & getGeoLabel()
void removeChild(FXMDIChild *child)
removes the given child window from the list
void unlock()
release mutex lock
Definition: MFXMutex.cpp:94
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
FXDockSite * myBottomDock
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
Definition: GUIMainWindow.h:92
FXDockSite * myTopDock
virtual ~GUIMainWindow()
void lock()
lock mutex
Definition: MFXMutex.cpp:84
FXMDIClient * myMDIClient
The multi view panel.
Definition: GUIMainWindow.h:98
std::vector< std::string > getViewIDs() const