Engauge Digitizer  2
GraphicsPoint.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 GRAPHICS_POINT_H
8 #define GRAPHICS_POINT_H
9 
10 #include "GraphicsPointAbstractBase.h"
11 #include <QColor>
12 #include <QPointF>
13 
14 extern const double DEFAULT_HIGHLIGHT_OPACITY;
15 extern const double MAX_OPACITY;
16 
17 class CurveStyle;
18 class GeometryWindow;
21 class PointStyle;
22 class QColor;
23 class QGraphicsScene;
24 class QPolygonF;
25 class QTextStream;
26 class QVariant;
27 
43 {
44 public:
46  GraphicsPoint(QGraphicsScene &scene,
47  const QString &identifier,
48  const QPointF &posScreen,
49  const QColor &color,
50  unsigned int radius,
51  double lineWidth,
52  GeometryWindow *geometryWindow);
53 
55  GraphicsPoint(QGraphicsScene &scene,
56  const QString &identifier,
57  const QPointF &posScreen,
58  const QColor &color,
59  const QPolygonF &polygon,
60  double lineWidth,
61  GeometryWindow *geometryWindow);
62 
64  ~GraphicsPoint ();
65 
67  QVariant data (int key) const;
68 
70  double highlightOpacity () const;
71 
73  QPointF pos () const;
74 
76  void printStream (QString indentation,
77  QTextStream &str,
78  double ordinalKey) const;
79 
81  void reset();
82 
84  void setData (int key, const QVariant &data);
85 
87  void setHighlightOpacity (double highlightOpacity);
88 
90  void setPointStyle (const PointStyle &pointStyle);
91 
93  void setPos (const QPointF pos);
94 
96  void setWanted ();
97 
99  void updateCurveStyle (const CurveStyle &curveStyle);
100 
102  bool wanted () const;
103 
104 private:
105  GraphicsPoint();
106 
107  void createPointEllipse (unsigned int radius); // Attributes shared by circle and polygon points are passed through member variables
108  void createPointPolygon (const QPolygonF &polygon); // Attributes shared by circle and polygon points are passed through member variables
109 
110  QGraphicsScene &m_scene;
111 
112  // Ellipse graphics items. Unused if point is polygonal.
113  GraphicsPointEllipse *m_graphicsItemEllipse;
114  GraphicsPointEllipse *m_shadowZeroWidthEllipse; // Shadow item overlays the superclass instance to ensure visibility
115 
116  // Polygon graphics items. Unused if point is elliptical.
117  GraphicsPointPolygon *m_graphicsItemPolygon;
118  GraphicsPointPolygon *m_shadowZeroWidthPolygon; // Shadow item overlays the superclass instance to ensure visibility
119 
120  // Shared attributes
121  const QString m_identifier;
122  const QPointF m_posScreen;
123  const QColor m_color;
124  double m_lineWidth;
125 
126  // Housekeeping
127  bool m_wanted;
128 
129  double m_highlightOpacity;
130 
131  GeometryWindow *m_geometryWindow; // Can receive hover signals. Null if unused
132 };
133 
134 #endif // GRAPHICS_POINT_H
void setWanted()
Mark point as wanted. Marking as unwanted is done by the reset function.
QPointF pos() const
Proxy method for QGraphicsItem::pos.
void setHighlightOpacity(double highlightOpacity)
Set method for highlight opacity.
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
Base class for adding identifiers to graphics items that represent Points.
Window that displays the geometry information, as a table, for the current curve. ...
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
void setPos(const QPointF pos)
Update the position.
void setPointStyle(const PointStyle &pointStyle)
Update the point style.
void updateCurveStyle(const CurveStyle &curveStyle)
Update point and line styles that comprise the curve style.
This class add event handling to QGraphicsEllipseItem.
Details for a specific Point.
Definition: PointStyle.h:20
double highlightOpacity() const
Get method for highlight opacity.
~GraphicsPoint()
Destructor. This remove the graphics item from the scene.
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(...
Container for LineStyle and PointStyle for one Curve.
Definition: CurveStyle.h:18
bool wanted() const
Identify point as wanted//unwanted.
Graphics item for drawing a circular or polygonal Point.
Definition: GraphicsPoint.h:42
This class add event handling to QGraphicsPolygonItem.
void reset()
Mark point as unwanted, and unbind any bound lines.