v2.0.0
Loading...
Searching...
No Matches
averageselectionview.cpp
Go to the documentation of this file.
1//=============================================================================================================
14
15//=============================================================================================================
16// INCLUDES
17//=============================================================================================================
18
20
22
23//=============================================================================================================
24// QT INCLUDES
25//=============================================================================================================
26
27#include <QGridLayout>
28#include <QCheckBox>
29#include <QColorDialog>
30#include <QPalette>
31#include <QPushButton>
32#include <QDebug>
33#include <QSettings>
34#include <QPointer>
35
36//=============================================================================================================
37// EIGEN INCLUDES
38//=============================================================================================================
39
40#include<Eigen/Core>
41
42//=============================================================================================================
43// USED NAMESPACES
44//=============================================================================================================
45
46using namespace DISPLIB;
47using namespace Eigen;
48
49//=============================================================================================================
50// DEFINE MEMBER METHODS
51//=============================================================================================================
52
53AverageSelectionView::AverageSelectionView(const QString& sSettingsPath,
54 QWidget *parent,
55 Qt::WindowFlags f)
56: AbstractView(parent, f)
58, m_qMapAverageColor(QSharedPointer<QMap<QString, QColor> >::create())
59, m_qMapAverageActivation(QSharedPointer<QMap<QString, bool> >::create())
60{
61 m_sSettingsPath = sSettingsPath;
62 this->setWindowTitle("Average Selection");
63 this->setMinimumWidth(330);
64 this->setMaximumWidth(330);
65
67 redrawGUI();
68}
69
70//=============================================================================================================
71
76
77//=============================================================================================================
78
79QSharedPointer<QMap<QString, QColor> > AverageSelectionView::getAverageColor() const
80{
81 return m_qMapAverageColor;
82}
83
84//=============================================================================================================
85
86QSharedPointer<QMap<QString, bool> > AverageSelectionView::getAverageActivation() const
87{
89}
90
91//=============================================================================================================
92
93void AverageSelectionView::setAverageColor(const QSharedPointer<QMap<QString, QColor> > qMapAverageColor)
94{
95 m_qMapAverageColor = qMapAverageColor;
96 redrawGUI();
97}
98
99//=============================================================================================================
100
101void AverageSelectionView::setAverageActivation(const QSharedPointer<QMap<QString, bool> > qMapAverageActivation)
102{
103 m_qMapAverageActivation = qMapAverageActivation;
104 redrawGUI();
105}
106
107//=============================================================================================================
108
110{
111 if(m_sSettingsPath.isEmpty()) {
112 return;
113 }
114
115 QSettings settings("MNECPP");
116
117 settings.beginGroup(m_sSettingsPath + QString("/AverageSelectionView/averageColorMap"));
118 QMap<QString, QColor>::const_iterator iColor = m_qMapAverageColor->constBegin();
119 while (iColor != m_qMapAverageColor->constEnd()) {
120 settings.setValue(iColor.key(), iColor.value());
121 ++iColor;
122 }
123 settings.endGroup();
124
125 settings.beginGroup(m_sSettingsPath + QString("/AverageSelectionView/averageActivationMap"));
126 QMap<QString, bool>::const_iterator iActivation = m_qMapAverageActivation->constBegin();
127 while (iActivation != m_qMapAverageActivation->constEnd()) {
128 settings.setValue(iActivation.key(), iActivation.value());
129 ++iActivation;
130 }
131 settings.endGroup();
132}
133
134//=============================================================================================================
135
137{
138 if(m_sSettingsPath.isEmpty()) {
139 return;
140 }
141
142 QSettings settings("MNECPP");
143
144 settings.beginGroup(m_sSettingsPath + QString("/AverageSelectionView/averageColorMap"));
145 QStringList keys = settings.childKeys();
146 foreach (QString key, keys) {
147 m_qMapAverageColor->insert(key, settings.value(key).value<QColor>());
148 }
149 settings.endGroup();
150
151 settings.beginGroup(m_sSettingsPath + QString("/AverageSelectionView/averageActivationMap"));
152 keys = settings.childKeys();
153 foreach (QString key, keys) {
154 m_qMapAverageActivation->insert(key, settings.value(key).toBool());
155 }
156 settings.endGroup();
157}
158
159//=============================================================================================================
160
162{
163 switch(mode) {
165 break;
166 default: // default is research mode
167 break;
168 }
169}
170
171//=============================================================================================================
172
174{
175 switch(mode) {
177 break;
178 default: // default is realtime mode
179 break;
180 }
181}
182
183//=============================================================================================================
184
186{
187 if(m_qMapAverageColor->size() != m_qMapAverageActivation->size()) {
188 qDebug() << "AverageSelectionView::update - m_qMapAverageColor and m_qMapAverageActivation do not match in size. Returning.";
189 return;
190 }
191
192 //Delete all widgets in the averages layout
193 QGridLayout* topLayout = static_cast<QGridLayout*>(this->layout());
194 if(!topLayout) {
195 topLayout = new QGridLayout();
196 }
197
198 QLayoutItem *child;
199 while ((child = topLayout->takeAt(0)) != 0) {
200 delete child->widget();
201 delete child;
202 }
203
204 // Create new GUI elements
205 QMapIterator<QString, QColor> itr(*m_qMapAverageColor);
206 int count = 0;
207 while(itr.hasNext()) {
208 if(count >= m_iMaxNumAverages) {
209 break;
210 }
211
212 itr.next();
213
214 //Create average active checkbox
215 QPointer<QCheckBox> pCheckBox = new QCheckBox(itr.key());
216 pCheckBox->setChecked(m_qMapAverageActivation->value(itr.key()));
217 pCheckBox->setObjectName(itr.key());
218 topLayout->addWidget(pCheckBox, count, 0);
219 connect(pCheckBox.data(), &QCheckBox::clicked,
221
222 //Create average color pushbutton
223 QColor color = itr.value();
224 QPointer<QPushButton> pButton = new QPushButton("Click to change");
225 pButton->setObjectName(itr.key());
226 pButton->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(color.red()).arg(color.green()).arg(color.blue()));
227 topLayout->addWidget(pButton, count, 1);
228 connect(pButton.data(), &QPushButton::clicked,
230
231 ++count;
232 }
233
234 this->setLayout(topLayout);
235}
236
237//=============================================================================================================
238
240{
241 //Change color for average
242 if(QPointer<QPushButton> button = qobject_cast<QPushButton*>(sender())) {
243 QString sObjectName = button->objectName();
244
245 QColor color = QColorDialog::getColor(m_qMapAverageColor->value(sObjectName), this, "Set average color");
246
247 if(button) {
248 QPalette palette(QPalette::Button,color);
249 button->setPalette(palette);
250 button->update();
251
252 //Set color of button new new scene color
253 button->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(color.red()).arg(color.green()).arg(color.blue()));
254 }
255
256 m_qMapAverageColor->insert(sObjectName, color);
257
259 }
260
261 //Change color for average
262 if(QPointer<QCheckBox> checkBox = qobject_cast<QCheckBox*>(sender())) {
263 QString sObjectName = checkBox->objectName();
264
265 m_qMapAverageActivation->insert(sObjectName, checkBox->isChecked());
266
268 }
269
270 saveSettings();
271}
272
273//=============================================================================================================
274
Tabular picker for choosing which averaged conditions are visible and their plot colours.
Set of averaged evoked responses sharing a FiffInfo, plus the ave-style category / rejection descript...
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
void newAverageActivationMap(const QSharedPointer< QMap< QString, bool > > qMapAverageActivation)
AverageSelectionView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
QSharedPointer< QMap< QString, QColor > > getAverageColor() const
void newAverageColorMap(const QSharedPointer< QMap< QString, QColor > > qMapAverageColor)
void updateProcessingMode(ProcessingMode mode)
QSharedPointer< QMap< QString, bool > > m_qMapAverageActivation
QSharedPointer< QMap< QString, bool > > getAverageActivation() const
void setAverageActivation(const QSharedPointer< QMap< QString, bool > > qMapAverageActivation)
void setAverageColor(const QSharedPointer< QMap< QString, QColor > > qMapAverageColor)
QSharedPointer< QMap< QString, QColor > > m_qMapAverageColor