GUIGlChildWindow.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 //
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 "GUIGlChildWindow.h"
00031 #include <utils/gui/images/GUIIconSubSys.h>
00032 #include <utils/gui/windows/GUIAppEnum.h>
00033 #include <utils/foxtools/MFXCheckableButton.h>
00034 
00035 #ifdef CHECK_MEMORY_LEAKS
00036 #include <foreign/nvwa/debug_new.h>
00037 #endif // CHECK_MEMORY_LEAKS
00038 
00039 
00040 // ===========================================================================
00041 // FOX callback mapping
00042 // ===========================================================================
00043 FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[]={
00044     FXMAPFUNC(SEL_COMMAND,  MID_RECENTERVIEW,   GUIGlChildWindow::onCmdRecenterView),
00045     FXMAPFUNC(SEL_COMMAND,             MID_EDITVIEWPORT,  GUIGlChildWindow::onCmdEditViewport),
00046     FXMAPFUNC(SEL_COMMAND,  MID_SHOWTOOLTIPS,   GUIGlChildWindow::onCmdShowToolTips),
00047     FXMAPFUNC(SEL_COMMAND,  MID_COLOURSCHEMECHANGE,   GUIGlChildWindow::onCmdChangeColorScheme),
00048     FXMAPFUNC(SEL_COMMAND,             MID_EDITVIEWSCHEME,      GUIGlChildWindow::onCmdEditViewScheme),
00049 };
00050 
00051 FXIMPLEMENT(GUIGlChildWindow,FXMDIChild,GUIGlChildWindowMap,ARRAYNUMBER(GUIGlChildWindowMap))
00052 
00053 
00054 // ===========================================================================
00055 // member method definitions
00056 // ===========================================================================
00057 GUIGlChildWindow::GUIGlChildWindow(FXMDIClient* p,
00058                                    FXMDIMenu *mdimenu, const FXString& name,
00059                                    FXIcon* ic,
00060                                    FXuint opts,FXint x, FXint y, FXint w, FXint h)
00061         : FXMDIChild(p, name, ic, mdimenu, opts, x, y, w, h),
00062         myView(0) {
00063     // Make MDI Window Menu
00064     setTracking();
00065     myContentFrame =
00066         new FXVerticalFrame(this,
00067                             FRAME_SUNKEN|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
00068                             0,0,0,0,0,0,0,0);
00069     // build the tool bar
00070     buildNavigationToolBar(); // always there (recenter)
00071     buildColoringToolBar(); // always there (coloring)
00072     buildScreenshotToolBar(); // always there (screen shot)
00073 }
00074 
00075 
00076 GUIGlChildWindow::~GUIGlChildWindow() {
00077     delete myLocatorPopup;
00078     delete myNavigationToolBar;
00079 }
00080 
00081 
00082 void
00083 GUIGlChildWindow::create() {
00084     FXMDIChild::create();
00085     myNavigationToolBar->create();
00086     myLocatorPopup->create();
00087     myView->create();
00088 }
00089 
00090 
00091 void
00092 GUIGlChildWindow::buildNavigationToolBar() {
00093     myNavigationToolBar = new FXToolBar(myContentFrame,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
00094     // build the view settings
00095     // recenter view
00096     new FXButton(myNavigationToolBar,
00097                  "\tRecenter View\tRecenter view to the simulated area.",
00098                  GUIIconSubSys::getIcon(ICON_RECENTERVIEW), this, MID_RECENTERVIEW,
00099                  ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00100     // add viewport button
00101     new FXButton(myNavigationToolBar,
00102                  "\tEdit Viewport...\tOpens a menu which lets you edit the viewport.",
00103                  GUIIconSubSys::getIcon(ICON_EDITVIEWPORT), this, MID_EDITVIEWPORT,
00104                  ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00105     // build the locator popup
00106     myLocatorPopup = new FXPopup(myNavigationToolBar, POPUP_VERTICAL);
00107     myLocatorButton = new FXMenuButton(myNavigationToolBar,"\tLocate Structures\tLocate structures within the network.",
00108                                        GUIIconSubSys::getIcon(ICON_LOCATE), myLocatorPopup,
00109                                        MENUBUTTON_RIGHT|LAYOUT_TOP|BUTTON_TOOLBAR|FRAME_RAISED|FRAME_THICK);
00110     // add toggle button for tool-tips on/off
00111     new MFXCheckableButton(false, myNavigationToolBar,
00112                            "\tToggles Tool Tips\tToggles whether tool tips shall be shown.",
00113                            GUIIconSubSys::getIcon(ICON_SHOWTOOLTIPS), this, MID_SHOWTOOLTIPS,
00114                            BUTTON_NORMAL|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,
00115                            0,0, 23,23);
00116 }
00117 
00118 
00119 void
00120 GUIGlChildWindow::buildColoringToolBar() {
00121     // in fact, we currently are not able to build another bar
00122     //  we just add somthing to the navigation bar
00123 //    myColoringToolBar = new FXToolBar(myContentFrame,LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
00124     new FXToolBarGrip(myNavigationToolBar,NULL,0,TOOLBARGRIP_SINGLE|FRAME_SUNKEN);
00125 
00126     // build coloring tools
00127     // combo
00128     myColoringSchemes =
00129         new FXComboBox(myNavigationToolBar, 12, this, MID_COLOURSCHEMECHANGE,
00130                        FRAME_SUNKEN|LAYOUT_LEFT|LAYOUT_TOP|COMBOBOX_STATIC|LAYOUT_CENTER_Y);
00131     // editor
00132     new FXButton(myNavigationToolBar,
00133                  "\tEdit Coloring Schemes...\tOpens a menu which lets you edit the coloring schemes.",
00134                  GUIIconSubSys::getIcon(ICON_COLORWHEEL), this, MID_EDITVIEWSCHEME,
00135                  ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00136 }
00137 
00138 
00139 void
00140 GUIGlChildWindow::buildScreenshotToolBar() {
00141     // in fact, we currently are not able to build another bar
00142     //  we just add somthing to the navigation bar
00143 //    myScreenshotToolBar = new FXToolBar(myContentFrame,LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
00144     new FXToolBarGrip(myNavigationToolBar,NULL,0,TOOLBARGRIP_SINGLE|FRAME_SUNKEN);
00145     // snapshot
00146     new FXButton(myNavigationToolBar,
00147                  "\tMake Snapshot\tMakes a snapshot of the view.",
00148                  GUIIconSubSys::getIcon(ICON_CAMERA), this, MID_MAKESNAPSHOT,
00149                  ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00150 }
00151 
00152 
00153 FXGLCanvas *
00154 GUIGlChildWindow::getBuildGLCanvas() const {
00155     return myView;
00156 }
00157 
00158 
00159 FXToolBar &
00160 GUIGlChildWindow::getNavigationToolBar(GUISUMOAbstractView &) {
00161     return *myNavigationToolBar;
00162 }
00163 
00164 
00165 FXPopup *
00166 GUIGlChildWindow::getLocatorPopup() {
00167     return myLocatorPopup;
00168 }
00169 
00170 
00171 FXComboBox &
00172 GUIGlChildWindow::getColoringSchemesCombo() {
00173     return *myColoringSchemes;
00174 }
00175 
00176 
00177 long
00178 GUIGlChildWindow::onCmdRecenterView(FXObject*,FXSelector,void*) {
00179     myView->recenterView();
00180     myView->update();
00181     return 1;
00182 }
00183 
00184 
00185 long
00186 GUIGlChildWindow::onCmdEditViewport(FXObject*,FXSelector,void*) {
00187     myView->showViewportEditor();
00188     return 1;
00189 }
00190 
00191 
00192 long
00193 GUIGlChildWindow::onCmdEditViewScheme(FXObject*,FXSelector,void*) {
00194     myView->showViewschemeEditor();
00195     return 1;
00196 }
00197 
00198 
00199 long
00200 GUIGlChildWindow::onCmdShowToolTips(FXObject*sender,FXSelector,void*) {
00201     MFXCheckableButton *button = static_cast<MFXCheckableButton*>(sender);
00202     button->setChecked(!button->amChecked());
00203     myView->showToolTips(button->amChecked());
00204     update();
00205     myView->update();
00206     return 1;
00207 }
00208 
00209 
00210 long
00211 GUIGlChildWindow::onCmdChangeColorScheme(FXObject*,FXSelector ,void*data) {
00212     myView->setColorScheme((char*) data);
00213     return 1;
00214 }
00215 
00216 
00217 /****************************************************************************/
00218 

Generated on Wed May 5 00:06:29 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6