GUISUMOViewParent Class Reference

#include <GUISUMOViewParent.h>

Inheritance diagram for GUISUMOViewParent:

GUIGlChildWindow FXMDIChild

Detailed Description

A single child window which contains a view of the simulation area.

It is made of a tool-bar containing a field to change the type of display, buttons that allow to choose an artifact and some other view controlling options.

The rest of the window is a canvas that contains the display itself

Definition at line 63 of file GUISUMOViewParent.h.


Public Member Functions

virtual void buildColoringToolBar ()
virtual void buildNavigationToolBar ()
virtual void buildScreenshotToolBar ()
virtual void create ()
virtual FXGLCanvasgetBuildGLCanvas () const
FXComboBox & getColoringSchemesCombo ()
FXPopup * getLocatorPopup ()
FXToolBar & getNavigationToolBar (GUISUMOAbstractView &v)
GUIMainWindowgetParent () throw ()
 Returns the main window.
 GUISUMOViewParent (FXMDIClient *p, FXMDIMenu *mdimenu, const FXString &name, GUIMainWindow *parentWindow, FXIcon *ic=NULL, FXuint opts=0, FXint x=0, FXint y=0, FXint w=0, FXint h=0)
 Constructor.
virtual GUISUMOAbstractViewinit (FXGLCanvas *share, GUINet &net)
 "Initialises" this window by building the contents
long onCmdChangeColorScheme (FXObject *, FXSelector sel, void *)
long onCmdEditViewport (FXObject *, FXSelector, void *)
long onCmdEditViewScheme (FXObject *, FXSelector, void *)
long onCmdMakeSnapshot (FXObject *sender, FXSelector, void *)
 Called if the user wants to make a snapshot (screenshot).
long onCmdRecenterView (FXObject *, FXSelector, void *)
long onCmdShowToolTips (FXObject *sender, FXSelector, void *)
long onSimStep (FXObject *sender, FXSelector, void *)
 Called on a simulation step.
void setView (const GUIGlObject *const o) throw ()
 Centers the view onto the given artifact.
 ~GUISUMOViewParent ()
 Destructor.
locator-callbacks
long onCmdLocateAdd (FXObject *sender, FXSelector, void *)
 opens a locator for additional structures
long onCmdLocateEdge (FXObject *, FXSelector, void *)
 opens a locator for edges
long onCmdLocateJunction (FXObject *, FXSelector, void *)
 opens a locator for junctions
long onCmdLocateShape (FXObject *, FXSelector, void *)
 opens a locator for shapes
long onCmdLocateTLS (FXObject *, FXSelector, void *)
 opens a locator for traffic lights logics
long onCmdLocateVehicle (FXObject *, FXSelector, void *)
 opens a locator for vehicles

Protected Member Functions

 GUISUMOViewParent ()
 FOX needs this.
void showLocator (GUIGlObjectType type, FXIcon *icon, FXString title)
 Builds a locator for the given type.

Protected Attributes

FXComboBox * myColoringSchemes
FXVerticalFrame * myContentFrame
FXMenuButton * myLocatorButton
FXPopup * myLocatorPopup
 The locator menu.
FXToolBar * myNavigationToolBar
 The tool bar.
GUIMainWindowmyParent
 The parent window.
GUISUMOAbstractViewmyView
 the view

Constructor & Destructor Documentation

GUISUMOViewParent::GUISUMOViewParent ( FXMDIClient *  p,
FXMDIMenu *  mdimenu,
const FXString &  name,
GUIMainWindow parentWindow,
FXIcon *  ic = NULL,
FXuint  opts = 0,
FXint  x = 0,
FXint  y = 0,
FXint  w = 0,
FXint  h = 0 
)

Constructor.

Parameters:
[in] p The MDI-pane this window is shown within
[in] mdimenu The MDI-menu for alignment
[in] name The name of the window
[in] parentWindow The main window
[in] ic The icon of this window
[in] opts Window options
[in] x Initial x-position
[in] y Initial x-position
[in] w Initial width
[in] h Initial height

GUISUMOViewParent::~GUISUMOViewParent (  ) 

Destructor.

Definition at line 107 of file GUISUMOViewParent.cpp.

References myParent, and GUIMainWindow::removeChild().

00107                                       {
00108     myParent->removeChild(this);
00109 }

GUISUMOViewParent::GUISUMOViewParent (  )  [inline, protected]

FOX needs this.

Definition at line 152 of file GUISUMOViewParent.h.

00152 { }


Member Function Documentation

void GUIGlChildWindow::buildColoringToolBar (  )  [virtual, inherited]

Definition at line 120 of file GUIGlChildWindow.cpp.

