Added toggle to enable/disable dependency name presentation.
This commit is contained in:
@@ -74,12 +74,11 @@ void Phase::draw(QPainter *painter, const QwtScaleMap &xMap,
|
||||
if (getGranularity() == Granularity::Bankwise) {
|
||||
|
||||
bool drawDependencyText = true;
|
||||
DependencyOption drawDependenciesOption = drawingProperties.drawDependenciesOption;
|
||||
if (drawDependenciesOption == DependencyOption::All ||
|
||||
(drawDependenciesOption == DependencyOption::Selected && highlight))
|
||||
DependencyOptions drawDependenciesOptions = drawingProperties.drawDependenciesOption;
|
||||
if (drawDependenciesOptions.draw == DependencyOption::All ||
|
||||
(drawDependenciesOptions.draw == DependencyOption::Selected && highlight))
|
||||
{
|
||||
drawPhaseDependencies(span.Begin(), span.End(), line->getYVal(), drawingProperties,
|
||||
drawDependencyText, painter, xMap, yMap);
|
||||
drawPhaseDependencies(span.Begin(), span.End(), line->getYVal(), drawingProperties, painter, xMap, yMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +129,7 @@ void Phase::drawPhaseSymbol(traceTime begin, traceTime end, double y,
|
||||
}
|
||||
|
||||
void Phase::drawPhaseDependencies(traceTime begin, traceTime end, double y, const TraceDrawingProperties &drawingProperties,
|
||||
bool drawtext, QPainter *painter, const QwtScaleMap &xMap,
|
||||
QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap) const
|
||||
{
|
||||
QPen pen;
|
||||
@@ -149,10 +148,10 @@ void Phase::drawPhaseDependencies(traceTime begin, traceTime end, double y, cons
|
||||
|
||||
QPoint depLineTo(static_cast<int>(xMap.transform(begin/* + (end + offset - begin)/4*/)), static_cast<int>(yVal));
|
||||
|
||||
for (auto dep : _dependencies) {
|
||||
for (auto dep : mDependencies) {
|
||||
bool visible = false;
|
||||
if (dep->isVisible()) {
|
||||
if (!dep->draw(depLineTo, drawingProperties, drawtext, painter, xMap, yMap) ) {
|
||||
if (!dep->draw(depLineTo, drawingProperties, painter, xMap, yMap) ) {
|
||||
invisibleDeps += 1;
|
||||
}
|
||||
|
||||
@@ -253,5 +252,5 @@ std::vector<std::shared_ptr<TracePlotLine>> Phase::getTracePlotLines(const Trace
|
||||
}
|
||||
|
||||
void Phase::addDependency(std::shared_ptr<PhaseDependency> dependency) {
|
||||
_dependencies.push_back(dependency);
|
||||
mDependencies.push_back(dependency);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ protected:
|
||||
std::weak_ptr<Transaction> transaction;
|
||||
std::vector<Timespan> spansOnCommandBus;
|
||||
std::shared_ptr<Timespan> spanOnDataBus;
|
||||
std::vector<std::shared_ptr<PhaseDependency>> _dependencies;
|
||||
std::vector<std::shared_ptr<PhaseDependency>> mDependencies;
|
||||
|
||||
double hexagonHeight;
|
||||
TextPositioning captionPosition;
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
const QwtScaleMap &yMap) const;
|
||||
virtual void drawPhaseDependencies(traceTime begin, traceTime end, double y,
|
||||
const TraceDrawingProperties &drawingProperties,
|
||||
bool drawtext, QPainter *painter, const QwtScaleMap &xMap,
|
||||
QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap) const;
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ PhaseDependency::~PhaseDependency()
|
||||
}
|
||||
|
||||
bool PhaseDependency::draw(QPoint& end, const TraceDrawingProperties &drawingProperties,
|
||||
bool drawtext, QPainter *painter, const QwtScaleMap &xMap,
|
||||
QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap)
|
||||
{
|
||||
if (mIsInvisible) return false;
|
||||
@@ -36,7 +36,7 @@ bool PhaseDependency::draw(QPoint& end, const TraceDrawingProperties &drawingPro
|
||||
bool drawn = false;
|
||||
for (auto line : mDependency->getTracePlotLines(drawingProperties)) {
|
||||
if (!line->isCollapsed()) {
|
||||
mDraw(end, line->getYVal(), drawingProperties, drawtext, painter, xMap, yMap);
|
||||
mDraw(end, line->getYVal(), drawingProperties, painter, xMap, yMap);
|
||||
drawn = true;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ bool PhaseDependency::draw(QPoint& end, const TraceDrawingProperties &drawingPro
|
||||
}
|
||||
|
||||
void PhaseDependency::mDraw(QPoint& end, double depY, const TraceDrawingProperties &drawingProperties,
|
||||
bool drawtext, QPainter *painter, const QwtScaleMap &xMap,
|
||||
QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap)
|
||||
{
|
||||
traceTime depBegin = mDependency->span.Begin();
|
||||
@@ -74,7 +74,7 @@ void PhaseDependency::mDraw(QPoint& end, double depY, const TraceDrawingProperti
|
||||
painter->drawLine(line);
|
||||
painter->drawPolygon(arrowHead);
|
||||
|
||||
if (drawtext) {
|
||||
if (drawingProperties.drawDependenciesOption.text == DependencyTextOption::Enabled) {
|
||||
QPoint textPosition(line.x1() + (line.x2() - line.x1()) / 2, line.y1() + (line.y2() - line.y1()) / 2);
|
||||
auto alignment = TextPositioning::topRight;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class PhaseDependency
|
||||
bool isVisible() { return !mIsInvisible; }
|
||||
|
||||
bool draw(QPoint& end, const TraceDrawingProperties &drawingProperties,
|
||||
bool drawtext, QPainter *painter, const QwtScaleMap &xMap,
|
||||
QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap);
|
||||
|
||||
protected:
|
||||
@@ -36,6 +36,6 @@ class PhaseDependency
|
||||
bool mIsInvisible = false;
|
||||
|
||||
void mDraw(QPoint& end, double depY, const TraceDrawingProperties &drawingProperties,
|
||||
bool drawtext, QPainter *painter, const QwtScaleMap &xMap,
|
||||
QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap);
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "util/traceplotlinecache.h"
|
||||
#include "traceselector.h"
|
||||
|
||||
TraceDrawingProperties::TraceDrawingProperties(bool drawText, bool drawBorder, DependencyOption drawDependenciesOption,
|
||||
TraceDrawingProperties::TraceDrawingProperties(bool drawText, bool drawBorder, DependencyOptions drawDependenciesOption,
|
||||
ColorGrouping colorGrouping)
|
||||
: drawText(drawText), drawBorder(drawBorder), drawDependenciesOption(drawDependenciesOption),
|
||||
colorGrouping(colorGrouping)
|
||||
|
||||
@@ -64,6 +64,12 @@ enum class DependencyOption
|
||||
Selected,
|
||||
All
|
||||
};
|
||||
enum class DependencyTextOption {Enabled, Disabled};
|
||||
|
||||
typedef struct s_DependencyOptions {
|
||||
DependencyOption draw;
|
||||
DependencyTextOption text;
|
||||
} DependencyOptions;
|
||||
|
||||
class TraceDrawingProperties : public QObject
|
||||
{
|
||||
@@ -72,7 +78,7 @@ class TraceDrawingProperties : public QObject
|
||||
public:
|
||||
bool drawText;
|
||||
bool drawBorder;
|
||||
DependencyOption drawDependenciesOption;
|
||||
DependencyOptions drawDependenciesOption;
|
||||
ColorGrouping colorGrouping;
|
||||
|
||||
unsigned int numberOfRanks;
|
||||
@@ -83,7 +89,7 @@ public:
|
||||
unsigned int banksPerGroup;
|
||||
|
||||
TraceDrawingProperties(bool drawText = true, bool drawBorder = true,
|
||||
DependencyOption drawDependenciesOption = DependencyOption::Disabled,
|
||||
DependencyOptions drawDependenciesOption = {DependencyOption::Disabled, DependencyTextOption::Disabled},
|
||||
ColorGrouping colorGrouping = ColorGrouping::PhaseType);
|
||||
~TraceDrawingProperties();
|
||||
|
||||
|
||||
@@ -165,29 +165,46 @@ void TracePlot::setUpActions()
|
||||
disabledDependencies = new QAction("Disabled", this);
|
||||
selectedDependencies = new QAction("Selected transactions", this);
|
||||
allDependencies = new QAction("All transactions", this);
|
||||
enableDrawDependencyTexts = new QAction("Enabled", this);
|
||||
disableDrawDependencyTexts = new QAction("Disabled", this);
|
||||
|
||||
disabledDependencies->setCheckable(true);
|
||||
selectedDependencies->setCheckable(true);
|
||||
allDependencies->setCheckable(true);
|
||||
enableDrawDependencyTexts->setCheckable(true);
|
||||
disableDrawDependencyTexts->setCheckable(true);
|
||||
|
||||
disabledDependencies->setChecked(true);
|
||||
disableDrawDependencyTexts->setChecked(true);
|
||||
|
||||
QObject::connect(disabledDependencies, &QAction::triggered, this,
|
||||
[&]()
|
||||
{
|
||||
drawingProperties.drawDependenciesOption = DependencyOption::Disabled;
|
||||
drawingProperties.drawDependenciesOption.draw = DependencyOption::Disabled;
|
||||
replot();
|
||||
});
|
||||
QObject::connect(selectedDependencies, &QAction::triggered, this,
|
||||
[&]()
|
||||
{
|
||||
drawingProperties.drawDependenciesOption = DependencyOption::Selected;
|
||||
drawingProperties.drawDependenciesOption.draw = DependencyOption::Selected;
|
||||
replot();
|
||||
});
|
||||
QObject::connect(allDependencies, &QAction::triggered, this,
|
||||
[&]()
|
||||
{
|
||||
drawingProperties.drawDependenciesOption = DependencyOption::All;
|
||||
drawingProperties.drawDependenciesOption.draw = DependencyOption::All;
|
||||
replot();
|
||||
});
|
||||
QObject::connect(enableDrawDependencyTexts, &QAction::triggered, this,
|
||||
[&]()
|
||||
{
|
||||
drawingProperties.drawDependenciesOption.text = DependencyTextOption::Enabled;
|
||||
replot();
|
||||
});
|
||||
QObject::connect(disableDrawDependencyTexts, &QAction::triggered, this,
|
||||
[&]()
|
||||
{
|
||||
drawingProperties.drawDependenciesOption.text = DependencyTextOption::Disabled;
|
||||
replot();
|
||||
});
|
||||
|
||||
@@ -195,6 +212,9 @@ void TracePlot::setUpActions()
|
||||
dependenciesGroup->addAction(disabledDependencies);
|
||||
dependenciesGroup->addAction(selectedDependencies);
|
||||
dependenciesGroup->addAction(allDependencies);
|
||||
QActionGroup *dependencyTextsGroup = new QActionGroup(this);
|
||||
dependencyTextsGroup->addAction(enableDrawDependencyTexts);
|
||||
dependencyTextsGroup->addAction(disableDrawDependencyTexts);
|
||||
|
||||
setUpContextMenu();
|
||||
}
|
||||
@@ -211,6 +231,9 @@ void TracePlot::setUpContextMenu()
|
||||
QMenu *dependenciesSubMenu = new QMenu("Show dependencies", contextMenu);
|
||||
dependenciesSubMenu->addActions({disabledDependencies, selectedDependencies, allDependencies});
|
||||
contextMenu->addMenu(dependenciesSubMenu);
|
||||
QMenu *dependenciesTextSubMenu = new QMenu("Show dependency names", dependenciesSubMenu);
|
||||
dependenciesTextSubMenu->addActions({enableDrawDependencyTexts, disableDrawDependencyTexts});
|
||||
dependenciesSubMenu->addMenu(dependenciesTextSubMenu);
|
||||
|
||||
QMenu *goToSubMenu = new QMenu("Go to", contextMenu);
|
||||
goToSubMenu->addActions({goToPhase, goToTransaction, goToTime});
|
||||
|
||||
@@ -183,6 +183,8 @@ private:
|
||||
QAction *disabledDependencies;
|
||||
QAction *selectedDependencies;
|
||||
QAction *allDependencies;
|
||||
QAction *enableDrawDependencyTexts;
|
||||
QAction *disableDrawDependencyTexts;
|
||||
ToggleCollapsedAction *toggleCollapsedState;
|
||||
|
||||
TracePlotMouseLabel *mouseLabel;
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
|
||||
TraceScroller::TraceScroller(QWidget *parent)
|
||||
: QwtPlot(parent), isInitialized(false),
|
||||
drawingProperties(false, false, DependencyOption::Disabled, ColorGrouping::PhaseType)
|
||||
drawingProperties(false, false, {DependencyOption::Disabled, DependencyTextOption::Disabled},
|
||||
ColorGrouping::PhaseType)
|
||||
{
|
||||
setAxisScaleDraw(xBottom, new EngineeringScaleDraw);
|
||||
canvas()->setCursor(Qt::ArrowCursor);
|
||||
|
||||
Reference in New Issue
Block a user