MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
compensatorview.cpp
Go to the documentation of this file.
1//=============================================================================================================
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "compensatorview.h"
40
41#include <fiff/fiff_ctf_comp.h>
42
43//=============================================================================================================
44// QT INCLUDES
45//=============================================================================================================
46
47#include <QCheckBox>
48#include <QGridLayout>
49#include <QSignalMapper>
50#include <QSettings>
51#include <QDebug>
52
53//=============================================================================================================
54// EIGEN INCLUDES
55//=============================================================================================================
56
57//=============================================================================================================
58// USED NAMESPACES
59//=============================================================================================================
60
61using namespace DISPLIB;
62using namespace FIFFLIB;
63
64//=============================================================================================================
65// DEFINE MEMBER METHODS
66//=============================================================================================================
67
68CompensatorView::CompensatorView(const QString& sSettingsPath,
69 QWidget *parent,
70 Qt::WindowFlags f)
71: AbstractView(parent, f)
72, m_iLastTo(0)
73{
74 m_sSettingsPath = sSettingsPath;
75 this->setWindowTitle("Compensators");
76 this->setMinimumWidth(330);
77 this->setMaximumWidth(330);
78
80 redrawGUI();
81}
82
83//=============================================================================================================
84
89
90//=============================================================================================================
91
92QList<FIFFLIB::FiffCtfComp> CompensatorView::getCompensators() const
93{
94 return m_pComps;
95}
96
97//=============================================================================================================
98
99void CompensatorView::setCompensators(const QList<FIFFLIB::FiffCtfComp>& comps)
100{
101 m_pComps = comps;
102
103 for(int i = 0; i < m_pComps.size(); ++i) {
104 if(!m_mapCompActive.contains(m_pComps.at(i).kind)) {
105 m_mapCompActive.insert(m_pComps.at(i).kind, false);
106 }
107 }
108
109 redrawGUI();
110}
111
112//=============================================================================================================
113
115{
116 if(m_sSettingsPath.isEmpty()) {
117 return;
118 }
119
120 QSettings settings("MNECPP");
121
122 settings.beginGroup(m_sSettingsPath + QString("/CompensatorView/compensatorActive"));
123
124 QMap<int,bool>::const_iterator iComp = m_mapCompActive.constBegin();
125 while (iComp != m_mapCompActive.constEnd()) {
126 settings.setValue(QString::number(iComp.key()), iComp.value());
127 ++iComp;
128 }
129
130 settings.endGroup();
131}
132
133//=============================================================================================================
134
136{
137 if(m_sSettingsPath.isEmpty()) {
138 return;
139 }
140
141 QSettings settings("MNECPP");
142
143 settings.beginGroup(m_sSettingsPath + QString("/CompensatorView/compensatorActive"));
144
145 QStringList keys = settings.childKeys();
146 foreach (QString key, keys) {
147 m_mapCompActive[key.toInt()] = settings.value(key).toBool();
148 }
149
150 settings.endGroup();
151}
152
153//=============================================================================================================
154
156{
157 switch(mode) {
158 case GuiMode::Clinical:
159 break;
160 default: // default is research mode
161 break;
162 }
163}
164
165//=============================================================================================================
166
168{
169 switch(mode) {
170 case ProcessingMode::Offline:
171 break;
172 default: // default is realtime mode
173 break;
174 }
175}
176
177//=============================================================================================================
178
180{
181 return m_iLastTo;
182}
183
184//=============================================================================================================
185
187{
188 if(m_pComps.isEmpty()) {
189 return;
190 }
191
192 m_qListCompCheckBox.clear();
193
194 // Compensation Selection
195 QGridLayout *topLayout = new QGridLayout;
196
197 for(int i = 0; i < m_pComps.size(); ++i) {
198 QString numStr;
199 QCheckBox* checkBox = new QCheckBox(numStr.setNum(m_pComps[i].kind));
200
201 m_qListCompCheckBox.append(checkBox);
202
203 connect(checkBox, &QCheckBox::toggled,
205
206 checkBox->setChecked(m_mapCompActive[m_pComps.at(i).kind]);
207
208 topLayout->addWidget(checkBox, i, 0);
209 }
210
211 //Find Comp tab and add current layout
212 this->setLayout(topLayout);
213}
214
215//=============================================================================================================
216
218{
219 if(QCheckBox* pCheckBox = qobject_cast<QCheckBox*>(sender())) {
220 bool currentState = false;
221 QString compName = pCheckBox->text();
222
223 for(int i = 0; i < m_qListCompCheckBox.size(); ++i) {
224 if(m_qListCompCheckBox[i]->text() != compName) {
225 m_qListCompCheckBox[i]->setChecked(false);
226 m_mapCompActive[compName.toInt()] = false;
227 } else {
228 currentState = m_qListCompCheckBox[i]->isChecked();
229 m_mapCompActive[compName.toInt()] = currentState;
230 }
231 }
232
233 if(currentState) {
234 emit compSelectionChanged(compName.toInt());
235 m_iLastTo = compName.toInt();
236 } else { //If none selected
237 emit compSelectionChanged(0);
238 m_iLastTo = 0;
239 }
240 }
241
242 saveSettings();
243}
244
245//=============================================================================================================
246
248{
249
250}
Declaration of the CompensatorView Class.
FiffCtfComp class declaration.
The AbstractView class provides the base calss for all Disp viewers.
void updateProcessingMode(ProcessingMode mode)
CompensatorView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
QList< FIFFLIB::FiffCtfComp > m_pComps
QList< FIFFLIB::FiffCtfComp > getCompensators() const
void updateGuiMode(GuiMode mode)
void compSelectionChanged(int to)
void setCompensators(const QList< FIFFLIB::FiffCtfComp > &comps)
QList< QCheckBox * > m_qListCompCheckBox