42 #include "ui_enhancededitorwindow.h"
45 #include "ui_deletemessagebox.h"
56 #include <QMessageBox>
70 qint32 _atom_count = 1;
71 qint32 _sample_count = 64;
72 QList<qreal> value_a_list;
73 QList<qreal> value_b_list;
74 QList<qreal> value_c_list;
75 QList<qreal> value_d_list;
76 QList<qreal> value_e_list;
77 QList<qreal> value_f_list;
78 QList<qreal> value_g_list;
79 QList<qreal> value_h_list;
80 QStringList _names_list;
85 Enhancededitorwindow::Enhancededitorwindow(QWidget *parent): QWidget(parent), ui(new
Ui::
Enhancededitorwindow)
87 this->setAccessibleName(
"formel");
91 move(settings.value(
"pos_enhanced_editor", QPoint(200, 200)).toPoint());
93 m_strStandardFunction.append(
"");
94 m_strStandardFunction.append(
"PI");
95 m_strStandardFunction.append(
"ABS");
96 m_strStandardFunction.append(
"SQRT");
97 m_strStandardFunction.append(
"SINH");
98 m_strStandardFunction.append(
"COSH");
99 m_strStandardFunction.append(
"TANH");
100 m_strStandardFunction.append(
"ARCTAN");
101 m_strStandardFunction.append(
"LN");
102 m_strStandardFunction.append(
"LOG");
103 m_strStandardFunction.append(
"EXP");
104 m_strStandardFunction.append(
"SIN");
105 m_strStandardFunction.append(
"COS");
106 m_strStandardFunction.append(
"TAN");
107 m_strStandardFunction.append(
"COT");
108 m_strStandardFunction.append(
"ARCSIN");
109 m_strStandardFunction.append(
"ARCCOS");
110 m_strStandardFunction.append(
"INT");
111 m_strStandardFunction.append(
"RAD");
112 m_strStandardFunction.append(
"DEG");
113 m_strStandardFunction.append(
"SIGN");
114 m_strStandardFunction.append(
"ARSINH");
115 m_strStandardFunction.append(
"ARCOSH");
116 m_strStandardFunction.append(
"ARTANH");
117 m_strStandardFunction.append(
"KGV");
118 m_strStandardFunction.append(
"GGT");
125 Enhancededitorwindow::~Enhancededitorwindow()
132 void Enhancededitorwindow::closeEvent(QCloseEvent * event)
136 if(!this->isMaximized())
138 settings.setValue(
"pos_enhanced_editor", pos());
145 void Enhancededitorwindow::on_formula_saved()
153 void Enhancededitorwindow::read_formula()
156 ui->cb_AtomFormula->clear();
159 QFile formula_file(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox/user.fml");
161 if (formula_file.open(QIODevice::ReadOnly | QIODevice::Text))
163 while(!formula_file.atEnd())
165 contents = formula_file.readLine(0).constData();
166 ui->cb_AtomFormula->addItem(QIcon(
":/images/icons/formel.png"), contents.trimmed());
169 formula_file.close();
171 QDir dictDir = QDir(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox");
173 QStringList filterList;
174 filterList.append(
"*.dict");
175 filterList.append(
"*.pdict");
177 QFileInfoList fileList = dictDir.entryInfoList(filterList);
178 for(
int i = 0; i < fileList.length(); i++)
179 _names_list.append(fileList.at(i).baseName());
181 if(ui->cb_AtomFormula->count() != 0)
182 ui->cb_AtomFormula->setCurrentIndex(0);
188 void Enhancededitorwindow::on_chb_allCombined_toggled(
bool checked)
192 ui->sb_Atomcount->setEnabled(
false);
194 ui->dsb_StepVauleA->setEnabled(
true);
195 ui->dsb_StepVauleB->setEnabled(
true);
196 ui->dsb_StepVauleC->setEnabled(
true);
197 ui->dsb_StepVauleD->setEnabled(
true);
198 ui->dsb_StepVauleE->setEnabled(
true);
199 ui->dsb_StepVauleF->setEnabled(
true);
200 ui->dsb_StepVauleG->setEnabled(
true);
201 ui->dsb_StepVauleH->setEnabled(
true);
203 ui->dsb_EndValueA->setEnabled(
true);
204 ui->dsb_EndValueB->setEnabled(
true);
205 ui->dsb_EndValueC->setEnabled(
true);
206 ui->dsb_EndValueD->setEnabled(
true);
207 ui->dsb_EndValueE->setEnabled(
true);
208 ui->dsb_EndValueF->setEnabled(
true);
209 ui->dsb_EndValueG->setEnabled(
true);
210 ui->dsb_EndValueH->setEnabled(
true);
212 calc_atom_count_all_combined();
216 ui->sb_Atomcount->setEnabled(
true);
217 ui->dsb_EndValueA->setEnabled(
false);
218 ui->dsb_EndValueB->setEnabled(
false);
219 ui->dsb_EndValueC->setEnabled(
false);
220 ui->dsb_EndValueD->setEnabled(
false);
221 ui->dsb_EndValueE->setEnabled(
false);
222 ui->dsb_EndValueF->setEnabled(
false);
223 ui->dsb_EndValueG->setEnabled(
false);
224 ui->dsb_EndValueH->setEnabled(
false);
231 void Enhancededitorwindow::on_sb_Atomcount_valueChanged(
int arg1)
235 ui->dsb_StepVauleA->setEnabled(
false);
236 ui->dsb_StepVauleB->setEnabled(
false);
237 ui->dsb_StepVauleC->setEnabled(
false);
238 ui->dsb_StepVauleD->setEnabled(
false);
239 ui->dsb_StepVauleE->setEnabled(
false);
240 ui->dsb_StepVauleF->setEnabled(
false);
241 ui->dsb_StepVauleG->setEnabled(
false);
242 ui->dsb_StepVauleH->setEnabled(
false);
246 ui->dsb_StepVauleA->setEnabled(
true);
247 ui->dsb_StepVauleB->setEnabled(
true);
248 ui->dsb_StepVauleC->setEnabled(
true);
249 ui->dsb_StepVauleD->setEnabled(
true);
250 ui->dsb_StepVauleE->setEnabled(
true);
251 ui->dsb_StepVauleF->setEnabled(
true);
252 ui->dsb_StepVauleG->setEnabled(
true);
253 ui->dsb_StepVauleH->setEnabled(
true);
256 if(!ui->chb_allCombined->isChecked())
258 if(ui->lb_A->isVisible()) ui->dsb_EndValueA->setValue(calc_end_value(ui->dsb_StartValueA->value(), ui->dsb_StepVauleA->value()));
259 if(ui->lb_B->isVisible()) ui->dsb_EndValueB->setValue(calc_end_value(ui->dsb_StartValueB->value(), ui->dsb_StepVauleB->value()));
260 if(ui->lb_C->isVisible()) ui->dsb_EndValueC->setValue(calc_end_value(ui->dsb_StartValueC->value(), ui->dsb_StepVauleC->value()));
261 if(ui->lb_D->isVisible()) ui->dsb_EndValueD->setValue(calc_end_value(ui->dsb_StartValueD->value(), ui->dsb_StepVauleD->value()));
262 if(ui->lb_E->isVisible()) ui->dsb_EndValueE->setValue(calc_end_value(ui->dsb_StartValueE->value(), ui->dsb_StepVauleE->value()));
263 if(ui->lb_F->isVisible()) ui->dsb_EndValueF->setValue(calc_end_value(ui->dsb_StartValueF->value(), ui->dsb_StepVauleF->value()));
264 if(ui->lb_G->isVisible()) ui->dsb_EndValueG->setValue(calc_end_value(ui->dsb_StartValueG->value(), ui->dsb_StepVauleG->value()));
265 if(ui->lb_H->isVisible()) ui->dsb_EndValueH->setValue(calc_end_value(ui->dsb_StartValueH->value(), ui->dsb_StepVauleH->value()));
272 void Enhancededitorwindow::on_sb_SampleCount_editingFinished()
274 _sample_count = ui->sb_SampleCount->value();
280 void Enhancededitorwindow::on_cb_AtomFormula_currentIndexChanged(
const QString &arg1)
282 QList<QChar> foundChar;
284 for(qint32 i = 0; i < arg1.length(); i++)
286 bool beforeFound =
false;
287 bool nextfound =
false;
288 QChar upperChar = arg1.at(i).toUpper();
289 if((upperChar >=
'A' && upperChar <=
'H') || upperChar ==
'X')
293 QChar beforeUpperChar = arg1.at(i - 1).toUpper();
294 if(beforeUpperChar <
'A' || (beforeUpperChar >
'Z' && beforeUpperChar < 126)) beforeFound =
true;
296 else beforeFound =
true;
298 if(i < arg1.length() - 1)
300 QChar nextUpperChar = arg1.at(i+1).toUpper();
301 if(nextUpperChar <
'A' || (nextUpperChar >
'Z' && nextUpperChar < 126)) nextfound =
true;
303 else nextfound =
true;
306 if(beforeFound && nextfound)
308 if(upperChar ==
'A') foundChar.append(upperChar);
309 else if(upperChar ==
'B') foundChar.append(upperChar);
310 else if(upperChar ==
'C') foundChar.append(upperChar);
311 else if(upperChar ==
'D') foundChar.append(upperChar);
312 else if(upperChar ==
'E') foundChar.append(upperChar);
313 else if(upperChar ==
'F') foundChar.append(upperChar);
314 else if(upperChar ==
'G') foundChar.append(upperChar);
315 else if(upperChar ==
'H') foundChar.append(upperChar);
316 else if(upperChar ==
'X') foundChar.append(upperChar);
321 ui->gb_A->setHidden(
true);
322 ui->gb_B->setHidden(
true);
323 ui->gb_C->setHidden(
true);
324 ui->gb_D->setHidden(
true);
325 ui->gb_E->setHidden(
true);
326 ui->gb_F->setHidden(
true);
327 ui->gb_G->setHidden(
true);
328 ui->gb_H->setHidden(
true);
330 for(qint32 j = 0; j < foundChar.length(); j++)
332 if(foundChar.at(j) ==
'A') ui->gb_A->setHidden(
false);
333 else if(foundChar.at(j) ==
'B') ui->gb_B->setHidden(
false);
334 else if(foundChar.at(j) ==
'C') ui->gb_C->setHidden(
false);
335 else if(foundChar.at(j) ==
'D') ui->gb_D->setHidden(
false);
336 else if(foundChar.at(j) ==
'E') ui->gb_E->setHidden(
false);
337 else if(foundChar.at(j) ==
'F') ui->gb_F->setHidden(
false);
338 else if(foundChar.at(j) ==
'G') ui->gb_G->setHidden(
false);
339 else if(foundChar.at(j) ==
'H') ui->gb_H->setHidden(
false);
342 resize(minimumSize());
343 setFixedHeight(sizeHint().height());
348 void Enhancededitorwindow::on_btt_DeleteFormula_clicked()
352 if(settings.value(
"show_warnings",
true).toBool())
355 msgBox->setModal(
true);
356 qint32 result = msgBox->exec();
366 QFile formel_file(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox/user.fml");
367 QFile formel_temp_file(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox/user.temp");
369 if(!formel_temp_file.exists())
371 if (formel_temp_file.open(QIODevice::ReadWrite | QIODevice::Text))
372 formel_temp_file.close();
375 QTextStream stream( &formel_temp_file );
376 if (formel_file.open(QIODevice::ReadWrite | QIODevice::Text))
378 if (formel_temp_file.open (QIODevice::WriteOnly| QIODevice::Append))
380 while(!formel_file.atEnd())
382 contents = formel_file.readLine(0).constData();
383 if(!QString::compare(ui->cb_AtomFormula->currentText() +
"\n", contents) == 0)
390 formel_temp_file.close();
392 formel_file.remove();
393 formel_temp_file.rename(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox/user.fml");
395 ui->cb_AtomFormula->removeItem(ui->cb_AtomFormula->currentIndex());
401 void Enhancededitorwindow::calc_atom_count_all_combined()
413 if(value_a_list.length() != 0) count_a = value_a_list.length();
414 if(value_b_list.length() != 0) count_b = value_b_list.length();
415 if(value_c_list.length() != 0) count_c = value_c_list.length();
416 if(value_d_list.length() != 0) count_d = value_d_list.length();
417 if(value_e_list.length() != 0) count_e = value_e_list.length();
418 if(value_f_list.length() != 0) count_f = value_f_list.length();
419 if(value_g_list.length() != 0) count_g = value_g_list.length();
420 if(value_h_list.length() != 0) count_h = value_h_list.length();
422 count = count_a * count_b * count_c * count_d * count_e * count_f * count_g * count_h;
426 QMessageBox::warning(
this, tr(
"Error"),
427 tr(
"The number of atoms is too large."));
430 ui->sb_Atomcount->setValue(count);
435 QList<qreal> Enhancededitorwindow::calc_value_list(qreal start_value, qreal line_step_value, qreal end_value)
437 qreal atom_count = _atom_count;
438 QList<qreal> resultList;
439 if(ui->chb_allCombined->isChecked())
440 atom_count = (end_value - start_value + 1) / line_step_value;
442 for(qint32 i = 0; i < atom_count; i++)
443 resultList.append(start_value + (i * line_step_value));
450 qreal Enhancededitorwindow::calc_end_value(qreal startValue, qreal linStepValue)
452 if(ui->sb_Atomcount->value() == 1)
454 return startValue + (_atom_count * linStepValue);
459 void Enhancededitorwindow::on_dsb_StepVauleA_valueChanged(
double arg1)
461 value_a_list = calc_value_list(ui->dsb_StartValueA->value(), arg1, ui->dsb_EndValueA->value());
462 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueA->setValue(calc_end_value(ui->dsb_StartValueA->value(), arg1));
463 if(ui->chb_allCombined->isChecked())
465 ui->dsb_EndValueA->setMinimum(ui->dsb_StartValueA->value() + arg1);
466 calc_atom_count_all_combined();
470 void Enhancededitorwindow::on_dsb_StepVauleB_valueChanged(
double arg1)
472 value_b_list = calc_value_list(ui->dsb_StartValueB->value(), arg1, ui->dsb_EndValueB->value());
473 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueB->setValue(calc_end_value(ui->dsb_StartValueB->value(), arg1));
474 if(ui->chb_allCombined->isChecked())
476 ui->dsb_EndValueB->setMinimum(ui->dsb_StartValueB->value() + arg1);
477 calc_atom_count_all_combined();
481 void Enhancededitorwindow::on_dsb_StepVauleC_valueChanged(
double arg1)
483 value_c_list = calc_value_list(ui->dsb_StartValueC->value(), arg1, ui->dsb_EndValueC->value());
484 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueC->setValue(calc_end_value(ui->dsb_StartValueC->value(), arg1));
485 if(ui->chb_allCombined->isChecked())
487 ui->dsb_EndValueC->setMinimum(ui->dsb_StartValueC->value() + arg1);
488 calc_atom_count_all_combined();
492 void Enhancededitorwindow::on_dsb_StepVauleD_valueChanged(
double arg1)
494 value_d_list = calc_value_list(ui->dsb_StartValueD->value(), arg1, ui->dsb_EndValueD->value());
495 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueD->setValue(calc_end_value(ui->dsb_StartValueD->value(), arg1));
496 if(ui->chb_allCombined->isChecked())
498 ui->dsb_EndValueD->setMinimum(ui->dsb_StartValueD->value() + arg1);
499 calc_atom_count_all_combined();
503 void Enhancededitorwindow::on_dsb_StepVauleE_valueChanged(
double arg1)
505 value_e_list = calc_value_list(ui->dsb_StartValueE->value(), arg1, ui->dsb_EndValueE->value());
506 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueE->setValue(calc_end_value(ui->dsb_StartValueE->value(), arg1));
507 if(ui->chb_allCombined->isChecked())
509 ui->dsb_EndValueE->setMinimum(ui->dsb_StartValueE->value() + arg1);
510 calc_atom_count_all_combined();
514 void Enhancededitorwindow::on_dsb_StepVauleF_valueChanged(
double arg1)
516 value_f_list = calc_value_list(ui->dsb_StartValueF->value(), arg1, ui->dsb_EndValueF->value());
517 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueF->setValue(calc_end_value(ui->dsb_StartValueF->value(), arg1));
518 if(ui->chb_allCombined->isChecked())
520 ui->dsb_EndValueF->setMinimum(ui->dsb_StartValueF->value() + arg1);
521 calc_atom_count_all_combined();
525 void Enhancededitorwindow::on_dsb_StepVauleG_valueChanged(
double arg1)
527 value_g_list = calc_value_list(ui->dsb_StartValueG->value(), arg1, ui->dsb_EndValueG->value());
528 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueG->setValue(calc_end_value(ui->dsb_StartValueG->value(), arg1));
529 if(ui->chb_allCombined->isChecked())
531 ui->dsb_EndValueG->setMinimum(ui->dsb_StartValueG->value() + arg1);
532 calc_atom_count_all_combined();
536 void Enhancededitorwindow::on_dsb_StepVauleH_valueChanged(
double arg1)
538 value_h_list = calc_value_list(ui->dsb_StartValueH->value(), arg1, ui->dsb_EndValueH->value());
539 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueH->setValue(calc_end_value(ui->dsb_StartValueH->value(), arg1));
540 if(ui->chb_allCombined->isChecked())
542 ui->dsb_EndValueH->setMinimum(ui->dsb_StartValueH->value() + arg1);
543 calc_atom_count_all_combined();
550 void Enhancededitorwindow::on_dsb_StartValueA_valueChanged(
double arg1)
552 value_a_list = calc_value_list(arg1, ui->dsb_StepVauleA->value(), ui->dsb_EndValueA->value());
553 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueA->setValue(calc_end_value(arg1, ui->dsb_StepVauleA->value()));
554 if(ui->chb_allCombined->isChecked())
556 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleA->value());
557 calc_atom_count_all_combined();
561 void Enhancededitorwindow::on_dsb_StartValueB_valueChanged(
double arg1)
563 value_b_list = calc_value_list(arg1, ui->dsb_StepVauleB->value(), ui->dsb_EndValueB->value());
564 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueB->setValue(calc_end_value(arg1, ui->dsb_StepVauleB->value()));
565 if(ui->chb_allCombined->isChecked())
567 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleB->value());
568 calc_atom_count_all_combined();
572 void Enhancededitorwindow::on_dsb_StartValueC_valueChanged(
double arg1)
574 value_c_list = calc_value_list(arg1, ui->dsb_StepVauleC->value(), ui->dsb_EndValueC->value());
575 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueC->setValue(calc_end_value(arg1, ui->dsb_StepVauleC->value()));
576 if(ui->chb_allCombined->isChecked())
578 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleC->value());
579 calc_atom_count_all_combined();
583 void Enhancededitorwindow::on_dsb_StartValueD_valueChanged(
double arg1)
585 value_d_list = calc_value_list(arg1, ui->dsb_StepVauleD->value(), ui->dsb_EndValueD->value());
586 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueD->setValue(calc_end_value(arg1, ui->dsb_StepVauleD->value()));
587 if(ui->chb_allCombined->isChecked())
589 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleD->value());
590 calc_atom_count_all_combined();
594 void Enhancededitorwindow::on_dsb_StartValueE_valueChanged(
double arg1)
596 value_e_list = calc_value_list(arg1, ui->dsb_StepVauleE->value(), ui->dsb_EndValueE->value());
597 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueE->setValue(calc_end_value(arg1, ui->dsb_StepVauleE->value()));
598 if(ui->chb_allCombined->isChecked())
600 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleE->value());
601 calc_atom_count_all_combined();
605 void Enhancededitorwindow::on_dsb_StartValueF_valueChanged(
double arg1)
607 value_f_list = calc_value_list(arg1, ui->dsb_StepVauleF->value(), ui->dsb_EndValueF->value());
608 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueF->setValue(calc_end_value(arg1, ui->dsb_StepVauleF->value()));
609 if(ui->chb_allCombined->isChecked())
611 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleF->value());
612 calc_atom_count_all_combined();
616 void Enhancededitorwindow::on_dsb_StartValueG_valueChanged(
double arg1)
618 value_g_list = calc_value_list(arg1, ui->dsb_StepVauleG->value(), ui->dsb_EndValueG->value());
619 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueG->setValue(calc_end_value(arg1, ui->dsb_StepVauleG->value()));
620 if(ui->chb_allCombined->isChecked())
622 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleG->value());
623 calc_atom_count_all_combined();
627 void Enhancededitorwindow::on_dsb_StartValueH_valueChanged(
double arg1)
629 value_h_list = calc_value_list(arg1, ui->dsb_StepVauleH->value(), ui->dsb_EndValueH->value());
630 if(!ui->chb_allCombined->isChecked()) ui->dsb_EndValueH->setValue(calc_end_value(arg1, ui->dsb_StepVauleH->value()));
631 if(ui->chb_allCombined->isChecked())
633 ui->dsb_EndValueA->setMinimum(arg1 + ui->dsb_StepVauleH->value());
634 calc_atom_count_all_combined();
640 void Enhancededitorwindow::on_dsb_EndValueA_valueChanged(
double arg1)
642 value_a_list = calc_value_list(ui->dsb_StartValueA->value(), ui->dsb_StepVauleA->value(), arg1);
643 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
646 void Enhancededitorwindow::on_dsb_EndValueB_valueChanged(
double arg1)
648 value_b_list = calc_value_list(ui->dsb_StartValueB->value(), ui->dsb_StepVauleB->value(), arg1);
649 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
652 void Enhancededitorwindow::on_dsb_EndValueC_valueChanged(
double arg1)
654 value_c_list = calc_value_list(ui->dsb_StartValueC->value(), ui->dsb_StepVauleC->value(), arg1);
655 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
658 void Enhancededitorwindow::on_dsb_EndValueD_valueChanged(
double arg1)
660 value_d_list = calc_value_list(ui->dsb_StartValueD->value(), ui->dsb_StepVauleD->value(), arg1);
661 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
664 void Enhancededitorwindow::on_dsb_EndValueE_valueChanged(
double arg1)
666 value_e_list = calc_value_list(ui->dsb_StartValueE->value(), ui->dsb_StepVauleE->value(), arg1);
667 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
670 void Enhancededitorwindow::on_dsb_EndValueF_valueChanged(
double arg1)
672 value_f_list = calc_value_list(ui->dsb_StartValueF->value(), ui->dsb_StepVauleF->value(), arg1);
673 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
676 void Enhancededitorwindow::on_dsb_EndValueG_valueChanged(
double arg1)
678 value_g_list = calc_value_list(ui->dsb_StartValueG->value(), ui->dsb_StepVauleG->value(), arg1);
679 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
682 void Enhancededitorwindow::on_dsb_EndValueH_valueChanged(
double arg1)
684 value_h_list = calc_value_list(ui->dsb_StartValueH->value(), ui->dsb_StepVauleH->value(), arg1);
685 if(ui->chb_allCombined->isChecked()) calc_atom_count_all_combined();
691 void Enhancededitorwindow::on_pushButton_clicked()
693 QStringList results_list;
694 results_list.clear();
696 QString savePath = QString(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox/%1.pdict").arg(ui->tb_atom_name->text());
697 QFile dict(savePath);
699 if(ui->tb_atom_name->text().isEmpty())
701 QMessageBox::warning(
this, tr(
"Error"),
702 tr(
"There was no name assigned."));
703 ui->tb_atom_name->setFocus();
707 QStringList filterList;
708 filterList.append(
"*.pdict");
709 QDir dictDir = QDir(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox");
710 QFileInfoList fileList = dictDir.entryInfoList(filterList);
712 for(qint32 i = 0; i < fileList.length(); i++)
714 QFileInfo fileInfo = fileList.at(i);
715 if(QString::compare(fileInfo.baseName(), ui->tb_atom_name->text()) == 0)
717 QMessageBox::warning(
this, tr(
"Error"),
718 tr(
"The name for the dictionary is already taken."));
719 ui->tb_atom_name->setFocus();
720 ui->tb_atom_name->selectAll();
725 QString save_path_xml = QString(QDir::homePath() +
"/" +
"Matching-Pursuit-Toolbox/%1_xml.pdict").arg(ui->tb_atom_name->text());
726 QFile xml_file(save_path_xml);
728 xml_file.open(QIODevice::WriteOnly);
730 QXmlStreamWriter xmlWriter(&xml_file);
731 xmlWriter.setAutoFormatting(
true);
732 xmlWriter.writeStartDocument();
734 xmlWriter.writeStartElement(
"COUNT");
735 xmlWriter.writeAttribute(
"of_atoms", QString::number(ui->sb_Atomcount->value()));
736 xmlWriter.writeStartElement(
"built_Atoms");
738 xmlWriter.writeAttribute(
"formula", ui->cb_AtomFormula->currentText());
739 xmlWriter.writeAttribute(
"sample_count", QString::number(ui->sb_SampleCount->value()));
740 xmlWriter.writeAttribute(
"atom_count", QString::number(ui->sb_Atomcount->value()));
741 xmlWriter.writeAttribute(
"source_dict", ui->tb_atom_name->text());
743 if (dict.open (QIODevice::WriteOnly| QIODevice::Append))
745 QTextStream stream( &dict );
746 stream << QString(
"atomcount = %1 ").arg(_atom_count) <<
"\n";
747 if(ui->chb_allCombined->isChecked())
749 qint32 atomIndex = 0;
759 if(value_a_list.length() != 0) max_a = value_a_list.length();
760 if(value_b_list.length() != 0) max_b = value_b_list.length();
761 if(value_c_list.length() != 0) max_c = value_c_list.length();
762 if(value_d_list.length() != 0) max_d = value_d_list.length();
763 if(value_e_list.length() != 0) max_e = value_e_list.length();
764 if(value_f_list.length() != 0) max_f = value_f_list.length();
765 if(value_g_list.length() != 0) max_g = value_g_list.length();
766 if(value_h_list.length() != 0) max_h = value_h_list.length();
769 while(count_h < max_h)
772 while(count_g < max_g)
775 while(count_f < max_f)
778 while(count_e < max_e)
781 while(count_d < max_d)
784 while(count_c < max_c)
787 while(count_b < max_b)
790 while(count_a < max_a)
792 qreal temp_a = ui->dsb_StartValueA->value();
793 qreal temp_b = ui->dsb_StartValueB->value();
794 qreal temp_c = ui->dsb_StartValueC->value();
795 qreal temp_d = ui->dsb_StartValueD->value();
796 qreal temp_e = ui->dsb_StartValueE->value();
797 qreal temp_f = ui->dsb_StartValueF->value();
798 qreal temp_g = ui->dsb_StartValueG->value();
799 qreal temp_h = ui->dsb_StartValueH->value();
800 if(value_a_list.length() > 0) temp_a = value_a_list.at(count_a);
801 if(value_b_list.length() > 0) temp_b = value_b_list.at(count_b);
802 if(value_c_list.length() > 0) temp_c = value_c_list.at(count_c);
803 if(value_d_list.length() > 0) temp_d = value_d_list.at(count_d);
804 if(value_e_list.length() > 0) temp_e = value_e_list.at(count_e);
805 if(value_f_list.length() > 0) temp_f = value_f_list.at(count_f);
806 if(value_g_list.length() > 0) temp_g = value_g_list.at(count_g);
807 if(value_h_list.length() > 0) temp_h = value_h_list.at(count_h);
821 results_list.clear();
822 VectorXd formel_vec = VectorXd::Zero(_sample_count);
824 for(qint32 i = 0; i < _sample_count; i++)
826 formel_vec[i] = formula_parser.
calculation(ui->cb_AtomFormula->currentText(), i);
829 norm = formel_vec.norm();
830 if(norm != 0) formel_vec /= norm;
832 results_list.append(QString::number(formel_vec[i]));
834 stream << QString(
"%1_ATOM_%2 \n %3: a: %4 b: %5 c: %6 d: %7 e: %8 f: %9 g: %10 h: %11")
835 .arg(ui->tb_atom_name->text())
837 .arg(ui->cb_AtomFormula->currentText())
845 .arg(temp_h) <<
"\n";
847 for (QStringList::Iterator it = results_list.begin(); it != results_list.end(); it++)
848 stream << *it <<
"\n";
850 xmlWriter.writeStartElement(
"ATOM");
851 xmlWriter.writeAttribute(
"ID", QString::number(atomIndex));
852 xmlWriter.writeAttribute(
"a", QString::number(temp_a));
853 xmlWriter.writeAttribute(
"b", QString::number(temp_b));
854 xmlWriter.writeAttribute(
"c", QString::number(temp_c));
855 xmlWriter.writeAttribute(
"d", QString::number(temp_d));
856 xmlWriter.writeAttribute(
"e", QString::number(temp_e));
857 xmlWriter.writeAttribute(
"f", QString::number(temp_f));
858 xmlWriter.writeAttribute(
"g", QString::number(temp_g));
859 xmlWriter.writeAttribute(
"h", QString::number(temp_h));
861 xmlWriter.writeStartElement(
"samples");
862 QString samples_to_xml;
863 for (qint32 it = 0; it < results_list.length(); it++)
865 samples_to_xml.append(results_list.at(it));
866 samples_to_xml.append(
":");
868 xmlWriter.writeAttribute(
"samples", samples_to_xml);
869 xmlWriter.writeEndElement();
871 xmlWriter.writeEndElement();
894 qint32 atom_index = 0;
895 while (atom_index < _atom_count)
897 qreal temp_a = ui->dsb_StartValueA->value();
898 qreal temp_b = ui->dsb_StartValueB->value();
899 qreal temp_c = ui->dsb_StartValueC->value();
900 qreal temp_d = ui->dsb_StartValueD->value();
901 qreal temp_e = ui->dsb_StartValueE->value();
902 qreal temp_f = ui->dsb_StartValueF->value();
903 qreal temp_g = ui->dsb_StartValueG->value();
904 qreal temp_h = ui->dsb_StartValueH->value();
905 if(value_a_list.length() > 0 && atom_index < value_a_list.length()) temp_a = value_a_list.at(atom_index);
906 if(value_b_list.length() > 0 && atom_index < value_b_list.length()) temp_b = value_b_list.at(atom_index);
907 if(value_c_list.length() > 0 && atom_index < value_c_list.length()) temp_c = value_c_list.at(atom_index);
908 if(value_d_list.length() > 0 && atom_index < value_d_list.length()) temp_d = value_d_list.at(atom_index);
909 if(value_e_list.length() > 0 && atom_index < value_e_list.length()) temp_e = value_e_list.at(atom_index);
910 if(value_f_list.length() > 0 && atom_index < value_f_list.length()) temp_f = value_f_list.at(atom_index);
911 if(value_g_list.length() > 0 && atom_index < value_g_list.length()) temp_g = value_g_list.at(atom_index);
912 if(value_h_list.length() > 0 && atom_index < value_h_list.length()) temp_h = value_h_list.at(atom_index);
924 results_list.clear();
925 for(qint32 i = 0; i < _sample_count; i++)
926 results_list.append(QString::number(formula_parser.
calculation(ui->cb_AtomFormula->currentText(), i)));
928 stream << QString(
"%1_ATOM_%2 \n %3: a: %4 b: %5 c: %6 d: %7 e: %8 f: %9 g: %10 h: %11")
929 .arg(ui->tb_atom_name->text())
931 .arg(ui->cb_AtomFormula->currentText())
939 .arg(temp_h) <<
"\n";
941 for (QStringList::Iterator it = results_list.begin(); it != results_list.end(); it++)
942 stream << *it <<
"\n";
944 xmlWriter.writeStartElement(
"ATOM");
945 xmlWriter.writeAttribute(
"ID", QString::number(atom_index));
946 xmlWriter.writeAttribute(
"a", QString::number(temp_a));
947 xmlWriter.writeAttribute(
"b", QString::number(temp_b));
948 xmlWriter.writeAttribute(
"c", QString::number(temp_c));
949 xmlWriter.writeAttribute(
"d", QString::number(temp_d));
950 xmlWriter.writeAttribute(
"e", QString::number(temp_e));
951 xmlWriter.writeAttribute(
"f", QString::number(temp_f));
952 xmlWriter.writeAttribute(
"g", QString::number(temp_g));
953 xmlWriter.writeAttribute(
"h", QString::number(temp_h));
955 xmlWriter.writeStartElement(
"samples");
956 QString samples_to_xml;
957 for (qint32 it = 0; it < results_list.length(); it++)
959 samples_to_xml.append(results_list.at(it));
960 samples_to_xml.append(
":");
962 xmlWriter.writeAttribute(
"samples", samples_to_xml);
963 xmlWriter.writeEndElement();
965 xmlWriter.writeEndElement();
973 xmlWriter.writeEndElement();
974 xmlWriter.writeEndElement();
975 xmlWriter.writeEndDocument();
EnhancedEditorWindow class declaration which enables the adaption of parameters for stored formulas...
DeleteMessageBox class declaration, which asked for acknowledgment to delete dictionaries or formulas...