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