00001
00002
00003
00004
00005
00006
00007 #include "DataKey.h"
00008 #include "GraphicsPoint.h"
00009 #include "GraphicsPointPolygon.h"
00010 #include "Logger.h"
00011 #include <QGraphicsScene>
00012 #include "QtToString.h"
00013
00014 GraphicsPointPolygon::GraphicsPointPolygon(GraphicsPoint &graphicsPoint,
00015 const QPolygonF &polygon) :
00016 QGraphicsPolygonItem (polygon),
00017 m_graphicsPoint (graphicsPoint),
00018 m_shadow (0)
00019 {
00020 LOG4CPP_INFO_S ((*mainCat)) << "GraphicsPointPolygon::GraphicsPointPolygon";
00021 }
00022
00023 QVariant GraphicsPointPolygon::itemChange(GraphicsItemChange change,
00024 const QVariant &value)
00025 {
00026 if (change == QGraphicsItem::ItemPositionHasChanged) {
00027
00028 LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsPointPolygon::itemChange"
00029 << " identifier=" << data (DATA_KEY_IDENTIFIER).toString().toLatin1().data()
00030 << " positionHasChanged";
00031
00032 setData (DATA_KEY_POSITION_HAS_CHANGED, QVariant (true));
00033 }
00034
00035 return QGraphicsPolygonItem::itemChange(change,
00036 value);
00037 }
00038
00039 void GraphicsPointPolygon::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
00040 {
00041
00042 setOpacityForSubtree (m_graphicsPoint.highlightOpacity ());
00043
00044 emit signalPointHoverEnter (data (DATA_KEY_IDENTIFIER).toString ());
00045
00046 QGraphicsPolygonItem::hoverEnterEvent (event);
00047 }
00048
00049 void GraphicsPointPolygon::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
00050 {
00051
00052 setOpacityForSubtree (MAX_OPACITY);
00053
00054 emit signalPointHoverLeave (data (DATA_KEY_IDENTIFIER).toString ());
00055
00056 QGraphicsPolygonItem::hoverLeaveEvent (event);
00057 }
00058
00059 void GraphicsPointPolygon::setOpacityForSubtree (double opacity)
00060 {
00061
00062 setOpacity (opacity);
00063
00064 if (m_shadow != 0) {
00065
00066
00067 m_shadow->setOpacity (opacity < MAX_OPACITY ? 0.0 : opacity);
00068 }
00069 }
00070
00071 void GraphicsPointPolygon::setRadius(int radius)
00072 {
00073
00074 double scale = (2 * radius) / boundingRect().width();
00075 setScale (scale);
00076 }
00077
00078 void GraphicsPointPolygon::setShadow (GraphicsPointPolygon *shadow)
00079 {
00080 m_shadow = shadow;
00081 }