Make lines of TraceAnalyzer fully rearrangeable
This commit is a preparation for the upcoming feature that will make dynamically rearranging the lines of the TracePlot possible. All TracePlotLines can now be rearranged as wanted in the code.
This commit is contained in:
@@ -64,13 +64,11 @@ void Phase::draw(QPainter *painter, const QwtScaleMap &xMap,
|
||||
painter->setPen(pen);
|
||||
}
|
||||
|
||||
if (!isCollapsed(drawingProperties))
|
||||
for (auto line : getTracePlotLines(drawingProperties))
|
||||
{
|
||||
for (auto line : getTracePlotLines(drawingProperties))
|
||||
{
|
||||
if (!line->isCollapsed())
|
||||
drawPhaseSymbol(span.Begin(), span.End(), line->getYVal(),
|
||||
drawingProperties.drawText, getPhaseSymbol(), painter, xMap, yMap);
|
||||
}
|
||||
}
|
||||
|
||||
for (Timespan span : spansOnCommandBus)
|
||||
@@ -148,7 +146,7 @@ bool Phase::isSelected(traceTime time, double yVal,
|
||||
{
|
||||
for (auto line : getTracePlotLines(drawingProperties))
|
||||
{
|
||||
if (fabs(yVal - line->getYVal()) <= hexagonHeight)
|
||||
if (!line->isCollapsed() && fabs(yVal - line->getYVal()) <= hexagonHeight)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -201,12 +199,3 @@ std::vector<std::shared_ptr<TracePlotLine>> Phase::getTracePlotLines(const Trace
|
||||
% drawingProperties.banksPerGroup);
|
||||
}
|
||||
}
|
||||
|
||||
bool Phase::isCollapsed(const TraceDrawingProperties &drawingProperties) const
|
||||
{
|
||||
// Never discard REQ and RESP phases
|
||||
if (dynamic_cast<const REQ *>(this) != nullptr || dynamic_cast<const RESP *>(this) != nullptr)
|
||||
return false;
|
||||
|
||||
return drawingProperties.getRankCollapsedState(transaction->rank);
|
||||
}
|
||||
|
||||
@@ -104,8 +104,6 @@ protected:
|
||||
{
|
||||
return Granularity::Bankwise;
|
||||
}
|
||||
|
||||
bool isCollapsed(const TraceDrawingProperties &drawingProperties) const;
|
||||
};
|
||||
|
||||
class REQ : public Phase
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
*/
|
||||
|
||||
#include "tracedrawingproperties.h"
|
||||
#include "util/customlabelscaledraw.h"
|
||||
#include "traceplot.h"
|
||||
|
||||
TraceDrawingProperties::TraceDrawingProperties(bool drawText, bool drawBorder,
|
||||
ColorGrouping colorGrouping) :
|
||||
@@ -43,45 +45,52 @@ TraceDrawingProperties::TraceDrawingProperties(bool drawText, bool drawBorder,
|
||||
{
|
||||
}
|
||||
|
||||
void TraceDrawingProperties::init(std::shared_ptr<TracePlotLineVector> tracePlotLines,
|
||||
std::shared_ptr<QHash<int, bool>> collapsedRanks)
|
||||
void TraceDrawingProperties::init(std::shared_ptr<TracePlotLineVector> tracePlotLines)
|
||||
{
|
||||
this->tracePlotLines = tracePlotLines;
|
||||
this->collapsedRanks = collapsedRanks;
|
||||
}
|
||||
|
||||
void TraceDrawingProperties::init(std::shared_ptr<TracePlotLineVector> tracePlotLines,
|
||||
TracePlot *tracePlot)
|
||||
{
|
||||
this->tracePlotLines = tracePlotLines;
|
||||
this->tracePlot = tracePlot;
|
||||
}
|
||||
|
||||
void TraceDrawingProperties::setUpTracePlotLines()
|
||||
{
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotRequestLine>("REQ", collapsedRanks));
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotResponseLine>("RESP", collapsedRanks));
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotRequestLine>("REQ"));
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotResponseLine>("RESP"));
|
||||
|
||||
for (unsigned int rank = numberOfRanks; rank--;)
|
||||
{
|
||||
std::shared_ptr<TracePlotFirstRankLine> firstRankLine;
|
||||
|
||||
for (unsigned int group = groupsPerRank; group--;)
|
||||
{
|
||||
for (unsigned int bank = banksPerGroup; bank--;)
|
||||
{
|
||||
std::shared_ptr<TracePlotLine> line;
|
||||
std::shared_ptr<TracePlotBankLine> line;
|
||||
|
||||
if (bank == banksPerGroup - 1 && group == groupsPerRank - 1)
|
||||
line = std::make_shared<TracePlotFirstRankLine>(rank, group, bank, collapsedRanks);
|
||||
{
|
||||
firstRankLine = createFirstRankLine(rank, group, bank);
|
||||
line = firstRankLine;
|
||||
}
|
||||
else
|
||||
line = std::make_shared<TracePlotBankLine>(rank, group, bank, collapsedRanks);
|
||||
{
|
||||
line = std::make_shared<TracePlotBankLine>(rank, group, bank, firstRankLine);
|
||||
}
|
||||
|
||||
tracePlotLines->push_back(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotCommandBusLine>("Command Bus", collapsedRanks));
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotDataBusLine>("Data Bus", collapsedRanks));
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotCommandBusLine>("Command Bus"));
|
||||
tracePlotLines->push_back(std::make_shared<TracePlotDataBusLine>("Data Bus"));
|
||||
|
||||
// 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);
|
||||
updateLabels();
|
||||
}
|
||||
|
||||
void TraceDrawingProperties::updateLabels()
|
||||
@@ -97,20 +106,40 @@ void TraceDrawingProperties::updateLabels()
|
||||
// Don't add collapsed ranks, but always add the first rank line.
|
||||
auto bankLine = std::dynamic_pointer_cast<TracePlotBankLine>(*it);
|
||||
auto firstRankLine = std::dynamic_pointer_cast<TracePlotFirstRankLine>(*it);
|
||||
if (!firstRankLine && bankLine && (*collapsedRanks)[bankLine->rank])
|
||||
if (!firstRankLine && bankLine && bankLine->isCollapsed())
|
||||
continue;
|
||||
|
||||
(*labels)[i] = (*it)->getLabel();
|
||||
|
||||
(*it)->setYVal(i);
|
||||
|
||||
if (std::dynamic_pointer_cast<TracePlotCommandBusLine>(*it)) {
|
||||
// Add two spaces.
|
||||
i += 2;
|
||||
}
|
||||
// Another solution has to be found for this.
|
||||
// if (std::dynamic_pointer_cast<TracePlotCommandBusLine>(*it)) {
|
||||
// // Add two spaces.
|
||||
// i += 2;
|
||||
// }
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
Q_EMIT tracePlot->tracePlotLinesChanged();
|
||||
}
|
||||
|
||||
std::shared_ptr<TracePlotFirstRankLine> TraceDrawingProperties::createFirstRankLine(unsigned int rank, unsigned int group,
|
||||
unsigned int bank) const
|
||||
{
|
||||
auto firstRankLine = std::make_shared<TracePlotFirstRankLine>(rank, group, bank, tracePlot);
|
||||
|
||||
QObject::connect(firstRankLine.get(), &TracePlotFirstRankLine::collapsedStateChanged,
|
||||
this, &TraceDrawingProperties::updateLabels);
|
||||
|
||||
QObject::connect(firstRankLine.get(), &TracePlotFirstRankLine::collapsedStateChanged,
|
||||
tracePlot, &TracePlot::updateScrollbar);
|
||||
|
||||
QObject::connect(tracePlot->getCustomLabelScaleDraw(), &CustomLabelScaleDraw::scaleRedraw,
|
||||
firstRankLine.get(), &TracePlotFirstRankLine::updateButtonPosition);
|
||||
|
||||
return firstRankLine;
|
||||
}
|
||||
|
||||
const std::shared_ptr<QHash<int, QString>> TraceDrawingProperties::getLabels() const
|
||||
@@ -123,22 +152,11 @@ const TracePlotLineVector &TraceDrawingProperties::getTracePlotLines() const
|
||||
return *tracePlotLines;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if (!tracePlotLines)
|
||||
return 0;
|
||||
|
||||
unsigned int max = 0;
|
||||
|
||||
for (auto line : *tracePlotLines)
|
||||
@@ -150,7 +168,7 @@ unsigned int TraceDrawingProperties::getNumberOfDisplayedLines() const
|
||||
return max;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getCommandBusLines() const
|
||||
TracePlotLineVector TraceDrawingProperties::getCommandBusLines() const
|
||||
{
|
||||
if (commandBusLinesCache.size() != 0)
|
||||
return commandBusLinesCache;
|
||||
@@ -168,7 +186,7 @@ std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getCommandBu
|
||||
return commandBusLines;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getDataBusLines() const
|
||||
TracePlotLineVector TraceDrawingProperties::getDataBusLines() const
|
||||
{
|
||||
if (dataBusLinesCache.size() != 0)
|
||||
return dataBusLinesCache;
|
||||
@@ -186,7 +204,7 @@ std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getDataBusLi
|
||||
return dataBusLines;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getRequestLines() const
|
||||
TracePlotLineVector TraceDrawingProperties::getRequestLines() const
|
||||
{
|
||||
if (requestLinesCache.size() != 0)
|
||||
return requestLinesCache;
|
||||
@@ -204,7 +222,7 @@ std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getRequestLi
|
||||
return requestLines;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getResponseLines() const
|
||||
TracePlotLineVector TraceDrawingProperties::getResponseLines() const
|
||||
{
|
||||
if (responseLinesCache.size() != 0)
|
||||
return responseLinesCache;
|
||||
@@ -222,7 +240,7 @@ std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getResponseL
|
||||
return responseLines;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getFirstRankLines(unsigned int rank) const
|
||||
TracePlotLineVector TraceDrawingProperties::getFirstRankLines(unsigned int rank) const
|
||||
{
|
||||
Q_ASSERT(rank <= numberOfRanks - 1);
|
||||
|
||||
@@ -243,7 +261,7 @@ std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getFirstRank
|
||||
return firstRankLines;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getBankLinesFromRank(unsigned int rank) const
|
||||
TracePlotLineVector TraceDrawingProperties::getBankLinesFromRank(unsigned int rank) const
|
||||
{
|
||||
Q_ASSERT(rank <= numberOfRanks - 1);
|
||||
|
||||
@@ -264,7 +282,7 @@ std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getBankLines
|
||||
return bankLines;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getBankLinesFromGroup(unsigned int rank, unsigned int group) const
|
||||
TracePlotLineVector TraceDrawingProperties::getBankLinesFromGroup(unsigned int rank, unsigned int group) const
|
||||
{
|
||||
Q_ASSERT(rank <= numberOfRanks - 1);
|
||||
Q_ASSERT(group <= groupsPerRank - 1);
|
||||
@@ -289,8 +307,8 @@ std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getBankLines
|
||||
return bankLines;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> TraceDrawingProperties::getBankLines(unsigned int rank, unsigned int group,
|
||||
unsigned int bank) const
|
||||
TracePlotLineVector TraceDrawingProperties::getBankLines(unsigned int rank, unsigned int group,
|
||||
unsigned int bank) const
|
||||
{
|
||||
Q_ASSERT(rank <= numberOfRanks - 1);
|
||||
Q_ASSERT(group <= groupsPerRank - 1);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#ifndef TRACECOLLECTIONDRAWINGPROPERTIES_H
|
||||
#define TRACECOLLECTIONDRAWINGPROPERTIES_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
#include <map>
|
||||
@@ -51,7 +52,13 @@ enum class ColorGrouping {PhaseType, Transaction, Thread};
|
||||
|
||||
using TracePlotLineVector = std::vector<std::shared_ptr<TracePlotLine>>;
|
||||
|
||||
struct TraceDrawingProperties {
|
||||
class TracePlot;
|
||||
|
||||
class TraceDrawingProperties : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
bool drawText;
|
||||
bool drawBorder;
|
||||
ColorGrouping colorGrouping;
|
||||
@@ -67,34 +74,37 @@ struct TraceDrawingProperties {
|
||||
bool drawBorder = true,
|
||||
ColorGrouping colorGrouping = ColorGrouping::PhaseType);
|
||||
|
||||
void init(std::shared_ptr<TracePlotLineVector> tracePlotLines, std::shared_ptr<QHash<int, bool>> collapsedRanks);
|
||||
void init(std::shared_ptr<TracePlotLineVector> tracePlotLines);
|
||||
void init(std::shared_ptr<TracePlotLineVector> tracePlotLines, TracePlot *tracePlot);
|
||||
|
||||
void setUpTracePlotLines();
|
||||
|
||||
void setRankCollapsedState(unsigned int rank, bool collapse);
|
||||
bool getRankCollapsedState(unsigned int rank) const;
|
||||
|
||||
unsigned int getNumberOfDisplayedLines() const;
|
||||
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getRequestLines() const;
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getResponseLines() const;
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getCommandBusLines() const;
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getDataBusLines() const;
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getFirstRankLines(unsigned int rank) const;
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getBankLines(unsigned int rank, unsigned int group, unsigned int bank) const;
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getBankLinesFromGroup(unsigned int rank, unsigned int group) const;
|
||||
std::vector<std::shared_ptr<TracePlotLine>> getBankLinesFromRank(unsigned int rank) const;
|
||||
TracePlotLineVector getRequestLines() const;
|
||||
TracePlotLineVector getResponseLines() const;
|
||||
TracePlotLineVector getCommandBusLines() const;
|
||||
TracePlotLineVector getDataBusLines() const;
|
||||
TracePlotLineVector getFirstRankLines(unsigned int rank) const;
|
||||
TracePlotLineVector getBankLines(unsigned int rank, unsigned int group, unsigned int bank) const;
|
||||
TracePlotLineVector getBankLinesFromGroup(unsigned int rank, unsigned int group) const;
|
||||
TracePlotLineVector getBankLinesFromRank(unsigned int rank) const;
|
||||
|
||||
const TracePlotLineVector &getTracePlotLines() const;
|
||||
|
||||
void updateLabels();
|
||||
const std::shared_ptr<QHash<int, QString>> getLabels() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateLabels();
|
||||
|
||||
private:
|
||||
std::shared_ptr<TracePlotFirstRankLine> createFirstRankLine(unsigned int rank, unsigned int group,
|
||||
unsigned int bank) const;
|
||||
|
||||
std::shared_ptr<QHash<int, QString>> labels = std::make_shared<QHash<int, QString>>();
|
||||
|
||||
std::shared_ptr<QHash<int, bool>> collapsedRanks;
|
||||
std::shared_ptr<TracePlotLineVector> tracePlotLines;
|
||||
TracePlot *tracePlot;
|
||||
|
||||
// Caches
|
||||
mutable std::map<std::tuple<int, int, int>, std::vector<std::shared_ptr<TracePlotLine>>> bankLinesCache;
|
||||
|
||||
@@ -318,11 +318,6 @@ Timespan TraceNavigator::getSpanCoveredBySelectedTransaction()
|
||||
return Timespan(begin, end);
|
||||
}
|
||||
|
||||
std::shared_ptr<QHash<int, bool>> TraceNavigator::getCollapsedRanks()
|
||||
{
|
||||
return collapsedRanks;
|
||||
}
|
||||
|
||||
std::shared_ptr<TracePlotLineVector> TraceNavigator::getTracePlotLines()
|
||||
{
|
||||
return tracePlotLines;
|
||||
|
||||
@@ -117,7 +117,6 @@ public:
|
||||
void commitChangesToDB();
|
||||
void refreshData();
|
||||
|
||||
std::shared_ptr<QHash<int, bool>> getCollapsedRanks();
|
||||
std::shared_ptr<TracePlotLineVector> getTracePlotLines();
|
||||
|
||||
Q_SIGNALS:
|
||||
@@ -136,7 +135,6 @@ private:
|
||||
void getCommentsFromDB();
|
||||
bool changesToCommitExist;
|
||||
|
||||
std::shared_ptr<QHash<int, bool>> collapsedRanks = std::make_shared<QHash<int, bool>>();
|
||||
std::shared_ptr<TracePlotLineVector> tracePlotLines = std::make_shared<TracePlotLineVector>();
|
||||
};
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ using namespace std;
|
||||
|
||||
|
||||
TracePlot::TracePlot(QWidget *parent):
|
||||
QwtPlot(parent), isInitialized(false)
|
||||
QwtPlot(parent), isInitialized(false),
|
||||
customLabelScaleDraw(new CustomLabelScaleDraw(drawingProperties.getLabels()))
|
||||
{
|
||||
canvas()->setCursor(Qt::ArrowCursor);
|
||||
setUpActions();
|
||||
@@ -193,6 +194,9 @@ void TracePlot::init(TraceNavigator *navigator, QScrollBar *scrollBar)
|
||||
navigator->GeneralTraceInfo().clkPeriod, this->mouseDownData.zoomSpan);
|
||||
getAndDrawComments();
|
||||
setZoomLevel(1000);
|
||||
|
||||
updateScrollbar();
|
||||
|
||||
replot();
|
||||
}
|
||||
|
||||
@@ -209,7 +213,7 @@ void TracePlot::connectNavigatorQ_SIGNALS()
|
||||
|
||||
void TracePlot::setUpDrawingProperties()
|
||||
{
|
||||
drawingProperties.init(navigator->getTracePlotLines(), navigator->getCollapsedRanks());
|
||||
drawingProperties.init(navigator->getTracePlotLines(), this);
|
||||
|
||||
drawingProperties.numberOfRanks = navigator->GeneralTraceInfo().numberOfRanks;
|
||||
drawingProperties.numberOfBankgroups = navigator->GeneralTraceInfo().numberOfBankgroups;
|
||||
@@ -271,6 +275,8 @@ void TracePlot::updateScrollbar()
|
||||
}
|
||||
else
|
||||
scrollBar->hide();
|
||||
|
||||
verticalScrollbarChanged(scrollBar->value());
|
||||
}
|
||||
|
||||
void TracePlot::verticalScrollbarChanged(int value)
|
||||
@@ -291,63 +297,9 @@ void TracePlot::verticalScrollbarChanged(int value)
|
||||
|
||||
void TracePlot::setUpAxis()
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (auto line : drawingProperties.getFirstRankLines(rankButton->rank))
|
||||
{
|
||||
auto firstRankLine = static_pointer_cast<TracePlotFirstRankLine>(line);
|
||||
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<TracePlotFirstRankLine>(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();
|
||||
|
||||
Q_EMIT scrollBar->valueChanged(scrollBar->value());
|
||||
Q_EMIT tracePlotLinesChanged();
|
||||
});
|
||||
|
||||
rankCollapseButtons.push_back(button);
|
||||
}
|
||||
}
|
||||
customLabelScaleDraw->setMinimumExtent(135.0);
|
||||
|
||||
// Set up x axis.
|
||||
setAxisTitle(xBottom, "Time in ns");
|
||||
@@ -380,6 +332,11 @@ void TracePlot::getAndDrawComments()
|
||||
}
|
||||
}
|
||||
|
||||
CustomLabelScaleDraw *TracePlot::getCustomLabelScaleDraw() const
|
||||
{
|
||||
return customLabelScaleDraw;
|
||||
}
|
||||
|
||||
void TracePlot::enterZoomMode()
|
||||
{
|
||||
mouseDownData.mouseIsDownForZooming = true;
|
||||
|
||||
@@ -61,14 +61,7 @@
|
||||
*/
|
||||
|
||||
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 CustomLabelScaleDraw;
|
||||
|
||||
class TracePlot : public QwtPlot
|
||||
{
|
||||
@@ -87,12 +80,14 @@ public:
|
||||
void setUpActions();
|
||||
|
||||
void setUpContextMenu();
|
||||
|
||||
CustomLabelScaleDraw *getCustomLabelScaleDraw() const;
|
||||
public Q_SLOTS:
|
||||
void currentTraceTimeChanged();
|
||||
void selectedTransactionsChanged();
|
||||
void commentsChanged();
|
||||
void verticalScrollbarChanged(int value);
|
||||
|
||||
void updateScrollbar();
|
||||
|
||||
Q_SIGNALS:
|
||||
void tracePlotZoomChanged();
|
||||
@@ -127,6 +122,7 @@ private:
|
||||
QueryEditor *queryEditor;
|
||||
QMenu *contextMenu;
|
||||
QScrollBar *scrollBar;
|
||||
CustomLabelScaleDraw *customLabelScaleDraw;
|
||||
|
||||
void setUpTracePlotItem();
|
||||
void setUpDrawingProperties();
|
||||
@@ -138,9 +134,6 @@ private:
|
||||
|
||||
void getAndDrawComments();
|
||||
|
||||
void updateScrollbar();
|
||||
|
||||
|
||||
/* zooming
|
||||
*
|
||||
*/
|
||||
@@ -206,8 +199,6 @@ private:
|
||||
|
||||
MouseDownData mouseDownData;
|
||||
KeyPressData keyPressData;
|
||||
|
||||
std::vector<RankButton *> rankCollapseButtons;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,16 +34,17 @@
|
||||
*/
|
||||
|
||||
#include "traceplotline.h"
|
||||
#include "traceplot.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <qwt_plot.h>
|
||||
|
||||
TracePlotLine::TracePlotLine(const QString &label, const std::shared_ptr<QHash<int, bool>> collapsedRanks) :
|
||||
label(label),
|
||||
collapsedRanks(collapsedRanks)
|
||||
TracePlotLine::TracePlotLine(const QString &label) :
|
||||
label(label)
|
||||
{
|
||||
}
|
||||
|
||||
TracePlotLine::TracePlotLine(const std::shared_ptr<QHash<int, bool>> collapsedRanks) :
|
||||
collapsedRanks(collapsedRanks)
|
||||
TracePlotLine::TracePlotLine()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,7 +65,6 @@ void TracePlotLine::setYVal (int yVal)
|
||||
this->yVal = yVal;
|
||||
}
|
||||
|
||||
|
||||
int TracePlotLine::getYVal() const
|
||||
{
|
||||
return yVal;
|
||||
@@ -72,8 +72,13 @@ int TracePlotLine::getYVal() const
|
||||
|
||||
|
||||
TracePlotBankLine::TracePlotBankLine(unsigned int rank, unsigned int group, unsigned int bank,
|
||||
const std::shared_ptr<QHash<int, bool>> collapsedRanks) :
|
||||
TracePlotLine(collapsedRanks),
|
||||
std::shared_ptr<TracePlotFirstRankLine> firstRankLine) :
|
||||
TracePlotBankLine(rank, group, bank)
|
||||
{
|
||||
this->firstRankLine = firstRankLine;
|
||||
}
|
||||
|
||||
TracePlotBankLine::TracePlotBankLine(unsigned int rank, unsigned int group, unsigned int bank) :
|
||||
rank(rank), group(group), bank(bank)
|
||||
{
|
||||
QString rankLabel = QString("RA") + QString::number(rank);
|
||||
@@ -85,25 +90,41 @@ TracePlotBankLine::TracePlotBankLine(unsigned int rank, unsigned int group, unsi
|
||||
|
||||
bool TracePlotBankLine::isCollapsed() const
|
||||
{
|
||||
return (*collapsedRanks)[rank];
|
||||
return firstRankLine.lock()->isCollapsed();
|
||||
}
|
||||
|
||||
|
||||
TracePlotFirstRankLine::TracePlotFirstRankLine(unsigned int rank, unsigned int group, unsigned int bank,
|
||||
const std::shared_ptr<QHash<int, bool>> collapsedRanks) :
|
||||
TracePlotBankLine(rank, group, bank, collapsedRanks)
|
||||
TracePlot *tracePlot) :
|
||||
TracePlotBankLine(rank, group, bank),
|
||||
collapseButton(new QPushButton(tracePlot)), tracePlot(tracePlot)
|
||||
{
|
||||
collapsedLabel = QString("RA") + QString::number(rank);
|
||||
|
||||
collapseButton->setText(collapsed ? "+" : "-");
|
||||
|
||||
QObject::connect(collapseButton, &QPushButton::pressed, this, [=](){
|
||||
collapsed = !collapsed;
|
||||
collapseButton->setText(collapsed ? "+" : "-");
|
||||
Q_EMIT collapsedStateChanged();
|
||||
});
|
||||
updateButtonPosition();
|
||||
}
|
||||
|
||||
void TracePlotFirstRankLine::updateButtonPosition()
|
||||
{
|
||||
QPointF point = tracePlot->axisScaleDraw(QwtPlot::yLeft)->labelPosition(getYVal());
|
||||
collapseButton->setGeometry(point.x(), point.y() - 4, 25, 25);
|
||||
}
|
||||
|
||||
bool TracePlotFirstRankLine::isCollapsed() const
|
||||
{
|
||||
return false;
|
||||
return collapsed;
|
||||
}
|
||||
|
||||
const QString & TracePlotFirstRankLine::getLabel() const
|
||||
{
|
||||
if (TracePlotBankLine::isCollapsed())
|
||||
if (collapsed)
|
||||
return collapsedLabel;
|
||||
else
|
||||
return TracePlotLine::getLabel();
|
||||
|
||||
@@ -36,14 +36,22 @@
|
||||
#ifndef TRACELOTLINE_H
|
||||
#define TRACELOTLINE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
#include <memory>
|
||||
|
||||
class TracePlotLine
|
||||
class QPushButton;
|
||||
class TracePlot;
|
||||
|
||||
class TracePlotFirstRankLine;
|
||||
|
||||
class TracePlotLine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TracePlotLine(const QString &label, const std::shared_ptr<QHash<int, bool>> collapsedRanks);
|
||||
TracePlotLine(const QString &label);
|
||||
virtual ~TracePlotLine() = 0;
|
||||
|
||||
virtual const QString & getLabel() const;
|
||||
@@ -53,48 +61,65 @@ public:
|
||||
int getYVal() const;
|
||||
|
||||
protected:
|
||||
TracePlotLine(const std::shared_ptr<QHash<int, bool>> collapsedRanks);
|
||||
TracePlotLine();
|
||||
|
||||
QString label;
|
||||
int yVal;
|
||||
const std::shared_ptr<QHash<int, bool>> collapsedRanks;
|
||||
};
|
||||
|
||||
|
||||
class TracePlotBankLine : public TracePlotLine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TracePlotBankLine(unsigned int rank, unsigned int group, unsigned int bank,
|
||||
const std::shared_ptr<QHash<int, bool>> collapsedRanks);
|
||||
std::shared_ptr<TracePlotFirstRankLine> firstRankLine);
|
||||
~TracePlotBankLine() = default;
|
||||
void setCollapsed(bool value);
|
||||
virtual bool isCollapsed() const override;
|
||||
|
||||
const unsigned int rank;
|
||||
const unsigned int group;
|
||||
const unsigned int bank;
|
||||
|
||||
protected:
|
||||
TracePlotBankLine(unsigned int rank, unsigned int group, unsigned int bank);
|
||||
|
||||
private:
|
||||
std::weak_ptr<TracePlotFirstRankLine> firstRankLine;
|
||||
};
|
||||
|
||||
|
||||
class TracePlotFirstRankLine final : public TracePlotBankLine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TracePlotFirstRankLine(unsigned int rank, unsigned int group, unsigned int bank,
|
||||
const std::shared_ptr<QHash<int, bool>> collapsedRanks);
|
||||
TracePlot *tracePlot);
|
||||
|
||||
~TracePlotFirstRankLine() = default;
|
||||
|
||||
bool isCollapsed() const override;
|
||||
|
||||
const QString & getLabel() const override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateButtonPosition();
|
||||
|
||||
Q_SIGNALS:
|
||||
void collapsedStateChanged();
|
||||
|
||||
private:
|
||||
QString collapsedLabel;
|
||||
QPushButton *collapseButton;
|
||||
bool collapsed = true;
|
||||
TracePlot *tracePlot;
|
||||
};
|
||||
|
||||
|
||||
class TracePlotRequestLine final : public TracePlotLine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using TracePlotLine::TracePlotLine;
|
||||
~TracePlotRequestLine() = default;
|
||||
@@ -102,6 +127,8 @@ public:
|
||||
|
||||
class TracePlotResponseLine final : public TracePlotLine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using TracePlotLine::TracePlotLine;
|
||||
~TracePlotResponseLine() = default;
|
||||
@@ -109,6 +136,8 @@ public:
|
||||
|
||||
class TracePlotDataBusLine final : public TracePlotLine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using TracePlotLine::TracePlotLine;
|
||||
~TracePlotDataBusLine() = default;
|
||||
@@ -116,6 +145,8 @@ public:
|
||||
|
||||
class TracePlotCommandBusLine final : public TracePlotLine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using TracePlotLine::TracePlotLine;
|
||||
~TracePlotCommandBusLine() = default;
|
||||
|
||||
@@ -62,9 +62,11 @@ void TraceScroller::init(TraceNavigator *navigator, TracePlot *tracePlot)
|
||||
connectNavigatorQ_SIGNALS();
|
||||
|
||||
setUpDrawingProperties();
|
||||
// setUpDrawingProperties() must be called before setUpAxis().
|
||||
setUpAxis();
|
||||
setUpTracePlotItem();
|
||||
|
||||
updateAxis();
|
||||
|
||||
getAndDrawComments();
|
||||
|
||||
this->tracePlot = tracePlot;
|
||||
@@ -89,7 +91,7 @@ void TraceScroller::setUpTracePlotItem()
|
||||
|
||||
void TraceScroller::setUpDrawingProperties()
|
||||
{
|
||||
drawingProperties.init(navigator->getTracePlotLines(), navigator->getCollapsedRanks());
|
||||
drawingProperties.init(navigator->getTracePlotLines());
|
||||
|
||||
drawingProperties.numberOfRanks = navigator->GeneralTraceInfo().numberOfRanks;
|
||||
drawingProperties.numberOfBankgroups = navigator->GeneralTraceInfo().numberOfBankgroups;
|
||||
@@ -102,7 +104,6 @@ void TraceScroller::setUpDrawingProperties()
|
||||
|
||||
void TraceScroller::setUpAxis()
|
||||
{
|
||||
updateAxis();
|
||||
axisScaleDraw(yLeft)->enableComponent(QwtAbstractScaleDraw::Labels, false );
|
||||
axisScaleDraw(yLeft)->enableComponent(QwtAbstractScaleDraw::Ticks, false );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user