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

Box shape that is drawn through the three axis points, to temporarily (usually) or permanently (rarely) highlight the local up/down/left/right directions when all axis points have been defined. More...

#include <Checker.h>

Collaboration diagram for Checker:
Collaboration graph

Public Member Functions

 Checker (QGraphicsScene &scene)
 Single constructor for DlgSettingsAxesChecker, which does not have an explicit transformation. The identity transformation is assumed.
virtual ~Checker ()
void prepareForDisplay (const QPolygonF &polygon, int pointRadius, const DocumentModelAxesChecker &modelAxesChecker, const DocumentModelCoords &modelCoords, DocumentAxesPointsRequired documentAxesPointsRequired)
 Create the polygon from current information, including pixel coordinates, just prior to display.
void prepareForDisplay (const QList< Point > &Points, int pointRadius, const DocumentModelAxesChecker &modelAxesChecker, const DocumentModelCoords &modelCoords, const Transformation &transformation, DocumentAxesPointsRequired documentAxesPointsRequired)
 Create the polygon from current information, including pixel and graph coordinates, just prior to display.
void setVisible (bool visible)
 Show/hide this axes checker.
virtual void updateModelAxesChecker (const DocumentModelAxesChecker &modelAxesChecker)
 Apply the new DocumentModelAxesChecker, to the points already associated with this object.

Detailed Description

Box shape that is drawn through the three axis points, to temporarily (usually) or permanently (rarely) highlight the local up/down/left/right directions when all axis points have been defined.

The goal of the checker is to make it obvious when a mistake has happened so the screen-to-graph transformation is currently wrong - since the expected up/down/left/right directions will be awry which will distort the checker somehow. Unfortunately, errors in scale are not revealed by the checker.

Definition at line 33 of file Checker.h.

Constructor & Destructor Documentation

◆ Checker()

Checker::Checker ( QGraphicsScene & scene)

Single constructor for DlgSettingsAxesChecker, which does not have an explicit transformation. The identity transformation is assumed.

Definition at line 34 of file Checker.cpp.

34 :
35 m_scene (scene)
36{
37}

◆ ~Checker()

Checker::~Checker ( )
virtual

Definition at line 39 of file Checker.cpp.

40{
41 m_gridLines.clear ();
42}

Member Function Documentation

◆ prepareForDisplay() [1/2]

void Checker::prepareForDisplay ( const QList< Point > & Points,
int pointRadius,
const DocumentModelAxesChecker & modelAxesChecker,
const DocumentModelCoords & modelCoords,
const Transformation & transformation,
DocumentAxesPointsRequired documentAxesPointsRequired )

Create the polygon from current information, including pixel and graph coordinates, just prior to display.

This is for TransformationStateDefined. The point radius is used to exclude the lines from the axes points for clarity

Definition at line 173 of file Checker.cpp.

179{
180 LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay "
181 << " transformation=" << transformation;
182
183 ENGAUGE_ASSERT ((points.count () == NUM_AXES_POINTS_2) ||
184 (points.count () == NUM_AXES_POINTS_3) ||
185 (points.count () == NUM_AXES_POINTS_4));
186
187 // Remove previous lines
188 m_gridLines.clear ();
189
190 bool fourPoints = (documentAxesPointsRequired == DOCUMENT_AXES_POINTS_REQUIRED_4);
191
192 // Get the min and max of x and y. We initialize yTo to prevent compiler warning
193 double xFrom = 0, xTo = 0, yFrom = 0, yTo = 0;
194 int i;
195 bool firstX = true;
196 bool firstY = true;
197 for (i = 0; i < points.count(); i++) {
198 if (!fourPoints || (points.at(i).isXOnly() && fourPoints)) {
199
200 // X coordinate is defined
201 if (firstX) {
202 xFrom = points.at(i).posGraph().x();
203 xTo = points.at(i).posGraph().x();
204 firstX = false;
205 } else {
206 xFrom = qMin (xFrom, points.at(i).posGraph().x());
207 xTo = qMax (xTo , points.at(i).posGraph().x());
208 }
209 }
210
211 if (!fourPoints || (!points.at(i).isXOnly() && fourPoints)) {
212
213 // Y coordinate is defined
214 if (firstY) {
215 yFrom = points.at(i).posGraph().y();
216 yTo = points.at(i).posGraph().y();
217 firstY = false;
218 } else {
219 yFrom = qMin (yFrom, points.at(i).posGraph().y());
220 yTo = qMax (yTo , points.at(i).posGraph().y());
221 }
222 }
223 }
224
225 // Min and max of angles needs special processing since periodicity introduces some ambiguity. This is a noop for rectangular coordinates
226 // and for polar coordinates when periodicity is not an issue
227 adjustPolarAngleRanges (modelCoords,
228 transformation,
229 points,
230 xFrom,
231 xTo,
232 yFrom);
233
234 // Draw the bounding box as four sides. In polar plots the bottom side is zero-length, with pie shape resulting
235 GridLineFactory factory (m_scene,
236 pointRadius,
237 points,
238 modelCoords);
239 m_gridLines.add (factory.createGridLine (xFrom, yFrom, xFrom, yTo , transformation));
240 m_gridLines.add (factory.createGridLine (xFrom, yTo , xTo , yTo , transformation));
241 m_gridLines.add (factory.createGridLine (xTo , yTo , xTo , yFrom, transformation));
242 m_gridLines.add (factory.createGridLine (xTo , yFrom, xFrom, yFrom, transformation));
243
244 updateModelAxesChecker (modelAxesChecker);
245}
const int NUM_AXES_POINTS_2
Definition Checker.cpp:23
const int NUM_AXES_POINTS_4
Definition Checker.cpp:25
const int NUM_AXES_POINTS_3
Definition Checker.cpp:24
@ DOCUMENT_AXES_POINTS_REQUIRED_4
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
log4cpp::Category * mainCat
Definition Logger.cpp:14
virtual void updateModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Apply the new DocumentModelAxesChecker, to the points already associated with this object.
Definition Checker.cpp:252
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ prepareForDisplay() [2/2]

