GUIMainWindow.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <string>
00031 #include "GUIMainWindow.h"
00032 #include <algorithm>
00033 #include "GUIAppEnum.h"
00034 #include <fx3d.h>
00035 #include <utils/common/StringUtils.h>
00036
00037 #ifdef CHECK_MEMORY_LEAKS
00038 #include <foreign/nvwa/debug_new.h>
00039 #endif // CHECK_MEMORY_LEAKS
00040
00041
00042
00043
00044
00045 GUIMainWindow::GUIMainWindow(FXApp* a)
00046 : FXMainWindow(a,"SUMO-gui main window",NULL,NULL,DECOR_ALL,20,20,600,400),
00047 myGLVisual(new FXGLVisual(a, VISUAL_DOUBLEBUFFER|VISUAL_STEREO)),
00048 myRunAtBegin(false), myAmGaming(false) {
00049
00050 FXFontDesc fdesc;
00051 getApp()->getNormalFont()->getFontDesc(fdesc);
00052 fdesc.weight = FXFont::Bold;
00053 myBoldFont = new FXFont(getApp(), fdesc);
00054
00055 myTopDock=new FXDockSite(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
00056 myBottomDock=new FXDockSite(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X);
00057 myLeftDock=new FXDockSite(this,LAYOUT_SIDE_LEFT|LAYOUT_FILL_Y);
00058 myRightDock=new FXDockSite(this,LAYOUT_SIDE_RIGHT|LAYOUT_FILL_Y);
00059 }
00060
00061
00062 GUIMainWindow::~GUIMainWindow() {
00063 delete myBoldFont;
00064 delete myTopDock;
00065 delete myBottomDock;
00066 delete myLeftDock;
00067 delete myRightDock;
00068 }
00069
00070
00071
00072 void
00073 GUIMainWindow::addChild(FXMDIChild *child, bool ) {
00074 mySubWindows.push_back(child);
00075 }
00076
00077
00078 void
00079 GUIMainWindow::removeChild(FXMDIChild *child) {
00080 std::vector<FXMDIChild*>::iterator i =
00081 std::find(mySubWindows.begin(), mySubWindows.end(), child);
00082 if (i!=mySubWindows.end()) {
00083 mySubWindows.erase(i);
00084 }
00085 }
00086
00087
00088 void
00089 GUIMainWindow::addChild(FXMainWindow *child, bool ) {
00090 myTrackerLock.lock();
00091 myTrackerWindows.push_back(child);
00092 myTrackerLock.unlock();
00093 }
00094
00095
00096 void
00097 GUIMainWindow::removeChild(FXMainWindow *child) {
00098 myTrackerLock.lock();
00099 std::vector<FXMainWindow*>::iterator i =
00100 std::find(myTrackerWindows.begin(), myTrackerWindows.end(), child);
00101 myTrackerWindows.erase(i);
00102 myTrackerLock.unlock();
00103 }
00104
00105
00106 FXFont *
00107 GUIMainWindow::getBoldFont() {
00108 return myBoldFont;
00109 }
00110
00111
00112 void
00113 GUIMainWindow::updateChildren() {
00114
00115 myMDIClient->forallWindows(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
00116
00117 myTrackerLock.lock();
00118 for (size_t i=0; i<myTrackerWindows.size(); i++) {
00119 myTrackerWindows[i]->handle(this,FXSEL(SEL_COMMAND,MID_SIMSTEP), 0);
00120 }
00121 myTrackerLock.unlock();
00122 }
00123
00124
00125 FXGLVisual *
00126 GUIMainWindow::getGLVisual() const {
00127 return myGLVisual;
00128 }
00129
00130
00131 FXLabel &
00132 GUIMainWindow::getCartesianLabel() {
00133 return *myCartesianCoordinate;
00134 }
00135
00136
00137 FXLabel &
00138 GUIMainWindow::getGeoLabel() {
00139 return *myGeoCoordinate;
00140 }
00141
00142
00143 bool
00144 GUIMainWindow::isGaming() const throw() {
00145 return myAmGaming;
00146 }
00147
00148
00149
00150