MNE-CPP  0.1.9
A Framework for Electrophysiology
selectionsceneitem.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //=============================================================================================================
37 // INCLUDES
38 //=============================================================================================================
39 
40 #include "selectionsceneitem.h"
41 
42 //=============================================================================================================
43 // QT INCLUDES
44 //=============================================================================================================
45 
46 #include <QPainter>
47 #include <QStaticText>
48 
49 //=============================================================================================================
50 // EIGEN INCLUDES
51 //=============================================================================================================
52 
53 //=============================================================================================================
54 // USED NAMESPACES
55 //=============================================================================================================
56 
57 using namespace DISPLIB;
58 
59 //=============================================================================================================
60 // DEFINE MEMBER METHODS
61 //=============================================================================================================
62 
64  int channelNumber,
65  QPointF channelPosition,
66  int channelKind,
67  int channelUnit,
68  QColor channelColor,
69  bool bIsBadChannel)
70 : m_sChannelName(channelName)
71 , m_iChannelNumber(channelNumber)
72 , m_qpChannelPosition(channelPosition)
73 , m_cChannelColor(channelColor)
74 , m_bHighlightItem(false)
75 , m_iChannelKind(channelKind)
76 , m_iChannelUnit(channelUnit)
77 , m_bIsBadChannel(bIsBadChannel)
78 {
79  this->setAcceptHoverEvents(true);
80  this->setFlag(QGraphicsItem::ItemIsSelectable, true);
81 }
82 
83 //=============================================================================================================
84 
86 {
87  return QRectF(-25, -30, 50, 50);
88 }
89 
90 //=============================================================================================================
91 
92 void SelectionSceneItem::paint(QPainter *painter,
93  const QStyleOptionGraphicsItem *option,
94  QWidget *widget)
95 {
96  Q_UNUSED(option);
97  Q_UNUSED(widget);
98 
99  this->setPos(10*m_qpChannelPosition.x(), -10*m_qpChannelPosition.y());
100 
101  // Plot shadow
102  painter->setPen(Qt::NoPen);
103  painter->setBrush(Qt::darkGray);
104  painter->drawEllipse(-12, -12, 30, 30);
105 
106  //Plot red if bad
107  if(m_bIsBadChannel) {
108  painter->setBrush(Qt::red);
109  painter->drawEllipse(-15, -15, 30, 30);
110  } else {
111  painter->setBrush(m_cChannelColor);
112  painter->drawEllipse(-15, -15, 30, 30);
113  }
114 
115  //Plot selected item
116  if(this->isSelected()){
117  //painter->setPen(QPen(QColor(255,84,22), 5));
118  painter->setPen(QPen(Qt::red, 5));
119  painter->drawEllipse(-15, -15, 30, 30);
120  }
121 
122  //OLD
123 // //Plot selected item
124 // if(this->isSelected())
125 // painter->setBrush(QBrush(QColor(93,177,47)));
126 // else
127 // painter->setBrush(QBrush(m_cChannelColor));
128 
129 // //Plot highlighted selected item
130 // if(m_bHighlightItem) {
131 // painter->setPen(QPen(Qt::red, 4));
132 // painter->drawEllipse(-15, -15, 30, 30);
133 // }
134 // else {
135 // painter->setPen(QPen(Qt::black, 1));
136 // painter->drawEllipse(-15, -15, 30, 30);
137 // }
138 
139  // Plot electrode name
140  painter->setPen(QPen(Qt::black, 1));
141  QStaticText staticElectrodeName = QStaticText(m_sChannelName);
142  QSizeF sizeText = staticElectrodeName.size();
143  painter->drawStaticText(-15+((30-sizeText.width())/2), -32, staticElectrodeName);
144 }
145 
146 //=============================================================================================================
147 
148 SelectionItem::SelectionItem(const SelectionItem &other)
149 {
155 }
DISPLIB::SelectionSceneItem::m_qpChannelPosition
QPointF m_qpChannelPosition
Definition: selectionsceneitem.h:122
DISPLIB::SelectionSceneItem::m_bIsBadChannel
bool m_bIsBadChannel
Definition: selectionsceneitem.h:125
DISPLIB::SelectionItem::m_iChannelUnit
QList< int > m_iChannelUnit
Definition: selectionsceneitem.h:82
DISPLIB::SelectionSceneItem::boundingRect
QRectF boundingRect() const
Definition: selectionsceneitem.cpp:85
DISPLIB::SelectionItem
The SelectionSceneItem class provides a new data structure for visualizing channels in a 2D layout.
Definition: selectionsceneitem.h:72
DISPLIB::SelectionItem::m_iChannelNumber
QList< int > m_iChannelNumber
Definition: selectionsceneitem.h:80
selectionsceneitem.h
Contains the declaration of the SelectionSceneItem class.
DISPLIB::SelectionItem::m_qpChannelPosition
QList< QPointF > m_qpChannelPosition
Definition: selectionsceneitem.h:83
DISPLIB::SelectionSceneItem::m_cChannelColor
QColor m_cChannelColor
Definition: selectionsceneitem.h:123
DISPLIB::SelectionItem::m_iChannelKind
QList< int > m_iChannelKind
Definition: selectionsceneitem.h:81
DISPLIB::SelectionSceneItem::SelectionSceneItem
SelectionSceneItem(QString channelName, int channelNumber, QPointF channelPosition, int channelKind, int channelUnit, QColor channelColor=Qt::blue, bool bIsBadChannel=false)
Definition: selectionsceneitem.cpp:63
DISPLIB::SelectionSceneItem::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: selectionsceneitem.cpp:92
DISPLIB::SelectionSceneItem::m_sChannelName
QString m_sChannelName
Definition: selectionsceneitem.h:118
DISPLIB::SelectionItem::m_sChannelName
QList< QString > m_sChannelName
Definition: selectionsceneitem.h:79