Eclipse SUMO - Simulation of Urban MObility
GUIDialog_AppSettings.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-2022 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 /****************************************************************************/
19 // The application-settings dialog
20 /****************************************************************************/
21 #include <config.h>
22 
28 #include <gui/GUIGlobals.h>
29 #include "GUIDialog_AppSettings.h"
30 
31 
32 // ===========================================================================
33 // FOX callback mapping
34 // ===========================================================================
35 FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[] = {
37  FXMAPFUNC(SEL_COMMAND, MID_AUTOSTART, GUIDialog_AppSettings::onCmdSelect),
38  FXMAPFUNC(SEL_COMMAND, MID_DEMO, GUIDialog_AppSettings::onCmdSelect),
40  FXMAPFUNC(SEL_COMMAND, MID_LOCATELINKS, GUIDialog_AppSettings::onCmdSelect),
41  FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_OK, GUIDialog_AppSettings::onCmdOk),
43 };
44 
45 FXIMPLEMENT(GUIDialog_AppSettings, FXDialogBox, GUIDialog_AppSettingsMap, ARRAYNUMBER(GUIDialog_AppSettingsMap))
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
52  : FXDialogBox(parent, "Application Settings"),
53  myAppQuitOnEnd(GUIGlobals::gQuitOnEnd),
54  myAppAutoStart(GUIGlobals::gRunAfterLoad),
55  myAppDemo(GUIGlobals::gDemoAutoReload),
56  myAllowTextures(GUITexturesHelper::texturesAllowed()),
57  myLocateLinks(GUIMessageWindow::locateLinksEnabled()) {
58  FXCheckButton* b = nullptr;
59  FXVerticalFrame* f1 = new FXVerticalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);
60  b = new FXCheckButton(f1, "Quit on Simulation End", this, MID_QUITONSIMEND);
61  b->setCheck(myAppQuitOnEnd);
62  b = new FXCheckButton(f1, "Autostart Simulation on Load and Reload", this, MID_AUTOSTART);
63  b->setCheck(myAppAutoStart);
64  b = new FXCheckButton(f1, "Reload Simulation after finish (Demo mode)", this, MID_DEMO);
65  b->setCheck(myAppDemo);
66  b = new FXCheckButton(f1, "Locate elements when clicking on messages", this, MID_LOCATELINKS);
67  b->setCheck(myLocateLinks);
68 
69  FXMatrix* m1 = new FXMatrix(f1, 2, (LAYOUT_FILL_X | LAYOUT_LEFT | MATRIX_BY_COLUMNS), 0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
70  myBreakPointOffset = new FXRealSpinner(m1, 5, this, MID_TIMELINK_BREAKPOINT, GUIDesignViewSettingsSpinDial2 | SPIN_NOMIN);
71  myBreakPointOffset->setValue(STEPS2TIME(GUIMessageWindow::getBreakPointOffset()));
72  new FXLabel(m1, "Breakpoint offset when clicking on time message", nullptr, GUIDesignViewSettingsLabel1);
73 
74  new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X);
75  b = new FXCheckButton(f1, "Allow Textures", this, MID_ALLOWTEXTURES);
76  b->setCheck(myAllowTextures);
77  FXHorizontalFrame* f2 = new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
78  FXButton* initial = new FXButton(f2, "&OK", nullptr, this, MID_SETTINGS_OK, BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
79  new FXButton(f2, "&Cancel", nullptr, this, MID_SETTINGS_CANCEL, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
80  initial->setFocus();
82 }
83 
84 
86 
87 
88 long
89 GUIDialog_AppSettings::onCmdOk(FXObject*, FXSelector, void*) {
97  destroy();
98  return 1;
99 }
100 
101 
102 long
103 GUIDialog_AppSettings::onCmdCancel(FXObject*, FXSelector, void*) {
104  destroy();
105  return 1;
106 }
107 
108 long
109 GUIDialog_AppSettings::onCmdSelect(FXObject*, FXSelector sel, void*) {
110  switch (FXSELID(sel)) {
111  case MID_QUITONSIMEND:
113  break;
114  case MID_AUTOSTART:
116  break;
117  case MID_DEMO:
118  myAppDemo = !myAppDemo;
119  break;
120  case MID_LOCATELINKS:
122  break;
123  case MID_ALLOWTEXTURES:
125  break;
126  }
127  return 1;
128 }
129 
130 
131 /****************************************************************************/
@ MID_ALLOWTEXTURES
Allow textures - Option.
Definition: GUIAppEnum.h:521
@ MID_AUTOSTART
Start simulation when loaded - Option.
Definition: GUIAppEnum.h:517
@ MID_QUITONSIMEND
Close simulation at end - Option.
Definition: GUIAppEnum.h:515
@ MID_LOCATELINKS
Locate links in messages - Option.
Definition: GUIAppEnum.h:523
@ MID_TIMELINK_BREAKPOINT
Set breakpionts from messages - Option.
Definition: GUIAppEnum.h:525
@ MID_SETTINGS_OK
Ok-button was pushed.
Definition: GUIAppEnum.h:505
@ MID_DEMO
Demo mode - Option.
Definition: GUIAppEnum.h:519
@ MID_SETTINGS_CANCEL
Cancel-button was pushed.
Definition: GUIAppEnum.h:507
#define GUIDesignViewSettingsSpinDial2
Definition: GUIDesigns.h:485
#define GUIDesignViewSettingsLabel1
Label.
Definition: GUIDesigns.h:493
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
The dialog to change the application (gui) settings.
bool myAppDemo
Information whether the simulation restarts after ending (demo mode)
bool myAppQuitOnEnd
Information whether the application shall be quit.
long onCmdOk(FXObject *, FXSelector, void *)
Called on OK-button pressure.
bool myAppAutoStart
Information whether the simulation shall start directly after loading.
FXRealSpinner * myBreakPointOffset
Offset when adding breakpoints.
bool myLocateLinks
Information whether locate links appear in messages.
long onCmdSelect(FXObject *, FXSelector sel, void *)
Called on button change.
long onCmdCancel(FXObject *, FXSelector, void *)
Called on Cancel-button pressure.
bool myAllowTextures
Information whether textures may be used.
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:42
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
Definition: GUIGlobals.h:45
static bool gDemoAutoReload
the simulation shall reload when it has ended (demo)
Definition: GUIGlobals.h:48
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
A logging window for the gui.
static void enableLocateLinks(const bool val)
switch locate links on and off
static void setBreakPointOffset(SUMOTime val)
switch locate links on and off
static SUMOTime getBreakPointOffset()
ask whether locate links is enabled
Global storage for textures; manages and draws them.
static void allowTextures(const bool val)
switch texture drawing on and off