Vespucci  1.0.0
globalgradientdialog.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 "globalgradientdialog.h"
21 #include "ui_globalgradientdialog.h"
23 
24 class MainWindow;
25 
26 GlobalGradientDialog::GlobalGradientDialog(MainWindow *parent, QSharedPointer<VespucciWorkspace> workspace) :
27  QDialog(parent),
28  ui(new Ui::GlobalGradientDialog)
29 {
30  ui->setupUi(this);
31  workspace_ = workspace;
32  color_range_dialog_ = new ColorRangeDialog(this);
33  color_range_dialog_->SetGradientNames(workspace_->GradientNames());
34  RefreshListWidget();
35 }
36 
38 {
39  delete ui;
40 }
41 
42 void GlobalGradientDialog::AddGradient(QString name, QString gradient_key, double lower, double upper)
43 {
44  if (name.isEmpty()) return;
45  workspace_->AddGlobalGradient(name, gradient_key, lower, upper);
46  RefreshListWidget();
47 }
48 
49 void GlobalGradientDialog::on_addPushButton_clicked()
50 {
51  QString basename = "Color Scale";
52  QString name = basename;
53  uint i = 0;
54  while (workspace_->GradientNames().contains(name))
55  name = basename + " (" + QString::number(i++) + ")";
56 
57  color_range_dialog_->SetRange(0, 100);
58  color_range_dialog_->SetName(name, true);
59  color_range_dialog_->show();
60 }
61 
62 void GlobalGradientDialog::on_editPushButton_clicked()
63 {
64  QString current_range_name = ui->gradientListWidget->currentItem()->text();
65  QCPRange current_range = workspace_->GetGlobalGradient(current_range_name).range;
66  color_range_dialog_->SetRange(current_range.lower, current_range.upper);
67  color_range_dialog_->SetName(ui->gradientListWidget->currentItem()->text(), false);
68  color_range_dialog_->show();
69 }
70 
71 void GlobalGradientDialog::on_removePushButton_clicked()
72 {
73  QString name = ui->gradientListWidget->currentItem()->text();
74  workspace_->RemoveColorRange(name);
75  RefreshListWidget();
76 }
77 
78 void GlobalGradientDialog::on_recalculatePushButton_clicked()
79 {
80  QString name = ui->gradientListWidget->currentItem()->text();
81  workspace_->RecalculateGlobalGradient(name);
82 }
83 
84 void GlobalGradientDialog::RefreshListWidget()
85 {
86  ui->gradientListWidget->clear();
87  ui->gradientListWidget->addItems(workspace_->GlobalGradientKeys());
88 }
void AddGradient(QString name, QString gradient_key, double lower, double upper)
Definition: ahcadialog.h:26
void SetGradientNames(QStringList gradient_names)
void SetRange(double lower, double upper)
void SetName(QString name, bool editable)
double upper
Definition: qcustomplot.h:484
Represents the range an axis is encompassing.
Definition: qcustomplot.h:481
The MainWindow class The main window of the program, this is where the user performs most operations...
Definition: mainwindow.h:58
double lower
Definition: qcustomplot.h:484
GlobalGradientDialog(MainWindow *parent, QSharedPointer< VespucciWorkspace > workspace)