MNE-CPP  beta 1.0
selectionsceneitem.cpp
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include "selectionsceneitem.h"
43 
44 
45 //*************************************************************************************************************
46 //=============================================================================================================
47 // USED NAMESPACES
48 //=============================================================================================================
49 
50 using namespace XDISPLIB;
51 using namespace std;
52 
53 
54 //*************************************************************************************************************
55 //=============================================================================================================
56 // DEFINE MEMBER METHODS
57 //=============================================================================================================
58 
59 SelectionSceneItem::SelectionSceneItem(QString channelName, int channelNumber, QPointF channelPosition, int channelKind, int channelUnit, QColor channelColor)
60 : m_sChannelName(channelName)
61 , m_iChannelNumber(channelNumber)
62 , m_qpChannelPosition(channelPosition)
63 , m_cChannelColor(channelColor)
64 , m_bHighlightItem(false)
65 , m_iChannelKind(channelKind)
66 , m_iChannelUnit(channelUnit)
67 {
68  this->setAcceptHoverEvents(true);
69  this->setFlag(QGraphicsItem::ItemIsSelectable, true);
70 }
71 
72 
73 //*************************************************************************************************************
74 
76 {
77  return QRectF(-25, -30, 50, 50);
78 }
79 
80 
81 //*************************************************************************************************************
82 
83 void SelectionSceneItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
84 {
85  Q_UNUSED(option);
86  Q_UNUSED(widget);
87 
88  this->setPos(10*m_qpChannelPosition.x(), -10*m_qpChannelPosition.y());
89 
90  // Plot shadow
91  painter->setPen(Qt::NoPen);
92  painter->setBrush(Qt::darkGray);
93  painter->drawEllipse(-12, -12, 30, 30);
94 
95  //Plot selected item
96  if(this->isSelected())
97  painter->setBrush(QBrush(QColor(93,177,47)));
98  else
99  painter->setBrush(QBrush(m_cChannelColor));
100 
101  //Plot highlighted selected item
102  if(m_bHighlightItem) {
103  painter->setPen(QPen(Qt::red, 4));
104  painter->drawEllipse(-15, -15, 30, 30);
105  }
106  else {
107  painter->setPen(QPen(Qt::black, 1));
108  painter->drawEllipse(-15, -15, 30, 30);
109  }
110 
111  // Plot electrode name
112  painter->setPen(QPen(Qt::black, 1));
113  QStaticText staticElectrodeName = QStaticText(m_sChannelName);
114  QSizeF sizeText = staticElectrodeName.size();
115  painter->drawStaticText(-15+((30-sizeText.width())/2), -32, staticElectrodeName);
116 }
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
SelectionSceneItem(QString channelName, int channelNumber, QPointF channelPosition, int channelKind, int channelUnit, QColor averageColor=Qt::blue)