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.sourceforge.net/
12 // Copyright (C) 2001-2012 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 "GUIMainWindow.h"
35 #include <algorithm>
36 #include "GUIAppEnum.h"
37 #include <fx3d.h>
39 
40 #ifdef CHECK_MEMORY_LEAKS
41 #include <foreign/nvwa/debug_new.h>
42 #endif // CHECK_MEMORY_LEAKS
43 
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
49  : FXMainWindow(a, "SUMO-gui main window", NULL, NULL, DECOR_ALL, 20, 20, 600, 400),
50  myGLVisual(new FXGLVisual(a, VISUAL_DOUBLEBUFFER | VISUAL_STEREO)),
51  myAmGaming(false), myListInternal(false) {
52 
53  FXFontDesc fdesc;
54  getApp()->getNormalFont()->getFontDesc(fdesc);
55  fdesc.weight = FXFont::Bold;
56  myBoldFont = new FXFont(getApp(), fdesc);
57 
58  myTopDock = new FXDockSite(this, LAYOUT_SIDE_TOP | LAYOUT_FILL_X);
59  myBottomDock = new FXDockSite(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X);
60  myLeftDock = new FXDockSite(this, LAYOUT_SIDE_LEFT | LAYOUT_FILL_Y);
61  myRightDock = new FXDockSite(this, LAYOUT_SIDE_RIGHT | LAYOUT_FILL_Y);
62 }
63 
64 
66  delete myBoldFont;
67  delete myTopDock;
68  delete myBottomDock;
69  delete myLeftDock;
70  delete myRightDock;
71 }
72 
73 
74 
75 void
76 GUIMainWindow::addChild(FXMDIChild* child, bool /*updateOnSimStep !!!*/) {
77  mySubWindows.push_back(child);
78 }
79 
80 
81 void
83  std::vector<FXMDIChild*>::iterator i = std::find(mySubWindows.begin(), mySubWindows.end(), child);
84  if (i != mySubWindows.end()) {
85  mySubWindows.erase(i);
86  }
87 }
88 
89 
90 void
91 GUIMainWindow::addChild(FXMainWindow* child, bool /*updateOnSimStep !!!*/) {
93  myTrackerWindows.push_back(child);
95 }
96 
97 
98 void
101  std::vector<FXMainWindow*>::iterator i = std::find(myTrackerWindows.begin(), myTrackerWindows.end(), child);
102  myTrackerWindows.erase(i);
104 }
105 
106 
107 std::vector<std::string>
109  std::vector<std::string> ret;
110  for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
111  ret.push_back((*i)->getTitle().text());
112  }
113  return ret;
114 }
115 
116 
117 FXMDIChild*
118 GUIMainWindow::getViewByID(const std::string& id) const {
119  for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
120  if (std::string((*i)->getTitle().text()) == id) {
121  return *i;
122  }
123  }
124  return 0;
125 }
126 
127 
128 FXFont*
130  return myBoldFont;
131 }
132 
133 
134 void
136  // inform views
137  myMDIClient->forallWindows(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
138  // inform other windows
140  for (size_t i = 0; i < myTrackerWindows.size(); i++) {
141  myTrackerWindows[i]->handle(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
142  }
144 }
145 
146 
147 FXGLVisual*
149  return myGLVisual;
150 }
151 
152 
153 FXLabel&
155  return *myCartesianCoordinate;
156 }
157 
158 
159 FXLabel&
161  return *myGeoCoordinate;
162 }
163 
164 /****************************************************************************/
165