Engauge Digitizer  2
Checker.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef CHECKER_H
8 #define CHECKER_H
9 
10 #include "CheckerMode.h"
11 #include "DocumentAxesPointsRequired.h"
12 #include "GridLine.h"
13 #include "GridLines.h"
14 #include <QColor>
15 #include <QList>
16 #include <QPainterPath>
17 #include <QPolygonF>
18 
21 class Point;
22 class QGraphicsEllipseItem;
23 class QGraphicsItem;
24 class QGraphicsScene;
25 class QPolygonF;
26 class Transformation;
27 
33 class Checker
34 {
35 public:
37  Checker(QGraphicsScene &scene);
38  virtual ~Checker ();
39 
43  void prepareForDisplay (const QPolygonF &polygon,
44  int pointRadius,
45  const DocumentModelAxesChecker &modelAxesChecker,
46  const DocumentModelCoords &modelCoords,
47  DocumentAxesPointsRequired documentAxesPointsRequired);
48 
51  void prepareForDisplay (const QList<Point> &Points,
52  int pointRadius,
53  const DocumentModelAxesChecker &modelAxesChecker,
54  const DocumentModelCoords &modelCoords,
55  const Transformation &transformation,
56  DocumentAxesPointsRequired documentAxesPointsRequired);
57 
59  void setVisible (bool visible);
60 
63  virtual void updateModelAxesChecker (const DocumentModelAxesChecker &modelAxesChecker);
64 
65 private:
66  Checker();
67 
68  // For polar coordinates, pick the smallest angle range. Note that xMax may be less than xMin, in which case
69  // xMax+period should be used. Ymin is also set to zero for polar coordinates
70  void adjustPolarAngleRanges (const DocumentModelCoords &modelCoords,
71  const Transformation &transformation,
72  const QList<Point> &points,
73  double &xMin,
74  double &xMax,
75  double &yMin) const;
76 
77  // Low level routine to set line color
78  void setLineColor (GridLine &gridLine,
79  const QPen &pen);
80 
81  QGraphicsScene &m_scene;
82 
83  // These grid lines are QGraphicsLineItem line segments or QGraphicsEllipseItem arc segments. Together they
84  // make up a box (cartesian) or annular (polar) shape in cartesian coordinates.
85  //
86  // A major complication is that drawing the box with just four lines from corner to corner results in extremely
87  // thick lines through the axes points, which obscures the axis point unacceptably. So, each side is drawn with
88  // up to 3 visible lines:
89  // 1) corner1 to either point1 or corner2 (whichever comes first)
90  // 2) unused, or point1 to either point2 or corner2 (whichever comes first)
91  // 3) unused point2 to corner2
92  GridLines m_gridLines;
93 };
94 
95 #endif // CHECKER_H
virtual void updateModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Apply the new DocumentModelAxesChecker, to the points already associated with this object...
Definition: Checker.cpp:251
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:25
Box shape that is drawn through the three axis points, to temporarily (usually) or permanently (rarel...
Definition: Checker.h:33
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:134
Affine transformation between screen and graph coordinates, based on digitized axis points...
Container class for GridLine objects.
Definition: GridLines.h:18
Model for DlgSettingsCoords and CmdSettingsCoords.
Model for DlgSettingsAxesChecker and CmdSettingsAxesChecker.
void setVisible(bool visible)
Show/hide this axes checker.
Definition: Checker.cpp:246
Single grid line drawn a straight or curved line.
Definition: GridLine.h:20