MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
projectorsview.cpp
Go to the documentation of this file.
1//=============================================================================================================
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "projectorsview.h"
40
41//=============================================================================================================
42// QT INCLUDES
43//=============================================================================================================
44
45#include <QCheckBox>
46#include <QGridLayout>
47#include <QFrame>
48#include <QSettings>
49
50//=============================================================================================================
51// EIGEN INCLUDES
52//=============================================================================================================
53
54//=============================================================================================================
55// USED NAMESPACES
56//=============================================================================================================
57
58using namespace DISPLIB;
59using namespace FIFFLIB;
60
61//=============================================================================================================
62// DEFINE MEMBER METHODS
63//=============================================================================================================
64
65ProjectorsView::ProjectorsView(const QString& sSettingsPath,
66 QWidget *parent,
67 Qt::WindowFlags f)
68: AbstractView(parent, f)
69, m_pEnableDisableProjectors(Q_NULLPTR)
70{
71 m_sSettingsPath = sSettingsPath;
72 this->setWindowTitle("Projectors");
73 this->setMinimumWidth(330);
74 this->setMaximumWidth(330);
75
77 redrawGUI();
78}
79
80//=============================================================================================================
81
86
87//=============================================================================================================
88
89QList<FIFFLIB::FiffProj> ProjectorsView::getProjectors() const
90{
91 return m_pProjs;
92}
93
94//=============================================================================================================
95
96void ProjectorsView::setProjectors(const QList<FIFFLIB::FiffProj>& projs)
97{
98 m_pProjs = projs;
99
100 for(int i = 0; i < m_pProjs.size(); ++i) {
101 if(!m_mapProjActive.contains(m_pProjs.at(i).desc)) {
102 m_mapProjActive.insert(m_pProjs.at(i).desc, m_pProjs.at(i).active);
103 } else {
104 m_pProjs[i].active = m_mapProjActive[m_pProjs.at(i).desc];
105 }
106 }
107
108 redrawGUI();
109}
110
111//=============================================================================================================
112
114{
115 if(m_pProjs.isEmpty()) {
116 return;
117 }
118
119 m_qListProjCheckBox.clear();
120
121 // Projection Selection
122 QGridLayout *topLayout = new QGridLayout;
123
124 bool bAllActivated = true;
125
126 qint32 i = 0;
127
128 for(i; i < m_pProjs.size(); ++i) {
129 QCheckBox* checkBox = new QCheckBox(m_pProjs.at(i).desc);
130
131 if(m_pProjs.at(i).active == false) {
132 bAllActivated = false;
133 }
134
135 m_qListProjCheckBox.append(checkBox);
136
137 connect(checkBox, &QCheckBox::toggled,
139
140 checkBox->setChecked(m_pProjs.at(i).active);
141
142 topLayout->addWidget(checkBox, i, 0);
143 }
144
145 QFrame* line = new QFrame();
146 line->setFrameShape(QFrame::HLine);
147 line->setFrameShadow(QFrame::Sunken);
148
149 topLayout->addWidget(line, i+1, 0);
150
151 m_pEnableDisableProjectors = new QCheckBox("Enable all");
152 m_pEnableDisableProjectors->setChecked(bAllActivated);
153 topLayout->addWidget(m_pEnableDisableProjectors, i+2, 0);
154 connect(m_pEnableDisableProjectors, static_cast<void (QCheckBox::*)(bool)>(&QCheckBox::clicked),
156
157 this->setLayout(topLayout);
158
160}
161
162//=============================================================================================================
163
165{
166 if(m_sSettingsPath.isEmpty()) {
167 return;
168 }
169
170 QSettings settings("MNECPP");
171
172 settings.beginGroup(m_sSettingsPath + QString("/ProjectorsView/projectorsActive"));
173
174 QMap<QString,bool>::const_iterator iProj = m_mapProjActive.constBegin();
175 while (iProj != m_mapProjActive.constEnd()) {
176 settings.setValue(iProj.key(), iProj.value());
177 ++iProj;
178 }
179
180 settings.endGroup();
181}
182
183//=============================================================================================================
184
186{
187 if(m_sSettingsPath.isEmpty()) {
188 return;
189 }
190
191 QSettings settings("MNECPP");
192
193 settings.beginGroup(m_sSettingsPath + QString("/ProjectorsView/projectorsActive"));
194
195 QStringList keys = settings.childKeys();
196 foreach (QString key, keys) {
197 m_mapProjActive[key] = settings.value(key).toBool();
198 }
199 settings.endGroup();
200}
201
202//=============================================================================================================
203
205{
206 switch(mode) {
207 case GuiMode::Clinical:
208 break;
209 default: // default is research mode
210 break;
211 }
212}
213
214//=============================================================================================================
215
217{
218 switch(mode) {
219 case ProcessingMode::Offline:
220 break;
221 default: // default is realtime mode
222 break;
223 }
224}
225
226//=============================================================================================================
227
229{
230 //Set all checkboxes to status
231 for(int i = 0; i<m_qListProjCheckBox.size(); i++) {
232 m_qListProjCheckBox.at(i)->setChecked(status);
233 }
234
235 //Set all projection activation states to status
236 for(int i = 0; i < m_pProjs.size(); ++i) {
237 m_pProjs[i].active = status;
238 m_mapProjActive[m_pProjs.at(i).desc] = status;
239
240 }
241
243 m_pEnableDisableProjectors->setChecked(status);
244 }
245
247
248 saveSettings();
249}
250
251//=============================================================================================================
252
254{
255 bool bAllActivated = true;
256
257 for(qint32 i = 0; i < m_qListProjCheckBox.size(); ++i) {
258 if(m_qListProjCheckBox.at(i)->isChecked() == false) {
259 bAllActivated = false;
260 }
261
262 m_pProjs[i].active = m_qListProjCheckBox.at(i)->isChecked();
263 m_mapProjActive[m_pProjs.at(i).desc] = m_qListProjCheckBox.at(i)->isChecked();
264 }
265
267 m_pEnableDisableProjectors->setChecked(bAllActivated);
268 }
269
271
272 saveSettings();
273}
274
275//=============================================================================================================
276
278{
279
280}
Declaration of the ProjectorsView Class.
The AbstractView class provides the base calss for all Disp viewers.
void setProjectors(const QList< FIFFLIB::FiffProj > &projs)
void updateProcessingMode(ProcessingMode mode)
QCheckBox * m_pEnableDisableProjectors
void onEnableDisableAllProj(bool status)
ProjectorsView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
void projSelectionChanged(const QList< FIFFLIB::FiffProj > &projs)
void updateGuiMode(GuiMode mode)
QList< QCheckBox * > m_qListProjCheckBox
QList< FIFFLIB::FiffProj > getProjectors() const
QList< FIFFLIB::FiffProj > m_pProjs