Skip to content

Commit a4390e1

Browse files
authored
Merge pull request #7965 from The-OpenROAD-Project-staging/gui-debounce-select
gui: use a timer to debounce 'select' commands
2 parents c2f8e33 + 3f6f56c commit a4390e1

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/gui/src/mainWindow.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ MainWindow::MainWindow(bool load_settings, QWidget* parent)
9090
charts_widget_(new ChartsWidget(this)),
9191
help_widget_(new HelpWidget(this)),
9292
find_dialog_(new FindObjectDialog(this)),
93-
goto_dialog_(new GotoLocationDialog(this, viewers_))
93+
goto_dialog_(new GotoLocationDialog(this, viewers_)),
94+
selection_timer_(std::make_unique<QTimer>()),
95+
highlight_timer_(std::make_unique<QTimer>())
9496
{
9597
QFont font("Monospace");
9698
font.setStyleHint(QFont::Monospace);
@@ -379,6 +381,13 @@ MainWindow::MainWindow(bool load_settings, QWidget* parent)
379381
&MainWindow::displayUnitsChanged,
380382
goto_dialog_,
381383
&GotoLocationDialog::updateUnits);
384+
connect(selection_timer_.get(), &QTimer::timeout, [this]() {
385+
emit selectionChanged();
386+
});
387+
connect(highlight_timer_.get(),
388+
&QTimer::timeout,
389+
this,
390+
&MainWindow::highlightChanged);
382391

383392
createActions();
384393
createToolbars();
@@ -428,6 +437,12 @@ MainWindow::MainWindow(bool load_settings, QWidget* parent)
428437
= [this](const std::string& value, bool* ok) -> int {
429438
return convertStringToDBU(value, ok);
430439
};
440+
441+
selection_timer_->setSingleShot(true);
442+
highlight_timer_->setSingleShot(true);
443+
444+
selection_timer_->setInterval(100 /* ms */);
445+
highlight_timer_->setInterval(100 /* ms */);
431446
}
432447

433448
void MainWindow::showEvent(QShowEvent* event)
@@ -1134,7 +1149,7 @@ void MainWindow::addSelected(const SelectionSet& selections, bool find_in_cts)
11341149
}
11351150
status(std::string("Added ")
11361151
+ std::to_string(selected_.size() - prev_selected_size));
1137-
emit selectionChanged();
1152+
selection_timer_->start();
11381153

11391154
if (find_in_cts) {
11401155
emit findInCts(selections);
@@ -1178,7 +1193,7 @@ void MainWindow::addHighlighted(const SelectionSet& highlights,
11781193
group.insert(highlight);
11791194
}
11801195
}
1181-
emit highlightChanged();
1196+
highlight_timer_->start();
11821197
}
11831198

11841199
std::string MainWindow::addLabel(int x,

src/gui/src/mainWindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ class MainWindow : public QMainWindow, public odb::dbDatabaseObserver
374374
std::map<HeatMapDataSource*, QAction*> heatmap_actions_;
375375

376376
std::unique_ptr<utl::Progress> cli_progress_ = nullptr;
377+
378+
std::unique_ptr<QTimer> selection_timer_;
379+
std::unique_ptr<QTimer> highlight_timer_;
377380
};
378381

379382
} // namespace gui

0 commit comments

Comments
 (0)