SUMO - Simulation of Urban MObility
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-2017 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 
38 #include "GUIGlChildWindow.h"
39 
40 #ifdef CHECK_MEMORY_LEAKS
41 #include <foreign/nvwa/debug_new.h>
42 #endif // CHECK_MEMORY_LEAKS
43 
44 
45 // ===========================================================================
46 // FOX callback mapping
47 // ===========================================================================
48 FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[] = {
52  FXMAPFUNC(SEL_COMMAND, MID_ZOOM_STYLE, GUIGlChildWindow::onCmdZoomStyle),
55 };
56 
57 FXIMPLEMENT(GUIGlChildWindow, FXMDIChild, GUIGlChildWindowMap, ARRAYNUMBER(GUIGlChildWindowMap))
58 
59 
60 // ===========================================================================
61 // member method definitions
62 // ===========================================================================
64  FXMDIClient* p,
65  GUIMainWindow* parentWindow,
66  FXMDIMenu* mdimenu, const FXString& name,
67  FXIcon* ic,
68  FXuint opts, FXint x, FXint y, FXint w, FXint h) :
69  FXMDIChild(p, name, ic, mdimenu, opts, x, y, w, h),
70  myView(0),
71  myParent(parentWindow) {
72  // Make MDI Window Menu
73  setTracking();
74  myContentFrame = new FXVerticalFrame(this, GUIDesignFrameArea);
75  // build the tool bar
76  buildNavigationToolBar(); // always there (recenter)
77  buildColoringToolBar(); // always there (coloring)
78  buildScreenshotToolBar(); // always there (screen shot)
79 }
80 
81 
83  delete myLocatorPopup;
84  delete myNavigationToolBar;
85 }
86 
87 
88 void
90  FXMDIChild::create();
91  myNavigationToolBar->create();
92  myLocatorPopup->create();
93  myView->create();
94 }
95 
96 
97 void
99  // Build navigation toolbar
101 
102  // build the view settings
103  // recenter view
104  new FXButton(myNavigationToolBar,
105  "\tRecenter View\tRecenter view to the simulated area.",
107  // add viewport button
108  new FXButton(myNavigationToolBar,
109  "\tEdit Viewport...\tOpens a menu which lets you edit the viewport.",
111  // toggle button for zooming style
113  "\tToggles Zooming Style\tToggles whether zooming is based at cursor position or at the center of the view.",
115  zoomBut->setChecked(getApp()->reg().readIntEntry("gui", "zoomAtCenter", 1) != 1);
116 
117  // build the locator popup
118  myLocatorPopup = new FXPopup(myNavigationToolBar, POPUP_VERTICAL);
119  myLocatorButton = new FXMenuButton(myNavigationToolBar, "\tLocate Structures\tLocate structures within the network.",
122  // add toggle button for tool-tips on/off
124  "\tToggles Tool Tips\tToggles whether tool tips shall be shown.",
126 
127 }
128 
129 
130 void
132  // Create Vertical separator
133  new FXVerticalSeparator(myNavigationToolBar, GUIDesignVerticalSeparator);
134 
135  // build coloring tools
136  // combo
138  // editor
139  new FXButton(myNavigationToolBar,
140  "\tEdit Coloring Schemes...\tOpens a menu which lets you edit the coloring schemes.",
142 }
143 
144 
145 void
147  // Create Vertical separator
148  new FXVerticalSeparator(myNavigationToolBar, GUIDesignVerticalSeparator);
149  // snapshot
151  "\tMake Snapshot\tMakes a snapshot of the view.",
153 }
154 
155 
156 FXGLCanvas*
158  return myView;
159 }
160 
161 
162 FXToolBar&
164  return *myNavigationToolBar;
165 }
166 
167 
168 FXPopup*
170  return myLocatorPopup;
171 }
172 
173 
174 FXComboBox&
176  return *myColoringSchemes;
177 }
178 
179 
180 long
181 GUIGlChildWindow::onCmdRecenterView(FXObject*, FXSelector, void*) {
182  myView->recenterView();
183  myView->update();
184  return 1;
185 }
186 
187 
188 long
189 GUIGlChildWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
191  return 1;
192 }
193 
194 
195 long
196 GUIGlChildWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
198  return 1;
199 }
200 
201 
202 long
203 GUIGlChildWindow::onCmdShowToolTips(FXObject* sender, FXSelector, void*) {
204  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
205  button->setChecked(!button->amChecked());
206  myView->showToolTips(button->amChecked());
207  update();
208  myView->update();
209  return 1;
210 }
211 
212 
213 long
214 GUIGlChildWindow::onCmdZoomStyle(FXObject* sender, FXSelector, void*) {
215  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
216  button->setChecked(!button->amChecked());
217  getApp()->reg().writeIntEntry("gui", "zoomAtCenter",
218  button->amChecked() ? 0 : 1);
219  update();
220  myView->update();
221  return 1;
222 }
223 
224 
225 long
226 GUIGlChildWindow::onCmdChangeColorScheme(FXObject*, FXSelector , void* data) {
227  myView->setColorScheme((char*) data);
228  return 1;
229 }
230 
231 
232 void
234  // this is used by the locator widget. zooming to bounding box
235  myView->centerTo(id, true, -1);
236  myView->update();
237 }
238 
239 
240 bool
242  return gSelected.isSelected(o->getType(), o->getGlID());
243 }
244 /****************************************************************************/
245 
void showToolTips(bool val)
show tool tips
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.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
#define GUIDesignVerticalSeparator
vertical separator
Definition: GUIDesigns.h:269
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:89
void setChecked(bool val)
check or uncheck this MFXCheckableButton
Make snapshot - button.
Definition: GUIAppEnum.h:199
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 *)
FXPopup * myLocatorPopup
The locator menu.
#define GUIDesignFrameArea
Definition: GUIDesigns.h:214
Recenter view - button.
Definition: GUIAppEnum.h:169
Open viewport editor - button.
Definition: GUIAppEnum.h:193
GUIGlID getGlID() const
Returns the numerical id of the object.
virtual FXGLCanvas * getBuildGLCanvas() const
Show tool tips - button.
Definition: GUIAppEnum.h:197
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
toogle zooming style
Definition: GUIAppEnum.h:201
long onCmdShowToolTips(FXObject *sender, FXSelector, void *)
FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[]
#define GUIDesignButtonToolbarLocator
little checkable button with icon placed in navigation toolbar used specify for Locator ...
Definition: GUIDesigns.h:92
FXComboBox & getColoringSchemesCombo()
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
#define GUIDesignComboBoxStatic
Combo box static (not editable)
Definition: GUIDesigns.h:173
FXToolBar * myNavigationToolBar
The tool bar.
virtual bool setColorScheme(const std::string &)
set color scheme
unsigned int GUIGlID
Definition: GUIGlObject.h:50
virtual void showViewportEditor()
show viewport editor
#define GUIDesignBar
Definition: GUIDesigns.h:245
void setView(GUIGlID id)
Centers the view onto the given artifact.
FXComboBox * myColoringSchemes
virtual ~GUIGlChildWindow()
#define GUIDesignButtonToolbarCheckable
little checkable button with icon placed in navigation toolbar
Definition: GUIDesigns.h:96
FXMenuButton * myLocatorButton
GUISUMOAbstractView * myView
the view
long onCmdEditViewport(FXObject *, FXSelector, void *)
Open view editor - button.
Definition: GUIAppEnum.h:195
long onCmdRecenterView(FXObject *, FXSelector, void *)
void showViewschemeEditor()
show viewsscheme editor
long onCmdChangeColorScheme(FXObject *, FXSelector sel, void *)
virtual void create()
GUISelectedStorage gSelected
A global holder of selected objects.
Change coloring scheme - combo.
Definition: GUIAppEnum.h:223
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXVerticalFrame * myContentFrame
bool amChecked() const
check if this MFXCheckableButton is checked
FXPopup * getLocatorPopup()