Graph edge highlight (#1693)

* Highlight edges to and from current block in graph.
This commit is contained in:
karliss 2019-07-30 21:35:00 +03:00 committed by GitHub
parent fe4206999a
commit a5dc85c3c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 8 deletions

View File

@ -152,6 +152,8 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterSeekable* se
// Add header as widget to layout so it stretches to the layout width // Add header as widget to layout so it stretches to the layout width
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->setAlignment(Qt::AlignTop); layout->setAlignment(Qt::AlignTop);
this->scale_thickness_multiplier = true;
} }
void DisassemblerGraphView::connectSeekChanged(bool disconn) void DisassemblerGraphView::connectSeekChanged(bool disconn)
@ -601,6 +603,11 @@ GraphView::EdgeConfiguration DisassemblerGraphView::edgeConfiguration(GraphView:
} }
ec.start_arrow = false; ec.start_arrow = false;
ec.end_arrow = true; ec.end_arrow = true;
if (from.entry == currentBlockAddress) {
ec.width_scale = 2.0;
} else if (to->entry == currentBlockAddress) {
ec.width_scale = 2.0;
}
return ec; return ec;
} }
@ -922,6 +929,8 @@ void DisassemblerGraphView::blockClicked(GraphView::GraphBlock &block, QMouseEve
return; return;
} }
currentBlockAddress = block.entry;
highlight_token = getToken(instr, pos.x()); highlight_token = getToken(instr, pos.x());
RVA addr = instr->addr; RVA addr = instr->addr;
@ -983,6 +992,7 @@ bool DisassemblerGraphView::helpEvent(QHelpEvent *event)
void DisassemblerGraphView::blockTransitionedTo(GraphView::GraphBlock *to) void DisassemblerGraphView::blockTransitionedTo(GraphView::GraphBlock *to)
{ {
currentBlockAddress = to->entry;
if (transition_dont_seek) { if (transition_dont_seek) {
transition_dont_seek = false; transition_dont_seek = false;
return; return;

View File

@ -147,6 +147,7 @@ private:
int charOffset; int charOffset;
int baseline; int baseline;
bool emptyGraph; bool emptyGraph;
ut64 currentBlockAddress = RVA_INVALID;
DisassemblyContextMenu *blockMenu; DisassemblyContextMenu *blockMenu;
QMenu *contextMenu; QMenu *contextMenu;

View File

@ -918,9 +918,9 @@ void DisassemblyLeftPanel::paintEvent(QPaintEvent *event)
bool jumpDown = l.arrow > l.offset; bool jumpDown = l.arrow > l.offset;
p.setPen(jumpDown ? penDown : penUp); p.setPen(jumpDown ? penDown : penUp);
if (l.offset == currOffset) { if (l.offset == currOffset || l.arrow == currOffset) {
QPen pen = p.pen(); QPen pen = p.pen();
pen.setWidth((penSizePix * 3) / 2); pen.setWidthF((penSizePix * 3) / 2.0);
p.setPen(pen); p.setPen(pen);
} }
bool endVisible = true; bool endVisible = true;

View File

@ -336,8 +336,12 @@ void GraphView::paintGraphCache()
QPolygonF polyline = recalculatePolygon(edge.polyline); QPolygonF polyline = recalculatePolygon(edge.polyline);
EdgeConfiguration ec = edgeConfiguration(block, &blocks[edge.target]); EdgeConfiguration ec = edgeConfiguration(block, &blocks[edge.target]);
QPen pen(ec.color); QPen pen(ec.color);
pen.setWidth(pen.width() / ec.width_scale); pen.setStyle(ec.lineStyle);
if (pen.width() * current_scale < 2) { pen.setWidthF(pen.width() * ec.width_scale);
if (scale_thickness_multiplier * ec.width_scale > 1.01 && pen.widthF() * current_scale < 2) {
pen.setWidthF(ec.width_scale / current_scale);
}
if (pen.widthF() * current_scale < 2) {
pen.setWidth(0); pen.setWidth(0);
} }
p.setPen(pen); p.setPen(pen);

View File

@ -38,6 +38,7 @@ public:
bool start_arrow = false; bool start_arrow = false;
bool end_arrow = true; bool end_arrow = true;
qreal width_scale = 1.0; qreal width_scale = 1.0;
Qt::PenStyle lineStyle = Qt::PenStyle::SolidLine;
}; };
explicit GraphView(QWidget *parent); explicit GraphView(QWidget *parent);
@ -96,6 +97,7 @@ protected:
int width = 0; int width = 0;
int height = 0; int height = 0;
bool scale_thickness_multiplier = false;
void clampViewOffset(); void clampViewOffset();
void setViewOffsetInternal(QPoint pos, bool emitSignal = true); void setViewOffsetInternal(QPoint pos, bool emitSignal = true);
@ -125,9 +127,6 @@ private:
int scroll_base_y = 0; int scroll_base_y = 0;
bool scroll_mode = false; bool scroll_mode = false;
// Todo: remove charheight/charwidth cause it should be handled in child class
qreal charWidth = 10.0;
bool useGL; bool useGL;
/** /**

View File

@ -137,7 +137,7 @@ GraphView::EdgeConfiguration OverviewView::edgeConfiguration(GraphView::GraphBlo
auto baseEcIt = edgeConfigurations.find({from.entry, to->entry}); auto baseEcIt = edgeConfigurations.find({from.entry, to->entry});
if (baseEcIt != edgeConfigurations.end()) if (baseEcIt != edgeConfigurations.end())
ec = baseEcIt->second; ec = baseEcIt->second;
ec.width_scale = getViewScale(); ec.width_scale = 1.0 / getViewScale();
return ec; return ec;
} }