17#include <QGraphicsEllipseItem>
18#include <QGraphicsPolygonItem>
19#include <QGraphicsScene>
20#include <QGraphicsSceneContextMenuEvent>
40 m_graphicsItemEllipse (
nullptr),
41 m_shadowZeroWidthEllipse (
nullptr),
42 m_graphicsItemPolygon (
nullptr),
43 m_shadowZeroWidthPolygon (
nullptr),
44 m_identifier (identifier),
45 m_posScreen (posScreen),
47 m_lineWidth (lineWidth),
53 <<
" identifier=" << identifier.toLatin1 ().data ();
55 createPointEllipse (radius);
67 m_graphicsItemEllipse (
nullptr),
68 m_shadowZeroWidthEllipse (
nullptr),
69 m_graphicsItemPolygon (
nullptr),
70 m_shadowZeroWidthPolygon (
nullptr),
71 m_identifier (identifier),
72 m_posScreen (posScreen),
74 m_lineWidth (lineWidth),
80 <<
" identifier=" << identifier.toLatin1 ().data ();
82 createPointPolygon (polygon);
89 if (m_graphicsItemEllipse ==
nullptr) {
91 QGraphicsScene *scene = m_graphicsItemPolygon->scene();
94 scene->removeItem (m_graphicsItemPolygon);
95 delete m_graphicsItemPolygon;
96 m_graphicsItemPolygon =
nullptr;
97 m_shadowZeroWidthPolygon =
nullptr;
102 QGraphicsScene *scene = m_graphicsItemEllipse->scene();
105 scene->removeItem (m_graphicsItemEllipse);
106 delete m_graphicsItemEllipse;
107 m_graphicsItemEllipse =
nullptr;
108 m_shadowZeroWidthEllipse =
nullptr;
115 if (m_graphicsItemEllipse ==
nullptr) {
116 return m_graphicsItemPolygon->boundingRect ();
118 return m_graphicsItemEllipse->boundingRect ();
122void GraphicsPoint::createPointEllipse (
unsigned int radius)
132 m_scene.addItem (m_graphicsItemEllipse);
137 m_graphicsItemEllipse->setPos (m_posScreen.x (),
139 m_graphicsItemEllipse->setPen (
QPen (
QBrush (m_color), m_lineWidth));
140 m_graphicsItemEllipse->setEnabled (
true);
141 m_graphicsItemEllipse->setFlags (QGraphicsItem::ItemIsSelectable |
142 QGraphicsItem::ItemIsMovable |
143 QGraphicsItem::ItemSendsGeometryChanges);
145 if (m_geometryWindow !=
nullptr) {
146 QObject::connect (m_graphicsItemEllipse,
SIGNAL (signalPointHoverEnter (
QString)), m_geometryWindow,
SLOT (slotPointHoverEnter (
QString)));
147 QObject::connect (m_graphicsItemEllipse,
SIGNAL (signalPointHoverLeave (
QString)), m_geometryWindow,
SLOT (slotPointHoverLeave (
QString)));
157 m_shadowZeroWidthEllipse->setParentItem(m_graphicsItemPolygon);
160 m_shadowZeroWidthEllipse->setEnabled (
true);
162 m_graphicsItemEllipse->
setShadow (m_shadowZeroWidthEllipse);
165void GraphicsPoint::createPointPolygon (
const QPolygonF &polygon)
171 m_scene.addItem (m_graphicsItemPolygon);
176 m_graphicsItemPolygon->setPos (m_posScreen.x (),
178 m_graphicsItemPolygon->setPen (
QPen (
QBrush (m_color), m_lineWidth));
179 m_graphicsItemPolygon->setEnabled (
true);
180 m_graphicsItemPolygon->setFlags (QGraphicsItem::ItemIsSelectable |
181 QGraphicsItem::ItemIsMovable |
182 QGraphicsItem::ItemSendsGeometryChanges);
184 if (m_geometryWindow !=
nullptr) {
185 QObject::connect (m_graphicsItemPolygon,
SIGNAL (signalPointHoverEnter (
QString)), m_geometryWindow,
SLOT (slotPointHoverEnter (
QString)));
186 QObject::connect (m_graphicsItemPolygon,
SIGNAL (signalPointHoverLeave (
QString)), m_geometryWindow,
SLOT (slotPointHoverLeave (
QString)));
193 m_shadowZeroWidthPolygon->setParentItem(m_graphicsItemPolygon);
196 m_shadowZeroWidthPolygon->setEnabled (
true);
198 m_graphicsItemPolygon->
setShadow (m_shadowZeroWidthPolygon);
203 if (m_graphicsItemEllipse ==
nullptr) {
204 return m_graphicsItemPolygon->data (
key);
206 return m_graphicsItemEllipse->data (
key);
212 return m_highlightOpacity;
217 if (m_graphicsItemEllipse ==
nullptr) {
218 return m_graphicsItemPolygon->pos ();
220 return m_graphicsItemEllipse->pos ();
235 if (m_graphicsItemEllipse ==
nullptr) {
238 pos = m_graphicsItemPolygon->pos();
242 pos = m_graphicsItemEllipse->pos();
263 <<
" data=" <<
data.toString().toLatin1().data();
265 if (m_graphicsItemEllipse ==
nullptr) {
266 m_graphicsItemPolygon->setData (
key,
data);
268 m_graphicsItemEllipse->setData (
key,
data);
275 <<
" identifier=" << m_identifier.toLatin1().data()
283 if (m_graphicsItemEllipse ==
nullptr) {
284 m_graphicsItemPolygon->setFlag (QGraphicsItem::ItemIsFocusable,
false);
285 m_graphicsItemPolygon->setFlag (QGraphicsItem::ItemIsMovable,
false);
286 m_graphicsItemPolygon->setFlag (QGraphicsItem::ItemIsSelectable,
false);
288 m_graphicsItemEllipse->setFlag (QGraphicsItem::ItemIsFocusable,
false);
289 m_graphicsItemEllipse->setFlag (QGraphicsItem::ItemIsMovable,
false);
290 m_graphicsItemEllipse->setFlag (QGraphicsItem::ItemIsSelectable,
false);
298 if (m_graphicsItemEllipse ==
nullptr) {
302 delete m_graphicsItemPolygon;
303 m_graphicsItemPolygon =
nullptr;
304 m_shadowZeroWidthPolygon =
nullptr;
306 createPointEllipse (
unsigned (pointStyle.
radius()));
315 m_graphicsItemPolygon->setPolygon (pointStyle.
polygon());
316 m_shadowZeroWidthPolygon->setPolygon (pointStyle.
polygon());
323 delete m_graphicsItemEllipse;
324 m_graphicsItemEllipse =
nullptr;
325 m_shadowZeroWidthEllipse =
nullptr;
327 createPointPolygon (pointStyle.
polygon());
344 if (m_graphicsItemEllipse ==
nullptr) {
345 m_graphicsItemPolygon->setPos (
pos);
347 m_graphicsItemEllipse->setPos (
pos);
QString dataKeyToString(DataKey dataKey)
DataKey
Index values for storing item details in QGraphicsItem using setData/data.
@ DATA_KEY_GRAPHICS_ITEM_TYPE
Unique identifier for QGraphicsItem object
const int INNER_RADIUS_MIN
QColor ColorPaletteToQColor(ColorPalette color)
@ GRAPHICS_ITEM_TYPE_POINT
const double DEFAULT_HIGHLIGHT_OPACITY
log4cpp::Category * mainCat
const QString INDENTATION_DELTA
QString QPointFToString(const QPointF &pos)
Container for LineStyle and PointStyle for one Curve.
PointStyle pointStyle() const
Get method for PointStyle.
Window that displays the geometry information, as a table, for the current curve.
Base class for adding identifiers to graphics items that represent Points.
This class add event handling to QGraphicsEllipseItem.
void setShadow(GraphicsPointEllipse *shadow)
Bind this graphics item to its shadow.
void setRadius(int radius)
Update the radius.
This class add event handling to QGraphicsPolygonItem.
void setShadow(GraphicsPointPolygon *shadow)
Bind this graphics item to its shadow.
QPointF pos() const
Proxy method for QGraphicsItem::pos.
void setWanted()
Mark point as wanted. Marking as unwanted is done by the reset function.
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
void setPointStyle(const PointStyle &pointStyle)
Update the point style.
void updateCurveStyle(const CurveStyle &curveStyle)
Update point and line styles that comprise the curve style.
void setPassive()
Prevent automatic focus on point (=make it passive) for scale bar so drags can be made to work proper...
void reset()
Mark point as unwanted, and unbind any bound lines.
bool wanted() const
Identify point as wanted//unwanted.
GraphicsPoint(QGraphicsScene &scene, const QString &identifier, const QPointF &posScreen, const QColor &color, unsigned int radius, double lineWidth, GeometryWindow *geometryWindow)
Constructor of circular point.
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(...
~GraphicsPoint()
Destructor. This remove the graphics item from the scene.
QRectF boundingRect() const
Proxy method for QGraphicsItem::boundingRect.
void setHighlightOpacity(double highlightOpacity)
Set method for highlight opacity.
double highlightOpacity() const
Get method for highlight opacity.
void setPos(const QPointF pos)
Update the position.
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
Details for a specific Point.
unsigned int radius() const
Radius of point. For a circle this is all that is needed to draw a circle. For a polygon,...
QPolygonF polygon() const
Return the polygon for creating a QGraphicsPolygonItem. The size is determined by the radius.
PointShape shape() const
Get method for point shape.
ColorPalette paletteColor() const
Get method for point color.
int lineWidth() const
Get method for line width.
#define LOG4CPP_DEBUG_S(logger)