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