diff --git a/DRAMSys/traceAnalyzer/CMakeLists.txt b/DRAMSys/traceAnalyzer/CMakeLists.txt index fc9ba9dc..da7dbcda 100644 --- a/DRAMSys/traceAnalyzer/CMakeLists.txt +++ b/DRAMSys/traceAnalyzer/CMakeLists.txt @@ -31,6 +31,7 @@ # Authors: # Matthias Jung # Lukas Steiner +# Derek Christ cmake_minimum_required(VERSION 3.12) @@ -89,6 +90,9 @@ add_executable(TraceAnalyzer businessObjects/tracetestresults.cpp presentation/tracemetrictreewidget.cpp businessObjects/phases/phase.cpp + presentation/tracedrawingproperties.cpp + presentation/traceplotline.cpp + presentation/util/customlabelscaledraw.cpp selectmetrics.ui preferences.ui diff --git a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp index b4c96316..1f0308f9 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #include "phase.h" @@ -63,21 +64,24 @@ void Phase::draw(QPainter *painter, const QwtScaleMap &xMap, painter->setPen(pen); } - if (getGranularity() == Granularity::Rankwise) + if (!isCollapsed(drawingProperties)) { - for (int i = getYVal(drawingProperties); i < (int)(getYVal(drawingProperties) + drawingProperties.banksPerRank); i++) - drawPhaseSymbol(span.Begin(), span.End(), i, drawingProperties.drawText, - getPhaseSymbol(), painter, xMap, yMap); + if (getGranularity() == Granularity::Rankwise) + { + for (int i = getYVal(drawingProperties); i < (int)(getYVal(drawingProperties) + drawingProperties.banksPerRank); i++) + drawPhaseSymbol(span.Begin(), span.End(), i, drawingProperties.drawText, + getPhaseSymbol(), painter, xMap, yMap); + } + else if (getGranularity() == Granularity::Groupwise) + { + for (int i = getYVal(drawingProperties); i < (int)(getYVal(drawingProperties) + drawingProperties.banksPerRank); i += drawingProperties.banksPerGroup) + drawPhaseSymbol(span.Begin(), span.End(), i, drawingProperties.drawText, + getPhaseSymbol(), painter, xMap, yMap); + } + else // if (getGranularity() == Granularity::Bankwise) + drawPhaseSymbol(span.Begin(), span.End(), getYVal(drawingProperties), + drawingProperties.drawText, getPhaseSymbol(), painter, xMap, yMap); } - else if (getGranularity() == Granularity::Groupwise) - { - for (int i = getYVal(drawingProperties); i < (int)(getYVal(drawingProperties) + drawingProperties.banksPerRank); i += drawingProperties.banksPerGroup) - drawPhaseSymbol(span.Begin(), span.End(), i, drawingProperties.drawText, - getPhaseSymbol(), painter, xMap, yMap); - } - else // if (getGranularity() == Granularity::Bankwise) - drawPhaseSymbol(span.Begin(), span.End(), getYVal(drawingProperties), - drawingProperties.drawText, getPhaseSymbol(), painter, xMap, yMap); for (Timespan span : spansOnCommandBus) { @@ -136,12 +140,11 @@ QColor Phase::getColor(const TraceDrawingProperties &drawingProperties) const int Phase::getYVal(const TraceDrawingProperties &drawingProperties) const { if (getGranularity() == Granularity::Bankwise) - return transaction->bank; + return drawingProperties.getYValOfBank(transaction->bank); else if (getGranularity() == Granularity::Groupwise) - return transaction->rank * drawingProperties.banksPerRank - + transaction->bank % drawingProperties.banksPerGroup; + return drawingProperties.getYValOfBankGroup(transaction->rank, transaction->bank); else // if (getGranularity() == Granularity::Rankwise) - return transaction->rank * drawingProperties.banksPerRank; + return drawingProperties.getYValOfRank(transaction->rank); } Qt::BrushStyle Phase::getBrushStyle() const @@ -196,3 +199,12 @@ Phase::PhaseSymbol Phase::getPhaseSymbol() const { return PhaseSymbol::Hexagon; } + +bool Phase::isCollapsed(const TraceDrawingProperties &drawingProperties) const +{ + // Never discard REQ and RESP phases + if (dynamic_cast(this) != nullptr || dynamic_cast(this) != nullptr) + return false; + + return drawingProperties.getRankCollapsedState(transaction->rank); +} diff --git a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h index b8e52d27..986c0654 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h +++ b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #ifndef BANKPHASE_H @@ -101,6 +102,8 @@ protected: { return Granularity::Bankwise; } + + bool isCollapsed(const TraceDrawingProperties &drawingProperties) const; }; class REQ : public Phase diff --git a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.cpp b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.cpp new file mode 100644 index 00000000..7b9ef486 --- /dev/null +++ b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.cpp @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2021, Technische Universität Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: + * Derek Christ + */ + +#include "tracedrawingproperties.h" + +TraceDrawingProperties::TraceDrawingProperties() : + drawText(true), + drawBorder(true), + colorGrouping(ColorGrouping::PhaseType) +{ +} + +TraceDrawingProperties::TraceDrawingProperties(bool drawText, bool drawBorder, + ColorGrouping colorGrouping) : + drawText(drawText), + drawBorder(drawBorder), + colorGrouping(colorGrouping) +{ +} + +void TraceDrawingProperties::setUpTracePlotLines() +{ + tracePlotLines.push_back(std::make_shared("REQ", collapsedRanks)); + tracePlotLines.push_back(std::make_shared("RESP", collapsedRanks)); + + for (unsigned int rank = numberOfRanks; rank--;) + { + for (unsigned int group = groupsPerRank; group--;) + { + for (unsigned int bank = banksPerGroup; bank--;) + { + QString rankLabel = QString("RA") + QString::number(rank); + QString bankGroupLabel = QString("BG") + QString::number(group); + QString bankLabel = QString("BA") + QString::number(bank); + + QString label = rankLabel + QString(" ") + bankGroupLabel + QString(" ") + bankLabel; + + std::shared_ptr line; + + if (bank == banksPerGroup - 1 && group == groupsPerRank - 1) + line = std::make_shared(label, rankLabel, rank, collapsedRanks); + else + line = std::make_shared(label, rank, collapsedRanks); + + tracePlotLines.push_back(line); + } + } + } + + tracePlotLines.push_back(std::make_shared("Command Bus", collapsedRanks)); + tracePlotLines.push_back(std::make_shared("Data Bus", collapsedRanks)); + + // Collapse all ranks except the first one by default. + for (int i = 0; i < numberOfRanks; i++) + if (i == 0) + setRankCollapsedState(i, false); + else + setRankCollapsedState(i, true); +} + +void TraceDrawingProperties::updateLabels() +{ + // Clear hash table, because otherwise not all old values will be overwritten. + labels->clear(); + + // The data bus is defined to start at -4. + int i = -4; + + for (auto it = tracePlotLines.rbegin(); it != tracePlotLines.rend(); it++) + { + // Don't add collapsed ranks, but always add the first rank line. + auto bankLine = std::dynamic_pointer_cast(*it); + auto firstRankLine = std::dynamic_pointer_cast(*it); + if (!firstRankLine && bankLine && (*collapsedRanks)[bankLine->rank]) + continue; + + (*labels)[i] = (*it)->getLabel(); + + (*it)->setYVal(i); + + if (std::dynamic_pointer_cast(*it)) + yValRequest = i; + + if (std::dynamic_pointer_cast(*it)) + yValResponse = i; + + if (std::dynamic_pointer_cast(*it)) + yValDataBus = i; + + if (std::dynamic_pointer_cast(*it)) { + yValCommandBus = i; + + // Add two spaces. + i += 2; + } + + i++; + } +} + +const std::shared_ptr> TraceDrawingProperties::getLabels() const +{ + return labels; +} + +const std::vector> & TraceDrawingProperties::getTracePlotLines() const +{ + return tracePlotLines; +} + +const std::shared_ptr TraceDrawingProperties::getFirstRankLine(unsigned int rank) const +{ + // TODO: Maybe cache results? + Q_ASSERT(rank <= numberOfRanks - 1); + + std::shared_ptr firstRankLine; + + for (auto &line : tracePlotLines) + { + firstRankLine = std::dynamic_pointer_cast(line); + if (firstRankLine && firstRankLine->rank == rank) + break; + } + + return firstRankLine; +} + +void TraceDrawingProperties::setRankCollapsedState(unsigned int rank, bool collapse) +{ + Q_ASSERT(rank <= numberOfRanks - 1); + + (*collapsedRanks)[rank] = collapse; + + updateLabels(); +} + +bool TraceDrawingProperties::getRankCollapsedState(unsigned int rank) const +{ + return (*collapsedRanks)[rank]; +} + +unsigned int TraceDrawingProperties::getNumberOfDisplayedLines() const +{ + return yValRequest + 6; +} + +unsigned int TraceDrawingProperties::getYValOfBank(unsigned int bank) const +{ + unsigned int rank = bank / banksPerRank; + + return getYValOfRank(rank) + bank % banksPerRank; +} + +unsigned int TraceDrawingProperties::getYValOfBankGroup(unsigned int rank, unsigned int bank) const +{ + return getYValOfRank(rank) + bank % banksPerGroup; +} + +unsigned int TraceDrawingProperties::getYValOfRank(unsigned int rank) const +{ + unsigned int i = 0; + + for (unsigned int j = 0; j < rank; j++) + if ((*collapsedRanks)[j]) + i += 1; + else + i += banksPerRank; + + return i; +} diff --git a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h index 6fa65695..37ff6564 100644 --- a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h +++ b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #ifndef TRACECOLLECTIONDRAWINGPROPERTIES_H @@ -43,6 +44,7 @@ #include #include #include "tracedrawing.h" +#include "traceplotline.h" enum class ColorGrouping {PhaseType, Transaction, Thread}; @@ -61,36 +63,30 @@ struct TraceDrawingProperties { unsigned int groupsPerRank; unsigned int banksPerGroup; - TraceDrawingProperties() : drawText(true), drawBorder(true), - colorGrouping(ColorGrouping::PhaseType) {} - TraceDrawingProperties(bool drawText, bool drawBorder, - ColorGrouping colorGrouping) : drawText(drawText), drawBorder(drawBorder), - colorGrouping(colorGrouping) {} + TraceDrawingProperties(); + TraceDrawingProperties(bool drawText, bool drawBorder, ColorGrouping colorGrouping); + void setUpTracePlotLines(); - QHash getLabels() const - { - QHash result; + void setRankCollapsedState(unsigned int rank, bool collapse); + bool getRankCollapsedState(unsigned int rank) const; - unsigned i = 0; - for (unsigned rank = 0; rank < numberOfRanks; rank++) - { - for (unsigned group = 0; group < groupsPerRank; group++) - { - for (unsigned bank = 0; bank < banksPerGroup; bank++) - { - result[i++] = QString("RA") + QString::number(rank) - + QString(" BG") + QString::number(group) - + QString(" BA") + QString::number(bank); - } - } - } + unsigned int getNumberOfDisplayedLines() const; - result[yValCommandBus] = "Command Bus"; - result[yValResponse] = "RESP"; - result[yValRequest] = "REQ"; - result[yValDataBus] = "Data Bus"; - return result; - } + unsigned int getYValOfBank(unsigned int bank) const; + unsigned int getYValOfBankGroup(unsigned int rank, unsigned int bank) const; + unsigned int getYValOfRank(unsigned int rank) const; + + + const std::vector> & getTracePlotLines() const; + const std::shared_ptr getFirstRankLine(unsigned int rank) const; + + void updateLabels(); + const std::shared_ptr> getLabels() const; + +private: + std::shared_ptr> labels = std::make_shared>(); + std::shared_ptr> collapsedRanks = std::make_shared>(); + std::vector> tracePlotLines; }; #endif // TRACECOLLECTIONDRAWINGPROPERTIES_H diff --git a/DRAMSys/traceAnalyzer/presentation/traceplot.cpp b/DRAMSys/traceAnalyzer/presentation/traceplot.cpp index e54ab395..caf99c8f 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.cpp +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.cpp @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #include @@ -45,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -172,11 +174,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(); @@ -211,12 +215,9 @@ void TracePlot::setUpDrawingProperties() drawingProperties.banksPerRank = drawingProperties.numberOfBanks / drawingProperties.numberOfRanks; drawingProperties.groupsPerRank = drawingProperties.numberOfBankgroups / drawingProperties.numberOfRanks; drawingProperties.banksPerGroup = drawingProperties.numberOfBanks / drawingProperties.numberOfBankgroups; - drawingProperties.yValResponse = drawingProperties.numberOfBanks; - drawingProperties.yValRequest = drawingProperties.numberOfBanks + 1; - drawingProperties.yValCommandBus = -3; - drawingProperties.yValDataBus = -4; -} + drawingProperties.setUpTracePlotLines(); +} void TracePlot::setUpQueryEditor() { @@ -254,14 +255,97 @@ void TracePlot::setUpZoom() zoomZone->setVisible(false); } +void TracePlot::updateScrollbar() +{ + const unsigned int pageStep = scrollBar->pageStep(); + + const int maximum = drawingProperties.getNumberOfDisplayedLines() - pageStep; + + if (maximum >= 0) + { + scrollBar->setMaximum(drawingProperties.getNumberOfDisplayedLines() - pageStep); + scrollBar->show(); + } + else + scrollBar->hide(); +} + +void TracePlot::verticalScrollbarChanged(int value) +{ + const int yValRequest = drawingProperties.yValRequest; + + // The maximum number of displayed lines determined by the pageStep of the scroll bar. + const int maxDisplayedLines = scrollBar->pageStep(); + + if (drawingProperties.getNumberOfDisplayedLines() <= maxDisplayedLines) + { + setAxisScale(yLeft, -5, yValRequest + 1, 1.0); + } + else + { + setAxisScale(yLeft, yValRequest - maxDisplayedLines + 1 - value, yValRequest + 1 - value, 1.0); + } + + replot(); +} + void TracePlot::setUpAxis() { - int numberOfBanks = navigator->GeneralTraceInfo().numberOfBanks; + CustomLabelScaleDraw *customLabelScaleDraw = new CustomLabelScaleDraw(drawingProperties.getLabels()); + customLabelScaleDraw->setMinimumExtent(135.0); - setAxisScale(yLeft, -5, numberOfBanks + 2, 1.0); - setAxisScaleDraw(yLeft, new CustomLabelScaleDraw( - drawingProperties.getLabels())); + auto positionButton = [&](const TracePlotFirstRankLine &firstRankLine, RankButton &rankButton) { + QPointF point = this->axisScaleDraw(yLeft)->labelPosition(firstRankLine.getYVal()); + rankButton.setGeometry(point.x(), point.y() - 4, 25, 25); + }; + QObject::connect(customLabelScaleDraw, &CustomLabelScaleDraw::scaleRedraw, this, [=]() { + for (auto rankButton : rankCollapseButtons) + { + auto firstRankLine = drawingProperties.getFirstRankLine(rankButton->rank); + positionButton(*firstRankLine, *rankButton); + } + }); + + updateScrollbar(); + + // Set up y axis. + verticalScrollbarChanged(scrollBar->value()); + setAxisScaleDraw(yLeft, customLabelScaleDraw); + + // Add push buttons + for (auto line : drawingProperties.getTracePlotLines()) + { + auto firstRankLine = std::dynamic_pointer_cast(line); + if (firstRankLine) + { + auto button = new RankButton(firstRankLine->rank, this); + if (drawingProperties.getRankCollapsedState(firstRankLine->rank)) + button->setText("+"); + else + button->setText("-"); + + positionButton(*firstRankLine, *button); + + QObject::connect(button, &QPushButton::pressed, this, [=]() { + bool wasCollapsed = drawingProperties.getRankCollapsedState(button->rank); + drawingProperties.setRankCollapsedState(button->rank, !wasCollapsed); + + if (wasCollapsed) + button->setText("-"); + else + button->setText("+"); + + updateScrollbar(); + + emit scrollBar->valueChanged(scrollBar->value()); + }); + + rankCollapseButtons.push_back(button); + } + } + + // Set up x axis. 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..5f40a4eb 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.h +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.h @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #ifndef TRACEPLOT_H @@ -44,6 +45,8 @@ #include #include #include +#include +#include #include #include "traceplotitem.h" #include "tracenavigator.h" @@ -59,6 +62,14 @@ class TracePlotMouseLabel; +class RankButton : public QPushButton +{ + Q_OBJECT +public: + explicit RankButton(unsigned int rank, QWidget *parent = nullptr) : QPushButton(parent), rank(rank) {} + const unsigned int rank; +}; + class TracePlot : public QwtPlot { @@ -66,7 +77,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 +91,7 @@ public Q_SLOTS: void currentTraceTimeChanged(); void selectedTransactionsChanged(); void commentsChanged(); + void verticalScrollbarChanged(int value); Q_SIGNALS: @@ -113,6 +125,7 @@ private: std::vector> transactions; QueryEditor *queryEditor; QMenu *contextMenu; + QScrollBar *scrollBar; void setUpTracePlotItem(); void setUpDrawingProperties(); @@ -124,6 +137,8 @@ private: void getAndDrawComments(); + void updateScrollbar(); + /* zooming * @@ -190,6 +205,8 @@ private: MouseDownData mouseDownData; KeyPressData keyPressData; + + std::vector rankCollapseButtons; }; diff --git a/DRAMSys/traceAnalyzer/presentation/traceplotline.cpp b/DRAMSys/traceAnalyzer/presentation/traceplotline.cpp new file mode 100644 index 00000000..10834fb9 --- /dev/null +++ b/DRAMSys/traceAnalyzer/presentation/traceplotline.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021, Technische Universität Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: + * Derek Christ + */ + +#include "traceplotline.h" + + +TracePlotLine::TracePlotLine(const QString &label, const std::shared_ptr> collapsedRanks) : + label(label), + collapsedRanks(collapsedRanks) +{ +} + +TracePlotLine::~TracePlotLine() {} + +const QString & TracePlotLine::getLabel() const +{ + return label; +} + +bool TracePlotLine::isCollapsed() const +{ + return false; +} + +void TracePlotLine::setYVal (int yVal) +{ + this->yVal = yVal; +} + + +int TracePlotLine::getYVal() const +{ + return yVal; +} + + +TracePlotBankLine::TracePlotBankLine(const QString &label, unsigned int rank, + const std::shared_ptr> collapsedRanks) : + TracePlotLine(label, collapsedRanks), + rank(rank) +{ +} + +bool TracePlotBankLine::isCollapsed() const +{ + return (*collapsedRanks)[rank]; +} + + +TracePlotFirstRankLine::TracePlotFirstRankLine(const QString &label, const QString &collapsedLabel, + unsigned int rank, const std::shared_ptr> collapsedRanks) : + TracePlotBankLine(label, rank, collapsedRanks), + collapsedLabel(collapsedLabel) +{ +} + +const QString & TracePlotFirstRankLine::getLabel() const +{ + if (isCollapsed()) + return collapsedLabel; + else + return TracePlotLine::getLabel(); +} diff --git a/DRAMSys/traceAnalyzer/presentation/traceplotline.h b/DRAMSys/traceAnalyzer/presentation/traceplotline.h new file mode 100644 index 00000000..be93d6b4 --- /dev/null +++ b/DRAMSys/traceAnalyzer/presentation/traceplotline.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2021, Technische Universität Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: + * Derek Christ + */ + +#ifndef TRACELOTLINE_H +#define TRACELOTLINE_H + +#include +#include +#include + +class TracePlotLine +{ +public: + TracePlotLine(const QString &label, const std::shared_ptr> collapsedRanks); + virtual ~TracePlotLine() = 0; + + virtual const QString & getLabel() const; + virtual bool isCollapsed() const; + + void setYVal(int yVal); + int getYVal() const; + +protected: + QString label; + int yVal; + const std::shared_ptr> collapsedRanks; +}; + + +class TracePlotBankLine : public TracePlotLine +{ +public: + TracePlotBankLine(const QString &label, unsigned int rank, const std::shared_ptr> collapsedRanks); + ~TracePlotBankLine() = default; + void setCollapsed(bool value); + bool isCollapsed() const override; + + const unsigned int rank; +}; + + +class TracePlotFirstRankLine final : public TracePlotBankLine +{ +public: + TracePlotFirstRankLine(const QString &label, const QString &collapsedLabel, + unsigned int rank, const std::shared_ptr> collapsedRanks); + + ~TracePlotFirstRankLine() = default; + + const QString & getLabel() const override; + +private: + QString collapsedLabel; +}; + + +class TracePlotRequestLine final : public TracePlotLine +{ +public: + using TracePlotLine::TracePlotLine; + ~TracePlotRequestLine() = default; +}; + +class TracePlotResponseLine final : public TracePlotLine +{ +public: + using TracePlotLine::TracePlotLine; + ~TracePlotResponseLine() = default; +}; + +class TracePlotDataBusLine final : public TracePlotLine +{ +public: + using TracePlotLine::TracePlotLine; + ~TracePlotDataBusLine() = default; +}; + +class TracePlotCommandBusLine final : public TracePlotLine +{ +public: + using TracePlotLine::TracePlotLine; + ~TracePlotCommandBusLine() = default; +}; + +#endif // TRACELOTLINE_H diff --git a/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.cpp b/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.cpp new file mode 100644 index 00000000..3d31e243 --- /dev/null +++ b/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021, Technische Universität Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: + * Derek Christ + */ + +#include "customlabelscaledraw.h" + +CustomLabelScaleDraw::CustomLabelScaleDraw(std::shared_ptr> labels) : labels(labels), QObject(nullptr) {} + +QwtText CustomLabelScaleDraw::label(double v) const +{ + return QwtText((*labels)[static_cast(v)]); +} + +void CustomLabelScaleDraw::drawLabel(QPainter *painter, double value) const +{ + emit scaleRedraw(); + QwtScaleDraw::drawLabel(painter, value); +} diff --git a/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.h b/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.h index ceda496a..3218a21a 100644 --- a/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.h +++ b/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.h @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #ifndef CUSTOMLABELSCALEDRAW_H @@ -40,18 +41,25 @@ #include #include #include +#include -class CustomLabelScaleDraw : public QwtScaleDraw +class CustomLabelScaleDraw : public QObject, public QwtScaleDraw { + Q_OBJECT + private: - QHash labels; + const std::shared_ptr> labels; public: - CustomLabelScaleDraw(QHash labels): labels(labels) {} - virtual QwtText label(double v) const - { - return QwtText(labels[static_cast(v)]); - } + CustomLabelScaleDraw(std::shared_ptr> labels); + ~CustomLabelScaleDraw() = default; + + virtual QwtText label(double v) const override; + + void drawLabel(QPainter *painter, double value) const override; + +Q_SIGNALS: + void scaleRedraw() const; }; #endif // CUSTOMLABELSCALEDRAW_H diff --git a/DRAMSys/traceAnalyzer/tracefiletab.cpp b/DRAMSys/traceAnalyzer/tracefiletab.cpp index 981e60fb..b1ba2bd2 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.cpp +++ b/DRAMSys/traceAnalyzer/tracefiletab.cpp @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #include "tracefiletab.h" @@ -66,8 +67,11 @@ TraceFileTab::TraceFileTab(QWidget *parent, const QString &path) : initNavigatorAndItsDependentWidgets(path); setUpFileWatcher(path); + setUpTraceplotScrollbar(); + ui->fileDescriptionEdit->setPlainText( navigator->GeneralTraceInfo().description); + tracefileChanged(); } @@ -82,11 +86,17 @@ void TraceFileTab::commitChangesToDB() navigator->commitChangesToDB(); } +void TraceFileTab::setUpTraceplotScrollbar() +{ + 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..28b8be08 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.h +++ b/DRAMSys/traceAnalyzer/tracefiletab.h @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Derek Christ */ #ifndef TRACEFILETAB_H @@ -58,6 +59,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