Path: blob/main/src/guisim/Command_Hotkey_InductionLoop.cpp
169666 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file Command_Hotkey_InductionLoop.cpp14/// @author Jakob Erdmann15/// @date 31 Jan 202216///17// Registers custom hotkey for overriding detector value18/****************************************************************************/19#include <config.h>2021#include <fxkeys.h>22#include <microsim/output/MSInductLoop.h>23#include <guisim/GUINet.h>24#include "Command_Hotkey_InductionLoop.h"252627// ===========================================================================28// method definitions29// ===========================================================================30Command_Hotkey_InductionLoop::Command_Hotkey_InductionLoop(MSInductLoop* det, bool set) :31myDetector(det), mySet(set)32{ }333435Command_Hotkey_InductionLoop::~Command_Hotkey_InductionLoop() { }363738SUMOTime39Command_Hotkey_InductionLoop::execute(SUMOTime /*currentTime*/) {40myDetector->overrideTimeSinceDetection(mySet ? 0 : -1);41return 1;42}434445bool46Command_Hotkey_InductionLoop::registerHotkey(const std::string& key, MSInductLoop* det) {47int hotkey = -1;48if (key.size() == 1) {49char c = key[0];50if ('a' <= c && c <= 'z') {51// see FXAccelTable::parseAccel52hotkey = c + FX::KEY_space - ' ';53} else {54WRITE_WARNINGF(TL("Hotkey '%' is not supported"), key);55return false;56}57} else {58WRITE_WARNINGF(TL("Hotkey '%' is not supported"), key);59return false;60}61GUINet* gn = dynamic_cast<GUINet*>(MSNet::getInstance());62if (gn != nullptr) {63gn->addHotkey(hotkey,64new Command_Hotkey_InductionLoop(det, true),65new Command_Hotkey_InductionLoop(det, false));66}67return true;68}6970/****************************************************************************/717273