v2.0.0
Loading...
Searching...
No Matches
selectionsceneitem.cpp
Go to the documentation of this file.
1//=============================================================================================================
14
15//=============================================================================================================
16// INCLUDES
17//=============================================================================================================
18
19#include "selectionsceneitem.h"
20
21//=============================================================================================================
22// QT INCLUDES
23//=============================================================================================================
24
25#include <QPainter>
26#include <QStaticText>
27
28//=============================================================================================================
29// EIGEN INCLUDES
30//=============================================================================================================
31
32//=============================================================================================================
33// USED NAMESPACES
34//=============================================================================================================
35
36using namespace DISPLIB;
37
38//=============================================================================================================
39// DEFINE MEMBER METHODS
40//=============================================================================================================
41
43 int channelNumber,
44 QPointF channelPosition,
45 int channelKind,
46 int channelUnit,
47 QColor channelColor,
48 bool bIsBadChannel)
49: m_sChannelName(channelName)
50, m_iChannelNumber(channelNumber)
51, m_qpChannelPosition(channelPosition)
52, m_cChannelColor(channelColor)
53, m_bHighlightItem(false)
54, m_iChannelKind(channelKind)
55, m_iChannelUnit(channelUnit)
56, m_bIsBadChannel(bIsBadChannel)
57{
58 this->setAcceptHoverEvents(true);
59 this->setFlag(QGraphicsItem::ItemIsSelectable, true);
60}
61
62//=============================================================================================================
63
65{
66 return QRectF(-25, -30, 50, 50);
67}
68
69//=============================================================================================================
70
71void SelectionSceneItem::paint(QPainter *painter,
72 const QStyleOptionGraphicsItem *option,
73 QWidget *widget)
74{
75 Q_UNUSED(option);
76 Q_UNUSED(widget);
77
78 this->setPos(10*m_qpChannelPosition.x(), -10*m_qpChannelPosition.y());
79
80 // Plot shadow
81 painter->setPen(Qt::NoPen);
82 painter->setBrush(Qt::darkGray);
83 painter->drawEllipse(-12, -12, 30, 30);
84
85 //Plot red if bad
86 if(m_bIsBadChannel) {
87 painter->setBrush(Qt::red);
88 painter->drawEllipse(-15, -15, 30, 30);
89 } else {
90 painter->setBrush(m_cChannelColor);
91 painter->drawEllipse(-15, -15, 30, 30);
92 }
93
94 //Plot selected item
95 if(this->isSelected()){
96 //painter->setPen(QPen(QColor(255,84,22), 5));
97 painter->setPen(QPen(Qt::red, 5));
98 painter->drawEllipse(-15, -15, 30, 30);
99 }
100
101 //OLD
102// //Plot selected item
103// if(this->isSelected())
104// painter->setBrush(QBrush(QColor(93,177,47)));
105// else
106// painter->setBrush(QBrush(m_cChannelColor));
107
108// //Plot highlighted selected item
109// if(m_bHighlightItem) {
110// painter->setPen(QPen(Qt::red, 4));
111// painter->drawEllipse(-15, -15, 30, 30);
112// }
113// else {
114// painter->setPen(QPen(Qt::black, 1));
115// painter->drawEllipse(-15, -15, 30, 30);
116// }
117
118 // Plot electrode name
119 painter->setPen(QPen(Qt::black, 1));
120 QStaticText staticElectrodeName = QStaticText(m_sChannelName);
121 QSizeF sizeText = staticElectrodeName.size();
122 painter->drawStaticText(-15+((30-sizeText.width())/2), -32, staticElectrodeName);
123}
124
125//=============================================================================================================
126
Channel-selection group descriptor (SelectionItem) and the matching QGraphicsItem (SelectionSceneItem...
2-D display widgets and visualisation helpers (charts, topography, colour maps).
QList< QPointF > m_qpChannelPosition
QList< QString > m_sChannelName
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
SelectionSceneItem(QString channelName, int channelNumber, QPointF channelPosition, int channelKind, int channelUnit, QColor channelColor=Qt::blue, bool bIsBadChannel=false)