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 
42  void prepareForDisplay (const QPolygonF &polygon,
43  int pointRadius,
44  const DocumentModelAxesChecker &modelAxesChecker,
45  const DocumentModelCoords &modelCoords,
46  DocumentAxesPointsRequired documentAxesPointsRequired);
47 
50  void prepareForDisplay (const QList<Point> &Points,
51  int pointRadius,
52  const DocumentModelAxesChecker &modelAxesChecker,
53  const DocumentModelCoords &modelCoords,
54  const Transformation &transformation,
55  DocumentAxesPointsRequired documentAxesPointsRequired);
56 
58  void setVisible (bool visible);
59 
62  virtual void updateModelAxesChecker (const DocumentModelAxesChecker &modelAxesChecker);
63 
64 private:
65  Checker();
66 
67  // For polar coordinates, pick the smallest angle range. Note that xMax may be less than xMin, in which case
68  // xMax+period should be used. Ymin is also set to zero for polar coordinates
69  void adjustPolarAngleRanges (const DocumentModelCoords &modelCoords,
70  const Transformation &transformation,
71  const QList<Point> &points,
72  double &xMin,
73  double &xMax,
74  double &yMin) const;
75 
76  // Low level routine to set line color
77  void setLineColor (GridLine &gridLine,
78  const QPen &pen);
79 
80  QGraphicsScene &m_scene;
81 
82  // These grid lines are QGraphicsLineItem line segments or QGraphicsEllipseItem arc segments. Together they
83  // make up a box (cartesian) or annular (polar) shape in cartesian coordinates.
84  //
85  // A major complication is that drawing the box with just four lines from corner to corner results in extremely
86  // thick lines through the axes points, which obscures the axis point unacceptably. So, each side is drawn with
87  // up to 3 visible lines:
88  // 1) corner1 to either point1 or corner2 (whichever comes first)
89  // 2) unused, or point1 to either point2 or corner2 (whichever comes first)
90  // 3) unused point2 to corner2
91  GridLines m_gridLines;
92 };
93 
94 #endif // CHECKER_H
virtual void updateModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Apply the new DocumentModelAxesChecker, to the points already associated with this object...
Definition: Checker.cpp:247
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:23
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:130
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:242
Single grid line drawn a straight or curved line.
Definition: GridLine.h:20