Skip to content

Commit

Permalink
fix #10400
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 15, 2024
1 parent 074c41e commit a03865f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/gui/GUIApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ FXDEFMAP(GUIApplicationWindow) GUIApplicationWindowMap[] = {
FXMAPFUNC(SEL_COMMAND, MID_DELAY_TOGGLE, GUIApplicationWindow::onCmdDelayToggle),
FXMAPFUNC(SEL_COMMAND, MID_DEMAND_SCALE, GUIApplicationWindow::onCmdDemandScale),
FXMAPFUNC(SEL_COMMAND, MID_CLEARMESSAGEWINDOW, GUIApplicationWindow::onCmdClearMsgWindow),
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_B_BREAKPOINT, GUIApplicationWindow::onCmdBreakpoint),
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_ALT_B_BREAKPOINT_EARLY, GUIApplicationWindow::onCmdBreakpointEarly),
// Stats
FXMAPFUNC(SEL_COMMAND, MID_SHOWNETSTATS, GUIApplicationWindow::onCmdShowStats),
FXMAPFUNC(SEL_COMMAND, MID_SHOWVEHSTATS, GUIApplicationWindow::onCmdShowStats),
Expand Down Expand Up @@ -1396,6 +1398,22 @@ GUIApplicationWindow::onCmdClearMsgWindow(FXObject*, FXSelector, void*) {
}


long
GUIApplicationWindow::onCmdBreakpoint(FXObject*, FXSelector, void*) {
// see updateTimeLCD for the DELTA_T
addBreakpoint(SIMSTEP - DELTA_T);
return 1;
}


long
GUIApplicationWindow::onCmdBreakpointEarly(FXObject*, FXSelector, void*) {
// see updateTimeLCD for the DELTA_T
addBreakpoint(SIMSTEP - DELTA_T + GUIMessageWindow::getBreakPointOffset());
return 1;
}


long
GUIApplicationWindow::onUpdStart(FXObject* sender, FXSelector, void* ptr) {
sender->handle(this,
Expand Down Expand Up @@ -2398,6 +2416,18 @@ GUIApplicationWindow::setBreakpoints(const std::vector<SUMOTime>& breakpoints) {
}


void
GUIApplicationWindow::addBreakpoint(SUMOTime time) {
std::vector<SUMOTime> breakpoints = retrieveBreakpoints();
if (std::find(breakpoints.begin(), breakpoints.end(), time) == breakpoints.end()) {
breakpoints.push_back(time);
std::sort(breakpoints.begin(), breakpoints.end());
setBreakpoints(breakpoints);
setStatusBarText(TLF("Set breakpoint at %", time2string(time)));
}
}


const std::vector<SUMOTime>
GUIApplicationWindow::retrieveBreakpoints() const {
myRunThread->getBreakpointLock().lock();
Expand Down
9 changes: 9 additions & 0 deletions src/gui/GUIApplicationWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ class GUIApplicationWindow : public GUIMainWindow, public MFXInterThreadEventCli
/// @brief Called if the message window shall be cleared
long onCmdClearMsgWindow(FXObject*, FXSelector, void*);

/// @brief Called to set a breakpoint via hotkey
long onCmdBreakpoint(FXObject*, FXSelector, void*);

/// @brief Called to set an early breakpoint via hotkey
long onCmdBreakpointEarly(FXObject*, FXSelector, void*);

/// @brief Called on menu commands from the Locator menu
long onCmdLocate(FXObject*, FXSelector, void*);

Expand Down Expand Up @@ -331,6 +337,9 @@ class GUIApplicationWindow : public GUIMainWindow, public MFXInterThreadEventCli
/// @brief Sets the breakpoints of the parent application
virtual void setBreakpoints(const std::vector<SUMOTime>& breakpoints);

/// @brief Adds the given breakpoint
void addBreakpoint(SUMOTime time);

/// @brief Sends an event from the application thread to the GUI and waits until it is handled
virtual void sendBlockingEvent(GUIEvent* event);

Expand Down
5 changes: 5 additions & 0 deletions src/utils/gui/shortcuts/GUIShortcutsSubSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ GUIShortcutsSubSys::buildAccelerators(FXAccelTable* accelTable, FXObject* target
accelTable->addAccel(parseKey(KEY_a), target, FXSEL(SEL_COMMAND, MID_HOTKEY_A_MODE_STARTSIMULATION_ADDITIONALS_STOPS));
accelTable->addAccel(parseKey(KEY_A), target, FXSEL(SEL_COMMAND, MID_HOTKEY_A_MODE_STARTSIMULATION_ADDITIONALS_STOPS));

accelTable->addAccel(parseKey(KEY_b), target, FXSEL(SEL_COMMAND, MID_HOTKEY_B_BREAKPOINT));
accelTable->addAccel(parseKey(KEY_B), target, FXSEL(SEL_COMMAND, MID_HOTKEY_B_BREAKPOINT));

accelTable->addAccel(parseKey(KEY_c), target, FXSEL(SEL_COMMAND, MID_HOTKEY_C_MODE_CONNECT_CONTAINER));
accelTable->addAccel(parseKey(KEY_C), target, FXSEL(SEL_COMMAND, MID_HOTKEY_C_MODE_CONNECT_CONTAINER));

Expand Down Expand Up @@ -272,6 +275,8 @@ GUIShortcutsSubSys::buildAccelerators(FXAccelTable* accelTable, FXObject* target
accelTable->addAccel(parseKey(KEY_9, KEYMODIFIER_ALT), target, FXSEL(SEL_COMMAND, MID_HOTKEY_ALT_9_TOGGLEEDITOPTION));

accelTable->addAccel(parseKey(KEY_F4, KEYMODIFIER_ALT), target, FXSEL(SEL_COMMAND, MID_HOTKEY_ALT_F4_CLOSE));
accelTable->addAccel(parseKey(KEY_b, KEYMODIFIER_ALT), target, FXSEL(SEL_COMMAND, MID_HOTKEY_ALT_B_BREAKPOINT_EARLY));
accelTable->addAccel(parseKey(KEY_B, KEYMODIFIER_ALT), target, FXSEL(SEL_COMMAND, MID_HOTKEY_ALT_B_BREAKPOINT_EARLY));
}


Expand Down
5 changes: 4 additions & 1 deletion src/utils/gui/windows/GUIAppEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ enum {
MID_HOTKEY_A_MODE_STARTSIMULATION_ADDITIONALS_STOPS,
/// @brief hotkey for mode connecting lanes AND container
MID_HOTKEY_C_MODE_CONNECT_CONTAINER,
/// @brief hotkey for setting a breakpoint
MID_HOTKEY_B_BREAKPOINT,
/// @brief hotkey for perform a single simulation step in SUMO and set delete mode in netedit
MID_HOTKEY_D_MODE_SINGLESIMULATIONSTEP_DELETE,
/// @brief hotkey for mode adding edges AND edgeDatas
Expand Down Expand Up @@ -159,7 +161,8 @@ enum {
MID_HOTKEY_ALT_9_TOGGLEEDITOPTION,
/// @brief Main window closes
MID_HOTKEY_ALT_F4_CLOSE,

/// @brief hotkey for setting a breakpoint ahead of the current time
MID_HOTKEY_ALT_B_BREAKPOINT_EARLY,
/// @}

/// @name shift + hotkeys
Expand Down

0 comments on commit a03865f

Please sign in to comment.