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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
37 #include "GUIGlChildWindow.h"
38 
39 
40 // ===========================================================================
41 // FOX callback mapping
42 // ===========================================================================
43 FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[] = {
47  FXMAPFUNC(SEL_COMMAND, MID_ZOOM_STYLE, GUIGlChildWindow::onCmdZoomStyle),
50 };
51 
52 FXIMPLEMENT(GUIGlChildWindow, FXMDIChild, GUIGlChildWindowMap, ARRAYNUMBER(GUIGlChildWindowMap))
53 
54 
55 // ===========================================================================
56 // member method definitions
57 // ===========================================================================
59  FXMDIClient* p,
60  GUIMainWindow* parentWindow,
61  FXMDIMenu* mdimenu, const FXString& name,
62  FXIcon* ic,
63  FXuint opts, FXint x, FXint y, FXint w, FXint h) :
64  FXMDIChild(p, name, ic, mdimenu, opts, x, y, w, h),
65  myView(0),
66  myParent(parentWindow) {
67  // Make MDI Window Menu
68  setTracking();
69  myContentFrame = new FXVerticalFrame(this, GUIDesignFrameArea);
70  // build the tool bar
71  buildNavigationToolBar(); // always there (recenter)
72  buildColoringToolBar(); // always there (coloring)
73  buildScreenshotToolBar(); // always there (screen shot)
74 }
75 
76 
78  delete myLocatorPopup;
79  delete myNavigationToolBar;
80 }
81 
82 
83 void
85  FXMDIChild::create();
86  myNavigationToolBar->create();
87  myLocatorPopup->create();
88  myView->create();
89 }
90 
91 
92 void
94  // Build navigation toolbar
96 
97  // build the view settings
98  // recenter view
99  new FXButton(myNavigationToolBar,
100  "\tRecenter View\tRecenter view to the simulated area.",
102  // add viewport button
103  new FXButton(myNavigationToolBar,
104  "\tEdit Viewport...\tOpens a menu which lets you edit the viewport.",
106  // toggle button for zooming style
108  "\tToggles Zooming Style\tToggles whether zooming is based at cursor position or at the center of the view.",
110  zoomBut->setChecked(getApp()->reg().readIntEntry("gui", "zoomAtCenter", 1) != 1);
111 
112  // build the locator popup
113  myLocatorPopup = new FXPopup(myNavigationToolBar, POPUP_VERTICAL);
114  myLocatorButton = new FXMenuButton(myNavigationToolBar, "\tLocate Structures\tLocate structures within the network.",
117  // add toggle button for tool-tips on/off
119  "\tToggles Tool Tips\tToggles whether tool tips shall be shown.",
121 
122 }
123 
124 
125 void
127  // Create Vertical separator
128  new FXVerticalSeparator(myNavigationToolBar, GUIDesignVerticalSeparator);
129 
130  // build coloring tools
131  // combo
133  // editor
134  new FXButton(myNavigationToolBar,
135  "\tEdit Coloring Schemes...\tOpens a menu which lets you edit the coloring schemes.",
137 }
138 
139 
140 void
142  // Create Vertical separator
143  new FXVerticalSeparator(myNavigationToolBar, GUIDesignVerticalSeparator);
144  // snapshot
146  "\tMake Snapshot\tMakes a snapshot of the view.",
148 }
149 
150 
151 FXGLCanvas*
153  return myView;
154 }
155 
156 
157 FXToolBar&
159  return *myNavigationToolBar;
160 }
161 
162 
163 FXPopup*
165  return myLocatorPopup;
166 }
167 
168 
169 FXComboBox&
171  return *myColoringSchemes;
172 }
173 
174 
175 long
176 GUIGlChildWindow::onCmdRecenterView(FXObject*, FXSelector, void*) {
177  myView->recenterView();
178  myView->update();
179  return 1;
180 }
181 
182 
183 long
184 GUIGlChildWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
186  return 1;
187 }
188 
189 
190 long
191 GUIGlChildWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
193  return 1;
194 }
195 
196 
197 long
198 GUIGlChildWindow::onCmdShowToolTips(FXObject* sender, FXSelector, void*) {
199  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
200  button->setChecked(!button->amChecked());
201  myView->showToolTips(button->amChecked());
202  update();
203  myView->update();
204  return 1;
205 }
206 
207 
208 long
209 GUIGlChildWindow::onCmdZoomStyle(FXObject* sender, FXSelector, void*) {
210  MFXCheckableButton* button = static_cast<MFXCheckableButton*>(sender);
211  button->setChecked(!button->amChecked());
212  getApp()->reg().writeIntEntry("gui", "zoomAtCenter",
213  button->amChecked() ? 0 : 1);
214  update();
215  myView->update();
216  return 1;
217 }
218 
219 
220 long
221 GUIGlChildWindow::onCmdChangeColorScheme(FXObject*, FXSelector , void* data) {
222  myView->setColorScheme((char*) data);
223  return 1;
224 }
225 
226 
227 void
229  // this is used by the locator widget. zooming to bounding box
230  myView->centerTo(id, true, -1);
231  myView->update();
232 }
233 
234 
235 bool
237  return gSelected.isSelected(o->getType(), o->getGlID());
238 }
239 /****************************************************************************/
240 
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:199
virtual FXGLCanvas * getBuildGLCanvas() const
FXToolBar & getNavigationToolBar(GUISUMOAbstractView &v)
virtual void recenterView()
recenters the view
#define GUIDesignVerticalSeparator
vertical separator
Definition: GUIDesigns.h:286
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:81
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:234
Open viewport editor - button.
Definition: GUIAppEnum.h:188
Change coloring scheme - combo.
Definition: GUIAppEnum.h:218
toogle zooming style
Definition: GUIAppEnum.h:196
Recenter view - button.
Definition: GUIAppEnum.h:168
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:87
FXComboBox & getColoringSchemesCombo()
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
#define GUIDesignComboBoxStatic
Combo box static (not editable)
Definition: GUIDesigns.h:192
FXToolBar * myNavigationToolBar
The tool bar.
virtual bool setColorScheme(const std::string &)
set color scheme
unsigned int GUIGlID
Definition: GUIGlObject.h:49
virtual void showViewportEditor()
show viewport editor
#define GUIDesignBar
Definition: GUIDesigns.h:262
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:90
FXMenuButton * myLocatorButton
GUISUMOAbstractView * myView
the view
long onCmdEditViewport(FXObject *, FXSelector, void *)
Make snapshot - button.
Definition: GUIAppEnum.h:194
GUIGlID getGlID() const
Returns the numerical id of the object.
Show tool tips - button.
Definition: GUIAppEnum.h:192
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
Open view editor - button.
Definition: GUIAppEnum.h:190
FXPopup * getLocatorPopup()