MNE-CPP  beta 1.0
tmsielectrodeitem.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include "tmsielectrodeitem.h"
43 
44 
45 //*************************************************************************************************************
46 //=============================================================================================================
47 // USED NAMESPACES
48 //=============================================================================================================
49 
50 using namespace TMSIPlugin;
51 using namespace std;
52 
53 
54 //*************************************************************************************************************
55 //=============================================================================================================
56 // DEFINE MEMBER METHODS
57 //=============================================================================================================
58 
59 TMSIElectrodeItem::TMSIElectrodeItem(QString electrodeName, QPointF electrodePosition, QColor electrodeColor, int channelIndex)
60 : m_sElectrodeName(electrodeName)
61 , m_qpElectrodePosition(electrodePosition)
62 , m_cElectrodeColor(electrodeColor)
63 , m_dImpedanceValue(0.0)
64 , m_iChannelIndex(channelIndex)
65 {
66 }
67 
68 //*************************************************************************************************************
69 
71 {
72  return QRectF(-25, -35, 50, 70);
73 }
74 
75 //*************************************************************************************************************
76 
77 void TMSIElectrodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
78 {
79  Q_UNUSED(option);
80  Q_UNUSED(widget);
81 
82  // Plot shadow
83  painter->setPen(Qt::NoPen);
84  painter->setBrush(Qt::darkGray);
85  painter->drawEllipse(-12, -12, 30, 30);
86 
87  // Plot colored circle
88  painter->setPen(QPen(Qt::black, 1));
89  painter->setBrush(QBrush(m_cElectrodeColor));
90  painter->drawEllipse(-15, -15, 30, 30);
91 
92  // Plot electrode name
93  QStaticText staticElectrodeName = QStaticText(m_sElectrodeName);
94  QSizeF sizeText = staticElectrodeName.size();
95  painter->drawStaticText(-15+((30-sizeText.width())/2), -32, staticElectrodeName);
96 
97  // Plot electrodes impedance value
98  QString impedanceValueToString;
99  QStaticText staticElectrodeValue = QStaticText(QString("%1 %2").arg(impedanceValueToString.setNum(m_dImpedanceValue/1000)).arg(/*"kOhm"*/"k")); // transform to kilo ohm (divide by 1000)
100  QSizeF sizeValue = staticElectrodeValue.size();
101  painter->drawStaticText(-15+((30-sizeValue.width())/2), 19, staticElectrodeValue);
102 
103  this->setPos(m_qpElectrodePosition);
104 }
105 
106 //*************************************************************************************************************
107 
108 void TMSIElectrodeItem::setColor(QColor electrodeColor)
109 {
110  m_cElectrodeColor = electrodeColor;
111 }
112 
113 //*************************************************************************************************************
114 
116 {
117  return m_sElectrodeName;
118 }
119 
120 //*************************************************************************************************************
121 
122 void TMSIElectrodeItem::setImpedanceValue(double impedanceValue)
123 {
124  m_dImpedanceValue = impedanceValue;
125 }
126 
127 //*************************************************************************************************************
128 
130 {
131  return m_dImpedanceValue;
132 }
133 
134 //*************************************************************************************************************
135 
136 void TMSIElectrodeItem::setPosition(QPointF newPosition)
137 {
138  m_qpElectrodePosition = newPosition;
139 }
140 
141 //*************************************************************************************************************
142 
144 {
145  return m_qpElectrodePosition;
146 }
147 
148 //*************************************************************************************************************
149 
151 {
152  return m_iChannelIndex;
153 }
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
Contains the declaration of the TMSIElectrodeItem class.
void setPosition(QPointF newPosition)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
TMSIElectrodeItem(QString electrodeName, QPointF electrodePosition, QColor electrodeColor, int channelIndex)
void setImpedanceValue(double impedanceValue)
void setColor(QColor electrodeColor)