Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
GraphicsPointPolygon.cpp
1 #include "DataKey.h"
2 #include "GraphicsPoint.h"
3 #include "GraphicsPointPolygon.h"
4 #include "Logger.h"
5 #include <QGraphicsScene>
6 #include "QtToString.h"
7 
9  const QPolygonF &polygon) :
10  QGraphicsPolygonItem (polygon),
11  m_graphicsPoint (graphicsPoint)
12 
13 {
14  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsPointPolygon::GraphicsPointPolygon";
15 }
16 
17 QVariant GraphicsPointPolygon::itemChange(GraphicsItemChange change,
18  const QVariant &value)
19 {
20  if (change == QGraphicsItem::ItemPositionHasChanged) {
21 
22  LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsPointPolygon::itemChange"
23  << " identifier=" << data (DATA_KEY_IDENTIFIER).toString().toLatin1().data()
24  << " positionHasChanged";
25 
26  setData (DATA_KEY_POSITION_HAS_CHANGED, QVariant (true));
27  }
28 
29  return QGraphicsPolygonItem::itemChange(change,
30  value);
31 }
32 
34 {
35  // Resize assuming symmetry about the origin, and an aspect ratio of 1:1 (so x and y scales are the same)
36  double scale = (2 * radius) / boundingRect().width();
37  setScale (scale);
38 }
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Intercept moves by dragging so moved items can be identified. This replaces unreliable hit tests...
void setRadius(int radius)
Update the radius.
Graphics item for drawing a circular or polygonal Point.
Definition: GraphicsPoint.h:33
GraphicsPointPolygon(GraphicsPoint &graphicsPoint, const QPolygonF &polygon)
Single constructor.