v2.0.0
Loading...
Searching...
No Matches
projectorsview.cpp
Go to the documentation of this file.
1//=============================================================================================================
15
16//=============================================================================================================
17// INCLUDES
18//=============================================================================================================
19
20#include "projectorsview.h"
21
22//=============================================================================================================
23// QT INCLUDES
24//=============================================================================================================
25
26#include <QCheckBox>
27#include <QGridLayout>
28#include <QFrame>
29#include <QSettings>
30
31//=============================================================================================================
32// EIGEN INCLUDES
33//=============================================================================================================
34
35//=============================================================================================================
36// USED NAMESPACES
37//=============================================================================================================
38
39using namespace DISPLIB;
40using namespace FIFFLIB;
41
42//=============================================================================================================
43// DEFINE MEMBER METHODS
44//=============================================================================================================
45
46ProjectorsView::ProjectorsView(const QString& sSettingsPath,
47 QWidget *parent,
48 Qt::WindowFlags f)
49: AbstractView(parent, f)
51{
52 m_sSettingsPath = sSettingsPath;
53 this->setWindowTitle("Projectors");
54 this->setMinimumWidth(330);
55 this->setMaximumWidth(330);
56
58 redrawGUI();
59}
60
61//=============================================================================================================
62
67
68//=============================================================================================================
69
70QList<FIFFLIB::FiffProj> ProjectorsView::getProjectors() const
71{
72 return m_pProjs;
73}
74
75//=============================================================================================================
76
77void ProjectorsView::setProjectors(const QList<FIFFLIB::FiffProj>& projs)
78{
79 m_pProjs = projs;
80
81 for(int i = 0; i < m_pProjs.size(); ++i) {
82 if(!m_mapProjActive.contains(m_pProjs.at(i).desc)) {
83 m_mapProjActive.insert(m_pProjs.at(i).desc, m_pProjs.at(i).active);
84 } else {
85 m_pProjs[i].active = m_mapProjActive[m_pProjs.at(i).desc];
86 }
87 }
88
89 redrawGUI();
90}
91
92//=============================================================================================================
93
95{
96 if(m_pProjs.isEmpty()) {
97 return;
98 }
99
100 m_qListProjCheckBox.clear();
101
102 // Projection Selection
103 QGridLayout *topLayout = new QGridLayout;
104
105 bool bAllActivated = true;
106
107 qint32 i = 0;
108
109 for(; i < m_pProjs.size(); ++i) {
110 QCheckBox* checkBox = new QCheckBox(m_pProjs.at(i).desc);
111
112 if(m_pProjs.at(i).active == false) {
113 bAllActivated = false;
114 }
115
116 m_qListProjCheckBox.append(checkBox);
117
118 connect(checkBox, &QCheckBox::toggled,
120
121 checkBox->setChecked(m_pProjs.at(i).active);
122
123 topLayout->addWidget(checkBox, i, 0);
124 }
125
126 QFrame* line = new QFrame();
127 line->setFrameShape(QFrame::HLine);
128 line->setFrameShadow(QFrame::Sunken);
129
130 topLayout->addWidget(line, i+1, 0);
131
132 m_pEnableDisableProjectors = new QCheckBox("Enable all");
133 m_pEnableDisableProjectors->setChecked(bAllActivated);
134 topLayout->addWidget(m_pEnableDisableProjectors, i+2, 0);
135 connect(m_pEnableDisableProjectors, static_cast<void (QCheckBox::*)(bool)>(&QCheckBox::clicked),
137
138 this->setLayout(topLayout);
139
141}
142
143//=============================================================================================================
144
146{
147 if(m_sSettingsPath.isEmpty()) {
148 return;
149 }
150
151 QSettings settings("MNECPP");
152
153 settings.beginGroup(m_sSettingsPath + QString("/ProjectorsView/projectorsActive"));
154
155 QMap<QString,bool>::const_iterator iProj = m_mapProjActive.constBegin();
156 while (iProj != m_mapProjActive.constEnd()) {
157 settings.setValue(iProj.key(), iProj.value());
158 ++iProj;
159 }
160
161 settings.endGroup();
162}
163
164//=============================================================================================================
165
167{
168 if(m_sSettingsPath.isEmpty()) {
169 return;
170 }
171
172 QSettings settings("MNECPP");
173
174 settings.beginGroup(m_sSettingsPath + QString("/ProjectorsView/projectorsActive"));
175
176 QStringList keys = settings.childKeys();
177 foreach (QString key, keys) {
178 m_mapProjActive[key] = settings.value(key).toBool();
179 }
180 settings.endGroup();
181}
182
183//=============================================================================================================
184
186{
187 switch(mode) {
189 break;
190 default: // default is research mode
191 break;
192 }
193}
194
195//=============================================================================================================
196
198{
199 switch(mode) {
201 break;
202 default: // default is realtime mode
203 break;
204 }
205}
206
207//=============================================================================================================
208
210{
211 //Set all checkboxes to status
212 for(int i = 0; i<m_qListProjCheckBox.size(); i++) {
213 m_qListProjCheckBox.at(i)->setChecked(status);
214 }
215
216 //Set all projection activation states to status
217 for(int i = 0; i < m_pProjs.size(); ++i) {
218 m_pProjs[i].active = status;
219 m_mapProjActive[m_pProjs.at(i).desc] = status;
220
221 }
222
224 m_pEnableDisableProjectors->setChecked(status);
225 }
226
228
229 saveSettings();
230}
231
232//=============================================================================================================
233
235{
236 bool bAllActivated = true;
237
238 for(qint32 i = 0; i < m_qListProjCheckBox.size(); ++i) {
239 if(m_qListProjCheckBox.at(i)->isChecked() == false) {
240 bAllActivated = false;
241 }
242
243 m_pProjs[i].active = m_qListProjCheckBox.at(i)->isChecked();
244 m_mapProjActive[m_pProjs.at(i).desc] = m_qListProjCheckBox.at(i)->isChecked();
245 }
246
248 m_pEnableDisableProjectors->setChecked(bAllActivated);
249 }
250
252
253 saveSettings();
254}
255
256//=============================================================================================================
257
259{
260
261}
SSP projector enable / disable checkbox list.
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 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)
QMap< QString, bool > m_mapProjActive
void updateGuiMode(GuiMode mode)
QList< QCheckBox * > m_qListProjCheckBox
QList< FIFFLIB::FiffProj > getProjectors() const
QList< FIFFLIB::FiffProj > m_pProjs