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

Class for collecting and then displaying debug information computed during constant R ellipse calculations. More...

#include <CentipedeDebugPolar.h>

Collaboration diagram for CentipedeDebugPolar:
Collaboration graph

Public Member Functions

 CentipedeDebugPolar ()
 Default constructor with initial values overwritten later.
 CentipedeDebugPolar (const QPointF &posScreenParallelogramTL, const QPointF &posScreenParallelogramTR, const QPointF &posScreenParallelogramBL, const QPointF &posScreenParallelogramBR, double angleGraphAxisFromScreenAxis, double angleEllipseFromMajorAxis, double aAligned, double bAligned, double radius)
 Constructor with parallelogram (TL=top left, BR=bottom right,...) that circumscribes the ellipse, which gets converted into a right-angle rectangle.
 CentipedeDebugPolar (const CentipedeDebugPolar &other)
 Copy constructor.
CentipedeDebugPolaroperator= (const CentipedeDebugPolar &other)
 Assignment operator.
virtual ~CentipedeDebugPolar ()
double aAligned () const
 Get method for top left corner of rectangle.
double angleEllipseFromMajorAxis () const
 Get method for top left corner of rectangle.
double angleGraphAxisFromScreenAxis () const
 Get method for top left corner of rectangle.
double bAligned () const
 Get method for top left corner of rectangle.
void display (QGraphicsScene &scene, const DocumentModelCoords &modelCoords, const Transformation &transformation)
 Display member variable values on scene.
void dumpEllipseGraphicsItem (const QString &callerMethod, const QGraphicsEllipseItem *ellipse) const
 Dump ellipse grahics item.
QPointF posScreenParallelogramBL () const
 Get method for bottom left corner of rectangle.
QPointF posScreenParallelogramBR () const
 Get method for bottom right corner of rectangle.
QPointF posScreenParallelogramTL () const
 Get method for top left corner of rectangle.
QPointF posScreenParallelogramTR () const
 Get method for top right corner of rectangle.
double radius () const
 Get method for radius.

Detailed Description

Class for collecting and then displaying debug information computed during constant R ellipse calculations.

Definition at line 20 of file CentipedeDebugPolar.h.

Constructor & Destructor Documentation

◆ CentipedeDebugPolar() [1/3]

CentipedeDebugPolar::CentipedeDebugPolar ( )

Default constructor with initial values overwritten later.

Definition at line 21 of file CentipedeDebugPolar.cpp.

21 :
22 m_posScreenParallelogramTL (0, 0),
23 m_posScreenParallelogramTR (0, 0),
24 m_posScreenParallelogramBL (0, 0),
25 m_posScreenParallelogramBR (0, 0),
26 m_angleGraphAxisFromScreenAxis (0),
27 m_angleEllipseFromMajorAxis (0),
28 m_aAligned (0),
29 m_bAligned (0),
30 m_radius (0),
31 m_legendYPos (0)
32{
33}

◆ CentipedeDebugPolar() [2/3]

CentipedeDebugPolar::CentipedeDebugPolar ( const QPointF & posScreenParallelogramTL,
const QPointF & posScreenParallelogramTR,
const QPointF & posScreenParallelogramBL,
const QPointF & posScreenParallelogramBR,
double angleGraphAxisFromScreenAxis,
double angleEllipseFromMajorAxis,
double aAligned,
double bAligned,
double radius )

Constructor with parallelogram (TL=top left, BR=bottom right,...) that circumscribes the ellipse, which gets converted into a right-angle rectangle.

Definition at line 35 of file CentipedeDebugPolar.cpp.

43 :
44 m_posScreenParallelogramTL (posScreenParallelogramTL),
45 m_posScreenParallelogramTR (posScreenParallelogramTR),
46 m_posScreenParallelogramBL (posScreenParallelogramBL),
47 m_posScreenParallelogramBR (posScreenParallelogramBR),
48 m_angleGraphAxisFromScreenAxis (angleGraphAxisFromScreenAxis),
49 m_angleEllipseFromMajorAxis (angleEllipseFromMajorAxis),
50 m_aAligned (aAligned),
51 m_bAligned (bAligned),
52 m_radius (radius),
53 m_legendYPos (0)
54{
55}
QPointF posScreenParallelogramTL() const
Get method for top left corner of rectangle.
double radius() const
Get method for radius.
QPointF posScreenParallelogramBL() const
Get method for bottom left corner of rectangle.
QPointF posScreenParallelogramBR() const
Get method for bottom right corner of rectangle.
double angleGraphAxisFromScreenAxis() const
Get method for top left corner of rectangle.
double aAligned() const
Get method for top left corner of rectangle.
double bAligned() const
Get method for top left corner of rectangle.
double angleEllipseFromMajorAxis() const
Get method for top left corner of rectangle.
QPointF posScreenParallelogramTR() const
Get method for top right corner of rectangle.

