Engauge Digitizer 2
Loading...
Searching...
No Matches
GraphicsPointPolygon Class Reference

This class add event handling to QGraphicsPolygonItem. More...

#include <GraphicsPointPolygon.h>

Inheritance diagram for GraphicsPointPolygon:
Inheritance graph
Collaboration diagram for GraphicsPointPolygon:
Collaboration graph

Signals

void signalPointHoverEnter (QString)
 Signal for geometry window to highlight the current point upon hover enter.
void signalPointHoverLeave (QString)
 Signal for geometry window to unhighlight the current point upon hover leave.

Public Member Functions

 GraphicsPointPolygon (GraphicsPoint &graphicsPoint, const QPolygonF &polygon)
 Single constructor.
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 Intercept moves by dragging so moved items can be identified. This replaces unreliable hit tests.
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 Accept hover so point can be highlighted when cursor is over it as a guide to user.
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 Unhighlight this point.
void setRadius (int radius)
 Update the radius.
void setShadow (GraphicsPointPolygon *shadow)
 Bind this graphics item to its shadow.

Detailed Description

This class add event handling to QGraphicsPolygonItem.

Definition at line 17 of file GraphicsPointPolygon.h.

Constructor & Destructor Documentation

◆ GraphicsPointPolygon()

GraphicsPointPolygon::GraphicsPointPolygon ( GraphicsPoint & graphicsPoint,
const QPolygonF & polygon )

Single constructor.

Definition at line 14 of file GraphicsPointPolygon.cpp.

15 :
16 QGraphicsPolygonItem (polygon),
17 m_graphicsPoint (graphicsPoint),
18 m_shadow (nullptr)
19{
20 LOG4CPP_INFO_S ((*mainCat)) << "GraphicsPointPolygon::GraphicsPointPolygon";
21}
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

Member Function Documentation

◆ hoverEnterEvent()

void GraphicsPointPolygon::hoverEnterEvent ( QGraphicsSceneHoverEvent * event)
virtual

Accept hover so point can be highlighted when cursor is over it as a guide to user.

Definition at line 23 of file GraphicsPointPolygon.cpp.

24{
25 // Highlighted
26 setOpacityForSubtree (m_graphicsPoint.highlightOpacity ());
27
28 emit signalPointHoverEnter (data (DATA_KEY_IDENTIFIER).toString ());
29
30 QGraphicsPolygonItem::hoverEnterEvent (event);
31}
@ DATA_KEY_IDENTIFIER
Definition DataKey.h:14
void signalPointHoverEnter(QString)
Signal for geometry window to highlight the current point upon hover enter.

◆ hoverLeaveEvent()

void GraphicsPointPolygon::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event)
virtual

Unhighlight this point.

Definition at line 33 of file GraphicsPointPolygon.cpp.

34{
35 // Unhighlighted
36 setOpacityForSubtree (MAX_OPACITY);
37
38 emit signalPointHoverLeave (data (DATA_KEY_IDENTIFIER).toString ());
39
40 QGraphicsPolygonItem::hoverLeaveEvent (event);
41}
const double MAX_OPACITY
void signalPointHoverLeave(QString)
Signal for geometry window to unhighlight the current point upon hover leave.

◆ itemChange()

QVariant GraphicsPointPolygon::itemChange ( GraphicsItemChange change,
const QVariant & value )

Intercept moves by dragging so moved items can be identified. This replaces unreliable hit tests.

Definition at line 43 of file GraphicsPointPolygon.cpp.

45{
46 if (change == QGraphicsItem::ItemPositionHasChanged) {
47
48 LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsPointPolygon::itemChange"
49 << " identifier=" << data (DATA_KEY_IDENTIFIER).toString().toLatin1().data()
50 << " positionHasChanged";
51
52 setData (DATA_KEY_POSITION_HAS_CHANGED, QVariant (true));
53 }
54
55 return QGraphicsPolygonItem::itemChange(change,
56 value);
57}
@ DATA_KEY_POSITION_HAS_CHANGED
Definition DataKey.h:16
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ setRadius()

void GraphicsPointPolygon::setRadius ( int radius)

Update the radius.

Definition at line 71 of file GraphicsPointPolygon.cpp.

72{
73 // Resize assuming symmetry about the origin, and an aspect ratio of 1:1 (so x and y scales are the same)
74 if (boundingRect().width() > 0) {
75 double scale = (2 * radius) / boundingRect().width();
76 setScale (scale);
77 }
78}

◆ setShadow()

void GraphicsPointPolygon::setShadow ( GraphicsPointPolygon * shadow)

Bind this graphics item to its shadow.

Definition at line 80 of file GraphicsPointPolygon.cpp.

81{
82 m_shadow = shadow;
83}

◆ signalPointHoverEnter

void GraphicsPointPolygon::signalPointHoverEnter ( QString )
signal

Signal for geometry window to highlight the current point upon hover enter.

◆ signalPointHoverLeave

void GraphicsPointPolygon::signalPointHoverLeave ( QString )
signal

Signal for geometry window to unhighlight the current point upon hover leave.


The documentation for this class was generated from the following files: