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