◆ CentipedeDebugPolar() [3/3]

CentipedeDebugPolar::CentipedeDebugPolar ( const CentipedeDebugPolar & other)

Copy constructor.

Definition at line 57 of file CentipedeDebugPolar.cpp.

57 :
58 m_posScreenParallelogramTL (other.posScreenParallelogramTL ()),
59 m_posScreenParallelogramTR (other.posScreenParallelogramTR ()),
60 m_posScreenParallelogramBL (other.posScreenParallelogramBL ()),
61 m_posScreenParallelogramBR (other.posScreenParallelogramBR ()),
62 m_angleGraphAxisFromScreenAxis (other.angleGraphAxisFromScreenAxis ()),
63 m_angleEllipseFromMajorAxis (other.angleEllipseFromMajorAxis ()),
64 m_aAligned (other.aAligned ()),
65 m_bAligned (other.bAligned ()),
66 m_radius (other.radius ()),
67 m_legendYPos (0)
68{
69}

◆ ~CentipedeDebugPolar()

CentipedeDebugPolar::~CentipedeDebugPolar ( )
virtual

Definition at line 87 of file CentipedeDebugPolar.cpp.

88{
89}

Member Function Documentation

◆ aAligned()

double CentipedeDebugPolar::aAligned ( ) const

Get method for top left corner of rectangle.

Definition at line 91 of file CentipedeDebugPolar.cpp.

92{
93 return m_aAligned;
94}

◆ angleEllipseFromMajorAxis()

double CentipedeDebugPolar::angleEllipseFromMajorAxis ( ) const

Get method for top left corner of rectangle.

Definition at line 108 of file CentipedeDebugPolar.cpp.

109{
110 return m_angleEllipseFromMajorAxis;
111}

◆ angleGraphAxisFromScreenAxis()

double CentipedeDebugPolar::angleGraphAxisFromScreenAxis ( ) const

Get method for top left corner of rectangle.

Definition at line 113 of file CentipedeDebugPolar.cpp.

114{
115 return m_angleGraphAxisFromScreenAxis;
116}

◆ bAligned()

double CentipedeDebugPolar::bAligned ( ) const

Get method for top left corner of rectangle.

Definition at line 118 of file CentipedeDebugPolar.cpp.

119{
120 return m_bAligned;
121}

◆ display()

void CentipedeDebugPolar::display ( QGraphicsScene & scene,
const DocumentModelCoords & modelCoords,
const Transformation & transformation )

Display member variable values on scene.

Definition at line 123 of file CentipedeDebugPolar.cpp.

