Engauge Digitizer 2
Loading...
Searching...
No Matches
GraphicsPointEllipse.cpp
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#include "DataKey.h"
8#include "GraphicsPoint.h"
10#include "Logger.h"
11#include <QColor>
12#include <QGraphicsScene>
13#include "QtToString.h"
14
16 const QRect &rect) :
17 QGraphicsEllipseItem (rect),
18 m_graphicsPoint (graphicsPoint),
19 m_shadow (nullptr)
20{
21 LOG4CPP_INFO_S ((*mainCat)) << "GraphicsPointEllipse::GraphicsPointEllipse";
22}
23
25{
26 // Highlighted
27 setOpacityForSubtree (m_graphicsPoint.highlightOpacity());
28
30
31 QGraphicsEllipseItem::hoverEnterEvent (event);
32}
33
35{
36 // Unhighlighted
37 setOpacityForSubtree (MAX_OPACITY);
38
40
41 QGraphicsEllipseItem::hoverLeaveEvent (event);
42}
43
45 const QVariant &value)
46{
47 if (change == QGraphicsItem::ItemPositionHasChanged) {
48
49 LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsPointEllipse::itemChange"
50 << " identifier=" << data (DATA_KEY_IDENTIFIER).toString().toLatin1().data()
51 << " positionHasChanged";
52
54 }
55
56 return QGraphicsEllipseItem::itemChange(change,
57 value);
58}
59
60void GraphicsPointEllipse::setOpacityForSubtree (double opacity)
61{
62 // Set this item
64
65 if (m_shadow != nullptr) {
66
67 // Set the child item. Opacity < MAX_OPACITY is too dark so child is set to totally transparent
68 m_shadow->setOpacity (opacity < MAX_OPACITY ? 0.0 : opacity);
69 }
70}
71
73{
74 // Resize assuming symmetry about the origin, and an aspect ratio of 1:1 (so x and y scales are the same)
75 if (boundingRect().width() > 0) {
76 double scale = (2 * radius) / boundingRect().width();
78 }
79}
80
@ DATA_KEY_POSITION_HAS_CHANGED
‍Item type (i.e. image versus point)
Definition DataKey.h:16
@ DATA_KEY_IDENTIFIER
Definition DataKey.h:14
const int INNER_RADIUS_MIN
const double MAX_OPACITY
log4cpp::Category * mainCat
Definition Logger.cpp:14
This class add event handling to QGraphicsEllipseItem.
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Accept hover so point can be highlighted when cursor is over it as a guide to user.
void setShadow(GraphicsPointEllipse *shadow)
Bind this graphics item to its shadow.
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.
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Intercept moves by dragging so moved items can be identified. This replaces unreliable hit tests.
GraphicsPointEllipse(GraphicsPoint &graphicsPoint, const QRect &rect)
Single constructor.
void setRadius(int radius)
Update the radius.
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Unhighlight this point.
Graphics item for drawing a circular or polygonal Point.
double highlightOpacity() const
Get method for highlight opacity.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20