SUMO - Simulation of Urban MObility
GUIGlChildWindow.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 //
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
31 #include "GUIGlChildWindow.h"
32 
33 
34 // ===========================================================================
35 // FOX callback mapping
36 // ===========================================================================
37 FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[] = {
41  FXMAPFUNC(SEL_COMMAND, MID_ZOOM_STYLE, GUIGlChildWindow::onCmdZoomStyle),
44 };
45 
46 FXIMPLEMENT(GUIGlChildWindow, FXMDIChild, GUIGlChildWindowMap, ARRAYNUMBER(GUIGlChildWindowMap))
47 
48 
49 // ===========================================================================
50 // member method definitions
51 // ===========================================================================
53  FXMDIClient* p,
54  GUIMainWindow* parentWindow,
55  FXMDIMenu* mdimenu, const FXString& name,
56  FXIcon* ic,
57  FXuint opts, FXint x, FXint y, FXint w, FXint h) :
58  FXMDIChild(p, name, ic, mdimenu, opts, x, y, w, h),
59  myView(nullptr),
60  myParent(parentWindow) {
61  // Make MDI Window Menu
62  setTracking();
63  myContentFrame = new FXVerticalFrame(this, GUIDesignFrameArea);
64  // build the tool bar
65  buildNavigationToolBar(); // always there (recenter)
66  buildColoringToolBar(); // always there (coloring)
67  buildScreenshotToolBar(); // always there (screen shot)
68 }
69 
70 
72  delete myLocatorPopup;
73  delete myNavigationToolBar;
74 }
75 
76 
77 void
79  FXMDIChild::create();
80  myNavigationToolBar->create();
81  myLocatorPopup->create();
82  myView->create();
83 }
84 
85 
86 void
88  // Build navigation toolbar
90 
91  // build the view settings
92  // recenter view
93  new FXButton(myNavigationToolBar,
94  "\tRecenter View\tRecenter view to the simulated area.",
96  // add viewport button
97  new FXButton(myNavigationToolBar,
98  "\tEdit Viewport...\tOpens a menu which lets you edit the viewport.",
100  // toggle button for zooming style
102  "\tToggles Zooming Style\tToggles whether zooming is based at cursor position or at the center of the view.",
104  zoomBut->setChecked(getApp()->reg().readIntEntry("gui", "zoomAtCenter", 1) != 1);
105 
106  // build the locator popup
107  myLocatorPopup = new FXPopup(myNavigationToolBar, POPUP_VERTICAL);
108  myLocatorButton = new FXMenuButton(myNavigationToolBar, "\tLocate Structures\tLocate structures within the network.",
111  // add toggle button for tool-tips on/off
113  "\tToggles Tool Tips\tToggles whether tool tips shall be shown.",
115 
116 }
117 
118 
119 void
121  // Create Vertical separator
122  new FXVerticalSeparator(myNavigationToolBar, GUIDesignVerticalSeparator);
123 
124  // build coloring tools
125  // combo
127  // editor
128  new FXButton(myNavigationToolBar,
129  "\tEdit Coloring Schemes...\tOpens a menu which lets you edit the coloring schemes.",
131 }
132 
133 
134 void
136  // Create Vertical separator
137  new FXVerticalSeparator(myNavigationToolBar, GUIDesignVerticalSeparator);
138  // snapshot
140  "\tMake Snapshot\tMakes a snapshot of the view.",
142 }
143 
144 
145 FXGLCanvas*
147  return myView;
148 }
149 
150 
151 FXToolBar&
153  return *myNavigationToolBar;
154 }
155 
156 
157 FXPopup*
159  return myLocatorPopup;
160 }
161 
162 
163 FXComboBox&
165  return *myColoringSchemes;
166 }
167 
168 
169 long
170 GUIGlChildWindow::onCmdRecenterView(FXObject*, FXSelector, void*) {
171  myView->recenterView();
172  myView->update();
173  return 1;
174 }
175 
176 
177 long
178 GUIGlChildWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
180  return 1;
181 }
182 
183 
184 long
185 GUIGlChildWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
187  return 1;
188 }
189 
190 
191 long
192 GUIGlChildWindow::onCmdShowToolTips(FXObject* sender, FXSelector, void*) {
193  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
194  button->setChecked(!button->amChecked());
195  myView->showToolTips(button->amChecked());
196  update();
197  myView->update();
198  return 1;
199 }
200 
201 
202 long
203 GUIGlChildWindow::onCmdZoomStyle(FXObject* sender, FXSelector, void*) {
204  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
205  button->setChecked(!button->amChecked());
206  getApp()->reg().writeIntEntry("gui", "zoomAtCenter",
207  button->amChecked() ? 0 : 1);
208  update();
209  myView->update();
210  return 1;
211 }
212 
213 
214 long
215 GUIGlChildWindow::onCmdChangeColorScheme(FXObject*, FXSelector , void* data) {
216  myView->setColorScheme((char*) data);
217  return 1;
218 }
219 
220 
221 void
223  // this is used by the locator widget. zooming to bounding box
224  myView->centerTo(id, true, -1);
225  myView->update();
226 }
227 
228 
229 bool
231  return gSelected.isSelected(o->getType(), o->getGlID());
232 }
233 /****************************************************************************/
234 
bool amChecked() const
check if this MFXCheckableButton is checked
void showToolTips(bool val)
show tool tips
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.h:205
virtual FXGLCanvas * getBuildGLCanvas() const
FXToolBar & getNavigationToolBar(GUISUMOAbstractView &v)
virtual void recenterView()
recenters the view
#define GUIDesignVerticalSeparator
vertical separator
Definition: GUIDesigns.h:301
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:80
void setChecked(bool val)
check or uncheck this MFXCheckableButton
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:249
Show tool tips - button.
Definition: GUIAppEnum.h:192
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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:86
FXComboBox & getColoringSchemesCombo()
Open viewport editor - button.
Definition: GUIAppEnum.h:188
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
Change coloring scheme - combo.
Definition: GUIAppEnum.h:220
#define GUIDesignComboBoxStatic
Combo box static (not editable)
Definition: GUIDesigns.h:198
Make snapshot - button.
Definition: GUIAppEnum.h:194
FXToolBar * myNavigationToolBar
The tool bar.
Recenter view - button.
Definition: GUIAppEnum.h:168
Open view editor - button.
Definition: GUIAppEnum.h:190
virtual bool setColorScheme(const std::string &)
set color scheme
unsigned int GUIGlID
Definition: GUIGlObject.h:43
virtual void showViewportEditor()
show viewport editor
#define GUIDesignBar
Definition: GUIDesigns.h:277
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:89
FXMenuButton * myLocatorButton
toogle zooming style
Definition: GUIAppEnum.h:196
GUISUMOAbstractView * myView
the view
long onCmdEditViewport(FXObject *, FXSelector, void *)
GUIGlID getGlID() const
Returns the numerical id of the object.
virtual bool isSelected(GUIGlObject *o) const
true if the object is selected (may include extra logic besides calling gSelected) ...
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.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXVerticalFrame * myContentFrame
FXPopup * getLocatorPopup()