Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Command_Hotkey_TrafficLight.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-2024 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/****************************************************************************/
18// Registers custom hotkey for aborting current traffic light phase
19/****************************************************************************/
20#include <config.h>
21
22#include <fxkeys.h>
24#include <guisim/GUINet.h>
26
27
28// ===========================================================================
29// method definitions
30// ===========================================================================
34
35
37
38
45
46
47bool
49 int hotkey = -1;
50 if (key.size() == 1) {
51 char c = key[0];
52 if ('a' <= c && c <= 'z') {
53 // see FXAccelTable::parseAccel
54 hotkey = c + FX::KEY_space - ' ';
55 } else {
56 WRITE_WARNINGF(TL("Hotkey '%' is not supported"), key);
57 return false;
58 }
59 } else {
60 WRITE_WARNINGF(TL("Hotkey '%' is not supported"), key);
61 return false;
62 }
63 GUINet* gn = dynamic_cast<GUINet*>(MSNet::getInstance());
64 if (gn != nullptr) {
65 gn->addHotkey(hotkey, new Command_Hotkey_TrafficLight(tll));
66 }
67 return true;
68}
69
70
71/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define TL(string)
Definition MsgHandler.h:315
Set/unsets inductionloop override.
Command_Hotkey_TrafficLight(MSTrafficLightLogic &tll)
Constructor.
MSTrafficLightLogic & myLogic
The traffic light logic to be manipulated.
static bool registerHotkey(const std::string &key, MSTrafficLightLogic &tll)
register hotkey actions
SUMOTime execute(SUMOTime currentTime)
toggles override
A MSNet extended by some values for usage within the gui.
Definition GUINet.h:82
void addHotkey(int key, Command *press, Command *release=nullptr)
register custom hotkey action
Definition GUINet.cpp:776
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:185
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition MSNet.h:451
The parent class for traffic light logics.
virtual int getPhaseNumber() const =0
Returns the number of phases.
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
static double gn[11]