126{
127 // LOG4CPP is below
128
130
131 // Center
132 QPointF posOriginGraph (0, 0), posOriginScreen;
133 if (modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
134 posOriginGraph = QPointF (0,
135 modelCoords.originRadius());
136 }
137 transformation.transformRawGraphToScreen (posOriginGraph,
138 posOriginScreen);
139
140 // Circumscribing parallelogram
141 QVector<QPointF> points;
142 points << m_posScreenParallelogramBL;
143 points << m_posScreenParallelogramTL;
144 points << m_posScreenParallelogramTR;
145 points << m_posScreenParallelogramBR;
146 points << m_posScreenParallelogramBL;
147 QGraphicsPolygonItem *parallelogram = new QGraphicsPolygonItem (points);
148 parallelogram->setPen (QPen (Qt::green));
149 addToLegend (scene,
150 QString ("Parallelogram a=%1 b=%2").arg (m_aAligned).arg (m_bAligned),
151 Qt::green);
152 scene.addItem (parallelogram);
153
154 // X axis in circumscribing parallelogram
155 QPointF posAbsolute0 = (m_posScreenParallelogramTR + m_posScreenParallelogramBR) / 2.0;
156 QLineF xAxisLine0 (posOriginScreen,
157 posAbsolute0);
158 QPointF posRelative0 = posAbsolute0 - posOriginScreen;
159 double ang = qDegreesToRadians (45.0);
160 double ca = qCos (ang);
161 double sa = qSin (ang);
162 QLineF xAxisLine45 (posOriginScreen,
163 posOriginScreen + QPointF (ca * posRelative0.x() + sa * posRelative0.y(),
164 -1.0 * sa * posRelative0.x() + ca * posRelative0.y()));
165 QGraphicsLineItem *xAxisParallelogram0 = new QGraphicsLineItem (xAxisLine0);
166 QGraphicsLineItem *xAxisParallelogram45 = new QGraphicsLineItem (xAxisLine45);
167 xAxisParallelogram0->setPen (QPen (Qt::green));
168 xAxisParallelogram45->setPen (QPen (Qt::green));
169 scene.addItem (xAxisParallelogram0);
170 scene.addItem (xAxisParallelogram45);
171
172 // Right-angled rectangle
173 QRectF rect (posOriginScreen.x() - m_aAligned,
174 posOriginScreen.y() - m_bAligned,
175 2 * m_aAligned,
176 2 * m_bAligned);
177 rect.setLeft (posOriginScreen.x() - m_aAligned);
178 rect.setTop (posOriginScreen.y() - m_bAligned);
179
180 // Circumscribing rectangle
181 QGraphicsRectItem *rectItem = new QGraphicsRectItem (rect);
182 rectItem->setTransformOriginPoint(posOriginScreen);
183 rectItem->setRotation (qRadiansToDegrees (m_angleEllipseFromMajorAxis));
184 rectItem->setPen (QPen (Qt::cyan));
185 addToLegend (scene,
186 QString ("Rectangle rotation=%1").arg (qRadiansToDegrees (m_angleEllipseFromMajorAxis)),
187 Qt::cyan);
188 scene.addItem (rectItem);
189
190 // X axis in circumscribing rectangle. Without screen-to-ellipse rotation this would be horizontal
191 QLineF xAxisRectangle (posOriginScreen,
192 (rect.topRight() + rect.bottomRight()) / 2.0);
193 QGraphicsLineItem *xAxisRect = new QGraphicsLineItem (xAxisRectangle);
194 xAxisRect->setTransformOriginPoint (posOriginScreen);
195 xAxisRect->setRotation (m_angleGraphAxisFromScreenAxis);
196 xAxisRect->setPen (QPen (Qt::cyan));
197 scene.addItem (xAxisRect);
198
199 // Put an ellipse in the circumscribing rectangle to see if they line up
200 QGraphicsEllipseItem *ellipse = new QGraphicsEllipseItem (rect);
201 ellipse->setTransformOriginPoint (posOriginScreen);
202 ellipse->setRotation (qRadiansToDegrees (m_angleGraphAxisFromScreenAxis));
203 ellipse->setPen (QPen (Qt::red));
204 scene.addItem (ellipse);
205
206 // A and B axes. These are NOT orthogonal when there is shear
207 QPointF posAAxisGraph (0, m_radius), posBAxisGraph (90, m_radius);
208 QPointF posAAxisScreen, posBAxisScreen;
209 transformation.transformRawGraphToScreen (posAAxisGraph,
210 posAAxisScreen);
211 transformation.transformRawGraphToScreen (posBAxisGraph,
212 posBAxisScreen);
213
214 displayTics (scene,
215 transformation,
216 posOriginScreen,
217 posAAxisScreen,
218 QColor (255, 0, 0),
219 QColor (255, 150, 150));
220
221 // Finish up with details in log stream
222 LOG4CPP_DEBUG_S ((*mainCat)) << "CentipedeDebugPolar::displayTics"
223 << " angleFromAxis=" << qDegreesToRadians (m_angleEllipseFromMajorAxis)
224 << " angleFromScreen=" << qDegreesToRadians (m_angleGraphAxisFromScreenAxis);
225 }
226}
@ COORD_SCALE_LOG
Definition CoordScale.h:14
log4cpp::Category * mainCat
Definition Logger.cpp:14
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
double originRadius() const
Get method for origin radius in polar mode.
void transformRawGraphToScreen(const QPointF &pointRaw, QPointF &pointScreen) const
Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinate...
Priority::Value getPriority() const
Returns unused priority.
Definition Category.cpp:19
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ dumpEllipseGraphicsItem()

