MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / drawLineWithArrows

Method drawLineWithArrows

src/openms_gui/source/VISUAL/PainterBase.cpp:129–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127 }
128
129 QRectF PainterBase::drawLineWithArrows(QPainter* painter, const QPen& pen, const QPoint& start, const QPoint& end, const QPainterPath& arrow_start, const QPainterPath& arrow_end)
130 {
131 painter->setPen(pen);
132
133 auto line = QLineF(start, end);
134 // angle of line
135 qreal angle = -line.angle() + 180; // negate since angle() reports counter-clockwise; +180 since painter.rotate() is more intuitive then
136 QRectF bounding_rect = QRectF(line.p1(), line.p2()).normalized();
137 // draw the actual line
138 painter->drawLine(line);
139
140 //painter->save();
141 // draw arrow heads
142 if (!arrow_start.isEmpty())
143 {
144 //painter->translate(start);
145 //painter->rotate(angle);
146 QMatrix rotationMatrix;
147 rotationMatrix.translate(start.x(), start.y());
148 rotationMatrix.rotate(angle);
149 QPainterPath path = rotationMatrix.map(arrow_start);
150 painter->drawPath(path);
151 bounding_rect = bounding_rect.united(path.boundingRect());
152 //painter->restore();
153 }
154 if (!arrow_end.isEmpty())
155 {
156 QMatrix rotationMatrix;
157 rotationMatrix.translate(end.x(), end.y());
158 rotationMatrix.rotate(angle + 180);
159 QPainterPath path = rotationMatrix.map(arrow_end);
160 painter->drawPath(path);
161 bounding_rect = bounding_rect.united(path.boundingRect());
162 }
163 return bounding_rect;
164 }
165
166} // namespace OpenMS

Callers

nothing calls this directly

Calls 6

translateMethod · 0.80
mapMethod · 0.80
unitedMethod · 0.80
QRectFClass · 0.50
isEmptyMethod · 0.45
boundingRectMethod · 0.45

Tested by

no test coverage detected