Eclipse 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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 //
21 /****************************************************************************/
22 #include <config.h>
23 
30 
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 // ===========================================================================
52 GUIGlChildWindow::GUIGlChildWindow(FXMDIClient* p, GUIMainWindow* parentWindow, FXMDIMenu* mdimenu,
53  const FXString& name, FXMenuBar* gripNavigationToolbar, FXIcon* ic, FXuint opts, FXint x, FXint y, FXint w, FXint h) :
54  FXMDIChild(p, name, ic, mdimenu, opts, x, y, w, h),
55  myParent(parentWindow),
56  myGripNavigationToolbar(gripNavigationToolbar),
57  myStaticNavigationToolBar(nullptr),
58  myView(nullptr) {
59  // Make MDI Window Menu
60  setTracking();
61  // create a vertical frame to add elements
62  myContentFrame = new FXVerticalFrame(this, GUIDesignFrameArea);
63  // if menuBarGripElements isn't NULL, use it to create a grip navigation elements. In other cas, create a static FXToolbar
64  if (myGripNavigationToolbar == nullptr) {
65  myStaticNavigationToolBar = new FXToolBar(myContentFrame, GUIDesignToolbarMenuBar);
66  }
67  // build the tool bars
68  buildNavigationToolBar(); // always there (recenter)
69  buildColoringToolBar(); // always there (coloring)
70  buildScreenshotToolBar(); // always there (screenshot)
71 }
72 
73 
75  delete myLocatorPopup;
76  // only delete static navigation bar if it was created
79  }
80 }
81 
82 
83 void
85  FXMDIChild::create();
86  // only create static navigation bar if it was created
88  myStaticNavigationToolBar->create();
89  } else {
90  myGripNavigationToolbar->create();
91  }
92  myLocatorPopup->create();
93  myView->create();
94 }
95 
96 
99  return myView;
100 }
101 
102 
105  return myParent;
106 }
107 
108 
109 void
111  // build the view settings
112  // recenter view
114  "\tRecenter View\tRecenter view to the simulated area.",
116  // add viewport button
118  "\tEdit Viewport\tOpens a menu which lets you edit the viewport. (Ctrl+I)",
120  // toggle button for zooming style
122  "\tToggles Zooming Style\tToggles whether zooming is based at cursor position or at the center of the view.",
124  zoomBut->setChecked(getApp()->reg().readIntEntry("gui", "zoomAtCenter", 0) != 1);
125  // build the locator popup
127  // build locator button
129  "\tLocate Structures\tLocate structures within the network.",
131  // add toggle button for tool-tips on/off
133  "\tToggles Tool Tips\tToggles whether tool tips shall be shown.",
135 }
136 
137 
138 void
140  // Create Vertical separator
142  // build coloring tools
145  // editor
147  "\tEdit Coloring Schemes\tOpens a menu which lets you edit the coloring schemes. (F9)",
149 }
150 
151 
152 void
154  // Create Vertical separator
156  // snapshot
158  "\tMake Snapshot\tMakes a snapshot of the view.",
160 }
161 
162 
163 FXGLCanvas*
165  return myView;
166 }
167 
168 
169 FXToolBar*
172 }
173 
174 
175 FXPopup*
177  return myLocatorPopup;
178 }
179 
180 
181 FXComboBox*
183  return myColoringSchemes;
184 }
185 
186 
187 long
188 GUIGlChildWindow::onCmdRecenterView(FXObject*, FXSelector, void*) {
189  myView->recenterView();
190  myView->update();
191  return 1;
192 }
193 
194 
195 long
196 GUIGlChildWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
198  return 1;
199 }
200 
201 
202 long
203 GUIGlChildWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
205  return 1;
206 }
207 
208 
209 long
210 GUIGlChildWindow::onCmdShowToolTips(FXObject* sender, FXSelector, void*) {
211  MFXCheckableButton* button = dynamic_cast<MFXCheckableButton*>(sender);
212  // check if button was sucesfully casted
213  if (button) {
214  button->setChecked(!button->amChecked());
215  myView->showToolTips(button->amChecked());
216  update();
217  myView->update();
218  }
219  return 1;
220 }
221 
222 
223 long
224 GUIGlChildWindow::onCmdZoomStyle(FXObject* sender, FXSelector, void*) {
225  MFXCheckableButton* button = dynamic_cast<MFXCheckableButton*>(sender);
226  if (button) {
227  button->setChecked(!button->amChecked());
228  getApp()->reg().writeIntEntry("gui", "zoomAtCenter",
229  button->amChecked() ? 0 : 1);
230  update();
231  myView->update();
232  }
233  return 1;
234 }
235 
236 
237 long
238 GUIGlChildWindow::onCmdChangeColorScheme(FXObject*, FXSelector, void* data) {
239  myView->setColorScheme((char*) data);
240  return 1;
241 }
242 
243 
244 void
246  // this is used by the locator widget. zooming to bounding box
247  myView->centerTo(id, true, -1);
248  myView->update();
249 }
250 
251 
252 bool
254  return gSelected.isSelected(o->getType(), o->getGlID());
255 }
256 
257 
258 /****************************************************************************/
@ MID_MAKESNAPSHOT
Make snapshot - button.
Definition: GUIAppEnum.h:363
@ MID_SHOWTOOLTIPS
Show tool tips - button.
Definition: GUIAppEnum.h:361
@ MID_ZOOM_STYLE
toogle zooming style
Definition: GUIAppEnum.h:365
@ MID_HOTKEY_F9_EDIT_VIEWSCHEME
open edit scheme menu
Definition: GUIAppEnum.h:193
@ MID_HOTKEY_CTRL_I_EDITVIEWPORT
Open viewport editor.
Definition: GUIAppEnum.h:87
@ MID_COLOURSCHEMECHANGE
Change coloring scheme - combo.
Definition: GUIAppEnum.h:391
@ MID_RECENTERVIEW
Recenter view - button.
Definition: GUIAppEnum.h:335
#define GUIDesignComboBoxStatic
Combo box static (not editable)
Definition: GUIDesigns.h:240
#define GUIDesignMFXCheckableButton
Definition: GUIDesigns.h:105
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.h:255
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:91
#define GUIDesignFrameArea
Definition: GUIDesigns.h:301
#define GUIDesignVerticalSeparator
vertical separator
Definition: GUIDesigns.h:365
#define GUIDesignToolbarMenuBar
Definition: GUIDesigns.h:330
#define GUIDesignButtonToolbarLocator
little checkable button with icon placed in navigation toolbar used specify for Locator
Definition: GUIDesigns.h:97
FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[]
unsigned int GUIGlID
Definition: GUIGlObject.h:40
GUISelectedStorage gSelected
A global holder of selected objects.
@ EDITVIEWPORT
@ SHOWTOOLTIPS
@ RECENTERVIEW
virtual void create()
create GUIGlChildWindow
GUISUMOAbstractView * myView
The view.
long onCmdChangeColorScheme(FXObject *, FXSelector sel, void *)
FXComboBox * myColoringSchemes
The coloring schemes.
FXMenuButton * myLocatorButton
The locator button.
long onCmdEditViewScheme(FXObject *, FXSelector, void *)
virtual ~GUIGlChildWindow()
destructor
long onCmdEditViewport(FXObject *, FXSelector, void *)
FXToolBar * getNavigationToolBar(GUISUMOAbstractView &v)
return a reference to navigation toolbar
FXPopup * myLocatorPopup
The locator menu.
long onCmdShowToolTips(FXObject *sender, FXSelector, void *)
void setView(GUIGlID id)
Centers the view onto the given artifact.
long onCmdZoomStyle(FXObject *sender, FXSelector, void *)
FXComboBox * getColoringSchemesCombo()
return combobox with the current coloring schemes (standard, fastest standard, real world....
void buildColoringToolBar()
build coloring toolbar
void buildScreenshotToolBar()
build screenshot toolbar
virtual bool isSelected(GUIGlObject *o) const
true if the object is selected (may include extra logic besides calling gSelected)
long onCmdRecenterView(FXObject *, FXSelector, void *)
FXPopup * getLocatorPopup()
@ brief return a pointer to locator popup
GUISUMOAbstractView * getView() const
return GUISUMOAbstractView
GUIMainWindow * myParent
The parent window.
virtual FXGLCanvas * getBuildGLCanvas() const
get build GL Canvas
FXToolBar * myStaticNavigationToolBar
The static navigation tool bar.
void buildNavigationToolBar()
build navigation toolbar
GUIMainWindow * getParent()
Returns the main window.
FXMenuBar * myGripNavigationToolbar
The grip navigation tool bar.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void showViewschemeEditor()
show viewsscheme editor
virtual void recenterView()
recenters the view
virtual void showViewportEditor()
show viewport editor
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
void showToolTips(bool val)
show tool tips
virtual bool setColorScheme(const std::string &)
set color scheme
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
bool amChecked() const
check if this MFXCheckableButton is checked
void setChecked(bool val)
check or uncheck this MFXCheckableButton