MNE-CPP  beta 1.0
editorwindow.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include <utils/mp/atom.h>
43 #include "mainwindow.h"
44 #include "editorwindow.h"
45 #include "ui_editorwindow.h"
46 #include "stdio.h"
47 #include "deletemessagebox.h"
48 #include "ui_deletemessagebox.h"
49 
50 //*************************************************************************************************************
51 //=============================================================================================================
52 // QT INCLUDES
53 //=============================================================================================================
54 
55 #include <QtGui>
56 #include <QApplication>
57 #include <QModelIndex>
58 #include <QMessageBox>
59 
60 //*************************************************************************************************************
61 //=============================================================================================================
62 // USED NAMESPACES
63 //=============================================================================================================
64 
65 using namespace UTILSLIB;
66 
67 //*************************************************************************************************************
68 //=============================================================================================================
69 // FORWARD DECLARATIONS
70 
71 bool allCombined = false;
72 bool is_loading = false;
73 bool is_expanded = false;
74 
75 qreal linStepWidthScale = 1;
76 qreal linStepWidthModu = 1;
77 qreal linStepWidthPhase = 1;
78 qreal linStepWidthChirp = 1;
79 
80 qreal expStepWidthScale = 2;
81 qreal expStepWidthModu = 2;
82 qreal expStepWidthPhase = 2;
83 qreal expStepWidthChirp = 2;
84 
85 qreal startValueScale = 1;
86 qreal startValueModu = 0;
87 qreal startValuePhase = 0;
88 qreal startValueChirp = 0;
89 
90 qreal endValueScale = 1;
91 qreal endValueModu = 0;
92 qreal endValuePhase = 0;
93 qreal endValueChirp = 0;
94 
95 QString partDictName = "";
96 
97 QList<qreal> scaleList;
98 QList<qreal> moduList;
99 QList<qreal> phaseList;
100 QList<qreal> chirpList;
101 
102 qint32 old_width = 0;
103 qint32 atomCount = 1;
104 
105 MatrixXd _atom_matrix;
106 QList<QColor> _atom_colors;
107 EditorWindow::AtomType atomType;
108 
109 const qint32 window_height = 900;
110 const qint32 window_width = 605;
111 
112 
113 //*************************************************************************************************************
114 //=============================================================================================================
115 // MAIN
116 //=============================================================================================================
117 
118 //contructor
119 EditorWindow::EditorWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::EditorWindow)
120 {
121  this->setAccessibleName("simple");
122  ui->setupUi(this);
123  QSettings settings;
124  move(settings.value("pos_editor", QPoint(200, 200)).toPoint());
125  this->restoreState(settings.value("editor_state").toByteArray());
126  ui->dspb_StartValuePhase->setMaximum(ui->dspb_EndValueScale->value());
127  ui->dspb_EndValuePhase->setMaximum(ui->spb_AtomLength->value());
128 
129  //under construction, thats why invisible
130  ui->rb_ChirpAtomType->setVisible(false);
131  ui->fr_Chirp->setVisible(false);
132 
133  ui->dspb_StartValueScale->setMaximum(ui->spb_AtomLength->value());
134  read_dicts();
135  old_width = this->width();
136 
137  callAtomWindow = new AtomWindow();
138  callAtomWindow->setMouseTracking(true);
139  callAtomWindow->setMinimumHeight(500);
140  callAtomWindow->setMinimumWidth(500);
141  ui->l_paint_atom->addWidget(callAtomWindow);
142 
143  callXAxisAtomWindow = new XAxisAtomWindow();
144  callXAxisAtomWindow->setMaximumHeight(0);
145  callXAxisAtomWindow->setToolTip("samples");
146  ui->l_XAxis->addWidget(callXAxisAtomWindow);
147 
148  ui->gb_atom_viewer->setHidden(true);
149  ui->gb_atom_viewer->setAlignment(Qt::AlignLeft);
150 
151  this->setMinimumSize(window_width, window_height);
152  this->setMaximumSize(this->minimumSize());
153 
154  _atom_colors.clear();
155  _atom_colors.append(QColor(0, 0, 0));
156 }
157 
158 //*************************************************************************************************************
159 
160 EditorWindow::~EditorWindow()
161 {
162  delete ui;
163 }
164 
165 //*************************************************************************************************************************************
166 
167 void EditorWindow::closeEvent(QCloseEvent * event)
168 {
169  Q_UNUSED(event);
170  QSettings settings;
171  if(!this->isMaximized())
172  settings.setValue("pos_editor", pos());
173 
174  settings.setValue("editor_state", this->saveState());
175 }
176 
177 //*************************************************************************************************************
178 
179 void EditorWindow::read_dicts()
180 {
181  ui->list_AllDict->clear();
182  QDir dictDir = QDir(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox");
183 
184  QStringList filterList;
185  filterList.append("*.dict");
186  filterList.append("*.pdict");
187 
188  QFileInfoList fileList = dictDir.entryInfoList(filterList);
189 
190  for(int i = 0; i < fileList.length(); i++)
191  {
192  QIcon dictIcon;
193  QFileInfo file = fileList.at(i);
194  QString tooltip;
195  if(QString::compare(file.completeSuffix(), "dict") == 0)
196  {
197  dictIcon.addFile(":/images/icons/DictIcon.png");
198  tooltip = QString("%1.dict").arg(file.baseName());
199  }
200  else
201  {
202  dictIcon.addFile(":/images/icons/PartDictIcon.png");
203  tooltip = QString("%1.pdict").arg(file.baseName());
204  }
205 
206  QListWidgetItem *item1 = new QListWidgetItem;
207  item1->setToolTip(tooltip);
208  item1->setIcon(dictIcon);
209  item1->setText(fileList.at(i).baseName());
210 
211  QListWidgetItem *item2 = new QListWidgetItem;
212  item2->setToolTip(tooltip);
213  item2->setIcon(dictIcon);
214  item2->setText(fileList.at(i).baseName());
215 
216  ui->list_AllDict->addItem(item1);
217  ui->li_all_dicts->addItem(item2);
218  }
219  if(ui->list_AllDict->count() > 1) ui->list_AllDict->itemAt(0, 0)->setSelected(true);
220  update();
221 }
222 
223 //*************************************************************************************************************
224 
225 // calculates number of atoms if "combine all"
226 void EditorWindow::calc_atom_count_all_combined()
227 {
228  qint32 count = 0;
229  qint32 scaleCount = 1;
230  qint32 moduCount = 1;
231  qint32 phaseCount = 1;
232  qint32 chirpCount = 1;
233 
234  if(scaleList.length() != 0) scaleCount = scaleList.length();
235  if(moduList.length() != 0) moduCount = moduList.length();
236  if(phaseList.length() != 0) phaseCount = phaseList.length();
237  if(chirpList.length() != 0) chirpCount = chirpList.length();
238 
239  if(atomType == EditorWindow::Gauss)
240  count = scaleCount * moduCount * phaseCount;
241  else if( atomType == EditorWindow::Chirp)
242  count = scaleCount * moduCount * phaseCount * chirpCount;
243 
244  if(count > 100000000)
245  {
246  QMessageBox::warning(this, tr("Error"),
247  tr("The number of atoms is too large."));
248  return;
249  }
250  atomCount = count;
251  is_loading = true;
252  ui->spb_AtomCount->setValue(count);
253  is_loading = false;
254 }
255 
256 //*************************************************************************************************************
257 
258 // calculates parameters for linear stepwidth
259 QList<qreal> EditorWindow::calc_lin_pos_parameters(qreal startValue, qreal linStepValue)
260 {
261  QList<qreal> resultList;
262  qint32 i = 0;
263  qreal result = 0;
264 
265  i = 0;
266  while(i < atomCount)
267  {
268  result = startValue + (i * linStepValue);
269  resultList.append(result);
270  i++;
271  }
272  return resultList;
273 }
274 
275 //*************************************************************************************************************
276 
277 // calculates parameters for linear stepwidth (negativ)
278 QList<qreal> EditorWindow::calc_lin_neg_parameters(qreal startValue, qreal linStepValue)
279 {
280  QList<qreal> resultList;
281  qint32 i = 0;
282  qreal result = 0;
283 
284  i = 0;
285  while(i < atomCount)
286  {
287  result = startValue - (i * linStepValue);
288  resultList.append(result);
289  i++;
290  }
291  return resultList;
292 }
293 
294 //*************************************************************************************************************
295 
296 // calculates parameters for exponential stepwidth (positiv)
297 QList<qreal> EditorWindow::calc_exp_pos_parameters(qreal startValue, qreal expStepValue)
298 {
299  QList<qreal> resultList;
300  qint32 i = 0;
301  qreal result = 0;
302 
303  i = 0;
304  while(i < atomCount)
305  {
306  result = startValue + pow(i, expStepValue);
307  resultList.append(result);
308  i++;
309  }
310  return resultList;
311 }
312 
313 //*************************************************************************************************************
314 
315 // calculates parameters for exponential stepwidth (negativ)
316 QList<qreal> EditorWindow::calc_exp_neg_parameters(qreal startValue, qreal expStepValue)
317 {
318  QList<qreal> resultList;
319  qint32 i = 0;
320  qreal result = 0;
321 
322  i = 0;
323  while(i < atomCount)
324  {
325  result = startValue - pow(i, expStepValue);
326  resultList.append(result);
327  i++;
328  }
329  return resultList;
330 }
331 
332 //*************************************************************************************************************
333 
334 // calculates scale and save to list
335 QList<qreal> EditorWindow::calc_parameter_values_scale(qreal startValue, qreal linStepValue, qreal expStepValue)
336 {
337  QList<qreal> resultList;
338  resultList.clear();
339 
340  if(ui->rb_NoStepScale->isChecked())
341  resultList.append(startValue);
342  else if(ui->rb_LinStepScale->isChecked())
343  {
344  if(ui->rb_PosCountScale->isChecked()) resultList = calc_lin_pos_parameters(startValue, linStepValue);
345  else resultList = calc_lin_neg_parameters(startValue, linStepValue);
346  }
347  else if(ui->rb_ExpStepScale->isChecked())
348  {
349  if(ui->rb_PosCountScale->isChecked()) resultList = calc_exp_pos_parameters(startValue, expStepValue);
350  else resultList = calc_exp_neg_parameters(startValue, expStepValue);
351  }
352  if(!resultList.isEmpty()) ui->dspb_EndValueScale->setValue(resultList.last());
353  return resultList;
354 }
355 
356 //*************************************************************************************************************
357 
358 // calculates scale and save to list (AllCombined)
359 QList<qreal> EditorWindow::calc_all_comb_parameter_values_scale(qreal startValue, qreal endvalue, qreal linStepValue, qreal expStepValue)
360 {
361  QList<qreal> resultList;
362  resultList.clear();
363  qreal temp = endvalue - startValue + 1;
364  if(ui->rb_NoStepScale->isChecked())
365  resultList.append(startValue);
366  else if(ui->rb_LinStepScale->isChecked())
367  {
368  atomCount = temp / linStepValue;
369  resultList = calc_lin_pos_parameters(startValue, linStepValue);
370  }
371  else if(ui->rb_ExpStepScale->isChecked())
372  {
373  atomCount = pow(temp, (1/ expStepValue));
374  resultList = calc_exp_pos_parameters(startValue, expStepValue);
375  }
376  return resultList;
377 }
378 
379 //*************************************************************************************************************
380 
381 // calculates modulation and save to list
382 QList<qreal> EditorWindow::calc_parameter_values_modu(qreal startValue, qreal linStepValue, qreal expStepValue)
383 {
384  QList<qreal> resultList;
385  resultList.clear();
386 
387  if(ui->rb_NoStepModu->isChecked())
388  resultList.append(startValue);
389  else if(ui->rb_LinStepModu->isChecked())
390  {
391  if(ui->rb_PosCountModu->isChecked()) resultList = calc_lin_pos_parameters(startValue, linStepValue);
392  else resultList = calc_lin_neg_parameters(startValue, linStepValue);
393  }
394  else if(ui->rb_ExpStepModu->isChecked())
395  {
396  if(ui->rb_PosCountModu->isChecked()) resultList = calc_exp_pos_parameters(startValue, expStepValue);
397  else resultList = calc_exp_neg_parameters(startValue, expStepValue);
398  }
399  if(!resultList.isEmpty()) ui->dspb_EndValueModu->setValue(resultList.last());
400  return resultList;
401 }
402 
403 //*************************************************************************************************************
404 
405 // calculates modulation and save to list (AllCombined)
406 QList<qreal> EditorWindow::calc_all_comb_parameter_values_modu(qreal startValue, qreal endvalue, qreal linStepValue, qreal expStepValue)
407 {
408  QList<qreal> resultList;
409  resultList.clear();
410  qreal temp = endvalue - startValue + 1;
411  if(ui->rb_NoStepModu->isChecked())
412  resultList.append(startValue);
413  else if(ui->rb_LinStepModu->isChecked())
414  {
415  atomCount = temp / linStepValue;
416  resultList = calc_lin_pos_parameters(startValue, linStepValue);
417  }
418  if(ui->rb_ExpStepModu->isChecked())
419  {
420  atomCount = pow(temp, (1.0/ expStepValue));
421  resultList = calc_exp_pos_parameters(startValue, expStepValue);
422  }
423  return resultList;
424 }
425 
426 //*************************************************************************************************************
427 
428 // calculates phase and save to list
429 QList<qreal> EditorWindow::calc_parameter_values_phase(qreal startValue, qreal linStepValue, qreal expStepValue)
430 {
431  QList<qreal> resultList;
432  resultList.clear();
433 
434  if(ui->rb_NoStepPhase->isChecked())
435  resultList.append(startValue);
436  else if(ui->rb_LinStepPhase->isChecked())
437  {
438  if(ui->rb_PosCountPhase->isChecked()) resultList = calc_lin_pos_parameters(startValue, linStepValue);
439  else resultList = calc_lin_neg_parameters(startValue, linStepValue);
440  }
441  else if(ui->rb_ExpStepPhase->isChecked())
442  {
443  if(ui->rb_PosCountPhase->isChecked()) resultList = calc_exp_pos_parameters(startValue, expStepValue);
444  else resultList = calc_exp_neg_parameters(startValue, expStepValue);
445  }
446  if(!resultList.isEmpty()) ui->dspb_EndValuePhase->setValue(resultList.last());
447  return resultList;
448 }
449 
450 //*************************************************************************************************************
451 
452 // calculates phase and save to list (AllCombined)
453 QList<qreal> EditorWindow::calc_all_comb_parameter_values_phase(qreal startValue, qreal endvalue, qreal linStepValue, qreal expStepValue)
454 {
455  QList<qreal> resultList;
456  resultList.clear();
457  qreal temp = endvalue - startValue + 1;
458  if(ui->rb_NoStepPhase->isChecked())
459  resultList.append(startValue);
460  else if(ui->rb_LinStepPhase->isChecked())
461  {
462  atomCount = temp / linStepValue;
463  resultList = calc_lin_pos_parameters(startValue, linStepValue);
464  }
465  else if(ui->rb_ExpStepPhase->isChecked())
466  {
467  atomCount = pow(temp, (1/ expStepValue));
468  resultList = calc_exp_pos_parameters(startValue, expStepValue);
469  }
470  return resultList;
471 }
472 
473 //*************************************************************************************************************
474 
475 // calculates chirp and save to list
476 QList<qreal> EditorWindow::calc_parameter_values_chirp(qreal startValue, qreal linStepValue, qreal expStepValue)
477 {
478  QList<qreal> resultList;
479  resultList.clear();
480 
481  if(ui->rb_NoStepChirp->isChecked())
482  resultList.append(startValue);
483  else if(ui->rb_LinStepChirp->isChecked())
484  {
485  if(ui->rb_PosCountChirp->isChecked()) resultList = calc_lin_pos_parameters(startValue, linStepValue);
486  else resultList = calc_lin_neg_parameters(startValue, linStepValue);
487  }
488  else if(ui->rb_ExpStepChirp->isChecked())
489  {
490  if(ui->rb_PosCountChirp->isChecked()) resultList = calc_exp_pos_parameters(startValue, expStepValue);
491  else resultList = calc_exp_neg_parameters(startValue, expStepValue);
492  }
493  if(!resultList.isEmpty()) ui->dspb_EndValuePhase->setValue(resultList.last());
494  return resultList;
495 }
496 
497 //*************************************************************************************************************
498 
499 // calculates chirp and save to list (AllCombined)
500 QList<qreal> EditorWindow::calc_all_comb_parameter_values_chirp(qreal startValue, qreal endvalue, qreal linStepValue, qreal expStepValue)
501 {
502  QList<qreal> resultList;
503  resultList.clear();
504  qreal temp = endvalue - startValue + 1;
505  if(ui->rb_NoStepChirp->isChecked())
506  resultList.append(startValue);
507  else if(ui->rb_LinStepChirp->isChecked())
508  {
509  atomCount = temp / linStepValue;
510  resultList = calc_lin_pos_parameters(startValue, linStepValue);
511  }
512  else if(ui->rb_ExpStepChirp->isChecked())
513  {
514  atomCount = pow(temp, (1/ expStepValue));
515  resultList = calc_exp_pos_parameters(startValue, expStepValue);
516  }
517  return resultList;
518 }
519 
520 //*************************************************************************************************************
521 
522 // handle scale
523 void EditorWindow::calc_scale_value()
524 {
525  if(allCombined)
526  {
527  ui->dspb_EndValueScale->setDisabled(ui->rb_NoStepScale->isChecked());
528  if(ui->rb_LinStepScale->isChecked()) ui->dspb_EndValueScale->setMinimum(startValueScale + linStepWidthScale);
529  else if(ui->rb_ExpStepScale->isChecked()) ui->dspb_EndValueScale->setMinimum(startValueScale + 1);
530  else
531  {
532  ui->dspb_EndValueScale->setMinimum(startValueScale);
533  ui->dspb_EndValueScale->setValue(startValueScale);
534  }
535  scaleList = calc_all_comb_parameter_values_scale(startValueScale, endValueScale, linStepWidthScale, expStepWidthScale);
536  calc_atom_count_all_combined();
537  }
538  else
539  {
540  ui->dspb_EndValueScale->setMinimum(0.05);
541  scaleList = calc_parameter_values_scale(startValueScale, linStepWidthScale, expStepWidthScale);
542  }
543 }
544 
545 //*************************************************************************************************************
546 
547 // handle modulation
548 void EditorWindow::calc_modu_value()
549 {
550  if(allCombined)
551  {
552  ui->dspb_EndValueModu->setDisabled(ui->rb_NoStepModu->isChecked());
553  if(ui->rb_LinStepModu->isChecked()) ui->dspb_EndValueModu->setMinimum(startValueModu + linStepWidthModu);
554  else if(ui->rb_ExpStepModu->isChecked()) ui->dspb_EndValueModu->setMinimum(startValueModu + 1);
555  else
556  {
557  ui->dspb_EndValueModu->setMinimum(startValueModu);
558  ui->dspb_EndValueModu->setValue(startValueModu);
559  }
560  moduList = calc_all_comb_parameter_values_modu(startValueModu, endValueModu, linStepWidthModu, expStepWidthModu);
561  calc_atom_count_all_combined();
562  }
563  else
564  moduList = calc_parameter_values_modu(startValueModu, linStepWidthModu, expStepWidthModu);
565 }
566 
567 //*************************************************************************************************************
568 
569 // handle phase
570 void EditorWindow::calc_phase_value()
571 {
572  if(allCombined)
573  {
574  ui->dspb_EndValuePhase->setDisabled(ui->rb_NoStepPhase->isChecked());
575  if(ui->rb_LinStepPhase->isChecked()) ui->dspb_EndValuePhase->setMinimum(startValuePhase + linStepWidthPhase);
576  else if(ui->rb_ExpStepPhase->isChecked()) ui->dspb_EndValuePhase->setMinimum(startValuePhase + 1);
577  else
578  {
579  ui->dspb_EndValuePhase->setMinimum(startValuePhase);
580  ui->dspb_EndValuePhase->setValue(startValuePhase);
581  }
582  phaseList = calc_all_comb_parameter_values_phase(startValuePhase, endValuePhase, linStepWidthPhase, expStepWidthPhase);
583  calc_atom_count_all_combined();
584  }
585  else
586  phaseList = calc_parameter_values_phase(startValuePhase, linStepWidthPhase, expStepWidthPhase);
587 }
588 
589 //*************************************************************************************************************
590 
591 // handle chirp
592 void EditorWindow::calc_chirp_value()
593 {
594  if(allCombined)
595  {
596  ui->dspb_EndValueChirp->setDisabled(ui->rb_NoStepChirp->isChecked());
597  if(ui->rb_LinStepChirp->isChecked()) ui->dspb_EndValueChirp->setMinimum(startValueChirp + linStepWidthChirp);
598  else if(ui->rb_ExpStepChirp->isChecked()) ui->dspb_EndValueChirp->setMinimum(startValueChirp + 1);
599  else
600  {
601  ui->dspb_EndValueChirp->setMinimum(startValueChirp);
602  ui->dspb_EndValueChirp->setValue(startValueChirp);
603  }
604  chirpList = calc_all_comb_parameter_values_chirp(startValueChirp, endValueChirp, linStepWidthChirp, expStepWidthChirp);
605  calc_atom_count_all_combined();
606  }
607  else
608  chirpList = calc_parameter_values_chirp(startValueChirp, linStepWidthChirp, expStepWidthChirp);
609 }
610 
611 //*************************************************************************************************************
612 
613 // access if namechange of PartDictName
614 void EditorWindow::on_tb_PartDictName_editingFinished()
615 {
616  partDictName = ui->tb_PartDictName->text();
617 }
618 
619 //*************************************************************************************************************
620 
621 // access if "All combined"
622 void EditorWindow::on_chb_CombAllPara_toggled(bool checked)
623 {
624  allCombined = checked;
625 
626  ui->spb_AtomCount->setDisabled(checked);
627  ui->dspb_EndValueScale->setEnabled(true);
628  ui->dspb_EndValueModu->setEnabled(true);
629  ui->dspb_EndValuePhase->setEnabled(true);
630  ui->dspb_EndValueChirp->setEnabled(true);
631 
632  ui->dspb_LinStepScale->setEnabled(ui->rb_LinStepScale->isChecked() && ui->spb_AtomCount->value() > 1);
633  ui->dspb_LinStepModu->setEnabled(ui->rb_LinStepModu->isChecked() && ui->spb_AtomCount->value() > 1);
634  ui->dspb_LinStepPhase->setEnabled(ui->rb_LinStepPhase->isChecked() && ui->spb_AtomCount->value() > 1);
635  ui->dspb_LinStepChirp->setEnabled(ui->rb_LinStepChirp->isChecked() && ui->spb_AtomCount->value() > 1);
636 
637  ui->dspb_ExpStepScale->setEnabled(ui->rb_ExpStepScale->isChecked() && ui->spb_AtomCount->value() > 1);
638  ui->dspb_ExpStepModu->setEnabled(ui->rb_ExpStepModu->isChecked() && ui->spb_AtomCount->value() > 1);
639  ui->dspb_ExpStepPhase->setEnabled(ui->rb_ExpStepPhase->isChecked() && ui->spb_AtomCount->value() > 1);
640  ui->dspb_ExpStepChirp->setEnabled(ui->rb_ExpStepChirp->isChecked() && ui->spb_AtomCount->value() > 1);
641 
642  ui->lb_LinNScale->setEnabled(ui->rb_LinStepScale->isChecked());
643  ui->lb_LinNModu->setEnabled(ui->rb_LinStepModu->isChecked());
644  ui->lb_LinNPhase->setEnabled(ui->rb_LinStepPhase->isChecked());
645  ui->lb_LinNChirp->setEnabled(ui->rb_LinStepChirp->isChecked());
646 
647  ui->lb_ExpNScale->setEnabled(ui->rb_ExpStepScale->isChecked());
648  ui->lb_ExpNModu->setEnabled(ui->rb_ExpStepModu->isChecked());
649  ui->lb_ExpNPhase->setEnabled(ui->rb_ExpStepPhase->isChecked());
650  ui->lb_ExpNChirp->setEnabled(ui->rb_ExpStepChirp->isChecked());
651 
652  ui->lb_EndValueScale->setDisabled(ui->rb_NoStepScale->isChecked());
653  ui->lb_EndValueModu->setDisabled(ui->rb_NoStepModu->isChecked());
654  ui->lb_EndValuePhase->setDisabled(ui->rb_NoStepPhase->isChecked());
655  ui->lb_EndValueChirp->setDisabled(ui->rb_NoStepChirp->isChecked());
656 
657  ui->lb_CountDirectionScale->setDisabled(true);
658  ui->lb_CountDirectionModu->setDisabled(true);
659  ui->lb_CountDirectionPhase->setDisabled(true);
660  ui->lb_CountDirectionChirp->setDisabled(true);
661 
662  ui->fr_CountDirectionScale->setDisabled(true);
663  ui->fr_CountDirectionModu->setDisabled(true);
664  ui->fr_CountDirectionPhase->setDisabled(true);
665  ui->fr_CountDirectionChirp->setDisabled(true);
666 
667  ui->dspb_EndValueScale->setDisabled(ui->rb_NoStepScale->isChecked());
668  ui->dspb_EndValueModu->setDisabled(ui->rb_NoStepModu->isChecked());
669  ui->dspb_EndValuePhase->setDisabled(ui->rb_NoStepPhase->isChecked());
670  ui->dspb_EndValueChirp->setDisabled(ui->rb_NoStepChirp->isChecked());
671 
672  if(ui->rb_LinStepScale->isChecked()) ui->dspb_EndValueScale->setMinimum(startValueScale + linStepWidthScale);
673  else if(ui->rb_ExpStepScale->isChecked()) ui->dspb_EndValueScale->setMinimum(startValueScale + 1);
674  else ui->dspb_EndValueScale->setValue(startValueScale);
675 
676  if(ui->rb_LinStepModu->isChecked()) ui->dspb_EndValueModu->setMinimum(startValueModu + linStepWidthModu);
677  else if(ui->rb_ExpStepModu->isChecked()) ui->dspb_EndValueModu->setMinimum(startValueModu + 1);
678  else ui->dspb_EndValueModu->setValue(startValueModu);
679 
680  if(ui->rb_LinStepPhase->isChecked()) ui->dspb_EndValuePhase->setMinimum(startValuePhase + linStepWidthPhase);
681  else if(ui->rb_ExpStepPhase->isChecked()) ui->dspb_EndValuePhase->setMinimum(startValuePhase + 1);
682  else ui->dspb_EndValuePhase->setValue(startValuePhase);
683 
684  if(ui->rb_LinStepChirp->isChecked()) ui->dspb_EndValueChirp->setMinimum(startValueChirp + linStepWidthChirp);
685  else if(ui->rb_ExpStepChirp->isChecked()) ui->dspb_EndValueChirp->setMinimum(startValueChirp + 1);
686  else ui->dspb_EndValueChirp->setValue(startValueChirp);
687 
688  if(!checked)
689  {
690  ui->dspb_EndValueScale->setMinimum(0.05);
691  ui->dspb_EndValueModu->setMinimum(0.00);
692  ui->dspb_EndValuePhase->setMinimum(0.00);
693  ui->dspb_EndValueScale->setMinimum(0.00);
694 
695  ui->dspb_EndValueScale->setDisabled(true);
696  ui->dspb_EndValueModu->setDisabled(true);
697  ui->dspb_EndValuePhase->setDisabled(true);
698  ui->dspb_EndValueChirp->setDisabled(true);
699 
700  ui->lb_CountDirectionScale->setEnabled(!ui->rb_NoStepScale->isChecked());
701  ui->lb_CountDirectionModu->setEnabled(!ui->rb_NoStepModu->isChecked());
702  ui->lb_CountDirectionPhase->setEnabled(!ui->rb_NoStepPhase->isChecked());
703  ui->lb_CountDirectionChirp->setEnabled(!ui->rb_NoStepChirp->isChecked());
704 
705  ui->fr_CountDirectionScale->setEnabled(!ui->rb_NoStepScale->isChecked());
706  ui->fr_CountDirectionModu->setEnabled(!ui->rb_NoStepModu->isChecked());
707  ui->fr_CountDirectionPhase->setEnabled(!ui->rb_NoStepPhase->isChecked());
708  ui->fr_CountDirectionChirp->setEnabled(!ui->rb_NoStepChirp->isChecked());
709  }
710 
711  ui->rb_NoStepScale->setEnabled(checked);
712  ui->rb_NoStepModu->setEnabled(checked);
713  ui->rb_NoStepPhase->setEnabled(checked);
714  ui->rb_NoStepChirp->setEnabled(checked);
715 
716  ui->lb_StepDefScale ->setEnabled(checked);
717  ui->lb_StepDefModu ->setEnabled(checked);
718  ui->lb_StepDefPhase ->setEnabled(checked);
719  ui->lb_StepDefChirp ->setEnabled(checked);
720 
721  ui->rb_LinStepScale->setEnabled(checked);
722  ui->rb_LinStepModu->setEnabled(checked);
723  ui->rb_LinStepPhase->setEnabled(checked);
724  ui->rb_LinStepChirp->setEnabled(checked);
725 
726  ui->rb_ExpStepScale->setEnabled(checked);
727  ui->rb_ExpStepModu->setEnabled(checked);
728  ui->rb_ExpStepPhase->setEnabled(checked);
729  ui->rb_ExpStepChirp->setEnabled(checked);
730 
731  ui->lb_LinNScale->setEnabled(checked);
732  ui->lb_LinNModu->setEnabled(checked);
733  ui->lb_LinNPhase->setEnabled(checked);
734  ui->lb_LinNChirp->setEnabled(checked);
735 
736  ui->lb_ExpNScale->setEnabled(checked);
737  ui->lb_ExpNModu->setEnabled(checked);
738  ui->lb_ExpNPhase->setEnabled(checked);
739  ui->lb_ExpNChirp->setEnabled(checked);
740 
741  endValueScale = ui->dspb_EndValueScale->value();
742  endValueModu = ui->dspb_EndValueModu->value();
743  endValuePhase = ui->dspb_EndValuePhase->value();
744  endValueChirp = ui->dspb_EndValueChirp->value();
745 
746  ui->dspb_StartValuePhase->setMaximum( ui->dspb_EndValueScale->value());
747  ui->dspb_EndValuePhase->setMaximum( ui->dspb_EndValueScale->value());
748  //ui->dspb_StartValueChirpValueChirp->setMinim ui->spb_AtomLength->value() / 2);
749 
750  calc_scale_value();
751  calc_modu_value();
752  calc_phase_value();
753  calc_chirp_value();
754 
755  // update ui
756  is_loading = true;
757  ui->spb_AtomCount->setValue(ui->spb_AtomCount->value() + 1);
758  ui->spb_AtomCount->setValue(ui->spb_AtomCount->value() - 1);
759  is_loading = false;
760  //calc_atom_count_all_combined();
761 
762 }
763 
764 //*************************************************************************************************************
765 
766 void EditorWindow::on_spb_AtomLength_editingFinished()
767 {
768  // set max startvalue of scale
769  ui->dspb_StartValueScale->setMaximum(ui->spb_AtomLength->value());
770  ui->dspb_StartValueModu->setMaximum(ui->spb_AtomLength->value() / 2);
771  ui->dspb_StartValuePhase->setMaximum(ui->spb_AtomLength->value());
772  ui->dspb_StartValueChirp->setMaximum(ui->spb_AtomLength->value() / 2);
773 
774  ui->dspb_EndValueScale->setMaximum(ui->spb_AtomLength->value());
775  ui->dspb_EndValueModu->setMaximum(ui->spb_AtomLength->value() / 2);
776  ui->dspb_EndValuePhase->setMaximum(ui->spb_AtomLength->value());
777  ui->dspb_EndValueChirp->setMaximum(ui->spb_AtomLength->value() / 2);
778 
779  ui->dspb_LinStepScale->setMaximum(ui->spb_AtomLength->value());
780  ui->dspb_LinStepModu->setMaximum(ui->spb_AtomLength->value() / 2);
781  ui->dspb_LinStepPhase->setMaximum(ui->spb_AtomLength->value());
782  ui->dspb_LinStepChirp->setMaximum(ui->spb_AtomLength->value() / 2);
783 }
784 
785 //*************************************************************************************************************
786 
787 // set number of atoms (recalculate stopvalues)
788 void EditorWindow::on_spb_AtomCount_valueChanged(int arg1)
789 {
790  if(is_loading) return;
791 
792  atomCount = arg1;
793  bool oneAtom = true;
794  if(atomCount != 1 || atomCount == 1 && allCombined)oneAtom = false;
795 
796  ui->rb_NoStepScale->setChecked(oneAtom);
797  ui->rb_NoStepModu->setChecked(oneAtom);
798  ui->rb_NoStepPhase->setChecked(oneAtom);
799  ui->rb_NoStepChirp->setChecked(oneAtom);
800 
801  ui->rb_NoStepScale->setDisabled(oneAtom);
802  ui->rb_NoStepModu->setDisabled(oneAtom);
803  ui->rb_NoStepPhase->setDisabled(oneAtom);
804  ui->rb_NoStepChirp->setDisabled(oneAtom);
805 
806  ui->lb_StepDefScale ->setDisabled(oneAtom);
807  ui->lb_StepDefModu ->setDisabled(oneAtom);
808  ui->lb_StepDefPhase ->setDisabled(oneAtom);
809  ui->lb_StepDefChirp ->setDisabled(oneAtom);
810 
811  ui->rb_LinStepScale->setDisabled(oneAtom);
812  ui->rb_LinStepModu->setDisabled(oneAtom);
813  ui->rb_LinStepPhase->setDisabled(oneAtom);
814  ui->rb_LinStepChirp->setDisabled(oneAtom);
815 
816  ui->rb_ExpStepScale->setDisabled(oneAtom);
817  ui->rb_ExpStepModu->setDisabled(oneAtom);
818  ui->rb_ExpStepPhase->setDisabled(oneAtom);
819  ui->rb_ExpStepChirp->setDisabled(oneAtom);
820 
821  ui->lb_LinNScale->setDisabled(oneAtom);
822  ui->lb_LinNModu->setDisabled(oneAtom);
823  ui->lb_LinNPhase->setDisabled(oneAtom);
824  ui->lb_LinNChirp->setDisabled(oneAtom);
825 
826  ui->lb_ExpNScale->setDisabled(oneAtom);
827  ui->lb_ExpNModu->setDisabled(oneAtom);
828  ui->lb_ExpNPhase->setDisabled(oneAtom);
829  ui->lb_ExpNChirp->setDisabled(oneAtom);
830 
831  ui->dspb_LinStepScale->setDisabled(oneAtom);
832  ui->dspb_LinStepModu->setDisabled(oneAtom);
833  ui->dspb_LinStepPhase->setDisabled(oneAtom);
834  ui->dspb_LinStepChirp->setDisabled(oneAtom);
835 
836  ui->dspb_ExpStepScale->setDisabled(oneAtom);
837  ui->dspb_ExpStepModu->setDisabled(oneAtom);
838  ui->dspb_ExpStepPhase->setDisabled(oneAtom);
839  ui->dspb_ExpStepChirp->setDisabled(oneAtom);
840 
841  if(oneAtom)
842  {
843  ui->dspb_EndValueScale->setValue(startValueScale);
844  ui->dspb_EndValueModu->setValue(startValueModu);
845  ui->dspb_EndValuePhase->setValue(startValuePhase);
846  ui->dspb_EndValueChirp->setValue(startValueChirp);
847 
848  ui->lb_EndValueScale->setDisabled(true);
849  ui->lb_EndValueModu->setDisabled(true);
850  ui->lb_EndValuePhase->setDisabled(true);
851  ui->lb_EndValueChirp->setDisabled(true);
852  }
853  else
854  {
855  ui->lb_EndValueScale->setDisabled(ui->rb_NoStepScale->isChecked());
856  ui->lb_EndValueModu->setDisabled(ui->rb_NoStepModu->isChecked());
857  ui->lb_EndValuePhase->setDisabled(ui->rb_NoStepPhase->isChecked());
858  ui->lb_EndValueChirp->setDisabled(ui->rb_NoStepChirp->isChecked());
859 
860  ui->dspb_LinStepScale->setEnabled(ui->rb_LinStepScale->isChecked());
861  ui->dspb_LinStepModu->setEnabled(ui->rb_LinStepModu->isChecked());
862  ui->dspb_LinStepPhase->setEnabled(ui->rb_LinStepPhase->isChecked());
863  ui->dspb_LinStepChirp->setEnabled(ui->rb_LinStepChirp->isChecked());
864 
865  ui->dspb_ExpStepScale->setEnabled(ui->rb_ExpStepScale->isChecked());
866  ui->dspb_ExpStepModu->setEnabled(ui->rb_ExpStepModu->isChecked());
867  ui->dspb_ExpStepPhase->setEnabled(ui->rb_ExpStepPhase->isChecked());
868  ui->dspb_ExpStepChirp->setEnabled(ui->rb_ExpStepChirp->isChecked());
869 
870  ui->lb_LinNScale->setEnabled(ui->rb_LinStepScale->isChecked());
871  ui->lb_LinNModu->setEnabled(ui->rb_LinStepModu->isChecked());
872  ui->lb_LinNPhase->setEnabled(ui->rb_LinStepPhase->isChecked());
873  ui->lb_LinNChirp->setEnabled(ui->rb_LinStepChirp->isChecked());
874 
875  ui->lb_ExpNScale->setEnabled(ui->rb_ExpStepScale->isChecked());
876  ui->lb_ExpNModu->setEnabled(ui->rb_ExpStepModu->isChecked());
877  ui->lb_ExpNPhase->setEnabled(ui->rb_ExpStepPhase->isChecked());
878  ui->lb_ExpNChirp->setEnabled(ui->rb_ExpStepChirp->isChecked());
879  }
880 
881  calc_scale_value();
882  calc_modu_value();
883  calc_phase_value();
884  calc_chirp_value();
885 }
886 
887 //*************************************************************************************************************
888 
889 // for scale
890 void EditorWindow::on_dspb_StartValueScale_editingFinished()
891 {
892  startValueScale = ui->dspb_StartValueScale->value();
893  calc_scale_value();
894 }
895 
896 //*************************************************************************************************************
897 
898 void EditorWindow::on_dspb_EndValueScale_editingFinished()
899 {
900  ui->dspb_StartValuePhase->setMaximum( ui->dspb_EndValueScale->value());
901  ui->dspb_EndValuePhase->setMaximum( ui->dspb_EndValueScale->value());
902  endValueScale = ui->dspb_EndValueScale->value();
903  calc_scale_value();
904 }
905 
906 //*************************************************************************************************************
907 
908 void EditorWindow::on_rb_NoStepScale_toggled(bool checked)
909 {
910  if(checked) ui->lb_StartValueScale->setText("value:");
911  else ui->lb_StartValueScale->setText("start value:");
912 
913  ui->dspb_LinStepScale->setEnabled(false);
914  ui->dspb_ExpStepScale->setEnabled(false);
915 
916  ui->lb_EndValueScale->setDisabled(checked);
917  if(!checked)
918  {
919  ui->lb_CountDirectionScale->setDisabled(allCombined);
920  ui->fr_CountDirectionScale->setDisabled(allCombined);
921  }
922  else
923  {
924  ui->lb_CountDirectionScale->setDisabled(true);
925  ui->fr_CountDirectionScale->setDisabled(true);
926  }
927  calc_scale_value();
928 }
929 
930 //*************************************************************************************************************
931 
932 void EditorWindow::on_rb_LinStepScale_toggled(bool checked)
933 {
934  if(checked) linStepWidthScale = ui->dspb_LinStepScale->value();
935 
936  ui->dspb_LinStepScale->setEnabled(true);
937  ui->dspb_ExpStepScale->setEnabled(false);
938 
939  ui->dspb_StartValuePhase->setMaximum( ui->dspb_EndValueScale->value());
940  ui->dspb_EndValuePhase->setMaximum( ui->dspb_EndValueScale->value());
941 
942  calc_scale_value();
943 }
944 
945 //*************************************************************************************************************
946 
947 void EditorWindow::on_rb_ExpStepScale_toggled(bool checked)
948 {
949  if(checked) expStepWidthScale = ui->dspb_ExpStepScale->value();
950 
951  ui->dspb_ExpStepScale->setEnabled(true);
952  ui->dspb_LinStepScale->setEnabled(false);
953 
954 
955  ui->dspb_StartValuePhase->setMaximum( ui->dspb_EndValueScale->value());
956  ui->dspb_EndValuePhase->setMaximum( ui->dspb_EndValueScale->value());
957  calc_scale_value();
958 }
959 
960 //*************************************************************************************************************
961 
962 void EditorWindow::on_dspb_LinStepScale_editingFinished()
963 {
964  linStepWidthScale = ui->dspb_LinStepScale->value();
965  calc_scale_value();
966 }
967 
968 //*************************************************************************************************************
969 
970 void EditorWindow::on_dspb_ExpStepScale_editingFinished()
971 {
972  expStepWidthScale = ui->dspb_ExpStepScale->value();
973  calc_scale_value();
974 }
975 
976 //*************************************************************************************************************
977 
978 void EditorWindow::on_rb_PosCountScale_toggled()
979 {
980  if(!allCombined)
981  scaleList = calc_parameter_values_scale(startValueScale, linStepWidthScale, expStepWidthScale);
982 }
983 
984 //*************************************************************************************************************
985 
986 void EditorWindow::on_rb_NegCountScale_toggled()
987 {
988  if(!allCombined)
989  scaleList = calc_parameter_values_scale(startValueScale, linStepWidthScale, expStepWidthScale);
990 }
991 
992 //*************************************************************************************************************
993 
994 // for modulation
995 void EditorWindow::on_dspb_StartValueModu_editingFinished()
996 {
997  startValueModu = ui->dspb_StartValueModu->value();
998  calc_modu_value();
999 }
1000 
1001 //*************************************************************************************************************
1002 
1003 void EditorWindow::on_dspb_EndValueModu_editingFinished()
1004 {
1005  endValueModu = ui->dspb_EndValueModu->value();
1006  calc_modu_value();
1007 }
1008 
1009 //*************************************************************************************************************
1010 
1011 void EditorWindow::on_rb_NoStepModu_toggled(bool checked)
1012 {
1013  if(checked) ui->lb_StartValueModu->setText("value:");
1014  else ui->lb_StartValueModu->setText("start value:");
1015 
1016  ui->dspb_LinStepModu->setEnabled(false);
1017  ui->dspb_ExpStepModu->setEnabled(false);
1018 
1019  ui->lb_EndValueModu->setDisabled(checked);
1020  if(!checked)
1021  {
1022  ui->lb_CountDirectionModu->setDisabled(allCombined);
1023  ui->fr_CountDirectionModu->setDisabled(allCombined);
1024  }
1025  else
1026  {
1027  ui->lb_CountDirectionModu->setDisabled(true);
1028  ui->fr_CountDirectionModu->setDisabled(true);
1029  }
1030  calc_modu_value();
1031 }
1032 
1033 //*************************************************************************************************************
1034 
1035 void EditorWindow::on_rb_LinStepModu_toggled(bool checked)
1036 {
1037  if(checked) linStepWidthModu = ui->dspb_LinStepModu->value();
1038  ui->dspb_LinStepModu->setEnabled(true);
1039  ui->dspb_ExpStepModu->setEnabled(false);
1040 
1041  calc_modu_value();
1042 }
1043 
1044 //*************************************************************************************************************
1045 
1046 void EditorWindow::on_rb_ExpStepModu_toggled(bool checked)
1047 {
1048  if(checked) expStepWidthModu = ui->dspb_ExpStepModu->value();
1049  ui->dspb_ExpStepModu->setEnabled(true);
1050  ui->dspb_LinStepModu->setEnabled(false);
1051  calc_modu_value();
1052 }
1053 
1054 //*************************************************************************************************************
1055 
1056 void EditorWindow::on_dspb_LinStepModu_editingFinished()
1057 {
1058  linStepWidthModu = ui->dspb_LinStepModu->value();
1059  calc_modu_value();
1060 }
1061 
1062 //*************************************************************************************************************
1063 
1064 void EditorWindow::on_dspb_ExpStepModu_editingFinished()
1065 {
1066  expStepWidthModu = ui->dspb_ExpStepModu->value();
1067  calc_modu_value();
1068 }
1069 
1070 //*************************************************************************************************************
1071 
1072 void EditorWindow::on_rb_PosCountModu_toggled()
1073 {
1074  if(allCombined)
1075  moduList = calc_parameter_values_modu(startValueModu, linStepWidthModu, expStepWidthModu);
1076 }
1077 
1078 //*************************************************************************************************************
1079 
1080 void EditorWindow::on_rb_NegCountModu_toggled()
1081 {
1082  if(allCombined)
1083  moduList = calc_parameter_values_modu(startValueModu, linStepWidthModu, expStepWidthModu);
1084 }
1085 
1086 //*************************************************************************************************************
1087 
1088 // for phase
1089 void EditorWindow::on_dspb_StartValuePhase_editingFinished()
1090 {
1091  startValuePhase = ui->dspb_StartValuePhase->value();
1092  calc_phase_value();
1093 }
1094 
1095 //*************************************************************************************************************
1096 
1097 void EditorWindow::on_dspb_EndValuePhase_editingFinished()
1098 {
1099  endValuePhase = ui->dspb_EndValuePhase->value();
1100  calc_phase_value();
1101 }
1102 
1103 //*************************************************************************************************************
1104 
1105 void EditorWindow::on_rb_NoStepPhase_toggled(bool checked)
1106 {
1107  if(checked) ui->lb_StartValuePhase->setText("value:");
1108  else ui->lb_StartValuePhase->setText("start value:");
1109 
1110  ui->dspb_ExpStepPhase->setEnabled(false);
1111  ui->dspb_LinStepPhase->setEnabled(false);
1112 
1113  ui->lb_EndValuePhase->setDisabled(checked);
1114  if(!checked)
1115  {
1116  ui->lb_CountDirectionPhase->setDisabled(allCombined);
1117  ui->fr_CountDirectionPhase->setDisabled(allCombined);
1118  }
1119  else
1120  {
1121  ui->lb_CountDirectionPhase->setDisabled(true);
1122  ui->fr_CountDirectionPhase->setDisabled(true);
1123  }
1124  calc_phase_value();
1125 }
1126 
1127 //*************************************************************************************************************
1128 
1129 void EditorWindow::on_rb_LinStepPhase_toggled(bool checked)
1130 {
1131  if(checked) linStepWidthPhase = ui->dspb_LinStepPhase->value();
1132 
1133  ui->dspb_LinStepPhase->setEnabled(true);
1134  ui->dspb_ExpStepPhase->setEnabled(false);
1135 
1136  calc_phase_value();
1137 }
1138 
1139 //*************************************************************************************************************
1140 
1141 void EditorWindow::on_rb_ExpStepPhase_toggled(bool checked)
1142 {
1143  if(checked) expStepWidthPhase = ui->dspb_ExpStepPhase->value();
1144 
1145  ui->dspb_ExpStepPhase->setEnabled(true);
1146  ui->dspb_LinStepPhase->setEnabled(false);
1147 
1148  calc_phase_value();
1149 }
1150 
1151 //*************************************************************************************************************
1152 
1153 void EditorWindow::on_dspb_LinStepPhase_editingFinished()
1154 {
1155  linStepWidthPhase = ui->dspb_LinStepPhase->value();
1156  calc_phase_value();
1157 }
1158 
1159 //*************************************************************************************************************
1160 
1161 void EditorWindow::on_dspb_ExpStepPhase_editingFinished()
1162 {
1163  expStepWidthPhase = ui->dspb_ExpStepPhase->value();
1164  calc_phase_value();
1165 }
1166 
1167 //*************************************************************************************************************
1168 
1169 void EditorWindow::on_rb_PosCountPhase_toggled()
1170 {
1171  if(allCombined)
1172  phaseList = calc_parameter_values_phase(startValuePhase, linStepWidthPhase, expStepWidthPhase);
1173 }
1174 
1175 //*************************************************************************************************************
1176 
1177 void EditorWindow::on_rb_NegCountPhase_toggled()
1178 {
1179  if(allCombined)
1180  phaseList = calc_parameter_values_phase(startValuePhase, linStepWidthPhase, expStepWidthPhase);
1181 }
1182 
1183 //*************************************************************************************************************
1184 
1185 // for chirp
1186 void EditorWindow::on_dspb_StartValueChirp_editingFinished()
1187 {
1188  startValueChirp = ui->dspb_StartValueChirp->value();
1189  calc_chirp_value();
1190 }
1191 
1192 //*************************************************************************************************************
1193 
1194 void EditorWindow::on_dspb_EndValueChirp_editingFinished()
1195 {
1196  endValueChirp = ui->dspb_EndValueChirp->value();
1197  calc_chirp_value();
1198 }
1199 
1200 //*************************************************************************************************************
1201 
1202 void EditorWindow::on_rb_NoStepChirp_toggled(bool checked)
1203 {
1204  if(checked) ui->lb_StartValueChirp->setText("value:");
1205  else ui->lb_StartValueChirp->setText("start value:");
1206 
1207  ui->dspb_ExpStepChirp->setEnabled(false);
1208  ui->dspb_LinStepChirp->setEnabled(false);
1209 
1210  ui->lb_EndValueChirp->setDisabled(checked);
1211  if(!checked)
1212  {
1213  ui->lb_CountDirectionChirp->setDisabled(allCombined);
1214  ui->fr_CountDirectionChirp->setDisabled(allCombined);
1215  ui->rb_NegCountChirp->setDisabled(allCombined);
1216  ui->rb_PosCountChirp->setDisabled(allCombined);
1217  }
1218  else
1219  {
1220  ui->lb_CountDirectionChirp->setDisabled(true);
1221  ui->fr_CountDirectionChirp->setDisabled(true);
1222  ui->rb_NegCountChirp->setDisabled(true);
1223  ui->rb_PosCountChirp->setDisabled(true);
1224  }
1225  calc_chirp_value();
1226 }
1227 
1228 //*************************************************************************************************************
1229 
1230 void EditorWindow::on_rb_LinStepChirp_toggled(bool checked)
1231 {
1232  if(checked) linStepWidthChirp = ui->dspb_LinStepChirp->value();
1233 
1234  ui->dspb_LinStepChirp->setEnabled(true);
1235  ui->dspb_ExpStepChirp->setEnabled(false);
1236 
1237  calc_chirp_value();
1238 }
1239 
1240 //*************************************************************************************************************
1241 
1242 void EditorWindow::on_rb_ExpStepChirp_toggled(bool checked)
1243 {
1244  if(checked) expStepWidthChirp = ui->dspb_ExpStepChirp->value();
1245 
1246  ui->dspb_ExpStepChirp->setEnabled(true);
1247  ui->dspb_LinStepChirp->setEnabled(false);
1248 
1249  calc_chirp_value();
1250 }
1251 
1252 //*************************************************************************************************************
1253 
1254 void EditorWindow::on_dspb_LinStepChirp_editingFinished()
1255 {
1256  linStepWidthChirp = ui->dspb_LinStepChirp->value();
1257  calc_chirp_value();
1258 }
1259 
1260 //*************************************************************************************************************
1261 
1262 void EditorWindow::on_dspb_ExpStepChirp_editingFinished()
1263 {
1264  expStepWidthChirp = ui->dspb_ExpStepChirp->value();
1265  calc_chirp_value();
1266 }
1267 
1268 //*************************************************************************************************************
1269 
1270 void EditorWindow::on_rb_PosCountChirp_toggled()
1271 {
1272  if(allCombined)
1273  chirpList = calc_parameter_values_chirp(startValueChirp, linStepWidthChirp, expStepWidthChirp);
1274 }
1275 
1276 //*************************************************************************************************************
1277 
1278 void EditorWindow::on_rb_NegCountChirp_toggled()
1279 {
1280  if(allCombined)
1281  chirpList = calc_parameter_values_chirp(startValueChirp, linStepWidthChirp, expStepWidthChirp);
1282 }
1283 
1284 //*************************************************************************************************************
1285 
1286 // check whether gauss or chirp
1287 void EditorWindow::on_rb_GaussAtomType_toggled(bool checked)
1288 {
1289  if(checked) atomType = EditorWindow::Gauss;
1290 }
1291 
1292 //*************************************************************************************************************
1293 
1294 void EditorWindow::on_rb_ChirpAtomType_toggled(bool checked)
1295 {
1296  if(checked) atomType = EditorWindow::Chirp;
1297 
1298  if(checked && ui->spb_AtomCount->value() == 1 && !allCombined)
1299  {
1300  ui->lb_StepDefChirp->setDisabled(true);
1301  ui->rb_NoStepChirp->setDisabled(true);
1302  ui->rb_LinStepChirp->setDisabled(true);
1303  ui->lb_LinNChirp->setDisabled(true);
1304  ui->dspb_LinStepChirp->setDisabled(true);
1305  ui->rb_ExpStepChirp->setDisabled(true);
1306  ui->lb_ExpNChirp->setDisabled(true);
1307  ui->dspb_ExpStepChirp->setDisabled(true);
1308 
1309  ui->lb_CountDirectionChirp->setDisabled(true);
1310  ui->rb_PosCountChirp->setDisabled(true);
1311  ui->rb_NegCountChirp->setDisabled(true);
1312  ui->lb_EndValueChirp->setDisabled(true);
1313  ui->dspb_EndValueChirp->setDisabled(true);
1314  }
1315  else if(checked)
1316  {
1317  ui->lb_EndValueChirp->setDisabled(ui->rb_NoStepChirp->isChecked());
1318  ui->rb_PosCountChirp->setDisabled(ui->rb_NoStepChirp->isChecked());
1319  ui->rb_NegCountChirp->setDisabled(ui->rb_NoStepChirp->isChecked());
1320  ui->lb_EndValueChirp->setDisabled(!allCombined);
1321  }
1322 }
1323 
1324 //*************************************************************************************************************
1325 
1326 // calc all atoms with choosen parameters and save to list and to drive
1327 void EditorWindow::on_btt_CalcAtoms_clicked()
1328 {
1329  QStringList resultList;
1330  resultList.clear();
1331 
1332 
1333 
1334  if(partDictName.isEmpty())
1335  {
1336  QMessageBox::warning(this, tr("Error"),
1337  tr("It was not assigned a name."));
1338  ui->tb_PartDictName->setFocus();
1339  return;
1340  }
1341 
1342  qint32 k = 0;
1343  while(k < ui->list_AllDict->count())
1344  {
1345  if(QString::compare(partDictName, ui->list_AllDict->item(k)->text()) == 0)
1346  { QMessageBox::warning(this, tr("Error"),
1347  tr("The name is already taken."));
1348 
1349  ui->tb_PartDictName->setFocus();
1350  ui->tb_PartDictName->selectAll();
1351  return;
1352  }
1353  k++;
1354  }
1355 
1356  QString save_path_xml = QString(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/%1.pdict").arg(partDictName);
1357  QFile xml_file(save_path_xml);
1358  if (xml_file.open (QIODevice::WriteOnly))
1359  {
1360  QXmlStreamWriter xmlWriter(&xml_file);
1361  xmlWriter.setAutoFormatting(true);
1362  xmlWriter.writeStartDocument();
1363 
1364  xmlWriter.writeStartElement("COUNT");
1365  xmlWriter.writeAttribute("of_atoms", QString::number(ui->spb_AtomCount->value()));
1366  xmlWriter.writeStartElement("built_Atoms");
1367 
1368  if(atomType == EditorWindow::Chirp)
1369  xmlWriter.writeAttribute("formula", "Chirpatom");
1370  else if(atomType == EditorWindow::Gauss)
1371  xmlWriter.writeAttribute("formula", "Gaboratom");
1372  xmlWriter.writeAttribute("sample_count", QString::number(ui->spb_AtomLength->value()));
1373  xmlWriter.writeAttribute("atom_count", QString::number(atomCount));
1374  xmlWriter.writeAttribute("source_dict", partDictName);
1375 
1376  ChirpAtom *cAtom = new ChirpAtom();
1377  GaborAtom *gAtom = new GaborAtom();
1378 
1379  if(ui->chb_CombAllPara->isChecked())
1380  {
1381  qint32 atomIndex = 0;
1382  qint32 chirpCount = 0;
1383  qint32 chirpMax = 1;
1384 
1385  if(chirpList.length() != 0) chirpMax = chirpList.length();
1386 
1387  while(chirpCount < chirpMax)
1388  {
1389  qint32 phaseCount = 0;
1390  while(phaseCount < phaseList.length())
1391  {
1392  qint32 moduCount = 0;
1393  while(moduCount < moduList.length())
1394  {
1395  qint32 scaleCount = 0;
1396  while(scaleCount < scaleList.length())
1397  {
1398  qreal tempScale = ui->dspb_StartValueScale->value();
1399  if(scaleList.length() > 0 && scaleCount < scaleList.length()) tempScale = scaleList.at(scaleCount);
1400  qreal tempModu = ui->dspb_StartValueModu->value();
1401  if(moduList.length() > 0 && moduCount < moduList.length()) tempModu = moduList.at(moduCount);
1402  qreal tempPhase = 2 * PI * ui->dspb_StartValuePhase->value() / ui->spb_AtomLength->value();
1403  if(phaseList.length() > 0 && phaseCount < phaseList.length()) tempPhase = 2 * PI * phaseList.at(phaseCount) / ui->spb_AtomLength->value();
1404  qreal tempChirp = ui->dspb_StartValueChirp->value();
1405  if(chirpList.length() > 0 && chirpCount < chirpList.length()) tempChirp = chirpList.at(chirpCount);
1406 
1407  if(atomType == EditorWindow::Chirp)
1408  {
1409  resultList = cAtom->create_string_values(ui->spb_AtomLength->value(), tempScale, ui->spb_AtomLength->value() / 2, tempModu, tempPhase, tempChirp);
1410  xmlWriter.writeStartElement("ATOM");
1411  xmlWriter.writeAttribute("ID", QString::number(atomIndex));
1412  xmlWriter.writeAttribute("scale", QString::number(tempScale));
1413  xmlWriter.writeAttribute("modu", QString::number(tempModu));
1414  xmlWriter.writeAttribute("phase", QString::number(tempPhase));
1415  xmlWriter.writeAttribute("chirp", QString::number(tempChirp));
1416 
1417  }
1418  else if(atomType == EditorWindow::Gauss)
1419  {
1420  resultList = gAtom->create_string_values(ui->spb_AtomLength->value(), tempScale, ui->spb_AtomLength->value() / 2, tempModu, tempPhase);
1421  xmlWriter.writeStartElement("ATOM");
1422  xmlWriter.writeAttribute("ID", QString::number(atomIndex));
1423  xmlWriter.writeAttribute("scale", QString::number(tempScale));
1424  xmlWriter.writeAttribute("modu", QString::number(tempModu));
1425  xmlWriter.writeAttribute("phase", QString::number(tempPhase));
1426  }
1427 
1428  xmlWriter.writeStartElement("samples");
1429  QString samples_to_xml;
1430  for (qint32 it = 0; it < resultList.length(); it++)
1431  {
1432  samples_to_xml.append(resultList.at(it));
1433  samples_to_xml.append(":");
1434  }
1435  xmlWriter.writeAttribute("samples", samples_to_xml);
1436  xmlWriter.writeEndElement();
1437 
1438  xmlWriter.writeEndElement();
1439 
1440  atomIndex++;
1441  scaleCount++;
1442  }
1443  moduCount++;
1444  }
1445  phaseCount++;
1446  }
1447  chirpCount++;
1448  }
1449  }
1450  else //not all params combined
1451  {
1452  if(ui->spb_AtomCount->value() != 1)
1453  {
1454  if(ui->rb_ChirpAtomType->isChecked())
1455  {
1456  if(ui->rb_NoStepScale->isChecked() && ui->rb_NoStepModu->isChecked() && ui->rb_NoStepPhase->isChecked() && ui->rb_NoStepChirp)
1457  {
1458  QMessageBox::warning(this, tr("Warning"),QString("It created %1 identical atoms. Please change the number of atoms on one or let you vary a parameter.").arg(ui->spb_AtomCount->value()));
1459  return;
1460  }
1461  }
1462  else if(ui->rb_NoStepScale->isChecked() && ui->rb_NoStepModu->isChecked() && ui->rb_NoStepPhase->isChecked())
1463  {
1464  QMessageBox::warning(this, tr("Warning"),QString("It created %1 identical atoms. Please change the number of atoms on one or let you vary a parameter.").arg(ui->spb_AtomCount->value()));
1465  return;
1466  }
1467  }
1468 
1469  qint32 i = 0;
1470  while (i < atomCount)
1471  {
1472  qreal tempScale = ui->dspb_StartValueScale->value();
1473  if(scaleList.length() > 0 && i < scaleList.length()) tempScale = scaleList.at(i);
1474  qreal tempModu = ui->dspb_StartValueModu->value();
1475  if(moduList.length() > 0 && i < moduList.length()) tempModu = moduList.at(i);
1476  qreal tempPhase = 2 * PI * ui->dspb_StartValuePhase->value() / ui->spb_AtomLength->value();
1477  if(phaseList.length() > 0 && i < phaseList.length()) tempPhase = 2 * PI * phaseList.at(i) / ui->spb_AtomLength->value();
1478  qreal tempChirp = ui->dspb_StartValueChirp->value();
1479  if(chirpList.length() > 0 && i < chirpList.length()) tempChirp = chirpList.at(i);
1480 
1481  if(atomType == EditorWindow::Chirp)
1482  {
1483  resultList = cAtom->create_string_values(ui->spb_AtomLength->value(), tempScale, ui->spb_AtomLength->value() / 2, tempModu, tempPhase, tempChirp);
1484  xmlWriter.writeStartElement("ATOM");
1485  xmlWriter.writeAttribute("ID", QString::number(i));
1486  xmlWriter.writeAttribute("scale", QString::number(tempScale));
1487  xmlWriter.writeAttribute("modu", QString::number(tempModu));
1488  xmlWriter.writeAttribute("phase", QString::number(tempPhase));
1489  xmlWriter.writeAttribute("chirp", QString::number(tempChirp));
1490  }
1491  else if(atomType == EditorWindow::Gauss)
1492  {
1493  resultList = gAtom->create_string_values(ui->spb_AtomLength->value(), tempScale, ui->spb_AtomLength->value() / 2, tempModu, tempPhase);
1494  xmlWriter.writeStartElement("ATOM");
1495  xmlWriter.writeAttribute("ID", QString::number(i));
1496  xmlWriter.writeAttribute("scale", QString::number(tempScale));
1497  xmlWriter.writeAttribute("modu", QString::number(tempModu));
1498  xmlWriter.writeAttribute("phase", QString::number(tempPhase));
1499  }
1500 
1501  xmlWriter.writeStartElement("samples");
1502  QString samples_to_xml;
1503  for (qint32 it = 0; it < resultList.length(); it++)
1504  {
1505  samples_to_xml.append(resultList.at(it));
1506  samples_to_xml.append(":");
1507  }
1508  xmlWriter.writeAttribute("samples", samples_to_xml);
1509  xmlWriter.writeEndElement(); //samples
1510  xmlWriter.writeEndElement(); //ATOM
1511 
1512  i++;
1513  }
1514  }
1515  delete cAtom;
1516  delete gAtom;
1517 
1518  xmlWriter.writeEndElement(); //build_Atoms
1519  xmlWriter.writeEndElement(); //COUNT
1520  xmlWriter.writeEndDocument();
1521  }
1522  xml_file.close();
1523  read_dicts();
1524 
1525  if(ui->list_AllDict->count() > 1) ui->list_AllDict->itemAt(0, 0)->setSelected(true);
1526 }
1527 
1528 //*************************************************************************************************************
1529 
1530 void EditorWindow::on_btt_ToNewDict_clicked()
1531 {
1532  QList<QListWidgetItem*> selcItems = ui->list_AllDict->selectedItems();
1533  for(qint32 i = 0; i < selcItems.length(); i++)
1534  {
1535  QListWidgetItem* item = selcItems.at(i);
1536  ui->list_NewDict->addItem(item->clone());
1537 
1538  item->setSelected(false);
1539  delete item;
1540  }
1541  if(ui->list_AllDict->count() > 0) ui->list_AllDict->itemAt(0,0)->setSelected(true);
1542  if(ui->list_NewDict->count() > 0) ui->btt_SaveDicts->setEnabled(true);
1543 }
1544 
1545 //*************************************************************************************************************
1546 
1547 void EditorWindow::on_list_AllDict_doubleClicked()
1548 {
1549  QListWidgetItem* item = ui->list_AllDict->selectedItems().at(0);
1550  ui->list_NewDict->addItem(item->clone());
1551 
1552  item->setSelected(false);
1553  delete item;
1554  if(ui->list_AllDict->count() > 0) ui->list_AllDict->itemAt(0,0)->setSelected(true);
1555  if(ui->list_NewDict->count() > 0) ui->btt_SaveDicts->setEnabled(true);
1556 
1557 }
1558 
1559 //*************************************************************************************************************
1560 
1561 void EditorWindow::on_btt_ToAlldict_clicked()
1562 {
1563  QList<QListWidgetItem*> selcItems = ui->list_NewDict->selectedItems();
1564  for(qint32 i = 0; i < selcItems.length(); i++)
1565  {
1566  QListWidgetItem* item = selcItems.at(i);
1567  ui->list_AllDict->addItem(item->clone());
1568 
1569  item->setSelected(false);
1570  delete item;
1571  }
1572  if(ui->list_NewDict->count() > 1) ui->list_NewDict->itemAt(0,0)->setSelected(true);
1573  if(ui->list_NewDict->count() == 0) ui->btt_SaveDicts->setEnabled(false);
1574 }
1575 
1576 //*************************************************************************************************************
1577 
1578 void EditorWindow::on_list_NewDict_doubleClicked()
1579 {
1580  QListWidgetItem* item = ui->list_NewDict->selectedItems().at(0);
1581  ui->list_AllDict->addItem(item->clone());
1582 
1583  item->setSelected(false);
1584  delete item;
1585  if(ui->list_NewDict->count() > 1) ui->list_NewDict->itemAt(0,0)->setSelected(true);
1586  if(ui->list_NewDict->count() == 0) ui->btt_SaveDicts->setEnabled(false);
1587 }
1588 
1589 //*************************************************************************************************************
1590 
1591 void EditorWindow::on_btt_DeleteDict_clicked()
1592 {
1593  deleteDicts();
1594 }
1595 
1596 //*************************************************************************************************************
1597 
1598 void EditorWindow::deleteDicts()
1599 {
1600  QSettings settings;
1601  if(settings.value("show_warnings", true).toBool())
1602  {
1603  DeleteMessageBox* msgBox = new DeleteMessageBox(this);
1604  msgBox->setModal(true);
1605  qint32 result = msgBox->exec();
1606 
1607  if(result == 0)
1608  {
1609  msgBox->close();
1610  return;
1611  }
1612  msgBox->close();
1613  }
1614 
1615  qint32 i = 0;
1616  QList<QListWidgetItem*> delItemsList = ui->list_AllDict->selectedItems();
1617  while( i < delItemsList.length())
1618  {
1619  QFile file(QString(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/%1").arg(delItemsList.at(i)->toolTip()));
1620  file.remove();
1621 
1622  QListWidgetItem* delItem = delItemsList.at(i);
1623  delItem->setSelected(false);
1624  delete delItem;
1625  i++;
1626  }
1627  emit dict_saved();
1628 }
1629 
1630 //*************************************************************************************************************
1631 
1632 void EditorWindow::on_list_AllDict_itemSelectionChanged()
1633 {
1634  if(ui->list_AllDict->selectedItems().length() == 0)
1635  {
1636  ui->btt_ToNewDict->setEnabled(false);
1637  ui->btt_DeleteDict->setEnabled(false);
1638  }
1639  else
1640  {
1641  ui->btt_ToNewDict->setEnabled(true);
1642  ui->btt_DeleteDict->setEnabled(true);
1643  }
1644 }
1645 
1646 //*************************************************************************************************************
1647 
1648 void EditorWindow::on_list_NewDict_itemSelectionChanged()
1649 {
1650  if(ui->list_NewDict->selectedItems().length() == 0)
1651  {
1652  ui->btt_ToAlldict->setEnabled(false);
1653  }
1654  else
1655  {
1656  ui->btt_ToAlldict->setEnabled(true);
1657  }
1658 }
1659 
1660 //*************************************************************************************************************
1661 
1662 void EditorWindow::on_btt_SaveDicts_clicked()
1663 {
1664  QList<qint32> atomCountList;
1665  if(ui->tb_DictName->text().isEmpty())
1666  {
1667  QMessageBox::warning(this, tr("Error"),
1668  tr("There was no name for the dictionary awarded."));
1669  ui->tb_DictName->setFocus();
1670  return;
1671  }
1672 
1673  QStringList filterList;
1674  filterList.append("*.dict");
1675  QDir dictDir = QDir(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox");
1676  QFileInfoList fileList = dictDir.entryInfoList(filterList);
1677 
1678  for(qint32 i = 0; i < fileList.length(); i++)
1679  {
1680  QFileInfo fileInfo = fileList.at(i);
1681  if(QString::compare(fileInfo.baseName(), ui->tb_DictName->text()) == 0)
1682  {
1683  QMessageBox::warning(this, tr("Error"),
1684  tr("The name for the dictionary is already taken."));
1685  ui->tb_DictName->setFocus();
1686  ui->tb_DictName->selectAll();
1687  return;
1688  }
1689  }
1690 
1691  qint32 summarize_atoms = 0;
1692  QDomDocument xml_dict;
1693  QDomElement header = xml_dict.createElement("COUNT");
1694  for(qint32 i = 0; i < ui->list_NewDict->count(); i++)
1695  {
1696  QFile xml_file(QString(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/%1").arg(ui->list_NewDict->item(i)->toolTip()));
1697 
1698  QDomDocument xml_pdict;
1699  xml_pdict.setContent(&xml_file);
1700  QDomElement xml_root= xml_pdict.documentElement();
1701 
1702  QDomNodeList node_list = xml_root.childNodes();
1703 
1704  bool hasElement = false;
1705 
1706  qint32 node_count = node_list.count(); // to iterate over all nodes(part dictionaries) containing several atoms
1707  for(qint32 pdict_count = 0; pdict_count < node_count; pdict_count++)
1708  {
1709  QDomElement built = node_list.at(0).toElement(); //take next p_dict
1710 
1711  if(built.hasChildNodes())
1712  {
1713  QDomNodeList write_list = built.childNodes(); //old: .elementsByTagName("built_Atoms");
1714  qint32 count_2 = write_list.count();
1715  for(qint32 k = 0; k < count_2; k++)
1716  {
1717  QDomElement write_element = write_list.at(k).toElement();
1718  if((built.attribute("source_dict", built.text())) == (write_element.attribute("source_dict", write_element.text())))
1719  {
1720  hasElement = true;
1721  break;
1722  }
1723  }
1724  if(!hasElement)
1725  {
1726  summarize_atoms += (built.attribute("atom_count", built.text())).toInt();
1727  header.appendChild(built);
1728  QDomElement atom = built.firstChild().toElement();
1729  while(!atom.isNull())
1730  {
1731  built.appendChild(atom);
1732  atom = atom.nextSibling().toElement();
1733  }
1734  }
1735  }
1736  }
1737  }
1738 
1739  QString xml_new_path = QString(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/%1_xml.dict").arg(ui->tb_DictName->text());
1740  QFile xml_new_file(xml_new_path);
1741  if(xml_new_file.open(QIODevice::WriteOnly))
1742  {
1743  QTextStream xml_stream(&xml_new_file);
1744  QXmlStreamWriter writer(&xml_new_file);
1745  writer.setAutoFormatting(true);
1746  writer.writeStartDocument();
1747  xml_stream << "\n";
1748  header.setAttribute("of_atoms", QString::number(summarize_atoms));
1749  xml_dict.appendChild(header);
1750  xml_dict.save(xml_stream, 4);
1751  writer.writeEndDocument();
1752  }
1753  xml_new_file.close();
1754 
1755  read_dicts();
1756  ui->list_NewDict->clear();
1757  ui->tb_DictName->clear();
1758 
1759  emit dict_saved();
1760 }
1761 
1762 //*************************************************************************************************************************************
1763 
1764 void EditorWindow::keyReleaseEvent(QKeyEvent *event)
1765 {
1766  if(event->key() == Qt::Key_Delete && ui->list_AllDict->hasFocus() && ui->list_AllDict->selectedItems().count() > 0)
1767  {
1768  deleteDicts();
1769  }
1770 }
1771 
1772 //*************************************************************************************************************************************
1773 
1774 void EditorWindow::on_save_dicts()
1775 {
1776  read_dicts();
1777 }
1778 
1779 //begin atom viewer
1780 //==========================================================================================================================================================================================================
1781 //*************************************************************************************************************************************
1782 
1783 void EditorWindow::on_btt_extended_clicked()
1784 {
1785  QPropertyAnimation *animation = new QPropertyAnimation(this, "size");
1786  connect(animation, SIGNAL(finished()), this, SLOT(animation_finished()));
1787  if(window_width == this->width())
1788  {
1789  this->setMaximumWidth(16777215);
1790  animation->setDuration(1000);
1791  animation->setStartValue(QSize(this->size().width(), this->size().height()));
1792  QSettings settings;
1793  qint32 expanded_width = settings.value("size_expanded_editor", 1200).toInt();
1794  animation->setEndValue(QSize(expanded_width, this->size().height()));
1795  animation->start();
1796  }
1797  else
1798  {
1799  is_expanded = false;
1800  ui->gb_atom_viewer->setHidden(true);
1801  animation->setDuration(1000);
1802  animation->setStartValue(QSize(this->size().width(), this->size().height()));
1803  animation->setEndValue(QSize(window_width, this->size().height()));
1804  animation->start();
1805  }
1806 }
1807 
1808 //*************************************************************************************************************************************
1809 
1810 void EditorWindow::animation_finished()
1811 {
1812  if(window_width == this->width())
1813  {
1814  this->setMaximumSize(this->minimumSize());
1815  is_expanded = false;
1816  ui->btt_extended->setIcon(QIcon(":/images/icons/greenArrowRight.png"));
1817  }
1818  else
1819  {
1820  QSettings settings;
1821  settings.setValue("size_expanded_editor", this->width());
1822  is_expanded = true;
1823  ui->gb_atom_viewer->setVisible(true);
1824  ui->btt_extended->setIcon(QIcon(":/images/icons/greenArrowLeft.png"));
1825  }
1826 }
1827 
1828 //*************************************************************************************************************************************
1829 
1830 void EditorWindow::resizeEvent(QResizeEvent *event)
1831 {
1832  Q_UNUSED(event)
1833  if(is_expanded)
1834  {
1835  QSettings settings;
1836  settings.setValue("size_expanded_editor", this->width());
1837  if(this->size().width() < 1200)
1838  resize(1200, window_height);
1839  }
1840 }
1841 
1842 //*************************************************************************************************************************************
1843 
1844 void AtomWindow::paintEvent(QPaintEvent* event)
1845 {
1846  Q_UNUSED(event);
1847  paint_signal(_atom_matrix, this->size());
1848 }
1849 
1850 //*************************************************************************************************************************************
1851 
1852 void AtomWindow::paint_signal(MatrixXd atom_matrix, QSize window_size)
1853 {
1854 
1855  QPainter painter(this);
1856  painter.setRenderHint(QPainter::Antialiasing, true);
1857  painter.fillRect(0,0,window_size.width(),window_size.height(),QBrush(Qt::white)); // paint window white
1858  painter.drawRect(0,0, window_size.width(), window_size.height());
1859 
1860  if(atom_matrix.rows() > 0 && atom_matrix.cols() > 0)
1861  {
1862  const qint32 maxStrLenght = 55; // max lenght in pixel of x-axis string
1863  qint32 borderMarginWidth = 15; // reduce paintspace in GraphWindow of borderMargin pixels
1864  qreal border_margin_height = 5 + window_size.height() / 10; // adapt bordermargin to avoid painting out of range
1865  qreal maxPos = 0.0; // highest signalvalue
1866  qreal maxNeg = 0.0; // smalest signalvalue
1867  qreal maxmax = 0.0; // absolute difference maxpos - maxneg
1868  qreal scaleYText = 0.0;
1869  qint32 negScale = 0;
1870 
1871  maxPos = atom_matrix.maxCoeff();
1872  maxNeg = atom_matrix.minCoeff();
1873 
1874  // absolute signalheight
1875  if(maxNeg <= 0) maxmax = maxPos - maxNeg;
1876  else maxmax = maxPos + maxNeg;
1877 
1878  // scale axis text
1879  scaleYText = maxmax / 10.0;
1880 
1881  if(maxNeg < 0) negScale = floor((maxNeg * 10 / maxmax) + 0.5);
1882  if(maxPos <= 0) negScale = -10;
1883  //qreal signal_negative_scale = negScale; // to globe _signal_negative_scale
1884 
1885  // scale signal
1886  qreal scaleX = (window_size.width() - maxStrLenght - borderMarginWidth) / qreal(atom_matrix.rows() - 1);
1887  qreal scaleY = (window_size.height() - border_margin_height) / maxmax;
1888 
1889  //scale axis
1890  qreal scaleXAchse = (window_size.width() - maxStrLenght - borderMarginWidth) / 20.0;
1891  qreal scaleYAchse = (window_size.height() - border_margin_height) / 10.0;
1892 
1893  for(qint32 i = 0; i < 11; i++)
1894  {
1895  if(negScale == 0) // x-Axis reached (y-value = 0)
1896  {
1897  qint32 x_axis_height = i * scaleYAchse - window_size.height() + border_margin_height / 2; // position of x axis in height
1898 
1899  // append scaled signalpoints and paint signal
1900  for(qint32 channel = 0; channel < atom_matrix.cols(); channel++) // over all Channels
1901  {
1902  QPolygonF poly;
1903  for(qint32 h = 0; h < atom_matrix.rows(); h++)
1904  poly.append(QPointF((h * scaleX) + maxStrLenght, -(atom_matrix(h, channel) * scaleY + x_axis_height)));
1905  QPen pen(_atom_colors.at(channel), 0.5, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
1906  painter.setPen(pen);
1907  painter.drawPolyline(poly);
1908  }
1909 
1910  // paint x-axis
1911  for(qint32 j = 1; j < 21; j++)
1912  {
1913  if(fmod(j, 4.0) == 0) //draw light grey sectors
1914  {
1915  QPen pen(Qt::darkGray, 0.5, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
1916  painter.setPen(pen);
1917  painter.drawLine(j * scaleXAchse + maxStrLenght, -(x_axis_height - window_size.height()),
1918  j * scaleXAchse + maxStrLenght , -(x_axis_height + window_size.height())); // scalelines x-axis
1919  }
1920  QPen pen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
1921  painter.setPen(pen);
1922  painter.drawLine(j * scaleXAchse + maxStrLenght, -(x_axis_height - 2),
1923  j * scaleXAchse + maxStrLenght , -(x_axis_height + 2)); // scalelines x-axis
1924  }
1925  painter.drawLine(maxStrLenght - 40, -x_axis_height, window_size.width()-5, -x_axis_height); // paint x-axis
1926  }
1927  painter.drawText(3, -(i * scaleYAchse - window_size.height()) - border_margin_height / 2 + 4, QString::number(negScale * scaleYText, 'g', 3)); // paint scalevalue y-axis
1928 
1929  painter.drawLine(maxStrLenght - 2, -((i * scaleYAchse)-(window_size.height()) + border_margin_height / 2),
1930  maxStrLenght + 2, -((i * scaleYAchse)-(window_size.height()) + border_margin_height / 2)); // scalelines y-axis
1931 
1932  negScale++;
1933  }
1934  painter.drawLine(maxStrLenght, 2, maxStrLenght, window_size.height() - 2); // paint y-axis
1935  }
1936  painter.end();
1937 }
1938 
1939 //*************************************************************************************************************************************
1940 
1941 void XAxisAtomWindow::paintEvent(QPaintEvent* event)
1942 {
1943  Q_UNUSED(event);
1944  paint_axis(_atom_matrix, this->size());
1945 }
1946 
1947 //*************************************************************************************************************************************
1948 
1949 void XAxisAtomWindow::paint_axis(MatrixXd atom_matrix, QSize window_size)
1950 {
1951  QPainter painter(this);
1952  painter.setRenderHint(QPainter::Antialiasing, true);
1953 
1954  if(atom_matrix.rows() > 0 && atom_matrix.cols() > 0)
1955  {
1956  const qint32 maxStrLenght = 55;
1957  qint32 borderMarginWidth = 15;
1958  qreal scaleXText = (atom_matrix.rows() - 1) / 20.0; // divide signallength
1959  qreal scaleXAchse = (window_size.width() - maxStrLenght - borderMarginWidth) / 20.0;
1960 
1961  for(qint32 j = 0; j < 21; j++)
1962  {
1963  painter.drawText(j * scaleXAchse + 47, 20, QString::number(j * scaleXText, 'f', 0)); // scalevalue as string
1964  painter.drawLine(j * scaleXAchse + maxStrLenght, 5 + 2,
1965  j * scaleXAchse + maxStrLenght, 5 - 2); // scalelines
1966  }
1967  painter.drawText(5 , 20, "[sample]"); // unit
1968  painter.drawLine(5, 5, window_size.width()-5, 5); // paint y-line
1969  }
1970 }
1971 
1972 //*************************************************************************************************************************************
1973 
1974 void EditorWindow::on_li_all_dicts_itemSelectionChanged()
1975 {
1976  FixDictMp *fix_mp = new FixDictMp();
1977  QList<Dictionary> dicts = fix_mp->parse_xml_dict(QString(QDir::homePath() + "/Matching-Pursuit-Toolbox/%1").arg( ui->li_all_dicts->selectedItems().at(0)->toolTip()));
1978 
1979  current_dict.clear();
1980  for(qint32 i = 0; i < dicts.length(); i++)
1981  current_dict.atoms.append(dicts.at(i).atoms);
1982 
1983  current_atom_number = 1;
1984  atom_changed(current_atom_number);
1985 
1986  ui->spb_atom_number->setEnabled(true);
1987  ui->spb_atom_number->setMaximum(current_dict.atom_count());
1988  ui->l_max_dict_number->setText(QString(" / %1").arg(current_dict.atom_count()));
1989 
1990  callXAxisAtomWindow->setMinimumHeight(22);
1991  callXAxisAtomWindow->setMaximumHeight(22);
1992  update();
1993 }
1994 
1995 //*************************************************************************************************************************************
1996 
1997 void EditorWindow::on_btt_next_dict_clicked()
1998 {
1999  atom_changed(++current_atom_number);
2000 }
2001 
2002 //*************************************************************************************************************************************
2003 
2004 void EditorWindow::on_btt_prev_dict_clicked()
2005 {
2006  atom_changed(--current_atom_number);
2007 }
2008 
2009 //*************************************************************************************************************************************
2010 
2011 void EditorWindow::on_spb_atom_number_editingFinished()
2012 {
2013  current_atom_number = ui->spb_atom_number->value();
2014  atom_changed(current_atom_number);
2015 }
2016 
2017 //*************************************************************************************************************************************
2018 
2019 void EditorWindow::atom_changed(qint32 atom_number)
2020 {
2021  if(current_atom_number == current_dict.atom_count()) ui->btt_next_dict->setEnabled(false);
2022  else ui->btt_next_dict->setEnabled(true);
2023 
2024  if(current_atom_number == 1) ui->btt_prev_dict->setEnabled(false);
2025  else ui->btt_prev_dict->setEnabled(true);
2026 
2027  ui->spb_atom_number->setValue(current_atom_number);
2028 
2029  _atom_matrix = MatrixXd::Zero(current_dict.atoms.at(atom_number - 1).atom_samples.rows(), 1);
2030  _atom_matrix.col(0) = current_dict.atoms.at(atom_number - 1).atom_samples;
2031  update();
2032 }
2033 
2034 //*************************************************************************************************************************************
2035 
2036 
2037 void EditorWindow::on_gb_atom_editor_toggled(bool arg1)
2038 {
2039  ui->gb_atom_editor->setChecked(true);
2040 }
2041 
2042 void EditorWindow::on_gb_dict_editor_toggled(bool arg1)
2043 {
2044  ui->gb_dict_editor->setChecked(true);
2045 }
2046 
2047 void EditorWindow::on_gb_atom_viewer_toggled(bool arg1)
2048 {
2049  ui->gb_atom_viewer->setChecked(true);
2050 }
GaborAtom used in adaptive MP Algorithm.
Definition: atom.h:192
Definition: aboutwindow.h:52
Editorwindow class declaration which enables the generation of individual dictionaries. Gaussian atoms (with parameters scale, modulation and phase) or chirp atoms could be created and saved as part dictionaries. For using the atoms for decompostion it's necessary to build an entire dictionary from serveral (minimum one) part dictionaries.
The fixdictMP class provides functions several calculating functions to run the Matching Pursuit Algo...
Definition: fixdictmp.h:149
void paint_signal(MatrixXd atom_matrix, QSize window_size)
QStringList create_string_values(qint32 sample_count, qreal scale, qint32 translation, qreal modulation, qreal phase)
Definition: atom.cpp:124
ATOM class declaration, providing core features and parameters of Atoms used in Matching Pursiut Algo...
DeleteMessageBox class declaration, which asked for acknowledgment to delete dictionaries or formulas...
void paint_axis(MatrixXd atom_matrix, QSize window_size)