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-2019 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 
32 
33 #include "GUIGlChildWindow.h"
34 
35 
36 // ===========================================================================
37 // FOX callback mapping
38 // ===========================================================================
39 FXDEFMAP(GUIGlChildWindow) GUIGlChildWindowMap[] = {
43  FXMAPFUNC(SEL_COMMAND, MID_ZOOM_STYLE, GUIGlChildWindow::onCmdZoomStyle),
46 };
47 
48 FXIMPLEMENT(GUIGlChildWindow, FXMDIChild, GUIGlChildWindowMap, ARRAYNUMBER(GUIGlChildWindowMap))
49 
50 
51 // ===========================================================================
52 // member method definitions
53 // ===========================================================================
54 GUIGlChildWindow::GUIGlChildWindow(FXMDIClient* p, GUIMainWindow* parentWindow, FXMDIMenu* mdimenu,
55  const FXString& name, FXMenuBar* gripNavigationToolbar, FXIcon* ic, FXuint opts, FXint x, FXint y, FXint w, FXint h) :
56  FXMDIChild(p, name, ic, mdimenu, opts, x, y, w, h),
57  myParent(parentWindow),
58  myGripNavigationToolbar(gripNavigationToolbar),
59  myStaticNavigationToolBar(nullptr),
60  myView(nullptr) {
61  // Make MDI Window Menu
62  setTracking();
63  // create a vertical frame to add elements
64  myContentFrame = new FXVerticalFrame(this, GUIDesignFrameArea);
65  // if menuBarGripElements isn't NULL, use it to create a grip navigation elements. In other cas, create a static FXToolbar
66  if (myGripNavigationToolbar == nullptr) {
67  myStaticNavigationToolBar = new FXToolBar(myContentFrame, GUIDesignToolbarMenuBar);
68  }
69  // build the tool bars
70  buildNavigationToolBar(); // always there (recenter)
71  buildColoringToolBar(); // always there (coloring)
72  buildScreenshotToolBar(); // always there (screenshot)
73 }
74 
75 
77  delete myLocatorPopup;
78  // only delete static navigation bar if it was created
81  }
82 }
83 
84 
85 void
87  FXMDIChild::create();
88  // only create static navigation bar if it was created
90  myStaticNavigationToolBar->create();
91  } else {
92  myGripNavigationToolbar->create();
93  }
94  myLocatorPopup->create();
95  myView->create();
96 }
97 
98 
101  return myView;
102 }
103 
104 
107  return myParent;
108 }
109 
110 
111 void
113  // build the view settings
114  // recenter view
116  "\tRecenter View\tRecenter view to the simulated area.",
118  // add viewport button
119  new FXButton(myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar,
120  "\tEdit ViewporttOpens a menu which lets you edit the viewport.",
122  // toggle button for zooming style
123  MFXCheckableButton* zoomBut = new MFXCheckableButton(false, myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar,
124  "\tToggles Zooming Style\tToggles whether zooming is based at cursor position or at the center of the view.",
126  zoomBut->setChecked(getApp()->reg().readIntEntry("gui", "zoomAtCenter", 1) != 1);
127  // build the locator popup
128  myLocatorPopup = new FXPopup(myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar, POPUP_VERTICAL);
129  // build locator button
130  myLocatorButton = new FXMenuButton(myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar,
131  "\tLocate Structures\tLocate structures within the network.",
133  // add toggle button for tool-tips on/off
134  new MFXCheckableButton(false, myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar,
135  "\tToggles Tool Tips\tToggles whether tool tips shall be shown.",
137 }
138 
139 
140 void
142  // Create Vertical separator
144  // build coloring tools
145  myColoringSchemes = new FXComboBox(myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar,
147  // editor
148  new FXButton(myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar,
149  "\tEdit Coloring Schemes\tOpens a menu which lets you edit the coloring schemes.",
151 }
152 
153 
154 void
156  // Create Vertical separator
158  // snapshot
159  new MFXCheckableButton(false, myGripNavigationToolbar ? myGripNavigationToolbar : myStaticNavigationToolBar,
160  "\tMake Snapshot\tMakes a snapshot of the view.",
162 }
163 
164 
165 FXGLCanvas*
167  return myView;
168 }
169 
170 
171 FXToolBar*
174 }
175 
176 
177 FXPopup*
179  return myLocatorPopup;
180 }
181 
182 
183 FXComboBox*
185  return myColoringSchemes;
186 }
187 
188 
189 long
190 GUIGlChildWindow::onCmdRecenterView(FXObject*, FXSelector, void*) {
191  myView->recenterView();
192  myView->update();
193  return 1;
194 }
195 
196 
197 long
198 GUIGlChildWindow::onCmdEditViewport(FXObject*, FXSelector, void*) {
200  return 1;
201 }
202 
203 
204 long
205 GUIGlChildWindow::onCmdEditViewScheme(FXObject*, FXSelector, void*) {
207  return 1;
208 }
209 
210 
211 long
212 GUIGlChildWindow::onCmdShowToolTips(FXObject* sender, FXSelector, void*) {
213  MFXCheckableButton* button = dynamic_cast<MFXCheckableButton*>(sender);
214  // check if button was sucesfully casted
215  if (button) {
216  button->setChecked(!button->amChecked());
217  myView->showToolTips(button->amChecked());
218  update();
219  myView->update();
220  }
221  return 1;
222 }
223 
224 
225 long
226 GUIGlChildWindow::onCmdZoomStyle(FXObject* sender, FXSelector, void*) {
227  MFXCheckableButton* button = dynamic_cast<MFXCheckableButton*>(sender);
228  if (button) {
229  button->setChecked(!button->amChecked());
230  getApp()->reg().writeIntEntry("gui", "zoomAtCenter",
231  button->amChecked() ? 0 : 1);
232  update();
233  myView->update();
234  }
235  return 1;
236 }
237 
238 
239 long
240 GUIGlChildWindow::onCmdChangeColorScheme(FXObject*, FXSelector, void* data) {
241  myView->setColorScheme((char*) data);
242  return 1;
243 }
244 
245 
246 void
248  // this is used by the locator widget. zooming to bounding box
249  myView->centerTo(id, true, -1);
250  myView->update();
251 }
252 
253 
254 bool
256  return gSelected.isSelected(o->getType(), o->getGlID());
257 }
258 
259 /****************************************************************************/
260 
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:233
virtual FXGLCanvas * getBuildGLCanvas() const
get build GL Canvas
virtual void recenterView()
recenters the view
void buildColoringToolBar()
build coloring toolbar
#define GUIDesignVerticalSeparator
vertical separator
Definition: GUIDesigns.h:340
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
Definition: GUIDesigns.h:95
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:277
FXMenuBar * myGripNavigationToolbar
The grip navigation tool bar.
void buildNavigationToolBar()
build navigation toolbar
Show tool tips - button.
Definition: GUIAppEnum.h:331
GUIMainWindow * myParent
The parent window.
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:101
FXToolBar * getNavigationToolBar(GUISUMOAbstractView &v)
return a reference to navigation toolbar
Open viewport editor - button.
Definition: GUIAppEnum.h:327
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:359
void buildScreenshotToolBar()
build screenshot toolbar
#define GUIDesignComboBoxStatic
Combo box static (not editable)
Definition: GUIDesigns.h:224
Make snapshot - button.
Definition: GUIAppEnum.h:333
Recenter view - button.
Definition: GUIAppEnum.h:303
Open view editor - button.
Definition: GUIAppEnum.h:329
virtual bool setColorScheme(const std::string &)
set color scheme
unsigned int GUIGlID
Definition: GUIGlObject.h:43
virtual void showViewportEditor()
show viewport editor
void setView(GUIGlID id)
Centers the view onto the given artifact.
FXComboBox * myColoringSchemes
The coloring schemes.
virtual ~GUIGlChildWindow()
destructor
#define GUIDesignButtonToolbarCheckable
little checkable button with icon placed in navigation toolbar
Definition: GUIDesigns.h:104
GUISUMOAbstractView * getView() const
return GUISUMOAbstractView
FXToolBar * myStaticNavigationToolBar
The static navigation tool bar.
FXMenuButton * myLocatorButton
The locator button.
toogle zooming style
Definition: GUIAppEnum.h:335
GUISUMOAbstractView * myView
The view.
long onCmdEditViewport(FXObject *, FXSelector, void *)
#define GUIDesignToolbarMenuBar
Definition: GUIDesigns.h:305
FXComboBox * getColoringSchemesCombo()
return combobox with the current coloring schemes (standard, fastest standard, real world...
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIMainWindow * getParent()
Returns the main window.
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()
create GUIGlChildWindow
GUISelectedStorage gSelected
A global holder of selected objects.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXPopup * getLocatorPopup()
@ brief return a pointer to locator popup