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.dev/sumo
3// Copyright (C) 2001-2023 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
29#include <gui/GUIGlobals.h>
31
32
33// ===========================================================================
34// FOX callback mapping
35// ===========================================================================
36FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[] = {
39 FXMAPFUNC(SEL_COMMAND, MID_DEMO, GUIDialog_AppSettings::onCmdSelect),
42 FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_OK, GUIDialog_AppSettings::onCmdOk),
44};
45
46FXIMPLEMENT(GUIDialog_AppSettings, FXDialogBox, GUIDialog_AppSettingsMap, ARRAYNUMBER(GUIDialog_AppSettingsMap))
47
48
49// ===========================================================================
50// method definitions
51// ===========================================================================
53 : FXDialogBox(parent, TL("Application Settings")),
54 myParent(parent),
55 myAppQuitOnEnd(GUIGlobals::gQuitOnEnd),
56 myAppAutoStart(GUIGlobals::gRunAfterLoad),
57 myAppDemo(GUIGlobals::gDemoAutoReload),
58 myAllowTextures(GUITexturesHelper::texturesAllowed()),
59 myLocateLinks(GUIMessageWindow::locateLinksEnabled()) {
60 FXCheckButton* b = nullptr;
61 FXVerticalFrame* f1 = new FXVerticalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);
62 b = new FXCheckButton(f1, TL("Quit on Simulation End"), this, MID_QUITONSIMEND);
63 b->setCheck(myAppQuitOnEnd);
64 b = new FXCheckButton(f1, TL("Autostart Simulation on Load and Reload"), this, MID_AUTOSTART);
65 b->setCheck(myAppAutoStart);
66 b = new FXCheckButton(f1, TL("Reload Simulation after finish (Demo mode)"), this, MID_DEMO);
67 b->setCheck(myAppDemo);
68 b = new FXCheckButton(f1, TL("Locate elements when clicking on messages"), this, MID_LOCATELINKS);
69 b->setCheck(myLocateLinks);
70
71 FXMatrix* m1 = new FXMatrix(f1, 2, (LAYOUT_FILL_X | LAYOUT_LEFT | MATRIX_BY_COLUMNS), 0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
72 myBreakPointOffset = new FXRealSpinner(m1, 5, this, MID_TIMELINK_BREAKPOINT, GUIDesignViewSettingsSpinDial2 | SPIN_NOMIN);
73 myBreakPointOffset->setValue(STEPS2TIME(GUIMessageWindow::getBreakPointOffset()));
74 new FXLabel(m1, TL("Breakpoint offset when clicking on time message"), nullptr, GUIDesignViewSettingsLabel1);
75 myTable = new FXTable(f1, this, MID_TABLE, GUIDesignBreakpointTable);
76 const auto& onlineMaps = parent->getOnlineMaps();
77 const int numRows = (int)onlineMaps.size() + 1;
78 myTable->setVisibleRows(numRows);
79 myTable->setVisibleColumns(2);
80 myTable->setTableSize(numRows, 2);
81 myTable->setBackColor(FXRGB(255, 255, 255));
82 myTable->getRowHeader()->setWidth(0);
83 myTable->setTableSize(numRows, 2);
84 myTable->setColumnText(0, "Name");
85 myTable->setColumnText(1, "URL");
86 FXHeader* header = myTable->getColumnHeader();
87 header->setHeight(GUIDesignHeight);
88 header->setItemSize(0, 60);
89 header->setItemSize(1, 275);
90 int row = 0;
91 for (const auto& item : onlineMaps) {
92 myTable->setItemText(row, 0, item.first.c_str());
93 myTable->setItemText(row, 1, item.second.c_str());
94 row++;
95 }
96
97 new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X);
98 b = new FXCheckButton(f1, TL("Allow Textures"), this, MID_ALLOWTEXTURES);
99 b->setCheck(myAllowTextures);
100 FXHorizontalFrame* f2 = new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
101 FXButton* initial = new FXButton(f2, TL("&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);
102 new FXButton(f2, TL("&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);
103 initial->setFocus();
105}
106
107
109
110
111long
112GUIDialog_AppSettings::onCmdOk(FXObject*, FXSelector, void*) {
120 FXString maps;
121 for (int r = 0; r < myTable->getNumRows(); r++) {
122 if (myTable->getItem(r, 0) != nullptr && myTable->getItem(r, 1) != nullptr) {
123 myParent->addOnlineMap(myTable->getItem(r, 0)->getText().text(), myTable->getItem(r, 1)->getText().text());
124 if (!maps.empty()) {
125 maps += "\n";
126 }
127 maps += myTable->getItem(r, 0)->getText() + "\t" + myTable->getItem(r, 1)->getText();
128 }
129 }
130 getApp()->reg().writeStringEntry("gui", "onlineMaps", maps.text());
131 destroy();
132 return 1;
133}
134
135
136long
137GUIDialog_AppSettings::onCmdCancel(FXObject*, FXSelector, void*) {
138 destroy();
139 return 1;
140}
141
142long
143GUIDialog_AppSettings::onCmdSelect(FXObject*, FXSelector sel, void*) {
144 switch (FXSELID(sel)) {
145 case MID_QUITONSIMEND:
147 break;
148 case MID_AUTOSTART:
150 break;
151 case MID_DEMO:
153 break;
154 case MID_LOCATELINKS:
156 break;
159 break;
160 }
161 return 1;
162}
163
164
165/****************************************************************************/
@ MID_ALLOWTEXTURES
Allow textures - Option.
Definition: GUIAppEnum.h:560
@ MID_TABLE
The Table.
Definition: GUIAppEnum.h:532
@ MID_AUTOSTART
Start simulation when loaded - Option.
Definition: GUIAppEnum.h:556
@ MID_QUITONSIMEND
Close simulation at end - Option.
Definition: GUIAppEnum.h:554
@ MID_LOCATELINKS
Locate links in messages - Option.
Definition: GUIAppEnum.h:562
@ MID_TIMELINK_BREAKPOINT
Set breakpionts from messages - Option.
Definition: GUIAppEnum.h:564
@ MID_SETTINGS_OK
Ok-button was pushed.
Definition: GUIAppEnum.h:544
@ MID_DEMO
Demo mode - Option.
Definition: GUIAppEnum.h:558
@ MID_SETTINGS_CANCEL
Cancel-button was pushed.
Definition: GUIAppEnum.h:546
#define GUIDesignHeight
define a standard height for all elements (Change it carefully)
Definition: GUIDesigns.h:37
#define GUIDesignViewSettingsSpinDial2
Definition: GUIDesigns.h:545
#define GUIDesignViewSettingsLabel1
Label.
Definition: GUIDesigns.h:553
#define GUIDesignBreakpointTable
design for Breakpoint table
Definition: GUIDesigns.h:649
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
#define TL(string)
Definition: MsgHandler.h:287
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
The dialog to change the application (gui) settings.
bool myAppDemo
Information whether the simulation restarts after ending (demo mode)
FXTable * myTable
The list that holds the URLs.
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.
GUIMainWindow * myParent
FOX needs this.
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:37
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
Definition: GUIGlobals.h:40
static bool gDemoAutoReload
the simulation shall reload when it has ended (demo)
Definition: GUIGlobals.h:43
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void addOnlineMap(const std::string &name, const std::string &url)
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