MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / paint

Method paint

ImagePlay/src/IPProcessEdgeTmp.cpp:35–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void IPProcessEdgeTmp::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
36{
37 // main line
38 QPen pen(Qt::DotLine);
39 pen.setCapStyle(Qt::RoundCap);
40 pen.setWidth(2);
41 pen.setColor(Qt::red);
42
43 painter->setPen(pen);
44 QLineF line(_from.toPoint()+QPoint(32,32), _to.toPoint());
45
46 painter->drawLine(line);
47
48 // arrow
49 QPolygonF arrowPolygon;
50 double arrowSize = 10;
51 double angle = acos(line.dx() / line.length());
52 if (line.dy() >= 0)
53 angle = (Pi * 2) - angle;
54
55 QPointF arrowP1 = _to - QPointF(sin(angle + Pi / 3) * arrowSize,
56 cos(angle + Pi / 3) * arrowSize);
57 QPointF arrowP2 = _to - QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
58 cos(angle + Pi - Pi / 3) * arrowSize);
59 arrowPolygon.clear();
60 arrowPolygon << _to << arrowP1 << arrowP2;
61
62 pen.setStyle(Qt::SolidLine);
63 painter->setPen(pen);
64 painter->drawPolygon(arrowPolygon);
65}

Callers

nothing calls this directly

Calls 3

toPointMethod · 0.80
lengthMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected