|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 00020 00021 // =========================================================================== 00022 // included modules 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 // member method definitions 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), myListInternal(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 /*updateOnSimStep !!!*/) { 00074 mySubWindows.push_back(child); 00075 } 00076 00077 00078 void 00079 GUIMainWindow::removeChild(FXMDIChild* child) { 00080 std::vector<FXMDIChild*>::iterator i = std::find(mySubWindows.begin(), mySubWindows.end(), child); 00081 if (i!=mySubWindows.end()) { 00082 mySubWindows.erase(i); 00083 } 00084 } 00085 00086 00087 void 00088 GUIMainWindow::addChild(FXMainWindow* child, bool /*updateOnSimStep !!!*/) { 00089 myTrackerLock.lock(); 00090 myTrackerWindows.push_back(child); 00091 myTrackerLock.unlock(); 00092 } 00093 00094 00095 void 00096 GUIMainWindow::removeChild(FXMainWindow* child) { 00097 myTrackerLock.lock(); 00098 std::vector<FXMainWindow*>::iterator i = std::find(myTrackerWindows.begin(), myTrackerWindows.end(), child); 00099 myTrackerWindows.erase(i); 00100 myTrackerLock.unlock(); 00101 } 00102 00103 00104 std::vector<std::string> 00105 GUIMainWindow::getViewIDs() const throw() { 00106 std::vector<std::string> ret; 00107 for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i!=mySubWindows.end(); ++i) { 00108 ret.push_back((*i)->getTitle().text()); 00109 } 00110 return ret; 00111 } 00112 00113 00114 FXMDIChild* 00115 GUIMainWindow::getViewByID(const std::string& id) const throw() { 00116 for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i!=mySubWindows.end(); ++i) { 00117 if (std::string((*i)->getTitle().text())==id) { 00118 return *i; 00119 } 00120 } 00121 return 0; 00122 } 00123 00124 00125 FXFont* 00126 GUIMainWindow::getBoldFont() { 00127 return myBoldFont; 00128 } 00129 00130 00131 void 00132 GUIMainWindow::updateChildren() { 00133 // inform views 00134 myMDIClient->forallWindows(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0); 00135 // inform other windows 00136 myTrackerLock.lock(); 00137 for (size_t i=0; i<myTrackerWindows.size(); i++) { 00138 myTrackerWindows[i]->handle(this,FXSEL(SEL_COMMAND,MID_SIMSTEP), 0); 00139 } 00140 myTrackerLock.unlock(); 00141 } 00142 00143 00144 FXGLVisual* 00145 GUIMainWindow::getGLVisual() const { 00146 return myGLVisual; 00147 } 00148 00149 00150 FXLabel& 00151 GUIMainWindow::getCartesianLabel() { 00152 return *myCartesianCoordinate; 00153 } 00154 00155 00156 FXLabel& 00157 GUIMainWindow::getGeoLabel() { 00158 return *myGeoCoordinate; 00159 } 00160 00161 /****************************************************************************/ 00162