SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUIMainWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 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  //myGLVisual->setStencilSize(8); // enable stencil buffer
76 }
77 
78 
80  delete myBoldFont;
81  delete myTopDock;
82  delete myBottomDock;
83  delete myLeftDock;
84  delete myRightDock;
85 }
86 
87 
88 
89 void
90 GUIMainWindow::addChild(FXMDIChild* child, bool /*updateOnSimStep !!!*/) {
91  mySubWindows.push_back(child);
92 }
93 
94 
95 void
97  std::vector<FXMDIChild*>::iterator i = std::find(mySubWindows.begin(), mySubWindows.end(), child);
98  if (i != mySubWindows.end()) {
99  mySubWindows.erase(i);
100  }
101 }
102 
103 
104 void
105 GUIMainWindow::addChild(FXMainWindow* child, bool /*updateOnSimStep !!!*/) {
107  myTrackerWindows.push_back(child);
109 }
110 
111 
112 void
115  std::vector<FXMainWindow*>::iterator i = std::find(myTrackerWindows.begin(), myTrackerWindows.end(), child);
116  myTrackerWindows.erase(i);
118 }
119 
120 
121 std::vector<std::string>
123  std::vector<std::string> ret;
124  for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
125  ret.push_back((*i)->getTitle().text());
126  }
127  return ret;
128 }
129 
130 
131 FXMDIChild*
132 GUIMainWindow::getViewByID(const std::string& id) const {
133  for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
134  if (std::string((*i)->getTitle().text()) == id) {
135  return *i;
136  }
137  }
138  return 0;
139 }
140 
141 
142 FXFont*
144  return myBoldFont;
145 }
146 
147 
148 void
150  // inform views
151  myMDIClient->forallWindows(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
152  // inform other windows
154  for (size_t i = 0; i < myTrackerWindows.size(); i++) {
155  myTrackerWindows[i]->handle(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
156  }
158 }
159 
160 
161 FXGLVisual*
163  return myGLVisual;
164 }
165 
166 
167 FXLabel&
169  return *myCartesianCoordinate;
170 }
171 
172 
173 FXLabel&
175  return *myGeoCoordinate;
176 }
177 
178 
181  if (myInstance != 0) {
182  return myInstance;
183  }
184  throw ProcessError("A GUIMainWindow instance was not yet constructed.");
185 }
186 
187 
188 /****************************************************************************/
189 
std::vector< FXMainWindow * > myTrackerWindows
Definition: GUIMainWindow.h:97
FXLabel * myGeoCoordinate
FXFont * myBoldFont
Font used for popup-menu titles.
FXDockSite * myRightDock
FXGLVisual * myGLVisual
The gl-visual used.
FXMDIChild * getViewByID(const std::string &id) const
#define new
Definition: debug_new.h:123
FXLabel & getCartesianLabel()
std::vector< FXMDIChild * > mySubWindows
Definition: GUIMainWindow.h:96
void addChild(FXMDIChild *child, bool updateOnSimStep=true)
Adds a further child window to the list.
static GUIMainWindow * getInstance()
FXDockSite * myLeftDock
A Simulation step was performed.
Definition: GUIAppEnum.h:273
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:96
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:99
FXDockSite * myTopDock
virtual ~GUIMainWindow()
void lock()
lock mutex
Definition: MFXMutex.cpp:86
FXMDIClient * myMDIClient
The multi view panel.
std::vector< std::string > getViewIDs() const