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

Enable postponed geometry changes for GraphicsArcItem, using a signal to trigger this class to update its associated GraphicsArcItem instance. More...

#include <GraphicsArcItemRelay.h>

Inheritance diagram for GraphicsArcItemRelay:
Inheritance graph
Collaboration diagram for GraphicsArcItemRelay:
Collaboration graph

Public Slots

void slotUpdateAngles (QPointF posTangentialLow, QPointF posTangentialCenter, QPointF posTangentialHigh, double widthToHeight, double scaling)
 Slot inputs to QGraphicsEllipseItem::setStartAngle and QGraphicsEllipseItem::setSpanAngle.

Public Member Functions

 GraphicsArcItemRelay (QObject *caller, GraphicsArcItem *graphicsItem)
 Single constructor with associated GraphicsArcItem.
virtual ~GraphicsArcItemRelay ()

Detailed Description

Enable postponed geometry changes for GraphicsArcItem, using a signal to trigger this class to update its associated GraphicsArcItem instance.

By postponing geometry updates locally, this class simplifies the calling code which can invoked while an event handler is on the stack. Updating QGraphicsEllipseItem geometry while an event handler is on the stack is not good software design

Definition at line 21 of file GraphicsArcItemRelay.h.

Constructor & Destructor Documentation

◆ GraphicsArcItemRelay()

GraphicsArcItemRelay::GraphicsArcItemRelay ( QObject * caller,
GraphicsArcItem * graphicsItem )

Single constructor with associated GraphicsArcItem.

Definition at line 19 of file GraphicsArcItemRelay.cpp.

20 :
21 m_graphicsItem (graphicsItem)
22{
23 // Queue for later by including Qt::QueuedConnection
24 connect (caller, SIGNAL (signalUpdateAngles (QPointF, QPointF, QPointF, double, double)),
25 this, SLOT (slotUpdateAngles (QPointF, QPointF, QPointF, double, double)),
26 Qt::QueuedConnection);
27}
void slotUpdateAngles(QPointF posTangentialLow, QPointF posTangentialCenter, QPointF posTangentialHigh, double widthToHeight, double scaling)
Slot inputs to QGraphicsEllipseItem::setStartAngle and QGraphicsEllipseItem::setSpanAngle.

◆ ~GraphicsArcItemRelay()

GraphicsArcItemRelay::~GraphicsArcItemRelay ( )
virtual

Definition at line 29 of file GraphicsArcItemRelay.cpp.

30{
31 // Calling code is responsible for deallocating graphics item
32}

Member Function Documentation

◆ slotUpdateAngles

void GraphicsArcItemRelay::slotUpdateAngles ( QPointF posTangentialLow,
QPointF posTangentialCenter,
QPointF posTangentialHigh,
double widthToHeight,
double scaling )
slot

Slot inputs to QGraphicsEllipseItem::setStartAngle and QGraphicsEllipseItem::setSpanAngle.

Definition at line 34 of file GraphicsArcItemRelay.cpp.

39{
40 // Rotate into ellipse reference frame (where x and y axis are aligned with
41 // semimajor/semiminor axes. The QTransform supplied by m_graphicsItem is
42 // just the identity transform and therefore not useful
43 double angleRotation = -1.0 * m_graphicsItem->rotation();
44 QTransform rotateTransform;
45 rotateTransform.rotate (angleRotation);
46 QPointF posLowInEllipseFrame = rotateTransform.map (posTangentialLow);
47 QPointF posCenterInEllipseFrame = rotateTransform.map (posTangentialCenter);
48 QPointF posHighInEllipseFrame = rotateTransform.map (posTangentialHigh);
49
50 // Compensate for y scale being different than x scale using widthToHeight
51 double angleLow = -1.0 * qAtan2 (posLowInEllipseFrame.y() * widthToHeight,
52 posLowInEllipseFrame.x());
53 double angleCenter = -1.0 * qAtan2 (posCenterInEllipseFrame.y() * widthToHeight,
54 posCenterInEllipseFrame.x());
55 double angleHigh = -1.0 * qAtan2 (posHighInEllipseFrame.y() * widthToHeight,
56 posHighInEllipseFrame.x());
57
58 int lowTics = (int) (RADIANS_TO_TICS * (angleCenter + scaling * (angleLow - angleCenter)));
59 int highTics = (int) (RADIANS_TO_TICS * (angleCenter + scaling * (angleHigh - angleCenter)));
60
61 m_graphicsItem->setStartAngle (lowTics);
62 m_graphicsItem->setSpanAngle (highTics - lowTics);
63}
const double RADIANS_TO_TICS

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