Skip to content

Commit 6eb3aa4

Browse files
authored
Merge pull request #7859 from gadfort/gui-clock-depth
gui: expose clock depth to swig interface
2 parents 8001160 + be07b6f commit 6eb3aa4

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

src/gui/include/gui/gui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ class Gui
691691
const std::string& corner = "",
692692
int width_px = 0,
693693
int height_px = 0);
694-
void selectClockviewerClock(const std::string& clock_name);
694+
void selectClockviewerClock(const std::string& clock_name,
695+
std::optional<int> depth);
695696

696697
// Save histogram view
697698
void saveHistogramImage(const std::string& filename,

src/gui/src/clockWidget.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ void ClockTreeRenderer::resetTree()
152152

153153
void ClockTreeRenderer::setMaxColorDepth(int depth)
154154
{
155+
if (depth < 1) {
156+
return;
157+
}
158+
155159
max_depth_ = depth;
156160
redraw();
157161
}
@@ -1651,7 +1655,8 @@ void ClockWidget::postReadLiberty()
16511655
}
16521656
}
16531657

1654-
void ClockWidget::selectClock(const std::string& clock_name)
1658+
void ClockWidget::selectClock(const std::string& clock_name,
1659+
std::optional<int> depth)
16551660
{
16561661
setVisible(true);
16571662

@@ -1662,6 +1667,9 @@ void ClockWidget::selectClock(const std::string& clock_name)
16621667
for (auto& view : views_) {
16631668
if (view->getClockName() == clock_name) {
16641669
clocks_tab_->setCurrentWidget(view.get());
1670+
if (depth) {
1671+
view->updateColorDepth(*depth);
1672+
}
16651673

16661674
return;
16671675
}

src/gui/src/clockWidget.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,12 @@ class ClockTreeView : public QGraphicsView
404404
void setRendererState(RendererState state);
405405
void fit();
406406
void save(const QString& path = "");
407+
void updateColorDepth(int depth);
407408

408409
private slots:
409410
void selectionChanged();
410411
void highlightTo(odb::dbITerm* term);
411412
void clearHighlightTo();
412-
void updateColorDepth(int depth);
413413

414414
protected:
415415
void wheelEvent(QWheelEvent* event) override;
@@ -516,7 +516,8 @@ class ClockWidget : public QDockWidget, sta::dbNetworkObserver
516516
const std::string& corner,
517517
const std::optional<int>& width_px,
518518
const std::optional<int>& height_px);
519-
void selectClock(const std::string& clock_name);
519+
void selectClock(const std::string& clock_name,
520+
std::optional<int> depth = {});
520521

521522
void postReadLiberty() override;
522523

src/gui/src/gui.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,12 +832,13 @@ void Gui::saveHistogramImage(const std::string& filename,
832832
filename, chart_mode, width, height);
833833
}
834834

835-
void Gui::selectClockviewerClock(const std::string& clock_name)
835+
void Gui::selectClockviewerClock(const std::string& clock_name,
836+
std::optional<int> depth)
836837
{
837838
if (!enabled()) {
838839
return;
839840
}
840-
main_window->getClockViewer()->selectClock(clock_name);
841+
main_window->getClockViewer()->selectClock(clock_name, depth);
841842
}
842843

843844
static QWidget* findWidget(const std::string& name)

src/gui/src/gui.i

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,17 @@ void save_clocktree_image(const char* filename, const char* clock_name, const ch
310310
gui->saveClockTreeImage(clock_name, filename, corner, width_px, height_px);
311311
}
312312

313-
void select_clockviewer_clock(const char* clock_name)
313+
void select_clockviewer_clock(const char* clock_name, int depth = 0)
314314
{
315315
if (!check_gui("select_clockviewer_clock")) {
316316
return;
317317
}
318318
auto gui = gui::Gui::get();
319-
gui->selectClockviewerClock(clock_name);
319+
std::optional<int> clock_depth;
320+
if (depth > 0) {
321+
clock_depth = depth;
322+
}
323+
gui->selectClockviewerClock(clock_name, clock_depth);
320324
}
321325

322326
void save_histogram_image(const char* filename, const char* mode, int width_px = 0, int height_px = 0)

0 commit comments

Comments
 (0)