Engauge Digitizer 2
Loading...
Searching...
No Matches
CentipedeSegmentConstantXLine Class Reference

Centipede for constant XT using QGraphicsLineItem. More...

#include <CentipedeSegmentConstantXLine.h>

Inheritance diagram for CentipedeSegmentConstantXLine:
Inheritance graph
Collaboration diagram for CentipedeSegmentConstantXLine:
Collaboration graph

Signals

void signalUpdateEndpoints (QPointF start, QPointF end)
 Send new geometry for later updating.

Public Member Functions

 CentipedeSegmentConstantXLine (GraphicsScene &scene, const DocumentModelGuideline &modelGuideline, const Transformation &transformation, const QPointF &posClickScreen)
 Constructor with individual coordinates.
virtual ~CentipedeSegmentConstantXLine ()
virtual double distanceToClosestEndpoint (const QPointF &posScreen) const
 Return distance to closest endpoint.
virtual void updateRadius (double radius)
 Update geometry to reflect cursor movement.
Public Member Functions inherited from CentipedeSegmentAbstract
 CentipedeSegmentAbstract (const DocumentModelGuideline &modelGuideline, const Transformation &transformation, const QPointF &posClickScreen)
 Constructor with individual coordinates.
virtual ~CentipedeSegmentAbstract ()

Additional Inherited Members

Protected Member Functions inherited from CentipedeSegmentAbstract
double closestAngleToCentralAngle (double angleCenter, double angleOld) const
 Loop to find closest angle to angleCenter.
const DocumentModelGuidelinemodelGuideline () const
 Settings.
QPointF posClickScreen () const
 Center of circle in screen coordinates.
Transformation transformation () const
 Transformation which is static through the entire lifetime of the Centipede class instances.

Detailed Description

Centipede for constant XT using QGraphicsLineItem.

Definition at line 17 of file CentipedeSegmentConstantXLine.h.

Constructor & Destructor Documentation

◆ CentipedeSegmentConstantXLine()

CentipedeSegmentConstantXLine::CentipedeSegmentConstantXLine ( GraphicsScene & scene,
const DocumentModelGuideline & modelGuideline,
const Transformation & transformation,
const QPointF & posClickScreen )

Constructor with individual coordinates.

Definition at line 17 of file CentipedeSegmentConstantXLine.cpp.

20 :
24{
25 CentipedeEndpointsCartesian endpoints (modelGuideline,
28
29 m_posLow = endpoints.posScreenConstantXForLowY (modelGuideline.creationCircleRadius ());
30
31 m_posHigh = endpoints.posScreenConstantXForHighY (modelGuideline.creationCircleRadius ());
32
33 // Create graphics item and its relay
34 m_graphicsItem = new QGraphicsLineItem (QLineF (m_posLow,
35 m_posHigh));
36 m_graphicsItemRelay = new GraphicsLineItemRelay (this,
37 m_graphicsItem);
38
39 QColor color (ColorPaletteToQColor (modelGuideline.lineColor()));
40
41 m_graphicsItem->setPen (QPen (color,
42 modelGuideline.lineWidthActive ()));
43
44 scene.addItem (m_graphicsItem);
45}
QColor ColorPaletteToQColor(ColorPalette color)
Definition EnumsToQt.cpp:16
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.

◆ ~CentipedeSegmentConstantXLine()

CentipedeSegmentConstantXLine::~CentipedeSegmentConstantXLine ( )
virtual

Definition at line 47 of file CentipedeSegmentConstantXLine.cpp.

48{
49 delete m_graphicsItem;
50 delete m_graphicsItemRelay;
51}

Member Function Documentation

◆ distanceToClosestEndpoint()

double CentipedeSegmentConstantXLine::distanceToClosestEndpoint ( const QPointF & posScreen) const
virtual

Return distance to closest endpoint.

Implements CentipedeSegmentAbstract.

Definition at line 53 of file CentipedeSegmentConstantXLine.cpp.

54{
55 double distanceLow = magnitude (posScreen - m_posLow);
56 double distanceHigh = magnitude (posScreen - m_posHigh);
57
58 return qMin (distanceLow, distanceHigh);
59}
double magnitude(const QPointF &vec)
Norm of vector.
Definition mmsubs.cpp:193

◆ signalUpdateEndpoints

void CentipedeSegmentConstantXLine::signalUpdateEndpoints ( QPointF start,
QPointF end )
signal

Send new geometry for later updating.

◆ updateRadius()

void CentipedeSegmentConstantXLine::updateRadius ( double radius)
virtual

Update geometry to reflect cursor movement.

Implements CentipedeSegmentAbstract.

Definition at line 61 of file CentipedeSegmentConstantXLine.cpp.

62{
63 // Scale up/down the line segment length, keeping it centered on the same center point
64 QPointF posCenter = (m_posHigh + m_posLow) / 2.0;
65 QPointF delta = m_posHigh - m_posLow;
66 double radiusInitial = magnitude (delta) / 2.0; // Convert from diameter to radius
67 double scaling = radius / radiusInitial;
68 QPointF posLow = posCenter - scaling / 2.0 * delta;
69 QPointF posHigh = posCenter + scaling / 2.0 * delta;
70
71 // Update geometry but only after the event handler currently on the stack has disappeared.
72 // This means sending a signal instead of calling QGraphicsLineItem::setLine directly
73 emit signalUpdateEndpoints (posLow,
74 posHigh);
75}
void signalUpdateEndpoints(QPointF start, QPointF end)
Send new geometry for later updating.

The documentation for this class was generated from the following files: