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

Centipede for constant YR using QGraphicsLineItem. More...

#include <CentipedeSegmentConstantYLine.h>

Inheritance diagram for CentipedeSegmentConstantYLine:
Inheritance graph
Collaboration diagram for CentipedeSegmentConstantYLine:
Collaboration graph

Signals

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

Public Member Functions

 CentipedeSegmentConstantYLine (GraphicsScene &scene, const DocumentModelGuideline &modelGuideline, const Transformation &transformation, const QPointF &posClickScreen)
 Constructor with individual coordinates.
virtual ~CentipedeSegmentConstantYLine ()
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 YR using QGraphicsLineItem.

Definition at line 17 of file CentipedeSegmentConstantYLine.h.

Constructor & Destructor Documentation

◆ CentipedeSegmentConstantYLine()

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

Constructor with individual coordinates.

Definition at line 17 of file CentipedeSegmentConstantYLine.cpp.

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

◆ ~CentipedeSegmentConstantYLine()

CentipedeSegmentConstantYLine::~CentipedeSegmentConstantYLine ( )
virtual

Definition at line 46 of file CentipedeSegmentConstantYLine.cpp.

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

Member Function Documentation

◆ distanceToClosestEndpoint()

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

Return distance to closest endpoint.

Implements CentipedeSegmentAbstract.

Definition at line 52 of file CentipedeSegmentConstantYLine.cpp.

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

◆ signalUpdateEndpoints

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

Send new geometry for later updating.

◆ updateRadius()

void CentipedeSegmentConstantYLine::updateRadius ( double radius)
virtual

Update geometry to reflect cursor movement.

Implements CentipedeSegmentAbstract.

Definition at line 60 of file CentipedeSegmentConstantYLine.cpp.

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

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