SUMO - Simulation of Urban MObility
GUIMainWindow.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00009 //
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 
00023 
00024 // ===========================================================================
00025 // included modules
00026 // ===========================================================================
00027 #ifdef _MSC_VER
00028 #include <windows_config.h>
00029 #else
00030 #include <config.h>
00031 #endif
00032 
00033 #include <string>
00034 #include "GUIMainWindow.h"
00035 #include <algorithm>
00036 #include "GUIAppEnum.h"
00037 #include <fx3d.h>
00038 #include <utils/common/StringUtils.h>
00039 
00040 #ifdef CHECK_MEMORY_LEAKS
00041 #include <foreign/nvwa/debug_new.h>
00042 #endif // CHECK_MEMORY_LEAKS
00043 
00044 
00045 // ===========================================================================
00046 // member method definitions
00047 // ===========================================================================
00048 GUIMainWindow::GUIMainWindow(FXApp* a)
00049     : FXMainWindow(a, "SUMO-gui main window", NULL, NULL, DECOR_ALL, 20, 20, 600, 400),
00050       myGLVisual(new FXGLVisual(a, VISUAL_DOUBLEBUFFER | VISUAL_STEREO)),
00051       myAmGaming(false), myListInternal(false) {
00052 
00053     FXFontDesc fdesc;
00054     getApp()->getNormalFont()->getFontDesc(fdesc);
00055     fdesc.weight = FXFont::Bold;
00056     myBoldFont = new FXFont(getApp(), fdesc);
00057 
00058     myTopDock = new FXDockSite(this, LAYOUT_SIDE_TOP | LAYOUT_FILL_X);
00059     myBottomDock = new FXDockSite(this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X);
00060     myLeftDock = new FXDockSite(this, LAYOUT_SIDE_LEFT | LAYOUT_FILL_Y);
00061     myRightDock = new FXDockSite(this, LAYOUT_SIDE_RIGHT | LAYOUT_FILL_Y);
00062 }
00063 
00064 
00065 GUIMainWindow::~GUIMainWindow() {
00066     delete myBoldFont;
00067     delete myTopDock;
00068     delete myBottomDock;
00069     delete myLeftDock;
00070     delete myRightDock;
00071 }
00072 
00073 
00074 
00075 void
00076 GUIMainWindow::addChild(FXMDIChild* child, bool /*updateOnSimStep !!!*/) {
00077     mySubWindows.push_back(child);
00078 }
00079 
00080 
00081 void
00082 GUIMainWindow::removeChild(FXMDIChild* child) {
00083     std::vector<FXMDIChild*>::iterator i = std::find(mySubWindows.begin(), mySubWindows.end(), child);
00084     if (i != mySubWindows.end()) {
00085         mySubWindows.erase(i);
00086     }
00087 }
00088 
00089 
00090 void
00091 GUIMainWindow::addChild(FXMainWindow* child, bool /*updateOnSimStep !!!*/) {
00092     myTrackerLock.lock();
00093     myTrackerWindows.push_back(child);
00094     myTrackerLock.unlock();
00095 }
00096 
00097 
00098 void
00099 GUIMainWindow::removeChild(FXMainWindow* child) {
00100     myTrackerLock.lock();
00101     std::vector<FXMainWindow*>::iterator i = std::find(myTrackerWindows.begin(), myTrackerWindows.end(), child);
00102     myTrackerWindows.erase(i);
00103     myTrackerLock.unlock();
00104 }
00105 
00106 
00107 std::vector<std::string>
00108 GUIMainWindow::getViewIDs() const {
00109     std::vector<std::string> ret;
00110     for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
00111         ret.push_back((*i)->getTitle().text());
00112     }
00113     return ret;
00114 }
00115 
00116 
00117 FXMDIChild*
00118 GUIMainWindow::getViewByID(const std::string& id) const {
00119     for (std::vector<FXMDIChild*>::const_iterator i = mySubWindows.begin(); i != mySubWindows.end(); ++i) {
00120         if (std::string((*i)->getTitle().text()) == id) {
00121             return *i;
00122         }
00123     }
00124     return 0;
00125 }
00126 
00127 
00128 FXFont*
00129 GUIMainWindow::getBoldFont() {
00130     return myBoldFont;
00131 }
00132 
00133 
00134 void
00135 GUIMainWindow::updateChildren() {
00136     // inform views
00137     myMDIClient->forallWindows(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
00138     // inform other windows
00139     myTrackerLock.lock();
00140     for (size_t i = 0; i < myTrackerWindows.size(); i++) {
00141         myTrackerWindows[i]->handle(this, FXSEL(SEL_COMMAND, MID_SIMSTEP), 0);
00142     }
00143     myTrackerLock.unlock();
00144 }
00145 
00146 
00147 FXGLVisual*
00148 GUIMainWindow::getGLVisual() const {
00149     return myGLVisual;
00150 }
00151 
00152 
00153 FXLabel&
00154 GUIMainWindow::getCartesianLabel() {
00155     return *myCartesianCoordinate;
00156 }
00157 
00158 
00159 FXLabel&
00160 GUIMainWindow::getGeoLabel() {
00161     return *myGeoCoordinate;
00162 }
00163 
00164 /****************************************************************************/
00165 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines