v2.0.0
Loading...
Searching...
No Matches
compensatorview.cpp
Go to the documentation of this file.
1//=============================================================================================================
14
15//=============================================================================================================
16// INCLUDES
17//=============================================================================================================
18
19#include "compensatorview.h"
20
21#include <fiff/fiff_ctf_comp.h>
22
23//=============================================================================================================
24// QT INCLUDES
25//=============================================================================================================
26
27#include <QCheckBox>
28#include <QGridLayout>
29#include <QSignalMapper>
30#include <QSettings>
31#include <QDebug>
32
33//=============================================================================================================
34// EIGEN INCLUDES
35//=============================================================================================================
36
37//=============================================================================================================
38// USED NAMESPACES
39//=============================================================================================================
40
41using namespace DISPLIB;
42using namespace FIFFLIB;
43
44//=============================================================================================================
45// DEFINE MEMBER METHODS
46//=============================================================================================================
47
48CompensatorView::CompensatorView(const QString& sSettingsPath,
49 QWidget *parent,
50 Qt::WindowFlags f)
51: AbstractView(parent, f)
52, m_iLastTo(0)
53{
54 m_sSettingsPath = sSettingsPath;
55 this->setWindowTitle("Compensators");
56 this->setMinimumWidth(330);
57 this->setMaximumWidth(330);
58
60 redrawGUI();
61}
62
63//=============================================================================================================
64
69
70//=============================================================================================================
71
72QList<FIFFLIB::FiffCtfComp> CompensatorView::getCompensators() const
73{
74 return m_pComps;
75}
76
77//=============================================================================================================
78
79void CompensatorView::setCompensators(const QList<FIFFLIB::FiffCtfComp>& comps)
80{
81 m_pComps = comps;
82
83 for(int i = 0; i < m_pComps.size(); ++i) {
84 if(!m_mapCompActive.contains(m_pComps.at(i).kind)) {
85 m_mapCompActive.insert(m_pComps.at(i).kind, false);
86 }
87 }
88
89 redrawGUI();
90}
91
92//=============================================================================================================
93
95{
96 if(m_sSettingsPath.isEmpty()) {
97 return;
98 }
99
100 QSettings settings("MNECPP");
101
102 settings.beginGroup(m_sSettingsPath + QString("/CompensatorView/compensatorActive"));
103
104 QMap<int,bool>::const_iterator iComp = m_mapCompActive.constBegin();
105 while (iComp != m_mapCompActive.constEnd()) {
106 settings.setValue(QString::number(iComp.key()), iComp.value());
107 ++iComp;
108 }
109
110 settings.endGroup();
111}
112
113//=============================================================================================================
114
116{
117 if(m_sSettingsPath.isEmpty()) {
118 return;
119 }
120
121 QSettings settings("MNECPP");
122
123 settings.beginGroup(m_sSettingsPath + QString("/CompensatorView/compensatorActive"));
124
125 QStringList keys = settings.childKeys();
126 foreach (QString key, keys) {
127 m_mapCompActive[key.toInt()] = settings.value(key).toBool();
128 }
129
130 settings.endGroup();
131}
132
133//=============================================================================================================
134
136{
137 switch(mode) {
139 break;
140 default: // default is research mode
141 break;
142 }
143}
144
145//=============================================================================================================
146
148{
149 switch(mode) {
151 break;
152 default: // default is realtime mode
153 break;
154 }
155}
156
157//=============================================================================================================
158
160{
161 return m_iLastTo;
162}
163
164//=============================================================================================================
165
167{
168 if(m_pComps.isEmpty()) {
169 return;
170 }
171
172 m_qListCompCheckBox.clear();
173
174 // Compensation Selection
175 QGridLayout *topLayout = new QGridLayout;
176
177 for(int i = 0; i < m_pComps.size(); ++i) {
178 QString numStr;
179 QCheckBox* checkBox = new QCheckBox(numStr.setNum(m_pComps[i].kind));
180
181 m_qListCompCheckBox.append(checkBox);
182
183 connect(checkBox, &QCheckBox::toggled,
185
186 checkBox->setChecked(m_mapCompActive[m_pComps.at(i).kind]);
187
188 topLayout->addWidget(checkBox, i, 0);
189 }
190
191 //Find Comp tab and add current layout
192 this->setLayout(topLayout);
193}
194
195//=============================================================================================================
196
198{
199 if(QCheckBox* pCheckBox = qobject_cast<QCheckBox*>(sender())) {
200 bool currentState = false;
201 QString compName = pCheckBox->text();
202
203 for(int i = 0; i < m_qListCompCheckBox.size(); ++i) {
204 if(m_qListCompCheckBox[i]->text() != compName) {
205 m_qListCompCheckBox[i]->setChecked(false);
206 m_mapCompActive[compName.toInt()] = false;
207 } else {
208 currentState = m_qListCompCheckBox[i]->isChecked();
209 m_mapCompActive[compName.toInt()] = currentState;
210 }
211 }
212
213 if(currentState) {
214 emit compSelectionChanged(compName.toInt());
215 m_iLastTo = compName.toInt();
216 } else { //If none selected
217 emit compSelectionChanged(0);
218 m_iLastTo = 0;
219 }
220 }
221
222 saveSettings();
223}
224
225//=============================================================================================================
226
228{
229
230}
Gradient-compensation grade selector for Neuromag / CTF systems.
CTF / 4D Neuroimaging software gradient-compensation matrix block (FIFFB_MNE_CTF_COMP_DATA).
FIFF file I/O, in-memory data structures and high-level readers/writers.
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
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
QMap< int, bool > m_mapCompActive