Vespucci  1.0.0
filterdialog.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
21 #include "ui_filterdialog.h"
22 
29 FilterDialog::FilterDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws, const QString &dataset_key) :
30  QDialog(parent),
31  ui(new Ui::FilterDialog)
32 {
33  ui->setupUi(this);
34  workspace_ = ws;
35  dataset_ = workspace_->GetDataset(dataset_key);
36 }
37 
39 {
40  delete ui;
41 }
42 
47 void FilterDialog::on_methodComboBox_currentIndexChanged(int index)
48 {
49  if ((index != 4) && ui->epsilonSpinBox->isEnabled())
50  ui->epsilonSpinBox->setEnabled(false);
51  if ((index == 4) && !ui->epsilonSpinBox->isEnabled())
52  ui->epsilonSpinBox->setEnabled(true);
53  if (((index == 0) || (index == 1)) && !ui->windowSpinBox->isEnabled())
54  ui->windowSpinBox->setEnabled(true);
55  if ((index!=2) && (ui->derivativeSpinBox->isEnabled()))
56  ui->derivativeSpinBox->setEnabled(false);
57  if ((index == 2) && (!ui->derivativeSpinBox->isEnabled()))
58  ui->derivativeSpinBox->setEnabled(true);
59  if ((index == 2) && (!ui->windowSpinBox->isEnabled()))
60  ui->windowSpinBox->setEnabled(true);
61  if ((index != 2) && (ui->polynomialSpinBox->isEnabled()))
62  ui->polynomialSpinBox->setEnabled(false);
63  if ((index == 2)&&(!ui->polynomialSpinBox->isEnabled()))
64  ui->polynomialSpinBox->setEnabled(true);
65  if ((index != 3))
66  ui->singularValuesSpinBox->setDisabled(true);
67  if (index == 3){
68  ui->singularValuesSpinBox->setEnabled(true);
69  ui->windowSpinBox->setDisabled(true);
70  }
71 }
72 
76 void FilterDialog::on_buttonBox_accepted()
77 {
78  int SVD_rank;
79  switch (ui->methodComboBox->currentIndex())
80  {
81  case 0:
82  try{
83  dataset_->MedianFilter(ui->windowSpinBox->value());
84  }
85  catch(exception e){
86  workspace_->main_window()->DisplayExceptionWarning(e);
87  }
88  break;
89 
90  case 1:
91  try{
92  dataset_->LinearMovingAverage(ui->windowSpinBox->value());
93  }
94  catch(exception e){
95  workspace_->main_window()->DisplayExceptionWarning(e);
96  }
97  break;
98  case 2:
99  try{
100  dataset_->SavitzkyGolay(ui->derivativeSpinBox->value(),
101  ui->polynomialSpinBox->value(),
102  ui->windowSpinBox->value());
103  }
104  catch(exception e){
105  workspace_->main_window()->DisplayExceptionWarning(e);
106  }
107  break;
108  case 3:
109  try{
110  dataset_->SingularValue(ui->singularValuesSpinBox->value());
111  }
112  catch(exception e){
113  workspace_->main_window()->DisplayExceptionWarning(e);
114  }
115  break;
116  case 4:
117  try{
118  SVD_rank = dataset_->QUIC_SVD(ui->epsilonSpinBox->value());
119  }
120  catch(exception e){
121  workspace_->main_window()->DisplayExceptionWarning(e);
122  break;
123  }
124  QMessageBox::information(this,
125  "QUIC_SVD",
126  "The rank of the approximation is " +
127  QString::number(SVD_rank) + ".");
128  break;
129  default:
130  return;
131  }
132  close();
133  dataset_.clear(); //let go of pointer to dataset
134 
135 }
136 
140 void FilterDialog::on_buttonBox_rejected()
141 {
142  close();
143  dataset_.clear(); //let go of pointer to dataset
144 }
Definition: ahcadialog.h:26
The FilterDialog class This dialog allows the user to apply filtering, smoothing or derivatization to...
Definition: filterdialog.h:37
FilterDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws, const QString &dataset_key)
FilterDialog::FilterDialog.