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