References GUIIconSubSys::getIcon(), ICON_COLORWHEEL, MID_COLOURSCHEMECHANGE, MID_EDITVIEWSCHEME, GUIGlChildWindow::myColoringSchemes, and GUIGlChildWindow::myNavigationToolBar.

00120                                        {
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 }

void GUIGlChildWindow::buildNavigationToolBar (  )  [virtual, inherited]

Definition at line 92 of file GUIGlChildWindow.cpp.

References GUIIconSubSys::getIcon(), ICON_EDITVIEWPORT, ICON_LOCATE, ICON_RECENTERVIEW, ICON_SHOWTOOLTIPS, MID_EDITVIEWPORT, MID_RECENTERVIEW, MID_SHOWTOOLTIPS, GUIGlChildWindow::myContentFrame, GUIGlChildWindow::myLocatorButton, GUIGlChildWindow::myLocatorPopup, and GUIGlChildWindow::myNavigationToolBar.

00092                                          {
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 }

void GUIGlChildWindow::buildScreenshotToolBar (  )  [virtual, inherited]

Definition at line 140 of file GUIGlChildWindow.cpp.

References GUIIconSubSys::getIcon(), ICON_CAMERA, MID_MAKESNAPSHOT, and GUIGlChildWindow::myNavigationToolBar.

00140                                          {
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 }

void GUIGlChildWindow::create (  )  [virtual, inherited]

Definition at line 83 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myLocatorPopup, GUIGlChildWindow::myNavigationToolBar, and GUIGlChildWindow::myView.

Referenced by GUIApplicationWindow::openNewView().

00083                          {
00084     FXMDIChild::create();
00085     myNavigationToolBar->create();
00086     myLocatorPopup->create();
00087     myView->create();
00088 }

FXGLCanvas * GUIGlChildWindow::getBuildGLCanvas (  )  const [virtual, inherited]

Definition at line 154 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myView.

Referenced by GUIApplicationWindow::getBuildGLCanvas().

00154                                          {
00155     return myView;
00156 }

FXComboBox & GUIGlChildWindow::getColoringSchemesCombo (  )  [inherited]

FXPopup * GUIGlChildWindow::getLocatorPopup (  )  [inherited]

Definition at line 166 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myLocatorPopup.

Referenced by GUIViewTraffic::buildViewToolBars().

00166                                   {
00167     return myLocatorPopup;
00168 }

FXToolBar & GUIGlChildWindow::getNavigationToolBar ( GUISUMOAbstractView v  )  [inherited]

Definition at line 160 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myNavigationToolBar.

00160                                                             {
00161     return *myNavigationToolBar;
00162 }

GUIMainWindow* GUISUMOViewParent::getParent (  )  throw () [inline]

Returns the main window.

Returns:
This view's parent

Definition at line 131 of file GUISUMOViewParent.h.

References myParent.

Referenced by GUIDialog_GLObjChooser::~GUIDialog_GLObjChooser().

00131                                        {
00132         return myParent;
00133     }

GUISUMOAbstractView * GUISUMOViewParent::init ( FXGLCanvas share,
GUINet net 
) [virtual]

"Initialises" this window by building the contents

Parameters:
[in] share A canvas tor get the shared context from
[in] net The network to show
Todo:
Check whether this could be done in the constructor

Definition at line 99 of file GUISUMOViewParent.cpp.

References GUISUMOAbstractView::buildViewToolBars(), GUIMainWindow::getGLVisual(), GUIGlChildWindow::myContentFrame, myParent, and GUIGlChildWindow::myView.

Referenced by GUIApplicationWindow::openNewView().

00099                                                       {
00100     myView = new GUIViewTraffic(myContentFrame, *myParent, this, net,
00101                                 myParent->getGLVisual(), share);
00102     myView->buildViewToolBars(*this);
00103     return myView;
00104 }

long GUIGlChildWindow::onCmdChangeColorScheme ( FXObject ,
FXSelector  sel,
void *  data 
) [inherited]

Definition at line 211 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myView, and GUISUMOAbstractView::setColorScheme().

00211                                                                         {
00212     myView->setColorScheme((char*) data);
00213     return 1;
00214 }

long GUIGlChildWindow::onCmdEditViewport ( FXObject ,
FXSelector  ,
void *   
) [inherited]

Definition at line 186 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myView, and GUISUMOAbstractView::showViewportEditor().

00186                                                               {
00187     myView->showViewportEditor();
00188     return 1;
00189 }

long GUIGlChildWindow::onCmdEditViewScheme ( FXObject ,
FXSelector  ,
void *   
) [inherited]

Definition at line 193 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myView, and GUISUMOAbstractView::showViewschemeEditor().

