Vespucci  1.0.0
colorrangedialog.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 *******************************************************************************/
20 #include "colorrangedialog.h"
21 #include "ui_colorrangedialog.h"
22 
24  QDialog(parent),
25  ui(new Ui::ColorRangeDialog)
26 {
27  ui->setupUi(this);
28  parent_ = parent;
29  ui->minDoubleSpinBox->setRange(std::numeric_limits<double>::min(),
31  ui->maxDoubleSpinBox->setRange(std::numeric_limits<double>::min(),
33  ui->minDoubleSpinBox->setValue(0);
34  ui->maxDoubleSpinBox->setValue(1000);
35 }
36 
37 void ColorRangeDialog::SetGradientNames(QStringList gradient_names)
38 {
39  ui->gradientComboBox->addItems(gradient_names);
40 }
41 
42 void ColorRangeDialog::SetRange(double lower, double upper)
43 {
44  ui->minDoubleSpinBox->setValue(lower);
45  ui->maxDoubleSpinBox->setValue(upper);
46 }
47 
48 void ColorRangeDialog::SetName(QString name, bool editable)
49 {
50  ui->nameLineEdit->setText(name);
51  ui->nameLineEdit->setEnabled(editable);
52  ui->nameLabel->setEnabled(editable);
53 }
54 
56 {
57  delete ui;
58 }
59 
60 void ColorRangeDialog::on_buttonBox_accepted()
61 {
62  double lower = ui->minDoubleSpinBox->value();
63  double upper = ui->maxDoubleSpinBox->value();
64  QString name = ui->nameLineEdit->text();
65  QString gradient_key = ui->gradientComboBox->currentText();
66  if (upper <= lower){
67  QMessageBox::warning(this, "Range Invalid",
68  "The range entered is not valid",
69  QMessageBox::Ok, 0);
70  return;
71  }
72 
73  parent_->AddGradient(name, gradient_key, lower, upper);
74  close();
75 }
76 
77 void ColorRangeDialog::on_buttonBox_rejected()
78 {
79  close();
80 }
void AddGradient(QString name, QString gradient_key, double lower, double upper)
Definition: ahcadialog.h:26
void SetGradientNames(QStringList gradient_names)
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
Definition: accessory.cpp:237
void SetRange(double lower, double upper)
void SetName(QString name, bool editable)
VESPUCCI_EXPORT arma::uword min(arma::uword a, arma::uword b)
Vespucci::Math::min.
Definition: accessory.cpp:249
ColorRangeDialog(GlobalGradientDialog *parent=0)