MNE-CPP  0.1.9
A Framework for Electrophysiology
averagescene.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //=============================================================================================================
37 // INCLUDES
38 //=============================================================================================================
39 
40 #include "averagescene.h"
41 
42 #include "averagesceneitem.h"
43 #include "selectionsceneitem.h"
44 
45 //=============================================================================================================
46 // USED NAMESPACES
47 //=============================================================================================================
48 
49 using namespace DISPLIB;
50 
51 //=============================================================================================================
52 // QT INCLUDES
53 //=============================================================================================================
54 
55 //=============================================================================================================
56 // EIGEN INCLUDES
57 //=============================================================================================================
58 
59 //=============================================================================================================
60 // DEFINE MEMBER METHODS
61 //=============================================================================================================
62 
63 AverageScene::AverageScene(QGraphicsView* view, QObject* parent)
64 : LayoutScene(view, parent)
65 , m_colGlobalItemSignalColor(Qt::yellow)
66 {
67 }
68 
69 //=============================================================================================================
70 
71 void AverageScene::setScaleMap(const QMap<qint32,float> &scaleMap)
72 {
73  QList<QGraphicsItem*> itemList = this->items();
74 
75  QListIterator<QGraphicsItem*> i(itemList);
76  while (i.hasNext()) {
77  AverageSceneItem* AverageSceneItemTemp = static_cast<AverageSceneItem*>(i.next());
78  AverageSceneItemTemp->m_scaleMap = scaleMap;
79  }
80 
81  this->update();
82 }
83 
84 //=============================================================================================================
85 
86 void AverageScene::repaintItems(const QList<QGraphicsItem *> &selectedChannelItems)
87 {
88  this->clear();
89 
90  QListIterator<QGraphicsItem*> i(selectedChannelItems);
91 
92  while (i.hasNext()) {
93  SelectionSceneItem* selectionSceneItemTemp = static_cast<SelectionSceneItem*>(i.next());
94  AverageSceneItem* averageSceneItemTemp = new AverageSceneItem(selectionSceneItemTemp->m_sChannelName,
95  selectionSceneItemTemp->m_iChannelNumber,
96  selectionSceneItemTemp->m_qpChannelPosition,
97  selectionSceneItemTemp->m_iChannelKind,
98  selectionSceneItemTemp->m_iChannelUnit,
99  m_colGlobalItemSignalColor);
100 
101  connect(averageSceneItemTemp, &AverageSceneItem::sceneUpdateRequested,
103 
104  this->addItem(averageSceneItemTemp);
105  }
106 }
107 
108 //=============================================================================================================
109 
111 {
112  this->clear();
113 
114  for (int i = 0; i < selectedChannelItems.m_iChannelKind.size(); i++){
115  AverageSceneItem* averageSceneItemTemp = new AverageSceneItem(selectedChannelItems.m_sChannelName[i],
116  selectedChannelItems.m_iChannelNumber[i],
117  selectedChannelItems.m_qpChannelPosition[i],
118  selectedChannelItems.m_iChannelKind[i],
119  selectedChannelItems.m_iChannelUnit[i],
120  m_colGlobalItemSignalColor);
121 
122  connect(averageSceneItemTemp, &AverageSceneItem::sceneUpdateRequested,
124  this->addItem(averageSceneItemTemp);
125  }
126 }
127 
128 //=============================================================================================================
129 
130 void AverageScene::setActivationPerAverage(const QSharedPointer<QMap<QString, bool> > qMapActivationPerAverage)
131 {
132  QList<QGraphicsItem*> items = this->items();
133  QListIterator<QGraphicsItem*> i(items);
134  while (i.hasNext()) {
135  if(AverageSceneItem* averageSceneItemTemp = dynamic_cast<AverageSceneItem*>(i.next())) {
136  averageSceneItemTemp->m_qMapAverageActivation = *qMapActivationPerAverage;
137  }
138  }
139 
140  updateScene();
141 }
142 
143 //=============================================================================================================
144 
145 void AverageScene::setColorPerAverage(const QSharedPointer<QMap<QString, QColor> > qMapAverageColor)
146 {
147  QList<QGraphicsItem*> items = this->items();
148  QListIterator<QGraphicsItem*> i(items);
149  while (i.hasNext()) {
150  if(AverageSceneItem* averageSceneItemTemp = dynamic_cast<AverageSceneItem*>(i.next())) {
151  averageSceneItemTemp->m_qMapAverageColor = *qMapAverageColor;
152  }
153  }
154 
155  updateScene();
156 }
157 
158 //=============================================================================================================
159 
161 {
162  return m_colGlobalItemSignalColor;
163 }
164 
165 //=============================================================================================================
166 
168 {
169  this->update();
170 }
171 
172 //=============================================================================================================
173 
174 void AverageScene::setSignalItemColor(const QColor &signalColor)
175 {
176  QList<QGraphicsItem*> items = this->items();
177  QListIterator<QGraphicsItem*> i(items);
178 
179  m_colGlobalItemSignalColor = signalColor;
180 
181  while (i.hasNext()) {
182  if(AverageSceneItem* averageSceneItemTemp = dynamic_cast<AverageSceneItem*>(i.next())) {
183  averageSceneItemTemp->setDefaultColor(signalColor);
184  averageSceneItemTemp->update();
185  }
186  }
187 
188  repaintItems(items);
189  update();
190 }
DISPLIB::AverageScene::AverageScene
AverageScene(QGraphicsView *view, QObject *parent=0)
Definition: averagescene.cpp:63
DISPLIB::SelectionSceneItem::m_qpChannelPosition
QPointF m_qpChannelPosition
Definition: selectionsceneitem.h:122
DISPLIB::LayoutScene
The LayoutScene class provides a reimplemented QGraphicsScene for 2D layout plotting....
Definition: layoutscene.h:81
DISPLIB::AverageSceneItem::sceneUpdateRequested
void sceneUpdateRequested()
DISPLIB::AverageScene::repaintSelectionItems
void repaintSelectionItems(const DISPLIB::SelectionItem &selectedChannelItems)
Definition: averagescene.cpp:110
DISPLIB::SelectionItem::m_iChannelUnit
QList< int > m_iChannelUnit
Definition: selectionsceneitem.h:82
DISPLIB::AverageScene::setScaleMap
void setScaleMap(const QMap< qint32, float > &scaleMap)
Definition: averagescene.cpp:71
DISPLIB::AverageSceneItem
The AverageSceneItem class provides a new data structure for visualizing averages in a 2D layout.
Definition: averagesceneitem.h:79
DISPLIB::AverageScene::updateScene
void updateScene()
Definition: averagescene.cpp:167
DISPLIB::SelectionSceneItem::m_iChannelNumber
int m_iChannelNumber
Definition: selectionsceneitem.h:119
averagesceneitem.h
Contains the declaration of the AverageSceneItem class.
DISPLIB::SelectionSceneItem::m_iChannelKind
int m_iChannelKind
Definition: selectionsceneitem.h:120
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
DISPLIB::AverageScene::setActivationPerAverage
void setActivationPerAverage(const QSharedPointer< QMap< QString, bool > > qMapActivationPerAverage)
Definition: averagescene.cpp:130
DISPLIB::AverageSceneItem::m_scaleMap
QMap< qint32, float > m_scaleMap
Definition: averagesceneitem.h:128
selectionsceneitem.h
Contains the declaration of the SelectionSceneItem class.
DISPLIB::SelectionItem::m_qpChannelPosition
QList< QPointF > m_qpChannelPosition
Definition: selectionsceneitem.h:83
DISPLIB::AverageScene::getSignalColorForAllItems
const QColor & getSignalColorForAllItems()
Definition: averagescene.cpp:160
DISPLIB::AverageScene::setSignalItemColor
void setSignalItemColor(const QColor &signalColor)
Definition: averagescene.cpp:174
DISPLIB::AverageScene::repaintItems
void repaintItems(const QList< QGraphicsItem * > &selectedChannelItems)
Definition: averagescene.cpp:86
DISPLIB::SelectionItem::m_iChannelKind
QList< int > m_iChannelKind
Definition: selectionsceneitem.h:81
DISPLIB::SelectionSceneItem
Definition: selectionsceneitem.h:87
DISPLIB::SelectionSceneItem::m_sChannelName
QString m_sChannelName
Definition: selectionsceneitem.h:118
DISPLIB::AverageScene::setColorPerAverage
void setColorPerAverage(const QSharedPointer< QMap< QString, QColor > > qMapAverageColor)
Definition: averagescene.cpp:145
DISPLIB::SelectionSceneItem::m_iChannelUnit
int m_iChannelUnit
Definition: selectionsceneitem.h:121
averagescene.h
Contains the declaration of the AverageScene class.
DISPLIB::SelectionItem::m_sChannelName
QList< QString > m_sChannelName
Definition: selectionsceneitem.h:79