00193                                                                 {
00194     myView->showViewschemeEditor();
00195     return 1;
00196 }

long GUISUMOViewParent::onCmdLocateAdd ( FXObject sender,
FXSelector  ,
void *   
)

opens a locator for additional structures

Definition at line 183 of file GUISUMOViewParent.cpp.

References GUIIconSubSys::getIcon(), GLO_ADDITIONAL, ICON_LOCATEADD, and showLocator().

00183                                                              {
00184     showLocator(GLO_ADDITIONAL, GUIIconSubSys::getIcon(ICON_LOCATEADD), "Additional Objects Chooser");
00185     return 1;
00186 }

long GUISUMOViewParent::onCmdLocateEdge ( FXObject ,
FXSelector  ,
void *   
)

opens a locator for edges

Definition at line 162 of file GUISUMOViewParent.cpp.

References GUIIconSubSys::getIcon(), GLO_EDGE, ICON_LOCATEEDGE, and showLocator().

00162                                                               {
00163     showLocator(GLO_EDGE, GUIIconSubSys::getIcon(ICON_LOCATEEDGE), "Edge Chooser");
00164     return 1;
00165 }

long GUISUMOViewParent::onCmdLocateJunction ( FXObject ,
FXSelector  ,
void *   
)

opens a locator for junctions

Definition at line 155 of file GUISUMOViewParent.cpp.

References GUIIconSubSys::getIcon(), GLO_JUNCTION, ICON_LOCATEJUNCTION, and showLocator().

00155                                                                   {
00156     showLocator(GLO_JUNCTION, GUIIconSubSys::getIcon(ICON_LOCATEJUNCTION), "Junction Chooser");
00157     return 1;
00158 }

long GUISUMOViewParent::onCmdLocateShape ( FXObject sender,
FXSelector  ,
void *   
)

opens a locator for shapes

Definition at line 190 of file GUISUMOViewParent.cpp.

References GUIIconSubSys::getIcon(), GLO_SHAPE, ICON_LOCATESHAPE, and showLocator().

00190                                                                      {
00191     showLocator(GLO_SHAPE, GUIIconSubSys::getIcon(ICON_LOCATESHAPE), "Shape Chooser");
00192     return 1;
00193 }

long GUISUMOViewParent::onCmdLocateTLS ( FXObject ,
FXSelector  ,
void *   
)

opens a locator for traffic lights logics

Definition at line 176 of file GUISUMOViewParent.cpp.

References GUIIconSubSys::getIcon(), GLO_TLLOGIC, ICON_LOCATETLS, and showLocator().

00176                                                              {
00177     showLocator(GLO_TLLOGIC, GUIIconSubSys::getIcon(ICON_LOCATETLS), "Traffic Lights Chooser");
00178     return 1;
00179 }

long GUISUMOViewParent::onCmdLocateVehicle ( FXObject ,
FXSelector  ,
void *   
)

opens a locator for vehicles

Definition at line 169 of file GUISUMOViewParent.cpp.

References GUIIconSubSys::getIcon(), GLO_VEHICLE, ICON_LOCATEVEHICLE, and showLocator().

00169                                                                  {
00170     showLocator(GLO_VEHICLE, GUIIconSubSys::getIcon(ICON_LOCATEVEHICLE), "Vehicle Chooser");
00171     return 1;
00172 }

long GUISUMOViewParent::onCmdMakeSnapshot ( FXObject sender,
FXSelector  ,
void *   
)

Called if the user wants to make a snapshot (screenshot).

Definition at line 113 of file GUISUMOViewParent.cpp.

References gCurrentFolder, GUIIconSubSys::getIcon(), GUISUMOAbstractView::getSnapshot(), ICON_EMPTY, GUIGlChildWindow::myView, MFXImageHelper::saveImage(), and MFXUtils::userPermitsOverwritingWhenFileExists().

