From 1cf0d0c7436245dc75152f2172df2dc7005b25a5 Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Mon, 25 Oct 2021 15:34:58 +0200 Subject: [PATCH] Add a switch in the context menu to disable and enable dependency drawing --- .../businessObjects/phases/phase.cpp | 18 +++++---- .../presentation/tracedrawingproperties.cpp | 9 ++--- .../presentation/tracedrawingproperties.h | 12 +++++- .../traceAnalyzer/presentation/traceplot.cpp | 38 +++++++++++++++++++ .../traceAnalyzer/presentation/traceplot.h | 3 ++ .../presentation/tracescroller.cpp | 6 +-- 6 files changed, 68 insertions(+), 18 deletions(-) diff --git a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp index 17a46d4e..c7f261a5 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp @@ -72,16 +72,16 @@ void Phase::draw(QPainter *painter, const QwtScaleMap &xMap, drawingProperties.drawText, getPhaseSymbol(), painter, xMap, yMap); if (getGranularity() == Granularity::Bankwise) { - bool drawAllDependencies = false; - bool drawDependencies = true; + bool drawDependencyText = true; - if (drawAllDependencies || (highlight && drawDependencies)) { - drawPhaseDependencies(span.Begin(), span.End(), line->getYVal(), - drawingProperties, drawDependencyText, painter, xMap, yMap); + DependencyOption drawDependenciesOption = drawingProperties.drawDependenciesOption; + if (drawDependenciesOption == DependencyOption::All || + (drawDependenciesOption == DependencyOption::Selected && highlight)) + { + drawPhaseDependencies(span.Begin(), span.End(), line->getYVal(), drawingProperties, + drawDependencyText, painter, xMap, yMap); } - } - } } @@ -135,6 +135,8 @@ void Phase::drawPhaseDependencies(traceTime begin, traceTime end, double y, cons { QPen pen; pen.setWidth(2); + + painter->save(); painter->setPen(pen); painter->setRenderHint(QPainter::Antialiasing); @@ -164,8 +166,8 @@ void Phase::drawPhaseDependencies(traceTime begin, traceTime end, double y, cons QPoint invisibleDepsPoint(static_cast(xMap.transform(begin + (end + offset - begin)/2)), static_cast(yVal + 0.1*symbolHeight)); drawText(painter, QString(std::to_string(invisibleDeps).c_str()), invisibleDepsPoint, TextPositioning::centerCenter); } - + painter->restore(); } QColor Phase::getColor(const TraceDrawingProperties &drawingProperties) const diff --git a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.cpp b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.cpp index 95c0a4cd..25650211 100644 --- a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.cpp +++ b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.cpp @@ -40,11 +40,10 @@ #include "util/traceplotlinecache.h" #include "traceselector.h" -TraceDrawingProperties::TraceDrawingProperties(bool drawText, bool drawBorder, - ColorGrouping colorGrouping) : - drawText(drawText), - drawBorder(drawBorder), - colorGrouping(colorGrouping) +TraceDrawingProperties::TraceDrawingProperties(bool drawText, bool drawBorder, DependencyOption drawDependenciesOption, + ColorGrouping colorGrouping) + : drawText(drawText), drawBorder(drawBorder), drawDependenciesOption(drawDependenciesOption), + colorGrouping(colorGrouping) { } diff --git a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h index c51ee834..764498f5 100644 --- a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h +++ b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h @@ -58,6 +58,13 @@ class TracePlotLineCache; using TracePlotLineVector = std::vector>; +enum class DependencyOption +{ + Disabled, + Selected, + All +}; + class TraceDrawingProperties : public QObject { Q_OBJECT @@ -65,6 +72,7 @@ class TraceDrawingProperties : public QObject public: bool drawText; bool drawBorder; + DependencyOption drawDependenciesOption; ColorGrouping colorGrouping; unsigned int numberOfRanks; @@ -74,8 +82,8 @@ public: unsigned int groupsPerRank; unsigned int banksPerGroup; - TraceDrawingProperties(bool drawText = true, - bool drawBorder = true, + TraceDrawingProperties(bool drawText = true, bool drawBorder = true, + DependencyOption drawDependenciesOption = DependencyOption::Disabled, ColorGrouping colorGrouping = ColorGrouping::PhaseType); ~TraceDrawingProperties(); diff --git a/DRAMSys/traceAnalyzer/presentation/traceplot.cpp b/DRAMSys/traceAnalyzer/presentation/traceplot.cpp index 7adbcc69..d82a1347 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.cpp +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.cpp @@ -162,6 +162,40 @@ void TracePlot::setUpActions() SLOT(on_toggleCollapsedState())); toggleCollapsedState->setShortcut(Qt::CTRL + Qt::Key_X); + disabledDependencies = new QAction("Disabled", this); + selectedDependencies = new QAction("Selected transactions", this); + allDependencies = new QAction("All transactions", this); + + disabledDependencies->setCheckable(true); + selectedDependencies->setCheckable(true); + allDependencies->setCheckable(true); + + disabledDependencies->setChecked(true); + + QObject::connect(disabledDependencies, &QAction::triggered, this, + [&]() + { + drawingProperties.drawDependenciesOption = DependencyOption::Disabled; + replot(); + }); + QObject::connect(selectedDependencies, &QAction::triggered, this, + [&]() + { + drawingProperties.drawDependenciesOption = DependencyOption::Selected; + replot(); + }); + QObject::connect(allDependencies, &QAction::triggered, this, + [&]() + { + drawingProperties.drawDependenciesOption = DependencyOption::All; + replot(); + }); + + QActionGroup *dependenciesGroup = new QActionGroup(this); + dependenciesGroup->addAction(disabledDependencies); + dependenciesGroup->addAction(selectedDependencies); + dependenciesGroup->addAction(allDependencies); + setUpContextMenu(); } @@ -174,6 +208,10 @@ void TracePlot::setUpContextMenu() colorGroupingSubMenu->addActions({setColorGroupingPhase, setColorGroupingTransaction, setColorGroupingThread}); contextMenu->addMenu(colorGroupingSubMenu); + QMenu *dependenciesSubMenu = new QMenu("Show dependencies", contextMenu); + dependenciesSubMenu->addActions({disabledDependencies, selectedDependencies, allDependencies}); + contextMenu->addMenu(dependenciesSubMenu); + QMenu *goToSubMenu = new QMenu("Go to", contextMenu); goToSubMenu->addActions({goToPhase, goToTransaction, goToTime}); contextMenu->addMenu(goToSubMenu); diff --git a/DRAMSys/traceAnalyzer/presentation/traceplot.h b/DRAMSys/traceAnalyzer/presentation/traceplot.h index 5fff9b23..5a4399db 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.h +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.h @@ -180,6 +180,9 @@ private: QAction *setColorGroupingTransaction; QAction *setColorGroupingThread; QAction *exportToPdf; + QAction *disabledDependencies; + QAction *selectedDependencies; + QAction *allDependencies; ToggleCollapsedAction *toggleCollapsedState; TracePlotMouseLabel *mouseLabel; diff --git a/DRAMSys/traceAnalyzer/presentation/tracescroller.cpp b/DRAMSys/traceAnalyzer/presentation/tracescroller.cpp index 03803b87..287197ba 100644 --- a/DRAMSys/traceAnalyzer/presentation/tracescroller.cpp +++ b/DRAMSys/traceAnalyzer/presentation/tracescroller.cpp @@ -43,9 +43,9 @@ #include "traceplotitem.h" #include "util/engineeringScaleDraw.h" -TraceScroller::TraceScroller(QWidget *parent): - QwtPlot(parent), isInitialized(false), drawingProperties(false, false, - ColorGrouping::PhaseType) +TraceScroller::TraceScroller(QWidget *parent) + : QwtPlot(parent), isInitialized(false), + drawingProperties(false, false, DependencyOption::Disabled, ColorGrouping::PhaseType) { setAxisScaleDraw(xBottom, new EngineeringScaleDraw); canvas()->setCursor(Qt::ArrowCursor);