void Checker::prepareForDisplay ( const QPolygonF & polygon,
int pointRadius,
const DocumentModelAxesChecker & modelAxesChecker,
const DocumentModelCoords & modelCoords,
DocumentAxesPointsRequired documentAxesPointsRequired )

Create the polygon from current information, including pixel coordinates, just prior to display.

This is for DlgSettingsAxesChecker. The identity matrix is used for the transformations between screen and graph coordinates. The point radius is used to exclude the lines from the axes points for clarity

Definition at line 135 of file Checker.cpp.

140{
141 LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay";
142
143 ENGAUGE_ASSERT ((polygon.count () == NUM_AXES_POINTS_2) ||
144 (polygon.count () == NUM_AXES_POINTS_3) ||
145 (polygon.count () == NUM_AXES_POINTS_4));
146
147 // Convert pixel coordinates in QPointF to screen and graph coordinates in Point using
148 // identity transformation, so this routine can reuse computations provided by Transformation
149 QList<Point> points;
150 QPolygonF::const_iterator itr;
151 for (itr = polygon.begin (); itr != polygon.end (); itr++) {
152
153 const QPointF &pF = *itr;
154
155 Point p (DUMMY_CURVE_NAME,
156 pF,
157 pF,
158 false);
159 points.push_back (p);
160 }
161
162 // Screen and graph coordinates are treated as the same, so identity transform is used
163 Transformation transformIdentity;
164 transformIdentity.identity();
165 prepareForDisplay (points,
166 pointRadius,
167 modelAxesChecker,
168 modelCoords,
169 transformIdentity,
170 documentAxesPointsRequired);
171}
const QString DUMMY_CURVE_NAME
void prepareForDisplay(const QPolygonF &polygon, int pointRadius, const DocumentModelAxesChecker &modelAxesChecker, const DocumentModelCoords &modelCoords, DocumentAxesPointsRequired documentAxesPointsRequired)
Create the polygon from current information, including pixel coordinates, just prior to display.
Definition Checker.cpp:135
void identity()
Identity transformation.

◆ setVisible()

void Checker::setVisible ( bool visible)

Show/hide this axes checker.

Definition at line 247 of file Checker.cpp.

248{
249 m_gridLines.setVisible (visible);
250}

◆ updateModelAxesChecker()

void Checker::updateModelAxesChecker ( const DocumentModelAxesChecker & modelAxesChecker)
virtual

Apply the new DocumentModelAxesChecker, to the points already associated with this object.

This method starts the timer unless the mode is never or forever

Definition at line 252 of file Checker.cpp.

253{
254 QColor color = ColorPaletteToQColor (modelAxesChecker.lineColor());
255 QPen pen (QBrush (color), CHECKER_POINTS_WIDTH);
256
257 m_gridLines.setPen (pen);
258}
const int CHECKER_POINTS_WIDTH
Definition Checker.cpp:32
QColor ColorPaletteToQColor(ColorPalette color)
Definition EnumsToQt.cpp:16
ColorPalette lineColor() const
Get method for line color.

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