Merge branch 'work/transaction_selection' into 'develop'
Improve selection-area of transactions. See merge request ems/astdm/dram.sys!318
This commit is contained in:
@@ -137,22 +137,18 @@ Qt::BrushStyle Phase::getBrushStyle() const
|
||||
return Qt::SolidPattern;
|
||||
}
|
||||
|
||||
bool Phase::isSelected(traceTime time, double yVal,
|
||||
const TraceDrawingProperties &drawingProperties) const
|
||||
bool Phase::isSelected(Timespan timespan, double yVal, const TraceDrawingProperties &drawingProperties) const
|
||||
{
|
||||
// Increase selectable area of phases with zero span
|
||||
traceTime offset = (span.Begin() == span.End()) ? static_cast<traceTime>(0.05 * clk) : 0;
|
||||
|
||||
if (span.Begin() <= time && time <= (span.End() + offset))
|
||||
if (span.overlaps(timespan))
|
||||
{
|
||||
for (auto line : getTracePlotLines(drawingProperties))
|
||||
{
|
||||
if (!line->isCollapsed() && fabs(yVal - line->getYVal()) <= hexagonHeight)
|
||||
if (!line->isCollapsed() && fabs(yVal - line->getYVal()) <= hexagonHeight / 2)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (spanOnDataBus && spanOnDataBus->contains(time))
|
||||
if (spanOnDataBus && spanOnDataBus->overlaps(timespan))
|
||||
{
|
||||
for (auto dataBusLine : drawingProperties.getDataBusLines())
|
||||
{
|
||||
@@ -161,8 +157,9 @@ bool Phase::isSelected(traceTime time, double yVal,
|
||||
}
|
||||
}
|
||||
|
||||
for (Timespan span : spansOnCommandBus) {
|
||||
if (span.contains(time))
|
||||
for (const Timespan &span : spansOnCommandBus)
|
||||
{
|
||||
if (span.overlaps(timespan))
|
||||
{
|
||||
for (auto commandBusLine : drawingProperties.getCommandBusLines())
|
||||
{
|
||||
|
||||
@@ -64,8 +64,7 @@ public:
|
||||
void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, bool highlight,
|
||||
const TraceDrawingProperties &drawingProperties) const;
|
||||
bool isSelected(traceTime time, double yVal,
|
||||
const TraceDrawingProperties &drawingproperties) const;
|
||||
bool isSelected(Timespan timespan, double yVal, const TraceDrawingProperties &drawingproperties) const;
|
||||
const Timespan &Span() const
|
||||
{
|
||||
return span;
|
||||
|
||||
@@ -42,6 +42,11 @@ bool Timespan::contains(traceTime time) const
|
||||
return (begin <= time && time <= end);
|
||||
}
|
||||
|
||||
bool Timespan::overlaps(const Timespan &other) const
|
||||
{
|
||||
return other.Begin() < this->end && this->begin < other.End();
|
||||
}
|
||||
|
||||
void Timespan::shift(traceTime offset)
|
||||
{
|
||||
begin += offset;
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
end = time;
|
||||
}
|
||||
bool contains(traceTime time) const;
|
||||
bool overlaps(const Timespan &other) const;
|
||||
void shift(traceTime offset);
|
||||
};
|
||||
|
||||
|
||||
@@ -60,16 +60,13 @@ void Transaction::draw(QPainter *painter, const QwtScaleMap &xMap,
|
||||
phase->draw(painter, xMap, yMap, canvasRect, highlight, drawingProperties);
|
||||
}
|
||||
|
||||
bool Transaction::isSelected(traceTime time, double yVal,
|
||||
const TraceDrawingProperties &drawingproperties) const
|
||||
bool Transaction::isSelected(Timespan timespan, double yVal, const TraceDrawingProperties &drawingproperties) const
|
||||
{
|
||||
// Increase selectable area of transactions for phases with zero span
|
||||
traceTime offset = static_cast<traceTime>(0.05 * clk);
|
||||
|
||||
if (span.Begin() <= time && time <= (span.End() + offset))
|
||||
if (span.overlaps(timespan))
|
||||
{
|
||||
for (shared_ptr<Phase> phase : phases) {
|
||||
if (phase->isSelected(time, yVal, drawingproperties))
|
||||
for (shared_ptr<Phase> phase : phases)
|
||||
{
|
||||
if (phase->isSelected(timespan, yVal, drawingproperties))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ public:
|
||||
const TraceDrawingProperties &drawingProperties) const;
|
||||
void addPhase(std::shared_ptr<Phase> phase);
|
||||
|
||||
bool isSelected(traceTime time, double yVal,
|
||||
const TraceDrawingProperties &drawingproperties) const;
|
||||
bool isSelected(Timespan timespan, double yVal, const TraceDrawingProperties &drawingproperties) const;
|
||||
|
||||
const std::vector<std::shared_ptr<Phase>> &Phases() const
|
||||
{
|
||||
|
||||
@@ -723,12 +723,15 @@ bool TracePlot::eventFilter(QObject *object, QEvent *event)
|
||||
void TracePlot::SelectTransaction(int x, int y) const
|
||||
{
|
||||
double yVal = invTransform(yLeft, y);
|
||||
traceTime time = invTransform(xBottom, x);
|
||||
vector<shared_ptr<Transaction>> selectedTransactions =
|
||||
tracePlotItem->getSelectedTransactions(time, yVal);
|
||||
if (selectedTransactions.size() > 0) {
|
||||
Timespan timespan = hoveredTimespan(x);
|
||||
|
||||
auto selectedTransactions = tracePlotItem->getSelectedTransactions(timespan, yVal);
|
||||
|
||||
if (selectedTransactions.size() > 0)
|
||||
{
|
||||
if (!keyPressData.ctrlPressed)
|
||||
navigator->clearSelectedTransactions();
|
||||
|
||||
navigator->addSelectedTransactions(selectedTransactions);
|
||||
}
|
||||
}
|
||||
@@ -750,7 +753,7 @@ void TracePlot::SelectComment(int x) const
|
||||
Timespan TracePlot::hoveredTimespan(int x) const
|
||||
{
|
||||
traceTime time = invTransform(xBottom, x);
|
||||
traceTime offset = 0.01 * zoomLevel;
|
||||
traceTime offset = 0.005 * zoomLevel;
|
||||
|
||||
return Timespan(time - offset, time + offset);
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ void TracePlotItem::draw(QPainter *painter, const QwtScaleMap &xMap,
|
||||
}
|
||||
}
|
||||
|
||||
vector<shared_ptr<Transaction>> TracePlotItem::getSelectedTransactions(
|
||||
traceTime time, double yVal)
|
||||
vector<shared_ptr<Transaction>> TracePlotItem::getSelectedTransactions(Timespan timespan, double yVal)
|
||||
{
|
||||
vector<shared_ptr<Transaction>> result;
|
||||
|
||||
for (const auto &transaction : transactions) {
|
||||
if (transaction->isSelected(time, yVal, drawingProperties))
|
||||
for (const auto &transaction : transactions)
|
||||
{
|
||||
if (transaction->isSelected(timespan, yVal, drawingProperties))
|
||||
result.push_back(transaction);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,9 +65,7 @@ public:
|
||||
virtual int rtti() const;
|
||||
virtual void draw(QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap, const QRectF &canvasRect) const;
|
||||
std::vector<std::shared_ptr<Transaction>> getSelectedTransactions(
|
||||
traceTime time, double yVal);
|
||||
|
||||
std::vector<std::shared_ptr<Transaction>> getSelectedTransactions(Timespan timespan, double yVal);
|
||||
};
|
||||
|
||||
#endif // TRACEPLOTITEM_H
|
||||
|
||||
Reference in New Issue
Block a user