MNE-CPP  beta 1.0
settingwindow.cpp
1 //=============================================================================================================
38 //*************************************************************************************************************
39 //=============================================================================================================
40 // INCLUDES
41 //=============================================================================================================
42 #include "settingwindow.h"
43 #include "ui_settingwindow.h"
44 #include "mainwindow.h"
45 #include "QToolTip"
46 
47 //*************************************************************************************************************************************
48 
49 settingwindow::settingwindow(QWidget *parent) : QWidget(parent), ui(new Ui::settingwindow)
50 {
51  ui->setupUi(this);
52 
53  QSettings settings;
54  move(settings.value("pos_settings", QPoint(200, 200)).toPoint());
55  this->cb_model = new QStandardItemModel;
56  connect(this->cb_model, SIGNAL(dataChanged ( const QModelIndex&, const QModelIndex&)), this, SLOT(cb_selection_changed(const QModelIndex&, const QModelIndex&)));
57 
58  set_values();
59 }
60 
61 //*****************************************************************************************************************
62 
63 settingwindow::~settingwindow()
64 {
65  delete ui;
66 }
67 
68 //*****************************************************************************************************************
69 
70 void settingwindow::set_values()
71 {
72  QSettings settings;
73  fill_signal_type_combobox();
74  ui->chb_fixphase->setChecked(settings.value("fixPhase", false).toBool());
75  ui->chb_show_warnings->setChecked(settings.value("show_warnings", true).toBool());
76  ui->chb_show_infos->setChecked(settings.value("show_infos", true).toBool());
77  ui->chb_sort_results->setChecked(settings.value("sort_results", true).toBool());
78  ui->sb_adaptive_iteration->setValue(settings.value("adaptive_iterations", 1E3).toInt());
79  ui->dsb_adaptive_reflection->setValue(settings.value("adaptive_reflection", 1.00).toDouble());
80  ui->dsb_adaptive_expansion->setValue(settings.value("adaptive_expansion", 0.20).toDouble());
81  ui->dsb_adaptive_contraction->setValue(settings.value("adaptive_contraction", 0.5).toDouble());
82  ui->dsb_adaptive_fullcontraction->setValue(settings.value("adaptive_fullcontraction", 0.50).toDouble());
83  ui->sb_div_dict->setValue(settings.value("pdict_count", 8).toInt());
84  ui->chb_color_scheme->setChecked(settings.value("pastell_colors", false).toBool());
85  ui->dsb_delta_energy->setValue(settings.value("delta_energy", 0.0005).toDouble());
86  ui->sl_boost_fixDict->setValue(-1 * (settings.value("boost_fixDict", 0).toInt()));
87  ui->sl_boost->setValue(-1 * (settings.value("boost", 0).toInt()));
88  ui->chb_phys_params->setChecked(settings.value("show_phys_params", false).toBool());
89  ui->chb_trial_separation->setChecked(settings.value("trial_separation", false).toBool());
90 
91  if(settings.value("boost").toInt()== 0)
92  ui->sl_boost->setToolTip("only 1 channel consulted");
93  else
94  ui->sl_boost->setToolTip(QString("consulted channels: %1% ").arg(settings.value("boost").toInt()));
95 
96  if(settings.value("boost_fixDict").toInt()== 0)
97  ui->sl_boost_fixDict->setToolTip("only 1 channel consulted");
98  else
99  ui->sl_boost_fixDict->setToolTip(QString("consulted channels: %1% ").arg(settings.value("boost_fixDict").toInt()));
100 }
101 
102 //*************************************************************************************************************************************
103 
104 void settingwindow::closeEvent(QCloseEvent * event)
105 {
106  Q_UNUSED(event);
107  QSettings settings;
108  settings.setValue("pos_settings", pos());
109 }
110 
111 //*****************************************************************************************************************
112 
113 void settingwindow::on_btt_close_clicked()
114 {
115  QSettings settings;
116  settings.setValue("channel_names", sel_signal_type_map);
117  settings.setValue("boost", abs(ui->sl_boost->value()));
118  settings.setValue("boost_fixDict", abs(ui->sl_boost_fixDict->value()));
119  settings.setValue("fixPhase", ui->chb_fixphase->isChecked());
120  settings.setValue("adaptive_iterations", ui->sb_adaptive_iteration->value());
121  settings.setValue("adaptive_reflection", ui->dsb_adaptive_reflection->value());
122  settings.setValue("adaptive_expansion", ui->dsb_adaptive_expansion->value());
123  settings.setValue("adaptive_contraction", ui->dsb_adaptive_contraction->value());
124  settings.setValue("adaptive_fullcontraction", ui->dsb_adaptive_fullcontraction->value());
125  settings.setValue("delta_energy", ui->dsb_delta_energy->value());
126  settings.setValue("show_infos", ui->chb_show_infos->isChecked());
127  settings.setValue("show_warnings", ui->chb_show_warnings->isChecked());
128  settings.setValue("sort_results", ui->chb_sort_results->isChecked());
129  settings.setValue("pdict_count", ui->sb_div_dict->value());
130  settings.setValue("pastell_colors", ui->chb_color_scheme->isChecked());
131  settings.setValue("show_phys_params", ui->chb_phys_params->isChecked());
132  settings.setValue("trial_separation", ui->chb_trial_separation->isChecked());
133 
134  emit change_info_label();
135 
136  close();
137 }
138 
139 //*****************************************************************************************************************
140 
141 void settingwindow::on_btt_cancel_clicked()
142 {
143  close();
144 }
145 
146 //*****************************************************************************************************************
147 
148 void settingwindow::on_btt_max_it_default_clicked()
149 {
150  ui->sb_adaptive_iteration->setValue(1000);
151 }
152 
153 //*****************************************************************************************************************
154 
155 void settingwindow::on_btt_reflection_default_clicked()
156 {
157  ui->dsb_adaptive_reflection->setValue(1);
158 }
159 
160 //*****************************************************************************************************************
161 
162 void settingwindow::on_btt_expansion_default_clicked()
163 {
164  ui->dsb_adaptive_expansion->setValue(0.2);
165 }
166 
167 //*****************************************************************************************************************
168 
169 void settingwindow::on_btt_contraction_default_clicked()
170 {
171  ui->dsb_adaptive_contraction->setValue(0.5);
172 }
173 
174 //*****************************************************************************************************************
175 
176 void settingwindow::on_btt_full_contraction_default_clicked()
177 {
178  ui->dsb_adaptive_fullcontraction->setValue(0.5);
179 }
180 
181 //*****************************************************************************************************************
182 
183 void settingwindow::on_sl_boost_valueChanged(int value)
184 {
185  if(value == 0)
186  {
187  QToolTip::showText(ui->sl_boost->mapToGlobal(QPoint(-20 , -35)), "only 1 channel consulted");
188  ui->sl_boost->setToolTip("only 1 channel is consulted");
189  }
190  else
191  {
192  QToolTip::showText(ui->sl_boost->mapToGlobal(QPoint(-20, -35)), QString("consulted channels: %1% ").arg(-1 * value));
193  ui->sl_boost->setToolTip(QString("consulted channels: %1% ").arg(-1 * value));
194  }
195 }
196 
197 //*****************************************************************************************************************
198 
199 void settingwindow::on_sl_boost_sliderPressed()
200 {
201  if(ui->sl_boost->value() == 0)
202  QToolTip::showText(ui->sl_boost->mapToGlobal(QPoint(-20, -35)), "only 1 channel consulted");
203  else
204  QToolTip::showText(ui->sl_boost->mapToGlobal(QPoint(-20, -35)), QString("consulted channels: %1% ").arg(-1 *ui->sl_boost->value()));
205 }
206 
207 //*****************************************************************************************************************
208 
209 void settingwindow::on_sl_boost_fixDict_valueChanged(int value)
210 {
211  if(value == 0)
212  {
213  QToolTip::showText(ui->sl_boost_fixDict->mapToGlobal(QPoint(-20 , -35)), "only 1 channel consulted");
214  ui->sl_boost_fixDict->setToolTip("only 1 channel is consulted");
215  }
216  else
217  {
218  QToolTip::showText(ui->sl_boost_fixDict->mapToGlobal(QPoint(-20, -35)), QString("consulted channels: %1% ").arg(-1 * value));
219  ui->sl_boost_fixDict->setToolTip(QString("consulted channels: %1% ").arg(-1 * value));
220  }
221 }
222 
223 //*****************************************************************************************************************
224 
225 void settingwindow::on_sl_boost_fixDict_sliderPressed()
226 {
227  if(ui->sl_boost_fixDict->value() == 0)
228  QToolTip::showText(ui->sl_boost_fixDict->mapToGlobal(QPoint(-20, -35)), "only 1 channel consulted");
229  else
230  QToolTip::showText(ui->sl_boost_fixDict->mapToGlobal(QPoint(-20, -35)), QString("consulted channels: %1% ").arg(-1 *ui->sl_boost_fixDict->value()));
231 }
232 
233 //*****************************************************************************************************************
234 
235 void settingwindow::on_btt_delta_energy_default_clicked()
236 {
237  ui->dsb_delta_energy->setValue(0.0005);
238 }
239 
240 //*****************************************************************************************************************
241 
242 void settingwindow::fill_signal_type_combobox()
243 {
244  this->cb_items.clear();
245  this->cb_model->clear();
246 
247  QSettings settings;
248  QMap<QString, QVariant> chn_name_map;
249  for(qint32 m = 0; m < 4; m++)
250  chn_name_map.insert(QString("MEG;EEG;STI;EOG").split(';').at(m), true);
251  sel_signal_type_map = chn_name_map = settings.value("channel_names", chn_name_map).toMap();
252  qint32 j = 0;
253  QMapIterator<QString, QVariant> i(chn_name_map);
254  while (i.hasNext())
255  {
256  i.next();
257  //channel item
258  this->cb_item = new QStandardItem;
259  this->cb_item->setText(QString(i.key()));
260  this->cb_item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
261  if(i.value().toBool())
262  this->cb_item->setData(Qt::Checked, Qt::CheckStateRole);
263  else
264  this->cb_item->setData(Qt::Unchecked, Qt::CheckStateRole);
265  this->cb_items.push_back(this->cb_item);
266  this->cb_model->appendRow(this->cb_item);
267  j++;
268  }
269 
270  ui->cb_signal_types->setModel(this->cb_model);
271 }
272 
273 //*****************************************************************************************************************
274 
275 void settingwindow::cb_selection_changed(const QModelIndex& topLeft, const QModelIndex& bottomRight)
276 {
277  Q_UNUSED(bottomRight);
278 
279  QStandardItem* cb_item = this->cb_items[topLeft.row()];
280  //QMap<QString, QVariant> chn_name_map;
281 
282  if(cb_item->checkState() == Qt::Checked)
283  sel_signal_type_map[cb_item->text()].setValue(true);
284  else
285  sel_signal_type_map[cb_item->text()].setValue(false);
286 
287  //sel_signal_type_map = chn_name_map;
288 }
289 
290 //*****************************************************************************************************************
291 
292 void settingwindow::on_pushButton_clicked()
293 {
294  QSettings settings;
295  settings.clear();
296  set_values();
297 }
298 
299 //*****************************************************************************************************************
Definition: aboutwindow.h:52