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 void GraphicsPointPolygon::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
00024 {
00025
00026 setOpacityForSubtree (m_graphicsPoint.highlightOpacity ());
00027
00028 emit signalPointHoverEnter (data (DATA_KEY_IDENTIFIER).toString ());
00029
00030 QGraphicsPolygonItem::hoverEnterEvent (event);
00031 }
00032
00033 void GraphicsPointPolygon::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
00034 {
00035
00036 setOpacityForSubtree (MAX_OPACITY);
00037
00038 emit signalPointHoverLeave (data (DATA_KEY_IDENTIFIER).toString ());
00039
00040 QGraphicsPolygonItem::hoverLeaveEvent (event);
00041 }
00042
00043 QVariant GraphicsPointPolygon::itemChange(GraphicsItemChange change,
00044 const QVariant &value)
00045 {
00046 if (change == QGraphicsItem::ItemPositionHasChanged) {
00047
00048 LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsPointPolygon::itemChange"
00049 << " identifier=" << data (DATA_KEY_IDENTIFIER).toString().toLatin1().data()
00050 << " positionHasChanged";
00051
00052 setData (DATA_KEY_POSITION_HAS_CHANGED, QVariant (true));
00053 }
00054
00055 return QGraphicsPolygonItem::itemChange(change,
00056 value);
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 }