Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
Checker.h
1 #ifndef CHECKER_H
2 #define CHECKER_H
3 
4 #include "CheckerMode.h"
5 #include <QColor>
6 #include <QList>
7 #include <QPainterPath>
8 #include <QPolygonF>
9 
12 class Point;
13 class QGraphicsEllipseItem;
14 class QGraphicsItem;
15 class QGraphicsScene;
16 class QPolygonF;
17 class Transformation;
18 
19 typedef QList<QGraphicsItem *> SideSegments;
20 
28 class Checker
29 {
30 public:
32  Checker(QGraphicsScene &scene);
33 
37  void prepareForDisplay (const QPolygonF &polygon,
38  int pointRadius,
39  const DocumentModelAxesChecker &modelAxesChecker,
40  const DocumentModelCoords &modelCoords);
41 
44  void prepareForDisplay (const QList<Point> &Points,
45  int pointRadius,
46  const DocumentModelAxesChecker &modelAxesChecker,
47  const DocumentModelCoords &modelCoords,
48  const Transformation &transformation);
49 
51  void setVisible (bool visible);
52 
55  virtual void updateModelAxesChecker (const DocumentModelAxesChecker &modelAxesChecker);
56 
57 private:
58  Checker();
59 
60  // For polar coordinates, pick the smallest angle range. Note that xMax may be less than xMin, in which case
61  // xMax+period should be used. Ymin is also set to zero for polar coordinates
62  void adjustPolarAngleRanges (const DocumentModelCoords &modelCoords,
63  const Transformation &transformation,
64  const QList<Point> &points,
65  double &xMin,
66  double &xMax,
67  double &yMin) const;
68  void bindItemToScene(QGraphicsItem *item) const;
69 
70  // Create side, either along constant X/theta or constant Y/radius side. Line goes from pointFromGraph to pointToGraph.
71  // If the coordinates are polar, we go clockwise from pointFromGraph to pointToGraph (as set up by adjustPolarAngleRange).
72  void createSide (int pointRadius,
73  const QList<Point> &points,
74  const DocumentModelCoords &modelCoords,
75  double xFrom,
76  double yFrom,
77  double xTo,
78  double yTo,
79  const Transformation &transformation,
80  SideSegments &sideSegments);
81  void createTransformAlign (const Transformation &transformation,
82  double radiusLinearCartesian,
83  const QPointF &posOriginScreen,
84  QTransform &transformAlign,
85  double &ellipseXAxis,
86  double &ellipseYAxis) const;
87  void deleteSide (SideSegments &sideSegments);
88  QGraphicsItem *ellipseItem(const Transformation &transformation,
89  double radiusLinearCartesian,
90  const QPointF &posStartScreen,
91  const QPointF &posEndScreen) const;
92  void finishActiveSegment (const DocumentModelCoords &modelCoords,
93  const QPointF &posStartScreen,
94  const QPointF &posEndScreen,
95  double yFrom,
96  double yTo,
97  const Transformation &transformation,
98  SideSegments &sideSegments) const;
99  QGraphicsItem *lineItem (const QPointF &posStartScreen,
100  const QPointF &posEndScreen) const;
101  double minScreenDistanceFromPoints (const QPointF &posScreen,
102  const QList<Point> &points);
103 
104  // Low level routine to set line color
105  void setLineColor (SideSegments &sideSegments,
106  const QPen &pen);
107 
108  void setVisibleSide (SideSegments &sideSegments,
109  bool visible);
110 
111  QGraphicsScene &m_scene;
112 
113  // These segments are QGraphicsLineItem line segments or QGraphicsEllipseItem arc segments. Together they
114  // make up a box shape in cartesian coordinates.
115  //
116  // A major complication is that drawing the box with just four lines from corner to corner results in extremely
117  // thick lines through the axes points, which obscures the axis point unacceptably. So, each side is drawn with
118  // up to 3 visible lines:
119  // 1) corner1 to either point1 or corner2 (whichever comes first)
120  // 2) unused, or point1 to either point2 or corner2 (whichever comes first)
121  // 3) unused point2 to corner2
122  SideSegments m_sideLeft;
123  SideSegments m_sideTop;
124  SideSegments m_sideRight;
125  SideSegments m_sideBottom;
126 };
127 
128 #endif // CHECKER_H
virtual void updateModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Apply the new DocumentModelAxesChecker, to the points already associated with this object...
Definition: Checker.cpp:554
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:17
Box shape that is drawn through the three axis points, to temporarily (usually) or permanently (rarel...
Definition: Checker.h:28
Affine transformation between screen and graph coordinates, based on digitized axis points...
Model for DlgSettingsCoords and CmdSettingsCoords.
Model for DlgSettingsAxesChecker and CmdSettingsAxesChecker.
void setVisible(bool visible)
Show/hide this axes checker.
Definition: Checker.cpp:535
void prepareForDisplay(const QPolygonF &polygon, int pointRadius, const DocumentModelAxesChecker &modelAxesChecker, const DocumentModelCoords &modelCoords)
Create the polygon from current information, including pixel coordinates, just prior to display...
Definition: Checker.cpp:432