00113                                                                {
00114     // get the new file name
00115     FXFileDialog opendialog(this, "Save Snapshot");
00116     opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
00117     opendialog.setSelectMode(SELECTFILE_ANY);
00118     opendialog.setPatternList("All Image Files (*.gif, *.bmp, *.xpm, *.pcx, *.ico, *.rgb, *.xbm, *.tga, *.png, *.jpg, *.jpeg, *.tif, *.tiff)\n"
00119                               "GIF Image (*.gif)\nBMP Image (*.bmp)\nXPM Image (*.xpm)\nPCX Image (*.pcx)\nICO Image (*.ico)\n"
00120                               "RGB Image (*.rgb)\nXBM Image (*.xbm)\nTARGA Image (*.tga)\nPNG Image  (*.png)\n"
00121                               "JPEG Image (*.jpg, *.jpeg)\nTIFF Image (*.tif, *.tiff)\nAll Files (*)");
00122     if (gCurrentFolder.length()!=0) {
00123         opendialog.setDirectory(gCurrentFolder);
00124     }
00125     if (!opendialog.execute()||!MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
00126         return 1;
00127     }
00128     gCurrentFolder = opendialog.getDirectory();
00129     std::string file = opendialog.getFilename().text();
00130     FXColor *buf = myView->getSnapshot();
00131     // save
00132     try {
00133         MFXImageHelper::saveImage(file, myView->getWidth(), myView->getHeight(), buf);
00134     } catch (InvalidArgument e) {
00135         std::string msg = "Could not save '" + file + "'.\n" + e.what();
00136         FXMessageBox::error(this, MBOX_OK, "Saving failed.", msg.c_str());
00137     }
00138     FXFREE(&buf);
00139     return 1;
00140 }

long GUIGlChildWindow::onCmdRecenterView ( FXObject ,
FXSelector  ,
void *   
) [inherited]

Definition at line 178 of file GUIGlChildWindow.cpp.

References GUIGlChildWindow::myView, and GUISUMOAbstractView::recenterView().

00178                                                               {
00179     myView->recenterView();
00180     myView->update();
00181     return 1;
00182 }

long GUIGlChildWindow::onCmdShowToolTips ( FXObject sender,
FXSelector  ,
void *   
) [inherited]

Definition at line 200 of file GUIGlChildWindow.cpp.

References MFXCheckableButton::amChecked(), GUIGlChildWindow::myView, MFXCheckableButton::setChecked(), and GUISUMOAbstractView::showToolTips().

00200                                                                     {
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 }

long GUISUMOViewParent::onSimStep ( FXObject sender,
FXSelector  ,
void *   
)

Called on a simulation step.

Definition at line 203 of file GUISUMOViewParent.cpp.

References GUISUMOAbstractView::checkSnapshots(), and GUIGlChildWindow::myView.

00203                                                        {
00204     myView->update();
00205     myView->checkSnapshots();
00206     return 1;
00207 }

void GUISUMOViewParent::setView ( const GUIGlObject *const   o  )  throw ()

Centers the view onto the given artifact.

Parameters:
[in] o The object to center the view on

Definition at line 197 of file GUISUMOViewParent.cpp.

References GUISUMOAbstractView::centerTo(), and GUIGlChildWindow::myView.

Referenced by GUIDialog_GLObjChooser::onCmdCenter(), GUIDialog_GLObjChooser::onCmdText(), and GUIDialog_GLObjChooser::onListKeyPress().

00197                                                               {
00198     myView->centerTo(o);
00199 }

void GUISUMOViewParent::showLocator ( GUIGlObjectType  type,
FXIcon *  icon,
FXString  title 
) [protected]

Builds a locator for the given type.

Parameters:
[in] type gl-object type of objects to build the locator for
[in] icon The icon to use
[in] title The title to use

Definition at line 144 of file GUISUMOViewParent.cpp.

References GUIGlObjectStorage::gIDStorage, GUIGlChildWindow::myLocatorButton, and GUIGlChildWindow::myLocatorPopup.

Referenced by onCmdLocateAdd(), onCmdLocateEdge(), onCmdLocateJunction(), onCmdLocateShape(), onCmdLocateTLS(), and onCmdLocateVehicle().

00144                                                                                  {
00145     myLocatorPopup->popdown();
00146     myLocatorButton->killFocus();
00147     myLocatorPopup->update();
00148     GUIDialog_GLObjChooser *chooser = new GUIDialog_GLObjChooser(this, icon, title, type, GUIGlObjectStorage::gIDStorage);
00149     chooser->create();
00150     chooser->show();
00151 }


Field Documentation

FXComboBox* GUIGlChildWindow::myColoringSchemes [protected, inherited]

FXVerticalFrame* GUIGlChildWindow::myContentFrame [protected, inherited]

Definition at line 84 of file GUIGlChildWindow.h.

Referenced by GUIGlChildWindow::buildNavigationToolBar(), and init().

FXMenuButton* GUIGlChildWindow::myLocatorButton [protected, inherited]

Definition at line 82 of file GUIGlChildWindow.h.

Referenced by GUIGlChildWindow::buildNavigationToolBar(), and showLocator().

FXPopup* GUIGlChildWindow::myLocatorPopup [protected, inherited]

FXToolBar* GUIGlChildWindow::myNavigationToolBar [protected, inherited]

The parent window.

Definition at line 147 of file GUISUMOViewParent.h.

Referenced by getParent(), init(), and ~GUISUMOViewParent().


The documentation for this class was generated from the following files:

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