Engauge Digitizer  2
GraphicsPointEllipse.cpp
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"
9 #include "GraphicsPointEllipse.h"
10 #include "Logger.h"
11 #include <QGraphicsScene>
12 #include "QtToString.h"
13 
15  const QRect &rect) :
16  QGraphicsEllipseItem (rect),
17  m_graphicsPoint (graphicsPoint)
18 {
19  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsPointEllipse::GraphicsPointEllipse";
20 }
21 
22 QVariant GraphicsPointEllipse::itemChange(GraphicsItemChange change,
23  const QVariant &value)
24 {
25  if (change == QGraphicsItem::ItemPositionHasChanged) {
26 
27  LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsPointEllipse::itemChange"
28  << " identifier=" << data (DATA_KEY_IDENTIFIER).toString().toLatin1().data()
29  << " positionHasChanged";
30 
31  setData (DATA_KEY_POSITION_HAS_CHANGED, QVariant (true));
32  }
33 
34  return QGraphicsEllipseItem::itemChange(change,
35  value);
36 }
37 
39 {
40  // Resize assuming symmetry about the origin, and an aspect ratio of 1:1 (so x and y scales are the same)
41  double scale = (2 * radius) / boundingRect().width();
42  setScale (scale);
43 }
Graphics item for drawing a circular or polygonal Point.
Definition: GraphicsPoint.h:39
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.