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 #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 
91  void setHighlightOpacity (double highlightOpacity);
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
void setPassive()
Prevent automatic focus on point (=make it passive) for scale bar so drags can be made to work proper...
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
QRectF boundingRect() const
Proxy method for QGraphicsItem::boundingRect.
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:43
This class add event handling to QGraphicsPolygonItem.
void reset()
Mark point as unwanted, and unbind any bound lines.