void CentipedeDebugPolar::dumpEllipseGraphicsItem ( const QString & callerMethod,
const QGraphicsEllipseItem * ellipse ) const

Dump ellipse grahics item.

This is expected to be called just after all geometry settings for a QGraphicsEllipseItem have been completed in the Centipede code, and later in the Guideline code, so they can be compared when there is a problem. The broken code is adjusted to produce the values of the good ellipse (assuming there is one)

Definition at line 310 of file CentipedeDebugPolar.cpp.

312{
314
315 LOG4CPP_DEBUG_S ((*mainCat)) << "CentipedeDebugPolar::dumpEllipseGraphicsItem dump from "
316 << callerMethod.toLatin1().data();
317 LOG4CPP_DEBUG_S ((*mainCat)) << " rect=" << QRectFToString (ellipse->rect()).toLatin1().data();
318 LOG4CPP_DEBUG_S ((*mainCat)) << " rotation=" << ellipse->rotation();
319 LOG4CPP_DEBUG_S ((*mainCat)) << " start=" << (ellipse->startAngle() / 16.0);
320 LOG4CPP_DEBUG_S ((*mainCat)) << " span=" << (ellipse->spanAngle() / 16.0);
321 LOG4CPP_DEBUG_S ((*mainCat)) << " transformOrigin=" << QPointFToString (ellipse->transformOriginPoint()).toLatin1().data();
322 LOG4CPP_DEBUG_S ((*mainCat)) << " pos=" << QPointFToString (ellipse->pos ()).toLatin1().data();
323 LOG4CPP_DEBUG_S ((*mainCat)) << " radius=" << m_radius;
324 }
325}
QString QPointFToString(const QPointF &pos)
QString QRectFToString(const QRectF &rectF)

◆ operator=()

CentipedeDebugPolar & CentipedeDebugPolar::operator= ( const CentipedeDebugPolar & other)

Assignment operator.

Definition at line 71 of file CentipedeDebugPolar.cpp.

72{
73 m_posScreenParallelogramTL = other.posScreenParallelogramTL ();
74 m_posScreenParallelogramTR = other.posScreenParallelogramTR ();
75 m_posScreenParallelogramBL = other.posScreenParallelogramBL ();
76 m_posScreenParallelogramBR = other.posScreenParallelogramBR ();
77 m_angleGraphAxisFromScreenAxis = other.angleGraphAxisFromScreenAxis ();
78 m_angleEllipseFromMajorAxis = other.angleEllipseFromMajorAxis ();
79 m_aAligned = other.aAligned ();
80 m_bAligned = other.bAligned ();
81 m_radius = other.radius ();
82 m_legendYPos = 0;
83
84 return *this;
85}

◆ posScreenParallelogramBL()

QPointF CentipedeDebugPolar::posScreenParallelogramBL ( ) const

Get method for bottom left corner of rectangle.

Definition at line 347 of file CentipedeDebugPolar.cpp.

348{
349 return m_posScreenParallelogramBL;
350}

◆ posScreenParallelogramBR()

QPointF CentipedeDebugPolar::posScreenParallelogramBR ( ) const

Get method for bottom right corner of rectangle.

Definition at line 352 of file CentipedeDebugPolar.cpp.

353{
354 return m_posScreenParallelogramBR;
355}

◆ posScreenParallelogramTL()

QPointF CentipedeDebugPolar::posScreenParallelogramTL ( ) const

Get method for top left corner of rectangle.

Definition at line 357 of file CentipedeDebugPolar.cpp.

358{
359 return m_posScreenParallelogramTL;
360}

◆ posScreenParallelogramTR()

QPointF CentipedeDebugPolar::posScreenParallelogramTR ( ) const

Get method for top right corner of rectangle.

Definition at line 362 of file CentipedeDebugPolar.cpp.

363{
364 return m_posScreenParallelogramTR;
365}

◆ radius()

double CentipedeDebugPolar::radius ( ) const

Get method for radius.

Definition at line 367 of file CentipedeDebugPolar.cpp.

368{
369 return m_radius;
370}

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