Vespucci  1.0.0
cropdialog.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_cropdialog.h"
24 
31 CropDialog::CropDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws, const QString &dataset_key) :
32  QDialog(parent),
33  ui(new Ui::CropDialog)
34 {
35  ui->setupUi(this);
36  workspace_ = ws;
37  dataset_ = workspace_->GetDataset(dataset_key);
38 
39  if (dataset_->non_spatial()){
40  ui->xMinDoubleSpinBox->setDisabled(true);
41  ui->xMaxDoubleSpinBox->setDisabled(true);
42  ui->yMinDoubleSpinBox->setDisabled(true);
43  ui->yMaxDoubleSpinBox->setDisabled(true);
44  }
45 
46  double wl_min = dataset_->wavelength().min();
47  double wl_max = dataset_->wavelength().max();
48 
49  QCPRange key_range = dataset_->KeyRange();
50  QCPRange value_range = dataset_->ValueRange();
51 
52  ui->wlMinDoubleSpinBox->setMinimum(wl_min);
53  ui->wlMinDoubleSpinBox->setMaximum(wl_max);
54  ui->wlMaxDoubleSpinBox->setMinimum(wl_min);
55  ui->wlMaxDoubleSpinBox->setMaximum(wl_max);
56 
57  ui->xMinDoubleSpinBox->setMinimum(key_range.lower);
58  ui->xMinDoubleSpinBox->setMaximum(key_range.upper);
59  ui->xMaxDoubleSpinBox->setMinimum(key_range.lower);
60  ui->xMaxDoubleSpinBox->setMaximum(key_range.upper);
61 
62  ui->yMinDoubleSpinBox->setMinimum(value_range.lower);
63  ui->yMinDoubleSpinBox->setMaximum(value_range.upper);
64  ui->yMaxDoubleSpinBox->setMinimum(value_range.lower);
65  ui->yMaxDoubleSpinBox->setMaximum(value_range.upper);
66 
67 }
68 
69 
71 {
72  delete ui;
73 }
74 
75 
79 void CropDialog::on_buttonBox_accepted()
80 {
81  double x_min = ui->xMinDoubleSpinBox->value();
82  double x_max = ui->xMaxDoubleSpinBox->value();
83  double y_min = ui->yMinDoubleSpinBox->value();
84  double y_max = ui->yMaxDoubleSpinBox->value();
85  double wl_min = ui->wlMinDoubleSpinBox->value();
86  double wl_max = ui->wlMaxDoubleSpinBox->value();
87 
88  if (dataset_->non_spatial()){
89  x_min = std::nan("");
90  x_max = std::nan("");
91  y_min = std::nan("");
92  y_max = std::nan("");
93  }
94  if ((!std::isnan(x_max)) && ((x_max - x_min) <= 0 || (y_max - y_min <= 0))){
95  QMessageBox::warning(this, "Error", "Minimum is larger than maximum!");
96  return;
97  }
98 
99  else{
100  dataset_->CropSpectra(x_min, x_max, y_min, y_max, wl_min, wl_max);
101  }
102  close();
103  dataset_.clear();
104 
105 }
106 
110 void CropDialog::on_buttonBox_rejected()
111 {
112  close();
113  dataset_.clear();
114 }
CropDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws, const QString &dataset_key)
CropDialog::CropDialog.
Definition: cropdialog.cpp:31
Definition: ahcadialog.h:26
The CropDialog class A dialog that allows the user to "Crop" the dataset (delete all spectra that are...
Definition: cropdialog.h:35
double upper
Definition: qcustomplot.h:484
Represents the range an axis is encompassing.
Definition: qcustomplot.h:481
double lower
Definition: qcustomplot.h:484