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

Centipede for constant T radial using QGraphicsLineItem. More...

#include <CentipedeSegmentConstantTRadial.h>

Inheritance diagram for CentipedeSegmentConstantTRadial:
Inheritance graph
Collaboration diagram for CentipedeSegmentConstantTRadial:
Collaboration graph

Signals

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

Public Member Functions

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

Definition at line 18 of file CentipedeSegmentConstantTRadial.h.

Constructor & Destructor Documentation

◆ CentipedeSegmentConstantTRadial()

CentipedeSegmentConstantTRadial::CentipedeSegmentConstantTRadial ( GraphicsScene & scene,
const DocumentModelCoords & modelCoords,
const DocumentModelGuideline & modelGuideline,
const Transformation & transformation,
const QPointF & posClickScreen )

Constructor with individual coordinates.

Definition at line 18 of file CentipedeSegmentConstantTRadial.cpp.

22 :
26{
27 // Compute basis vectors that are used here and when by any callback(s)
28 QPointF posOriginGraph (0, 0);
29 if (modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
30 posOriginGraph = QPointF (0, modelCoords.originRadius());
31 }
32
33 QPointF posOriginScreen;
34 transformation.transformRawGraphToScreen (posOriginGraph,
35 posOriginScreen);
36
37 CentipedeEndpointsPolar endpoints (modelCoords,
41 posOriginScreen);
42
43 endpoints.posScreenConstantTForRHighLow (modelGuideline.creationCircleRadius(),
44 m_posLow,
45 m_posHigh);
46
47 m_graphicsItem = new QGraphicsLineItem (QLineF (m_posLow,
48 m_posHigh));
49 m_graphicsItemRelay = new GraphicsLineItemRelay (this,
50 m_graphicsItem);
51
52 QColor color (ColorPaletteToQColor (modelGuideline.lineColor()));
53
54 m_graphicsItem->setPen (QPen (color,
55 modelGuideline.lineWidthActive ()));
56
57 scene.addItem (m_graphicsItem);
58}
@ COORD_SCALE_LOG
Definition CoordScale.h:14
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.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
double originRadius() const
Get method for origin radius in polar mode.

◆ ~CentipedeSegmentConstantTRadial()

CentipedeSegmentConstantTRadial::~CentipedeSegmentConstantTRadial ( )
virtual

Definition at line 60 of file CentipedeSegmentConstantTRadial.cpp.

61{
62 delete m_graphicsItem;
63 delete m_graphicsItemRelay;
64}

Member Function Documentation

◆ distanceToClosestEndpoint()

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

Return distance to closest endpoint.

Implements CentipedeSegmentAbstract.

Definition at line 66 of file CentipedeSegmentConstantTRadial.cpp.

67{
68 double distanceLow = magnitude (posScreen - m_posLow);
69 double distanceHigh = magnitude (posScreen - m_posHigh);
70
71 return qMin (distanceLow, distanceHigh);
72}
double magnitude(const QPointF &vec)
Norm of vector.
Definition mmsubs.cpp:193

◆ signalUpdateEndpoints

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

Send new geometry for later updating.

◆ updateRadius()

void CentipedeSegmentConstantTRadial::updateRadius ( double radius)
virtual

Update geometry to reflect cursor movement.

Implements CentipedeSegmentAbstract.

Definition at line 74 of file CentipedeSegmentConstantTRadial.cpp.

75{
76 // Scale up/down the line segment length, keeping it centered on the same center point
77 QPointF posCenter = (m_posHigh + m_posLow) / 2.0;
78 QPointF delta = m_posHigh - m_posLow;
79 double radiusInitial = magnitude (delta) / 2.0; // Convert from diameter to radius
80 double scaling = radius / radiusInitial;
81 QPointF posLow = posCenter - scaling / 2.0 * delta;
82 QPointF posHigh = posCenter + scaling / 2.0 * delta;
83
84 // Update geometry but only after the event handler currently on the stack has disappeared.
85 // This means sending a signal instead of calling QGraphicsLineItem::setLine directly
86 emit signalUpdateEndpoints (posLow,
87 posHigh);
88}
void signalUpdateEndpoints(QPointF start, QPointF end)
Send new geometry for later updating.

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