diff --git a/DRAMSys/traceAnalyzer/CMakeLists.txt b/DRAMSys/traceAnalyzer/CMakeLists.txt index fc9ba9dc..22fb3b91 100644 --- a/DRAMSys/traceAnalyzer/CMakeLists.txt +++ b/DRAMSys/traceAnalyzer/CMakeLists.txt @@ -89,6 +89,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..815a9dac 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp @@ -63,21 +63,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 +139,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 +198,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..852e2757 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h +++ b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h @@ -101,6 +101,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..9cbbad48 100644 --- a/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h +++ b/DRAMSys/traceAnalyzer/presentation/tracedrawingproperties.h @@ -43,6 +43,7 @@ #include #include #include "tracedrawing.h" +#include "traceplotline.h" enum class ColorGrouping {PhaseType, Transaction, Thread}; @@ -61,36 +62,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 db13d1b9..145a76a3 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.cpp +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -213,12 +214,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() { @@ -256,20 +254,35 @@ 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) { - int numberOfBanks = drawingProperties.numberOfBanks; + const int yValRequest = drawingProperties.yValRequest; - // The maximum number of displayed rows determined by the pageStep of the scroll bar. - const int maxDisplayedRows = scrollBar->pageStep(); + // The maximum number of displayed lines determined by the pageStep of the scroll bar. + const int maxDisplayedLines = scrollBar->pageStep(); - if (numberOfBanks + 5 + 2 <= maxDisplayedRows) + if (drawingProperties.getNumberOfDisplayedLines() <= maxDisplayedLines) { - setAxisScale(yLeft, -5, numberOfBanks + 2, 1.0); + setAxisScale(yLeft, -5, yValRequest + 1, 1.0); } else { - setAxisScale(yLeft, numberOfBanks - maxDisplayedRows + 2 - value, numberOfBanks + 2 - value, 1.0); + setAxisScale(yLeft, yValRequest - maxDisplayedLines + 1 - value, yValRequest + 1 - value, 1.0); } replot(); @@ -277,14 +290,61 @@ void TracePlot::verticalScrollbarChanged(int value) void TracePlot::setUpAxis() { - // Set up y axis. - verticalScrollbarChanged(scrollBar->value()); - CustomLabelScaleDraw *customLabelScaleDraw = new CustomLabelScaleDraw(drawingProperties.getLabels()); customLabelScaleDraw->setMinimumExtent(135.0); + 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 554209e5..2aa7d04d 100644 --- a/DRAMSys/traceAnalyzer/presentation/traceplot.h +++ b/DRAMSys/traceAnalyzer/presentation/traceplot.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include "traceplotitem.h" #include "tracenavigator.h" @@ -60,6 +61,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 { @@ -127,6 +136,8 @@ private: void getAndDrawComments(); + void updateScrollbar(); + /* zooming * @@ -193,6 +204,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..a0315d24 100644 --- a/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.h +++ b/DRAMSys/traceAnalyzer/presentation/util/customlabelscaledraw.h @@ -40,18 +40,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 ad81fc59..5ab3ecea 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.cpp +++ b/DRAMSys/traceAnalyzer/tracefiletab.cpp @@ -87,13 +87,6 @@ void TraceFileTab::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))); }