SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUIGlChildWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 //
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
37 #include "GUIGlChildWindow.h"
38 
39 #ifdef CHECK_MEMORY_LEAKS
40 #include <foreign/nvwa/debug_new.h>
41 #endif // CHECK_MEMORY_LEAKS
42 
43 
44 // ===========================================================================
45 // FOX callback mapping
46 // ===========================================================================
47 FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[] = {
51  FXMAPFUNC(SEL_COMMAND, MID_ZOOM_STYLE, GUIGlChildWindow::onCmdZoomStyle),
54 };
55 
56 FXIMPLEMENT(GUIGlChildWindow, FXMDIChild, GUIGlChildWindowMap, ARRAYNUMBER(GUIGlChildWindowMap))
57 
58 
59 // ===========================================================================
60 // member method definitions
61 // ===========================================================================
63  FXMDIClient* p,
64  GUIMainWindow* parentWindow,
65  FXMDIMenu* mdimenu, const FXString& name,
66  FXIcon* ic,
67  FXuint opts, FXint x, FXint y, FXint w, FXint h) :
68  FXMDIChild(p, name, ic, mdimenu, opts, x, y, w, h),
69  myView(0),
70  myParent(parentWindow) {
71  // Make MDI Window Menu
72  setTracking();
73  myContentFrame =
74  new FXVerticalFrame(this,
75  FRAME_SUNKEN | LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y,
76  0, 0, 0, 0, 0, 0, 0, 0);
77  // build the tool bar
78  buildNavigationToolBar(); // always there (recenter)
79  buildColoringToolBar(); // always there (coloring)
80  buildScreenshotToolBar(); // always there (screen shot)
81 }
82 
83 
85  delete myLocatorPopup;
86  delete myNavigationToolBar;
87 }
88 
89 
90 void
92  FXMDIChild::create();
93  myNavigationToolBar->create();
94  myLocatorPopup->create();
95  myView->create();
96 }
97 
98 
99 void
101  myNavigationToolBar = new FXToolBar(myContentFrame, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
102  // build the view settings
103  // recenter view
105  "\tRecenter View\tRecenter view to the simulated area.",
107  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
108  // add viewport button
110  "\tEdit Viewport...\tOpens a menu which lets you edit the viewport.",
112  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
113  // toggle button for zooming style
115  "\tToggles Zooming Style\tToggles whether zooming is based at cursor position or at the center of the view.",
117  BUTTON_NORMAL | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT,
118  0, 0, 23, 23);
119  zoomBut->setChecked(getApp()->reg().readIntEntry("gui", "zoomAtCenter", 1) != 1);
120 
121  // build the locator popup
122  myLocatorPopup = new FXPopup(myNavigationToolBar, POPUP_VERTICAL);
123  myLocatorButton = new FXMenuButton(myNavigationToolBar, "\tLocate Structures\tLocate structures within the network.",
125  MENUBUTTON_RIGHT | LAYOUT_TOP | BUTTON_TOOLBAR | FRAME_RAISED | FRAME_THICK);
126  // add toggle button for tool-tips on/off
128  "\tToggles Tool Tips\tToggles whether tool tips shall be shown.",
130  BUTTON_NORMAL | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT,
131  0, 0, 23, 23);
132 
133 }
134 
135 
136 void
138  // in fact, we currently are not able to build another bar
139  // we just add somthing to the navigation bar
140 // myColoringToolBar = new FXToolBar(myContentFrame,LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
141  new FXToolBarGrip(myNavigationToolBar, NULL, 0, TOOLBARGRIP_SINGLE | FRAME_SUNKEN);
142 
143  // build coloring tools
144  // combo
146  new FXComboBox(myNavigationToolBar, 12, this, MID_COLOURSCHEMECHANGE,
147  FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y);
148  // editor
150  "\tEdit Coloring Schemes...\tOpens a menu which lets you edit the coloring schemes.",
152  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
153 }
154 
155 
156 void
158  // in fact, we currently are not able to build another bar
159  // we just add somthing to the navigation bar
160 // myScreenshotToolBar = new FXToolBar(myContentFrame,LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
161  new FXToolBarGrip(myNavigationToolBar, NULL, 0, TOOLBARGRIP_SINGLE | FRAME_SUNKEN);
162  // snapshot
164  "\tMake Snapshot\tMakes a snapshot of the view.",
166  ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
167 }
168 
169 
170 FXGLCanvas*
172  return myView;
173 }
174 
175 
176 FXToolBar&
178  return *myNavigationToolBar;
179 }
180 
181 
182 FXPopup*
184  return myLocatorPopup;
185 }
186 
187 
188 FXComboBox&
190  return *myColoringSchemes;
191 }
192 
193 
194 long
196  myView->recenterView();
197  myView->update();
198  return 1;
199 }
200 
201 
202 long
205  return 1;
206 }
207 
208 
209 long
212  return 1;
213 }
214 
215 
216 long
217 GUIGlChildWindow::onCmdShowToolTips(FXObject* sender, FXSelector, void*) {
218  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
219  button->setChecked(!button->amChecked());
220  myView->showToolTips(button->amChecked());
221  update();
222  myView->update();
223  return 1;
224 }
225 
226 
227 long
228 GUIGlChildWindow::onCmdZoomStyle(FXObject* sender, FXSelector, void*) {
229  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
230  button->setChecked(!button->amChecked());
231  getApp()->reg().writeIntEntry("gui", "zoomAtCenter",
232  button->amChecked() ? 0 : 1);
233  update();
234  myView->update();
235  return 1;
236 }
237 
238 
239 long
241  myView->setColorScheme((char*) data);
242  return 1;
243 }
244 
245 
246 void
248  // this is used by the locator widget. zoom using fixed distance makes it easier to identify objects
249  // (long streets in particular)
250  myView->centerTo(id, true);
251  myView->update();
252 }
253 
254 
255 bool
257  return gSelected.isSelected(o->getType(), o->getGlID());
258 }
259 /****************************************************************************/
260 
Make snapshot - button.
Definition: GUIAppEnum.h:183
Open view editor - button.
Definition: GUIAppEnum.h:179
FXToolBar & getNavigationToolBar(GUISUMOAbstractView &v)
virtual void centerTo(GUIGlID id, bool applyZoom, SUMOReal zoomDist=20)
centers to the chosen artifact
virtual void recenterView()
recenters the view
virtual void buildColoringToolBar()
void setChecked(bool val)
virtual bool isSelected(GUIGlObject *o) const
true if the object is selected (may include extra logic besides calling gSelected) ...
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
long onCmdZoomStyle(FXObject *sender, FXSelector, void *)
Show tool tips - button.
Definition: GUIAppEnum.h:181
FXPopup * myLocatorPopup
The locator menu.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
virtual FXGLCanvas * getBuildGLCanvas() const
virtual void buildNavigationToolBar()
Recenter view - button.
Definition: GUIAppEnum.h:157
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
long onCmdShowToolTips(FXObject *sender, FXSelector, void *)
FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[]
FXComboBox & getColoringSchemesCombo()
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
virtual void buildScreenshotToolBar()
FXToolBar * myNavigationToolBar
The tool bar.
unsigned int GUIGlID
Definition: GUIGlObject.h:48
virtual void showViewportEditor()
void setView(GUIGlID id)
Centers the view onto the given artifact.
FXComboBox * myColoringSchemes
virtual ~GUIGlChildWindow()
FXMenuButton * myLocatorButton
GUISUMOAbstractView * myView
the view
long onCmdEditViewport(FXObject *, FXSelector, void *)
virtual bool setColorScheme(const std::string &)
toogle zooming style
Definition: GUIAppEnum.h:185
Open viewport editor - button.
Definition: GUIAppEnum.h:177
long onCmdRecenterView(FXObject *, FXSelector, void *)
Change coloring scheme - combo.
Definition: GUIAppEnum.h:207
long onCmdChangeColorScheme(FXObject *, FXSelector sel, void *)
virtual void create()
GUISelectedStorage gSelected
A global holder of selected objects.
static FXIcon * getIcon(GUIIcon which)
FXVerticalFrame * myContentFrame
FXPopup * getLocatorPopup()