Engauge Digitizer  2
GraphicsPoint.h
Go to the documentation of this file.
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 GRAPHICS_POINT_H
8 #define GRAPHICS_POINT_H
9 
11 #include <QColor>
12 #include <QPointF>
13 #include <QRectF>
14 
15 extern const double DEFAULT_HIGHLIGHT_OPACITY;
16 extern const double MAX_OPACITY;
17 
18 class CurveStyle;
19 class GeometryWindow;
22 class PointStyle;
23 class QColor;
24 class QGraphicsScene;
25 class QPolygonF;
26 class QTextStream;
27 class QVariant;
28 
44 {
45 public:
47  GraphicsPoint(QGraphicsScene &scene,
48  const QString &identifier,
49  const QPointF &posScreen,
50  const QColor &color,
51  unsigned int radius,
52  double lineWidth,
53  GeometryWindow *geometryWindow);
54 
56  GraphicsPoint(QGraphicsScene &scene,
57  const QString &identifier,
58  const QPointF &posScreen,
59  const QColor &color,
60  const QPolygonF &polygon,
61  double lineWidth,
62  GeometryWindow *geometryWindow);
63 
65  ~GraphicsPoint ();
66 
68  QRectF boundingRect () const;
69 
71  QVariant data (int key) const;
72 
74  double highlightOpacity () const;
75 
77  QPointF pos () const;
78 
80  void printStream (QString indentation,
81  QTextStream &str,
82  double ordinalKey) const;
83 
85  void reset();
86 
88  void setData (int key, const QVariant &data);
89 
92 
94  void setPointStyle (const PointStyle &pointStyle);
95 
97  void setPos (const QPointF pos);
98 
100  void setPassive ();
101 
103  void setWanted ();
104 
106  void updateCurveStyle (const CurveStyle &curveStyle);
107 
109  bool wanted () const;
110 
111 private:
112  GraphicsPoint();
113 
114  void createPointEllipse (unsigned int radius); // Attributes shared by circle and polygon points are passed through member variables
115  void createPointPolygon (const QPolygonF &polygon); // Attributes shared by circle and polygon points are passed through member variables
116 
117  QGraphicsScene &m_scene;
118 
119  // Ellipse graphics items. Unused if point is polygonal.
120  GraphicsPointEllipse *m_graphicsItemEllipse;
121  GraphicsPointEllipse *m_shadowZeroWidthEllipse; // Shadow item overlays the superclass instance to ensure visibility
122 
123  // Polygon graphics items. Unused if point is elliptical.
124  GraphicsPointPolygon *m_graphicsItemPolygon;
125  GraphicsPointPolygon *m_shadowZeroWidthPolygon; // Shadow item overlays the superclass instance to ensure visibility
126 
127  // Shared attributes
128  const QString m_identifier;
129  const QPointF m_posScreen;
130  const QColor m_color;
131  double m_lineWidth;
132 
133  // Housekeeping
134  bool m_wanted;
135 
136  double m_highlightOpacity;
137 
138  GeometryWindow *m_geometryWindow; // Can receive hover signals. Null if unused
139 };
140 
141 #endif // GRAPHICS_POINT_H
GraphicsPoint::setWanted
void setWanted()
Mark point as wanted. Marking as unwanted is done by the reset function.
Definition: GraphicsPoint.cpp:351
GraphicsPoint::data
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
Definition: GraphicsPoint.cpp:201
GraphicsPoint::printStream
void printStream(QString indentation, QTextStream &str, double ordinalKey) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: GraphicsPoint.cpp:224
GraphicsPoint::setPassive
void setPassive()
Prevent automatic focus on point (=make it passive) for scale bar so drags can be made to work proper...
Definition: GraphicsPoint.cpp:281
GraphicsPoint::setPointStyle
void setPointStyle(const PointStyle &pointStyle)
Update the point style.
Definition: GraphicsPoint.cpp:294
GraphicsPoint::wanted
bool wanted() const
Identify point as wanted//unwanted.
Definition: GraphicsPoint.cpp:361
GraphicsPoint::~GraphicsPoint
~GraphicsPoint()
Destructor. This remove the graphics item from the scene.
Definition: GraphicsPoint.cpp:85
GraphicsPointAbstractBase
Base class for adding identifiers to graphics items that represent Points.
Definition: GraphicsPointAbstractBase.h:17
CurveStyle
Container for LineStyle and PointStyle for one Curve.
Definition: CurveStyle.h:17
GraphicsPointPolygon
This class add event handling to QGraphicsPolygonItem.
Definition: GraphicsPointPolygon.h:16
GraphicsPointAbstractBase.h
GraphicsPoint::setPos
void setPos(const QPointF pos)
Update the position.
Definition: GraphicsPoint.cpp:342
DEFAULT_HIGHLIGHT_OPACITY
const double DEFAULT_HIGHLIGHT_OPACITY
Definition: GraphicsPoint.cpp:27
GraphicsPoint::pos
QPointF pos() const
Proxy method for QGraphicsItem::pos.
Definition: GraphicsPoint.cpp:215
GraphicsPoint::highlightOpacity
double highlightOpacity() const
Get method for highlight opacity.
Definition: GraphicsPoint.cpp:210
MAX_OPACITY
const double MAX_OPACITY
Definition: GraphicsPoint.cpp:28
PointStyle
Details for a specific Point.
Definition: PointStyle.h:19
GraphicsPoint
Graphics item for drawing a circular or polygonal Point.
Definition: GraphicsPoint.h:42
GraphicsPoint::setData
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
Definition: GraphicsPoint.cpp:259
GraphicsPoint::setHighlightOpacity
void setHighlightOpacity(double highlightOpacity)
Set method for highlight opacity.
Definition: GraphicsPoint.cpp:272
GeometryWindow
Window that displays the geometry information, as a table, for the current curve.
Definition: GeometryWindow.h:27
GraphicsPoint::boundingRect
QRectF boundingRect() const
Proxy method for QGraphicsItem::boundingRect.
Definition: GraphicsPoint.cpp:113
GraphicsPoint::updateCurveStyle
void updateCurveStyle(const CurveStyle &curveStyle)
Update point and line styles that comprise the curve style.
Definition: GraphicsPoint.cpp:356
GraphicsPointEllipse
This class add event handling to QGraphicsEllipseItem.
Definition: GraphicsPointEllipse.h:16
GraphicsPoint::reset
void reset()
Mark point as unwanted, and unbind any bound lines.
Definition: GraphicsPoint.cpp:254