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
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, "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
76 myTable = new FXTable(f1, this, MID_TABLE, GUIDesignBreakpointTable);
77 const auto& onlineMaps = parent->getOnlineMaps();
78 const int numRows = (int)onlineMaps.size() + 1;
79 myTable->setVisibleRows(numRows);
80 myTable->setVisibleColumns(2);
81 myTable->setTableSize(numRows, 2);
82 myTable->setBackColor(FXRGB(255, 255, 255));
83 myTable->getRowHeader()->setWidth(0);
84 myTable->setTableSize(numRows, 2);
85 myTable->setColumnText(0, "Name");
86 myTable->setColumnText(1, "URL");
87 FXHeader* header = myTable->getColumnHeader();
88 header->setHeight(GUIDesignHeight);
89 header->setItemSize(0, 60);
90 header->setItemSize(1, 275);
91 int row = 0;
92 for (const auto& item : onlineMaps) {
93 myTable->setItemText(row, 0, item.first.c_str());
94 myTable->setItemText(row, 1, item.second.c_str());
95 row++;
96 }
97
98 new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X);
99 b = new FXCheckButton(f1, TL("Allow Textures"), this, MID_ALLOWTEXTURES);
100 b->setCheck(myAllowTextures);
101 FXHorizontalFrame* f2 = new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
102 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);
103 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);
104 initial->setFocus();
106}
107
108
110
111
112long
113GUIDialog_AppSettings::onCmdOk(FXObject*, FXSelector, void*) {
121 FXString maps;
122 for (int r = 0; r < myTable->getNumRows(); r++) {
123 if (myTable->getItem(r, 0) != nullptr && myTable->getItem(r, 1) != nullptr) {
124 myParent->addOnlineMap(myTable->getItem(r, 0)->getText().text(), myTable->getItem(r, 1)->getText().text());
125 if (!maps.empty()) {
126 maps += "\n";
127 }
128 maps += myTable->getItem(r, 0)->getText() + "\t" + myTable->getItem(r, 1)->getText();
129 }
130 }
131 getApp()->reg().writeStringEntry("gui", "onlineMaps", maps.text());
132 destroy();
133 return 1;
134}
135
136
137long
138GUIDialog_AppSettings::onCmdCancel(FXObject*, FXSelector, void*) {
139 destroy();
140 return 1;
141}
142
143long
144GUIDialog_AppSettings::onCmdSelect(FXObject*, FXSelector sel, void*) {
145 switch (FXSELID(sel)) {
146 case MID_QUITONSIMEND:
148 break;
149 case MID_AUTOSTART:
151 break;
152 case MID_DEMO:
154 break;
155 case MID_LOCATELINKS:
157 break;
160 break;
161 }
162 return 1;
163}
164
165
166/****************************************************************************/
@ MID_ALLOWTEXTURES
Allow textures - Option.
Definition: GUIAppEnum.h:558
@ MID_TABLE
The Table.
Definition: GUIAppEnum.h:530
@ MID_AUTOSTART
Start simulation when loaded - Option.
Definition: GUIAppEnum.h:554
@ MID_QUITONSIMEND
Close simulation at end - Option.
Definition: GUIAppEnum.h:552
@ MID_LOCATELINKS
Locate links in messages - Option.
Definition: GUIAppEnum.h:560
@ MID_TIMELINK_BREAKPOINT
Set breakpionts from messages - Option.
Definition: GUIAppEnum.h:562
@ MID_SETTINGS_OK
Ok-button was pushed.
Definition: GUIAppEnum.h:542
@ MID_DEMO
Demo mode - Option.
Definition: GUIAppEnum.h:556
@ MID_SETTINGS_CANCEL
Cancel-button was pushed.
Definition: GUIAppEnum.h:544
#define GUIDesignHeight
define a standard height for all elements (Change it carefully)
Definition: GUIDesigns.h:37
#define GUIDesignViewSettingsSpinDial2
Definition: GUIDesigns.h:542
#define GUIDesignViewSettingsLabel1
Label.
Definition: GUIDesigns.h:550
#define GUIDesignBreakpointTable
design for Breakpoint table
Definition: GUIDesigns.h:642
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
#define TL(string)
Definition: MsgHandler.h:282
#define STEPS2TIME(x)
Definition: SUMOTime.h:54
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
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
The main GUI window.
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
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