14#include <QGraphicsLineItem>
33 m_graphicsItem =
new QGraphicsLineItem (QLineF (m_posLow,
40 m_graphicsItem->setPen (QPen (color,
43 scene.addItem (m_graphicsItem);
48 delete m_graphicsItem;
49 delete m_graphicsItemRelay;
54 double distanceLow =
magnitude (posScreen - m_posLow);
55 double distanceHigh =
magnitude (posScreen - m_posHigh);
57 return qMin (distanceLow, distanceHigh);
63 QPointF posCenter = (m_posHigh + m_posLow) / 2.0;
64 QPointF delta = m_posHigh - m_posLow;
65 double radiusInitial =
magnitude (delta) / 2.0;
66 double scaling = radius / radiusInitial;
67 QPointF posLow = posCenter - scaling / 2.0 * delta;
68 QPointF posHigh = posCenter + scaling / 2.0 * delta;
QColor ColorPaletteToQColor(ColorPalette color)
Compute endpoints for cartesian centipedes.
QPointF posScreenConstantYForLowX(double radius) const
Screen point for Y value of circle/coordinate intersection in the decreasing X direction.
QPointF posScreenConstantYForHighX(double radius) const
Screen point for Y value of circle/coordinate intersection in the increasing X direction.
QPointF posClickScreen() const
Center of circle in screen coordinates.
CentipedeSegmentAbstract(const DocumentModelGuideline &modelGuideline, const Transformation &transformation, const QPointF &posClickScreen)
Constructor with individual coordinates.
const DocumentModelGuideline & modelGuideline() const
Settings.
Transformation transformation() const
Transformation which is static through the entire lifetime of the Centipede class instances.
virtual void updateRadius(double radius)
Update geometry to reflect cursor movement.
virtual ~CentipedeSegmentConstantYLine()
virtual double distanceToClosestEndpoint(const QPointF &posScreen) const
Return distance to closest endpoint.
CentipedeSegmentConstantYLine(GraphicsScene &scene, const DocumentModelGuideline &modelGuideline, const Transformation &transformation, const QPointF &posClickScreen)
Constructor with individual coordinates.
void signalUpdateEndpoints(QPointF start, QPointF end)
Send new geometry for later updating.
Model for managing the coordinate values corresponding Guidelines.
Enable postponed geometry changes for QGraphicsLineItem, using a signal to trigger this class to upda...
Add point and line handling to generic QGraphicsScene.
double magnitude(const QPointF &vec)
Norm of vector.