From b2345be678fde6e2833b1d6129d2bff6943a535d Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Wed, 26 May 2021 15:42:02 +0200 Subject: [PATCH] Add a scroll bar for TraceAnalyzer A scroll bar was added to the TraceAnalyzer to prepare for the upcoming changes of collapsing/folding ranks to increase readability when many ranks are displayed. The scroll bar is hidden up to a number of 25 rows in the TracePlot. --- .../traceAnalyzer/presentation/traceplot.cpp | 33 ++++++++-- .../traceAnalyzer/presentation/traceplot.h | 5 +- DRAMSys/traceAnalyzer/tracefiletab.cpp | 18 +++++- DRAMSys/traceAnalyzer/tracefiletab.h | 1 + DRAMSys/traceAnalyzer/tracefiletab.ui | 61 ++++++++++++++----- 5 files changed, 96 insertions(+), 22 deletions(-) diff --git a/DRAMSys/traceAnalyzer/presentation/traceplot.cpp b/DRAMSys/traceAnalyzer/presentation/traceplot.cpp index e54ab395..db13d1b9 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.cpp +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.cpp @@ -172,11 +172,13 @@ void TracePlot::setUpContextMenu() contextMenu->addActions({showQueryEditor, insertComment, exportToPdf}); } -void TracePlot::init(TraceNavigator *navigator) +void TracePlot::init(TraceNavigator *navigator, QScrollBar *scrollBar) { Q_ASSERT(isInitialized == false); isInitialized = true; + this->scrollBar = scrollBar; + this->navigator = navigator; connectNavigatorQ_SIGNALS(); setUpDrawingProperties(); @@ -254,13 +256,34 @@ void TracePlot::setUpZoom() zoomZone->setVisible(false); } +void TracePlot::verticalScrollbarChanged(int value) +{ + int numberOfBanks = drawingProperties.numberOfBanks; + + // The maximum number of displayed rows determined by the pageStep of the scroll bar. + const int maxDisplayedRows = scrollBar->pageStep(); + + if (numberOfBanks + 5 + 2 <= maxDisplayedRows) + { + setAxisScale(yLeft, -5, numberOfBanks + 2, 1.0); + } + else + { + setAxisScale(yLeft, numberOfBanks - maxDisplayedRows + 2 - value, numberOfBanks + 2 - value, 1.0); + } + + replot(); +} + void TracePlot::setUpAxis() { - int numberOfBanks = navigator->GeneralTraceInfo().numberOfBanks; + // Set up y axis. + verticalScrollbarChanged(scrollBar->value()); - setAxisScale(yLeft, -5, numberOfBanks + 2, 1.0); - setAxisScaleDraw(yLeft, new CustomLabelScaleDraw( - drawingProperties.getLabels())); + CustomLabelScaleDraw *customLabelScaleDraw = new CustomLabelScaleDraw(drawingProperties.getLabels()); + customLabelScaleDraw->setMinimumExtent(135.0); + + setAxisScaleDraw(yLeft, customLabelScaleDraw); setAxisTitle(xBottom, "Time in ns"); setAxisScaleDraw(xBottom, new EngineeringScaleDraw); diff --git a/DRAMSys/traceAnalyzer/presentation/traceplot.h b/DRAMSys/traceAnalyzer/presentation/traceplot.h index e7ac9737..554209e5 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.h +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.h @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "traceplotitem.h" #include "tracenavigator.h" @@ -66,7 +67,7 @@ class TracePlot : public QwtPlot public: TracePlot(QWidget *parent = NULL); - void init(TraceNavigator *navigator); + void init(TraceNavigator *navigator, QScrollBar *scrollBar); Timespan GetCurrentTimespan(); traceTime ZoomLevel() const { @@ -80,6 +81,7 @@ public Q_SLOTS: void currentTraceTimeChanged(); void selectedTransactionsChanged(); void commentsChanged(); + void verticalScrollbarChanged(int value); Q_SIGNALS: @@ -113,6 +115,7 @@ private: std::vector> transactions; QueryEditor *queryEditor; QMenu *contextMenu; + QScrollBar *scrollBar; void setUpTracePlotItem(); void setUpDrawingProperties(); diff --git a/DRAMSys/traceAnalyzer/tracefiletab.cpp b/DRAMSys/traceAnalyzer/tracefiletab.cpp index 981e60fb..ad81fc59 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.cpp +++ b/DRAMSys/traceAnalyzer/tracefiletab.cpp @@ -66,8 +66,11 @@ TraceFileTab::TraceFileTab(QWidget *parent, const QString &path) : initNavigatorAndItsDependentWidgets(path); setUpFileWatcher(path); + setUpTraceplotScrollbar(); + ui->fileDescriptionEdit->setPlainText( navigator->GeneralTraceInfo().description); + tracefileChanged(); } @@ -82,11 +85,24 @@ void TraceFileTab::commitChangesToDB() navigator->commitChangesToDB(); } +void TraceFileTab::setUpTraceplotScrollbar() +{ + unsigned int numberOfBanks = navigator->GeneralTraceInfo().numberOfBanks; + unsigned int pageStep = ui->traceplotScrollbar->pageStep(); + ui->traceplotScrollbar->setMaximum(numberOfBanks + 7 - pageStep); + + if (ui->traceplotScrollbar->maximum() <= 0) + ui->traceplotScrollbar->hide(); + + QObject::connect(ui->traceplotScrollbar, SIGNAL(valueChanged(int)), + ui->traceplot, SLOT(verticalScrollbarChanged(int))); +} + void TraceFileTab::initNavigatorAndItsDependentWidgets(QString path) { navigator = new TraceNavigator(path, this); - ui->traceplot->init(navigator); + ui->traceplot->init(navigator, ui->traceplotScrollbar); ui->traceScroller->init(navigator, ui->traceplot); connect(this, SIGNAL(colorGroupingChanged(ColorGrouping)), diff --git a/DRAMSys/traceAnalyzer/tracefiletab.h b/DRAMSys/traceAnalyzer/tracefiletab.h index 6a7890a4..10c38c07 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.h +++ b/DRAMSys/traceAnalyzer/tracefiletab.h @@ -58,6 +58,7 @@ public: ~TraceFileTab(); void setUpFileWatcher(QString filename); + void setUpTraceplotScrollbar(); void initNavigatorAndItsDependentWidgets(QString path); QString getPathToTraceFile() { diff --git a/DRAMSys/traceAnalyzer/tracefiletab.ui b/DRAMSys/traceAnalyzer/tracefiletab.ui index 73006015..c3a29753 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.ui +++ b/DRAMSys/traceAnalyzer/tracefiletab.ui @@ -41,27 +41,58 @@ Qt::Vertical - + - - 3 - 4 + + 0 + 250 - - - 0 - 0 - - - - Qt::StrongFocus - + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Qt::StrongFocus + + + + + + + true + + + 25 + + + Qt::Vertical + + + false + + + true + + + + - - 4 + + 0 1