-
Notifications
You must be signed in to change notification settings - Fork 59
/
contourtools.cpp
167 lines (142 loc) · 5.38 KB
/
contourtools.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/******************************************************************************
**
** Copyright 2016 Dale Eason
** This file is part of DFTFringe
** is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation version 3 of the License
** DFTFringe is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with DFTFringe. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "contourtools.h"
#include "ui_contourtools.h"
#include <QColorDialog>
#include <QPalette>
#include <QSettings>
#include <QDebug>
#include <QSettings>
ContourTools::ContourTools(QWidget *parent) :
QDockWidget(parent),
ui(new Ui::ContourTools)
{
ui->setupUi(this);
ui->ColorMapCB->addItem(tr("Hot cold"));
ui->ColorMapCB->addItem(tr("Tropical"));
ui->ColorMapCB->addItem(tr("Vibrant"));
ui->ColorMapCB->addItem(tr("Gray"));
ui->ColorMapCB->addItem(tr(" > Error limits"));
ui->ColorMapCB->addItem(tr("user map"));
ui->ColorMapCB->addItem(tr("OpenFringe"));
ui->colorRangeCB->addItem(tr("Auto"));
ui->colorRangeCB->addItem(tr("Min/Max"));
ui->colorRangeCB->addItem(tr("Fractions of Wave"));
QSettings s;
int ndx = s.value("colorMap ndx", 1).toInt();
ui->ColorMapCB->setCurrentIndex(ndx);
ui->zeroOffsetCB->addItem(tr("Middle"));
ui->zeroOffsetCB->addItem(tr("Minimum"));
ui->errorRangeSpin->setSingleStep(.01);
ui->errorRangeSpin->setMinimum(.01);
ui->errorRangeSpin->setDecimals(3);
QSettings settings;
QColor lineColor = QColor(settings.value("ContourLineColor", "white").toString());
QPalette pal = ui->lineColorDisplay->palette();
pal.setColor(QPalette::Window,lineColor);
ui->lineColorDisplay->setPalette(pal);
ui->lineColorDisplay->setAutoFillBackground( true );
m_minmaxEditTimer = new QTimer(this);
connect(m_minmaxEditTimer, SIGNAL(timeout()),this, SLOT(updateMinMax()));
}
ContourTools::~ContourTools()
{
delete ui;
}
void ContourTools::connectTo(QWidget *view){
connect(this, SIGNAL(ContourMapColorChanged(int)), view, SLOT(ContourMapColorChanged(int)));
connect(this, SIGNAL(contourZeroOffsetChanged(const QString &)),
view, SLOT(contourZeroOffsetChanged(const QString &)));
connect(this, SIGNAL(contourColorRangeChanged(const QString &)),
view, SLOT(contourColorRangeChanged(const QString &)));
connect(view, SIGNAL(setMinMaxValues(double,double)),this, SLOT(setMinMaxValues(double,double)));
connect(this, SIGNAL(contourWaveRangeChanged(double)),view, SLOT(contourWaveRangeChanged(double)));
connect(view, SIGNAL(setWaveRange(double)),this, SLOT(setWaveRange(double)));
connect(this, SIGNAL(lineColorChanged(QColor)), view, SLOT(on_line_color_changed(QColor)));
connect(this, SIGNAL(newDisplayErrorRange(double,double)), view, SLOT(newDisplayErrorRange(double,double)));
enablTools(false);
}
void ContourTools::enablTools(bool b){
QList<QWidget *> widgets = findChildren<QWidget *>();
foreach(QWidget * widget, widgets)
{
widget->setEnabled(b);
}
}
void ContourTools::setWaveRange(double val){
ui->errorRangeSpin->blockSignals(true);
ui->errorRangeSpin->setValue(val);
ui->errorRangeSpin->blockSignals(false);
}
void ContourTools::setMinMaxValues(double min, double max){
m_min = min;
m_max = max;
ui->minSB->blockSignals(true);
ui->maxSB->blockSignals(true);
ui->minSB->setValue(min);
ui->maxSB->setValue(max);
ui->maxSB->blockSignals(false);
ui->minSB->blockSignals(false);
emit newDisplayErrorRange(min,max);
}
void ContourTools::on_ColorMapCB_activated(int index)
{
QSettings set;
set.setValue("colorMap ndx",index);
emit ContourMapColorChanged(index);
}
void ContourTools::on_zeroOffsetCB_activated(const QString &arg1)
{
emit contourZeroOffsetChanged(arg1);
}
void ContourTools::on_colorRangeCB_activated(const QString &arg1)
{
ui->errorRangeSpin->setEnabled(arg1 == "Fractions of Wave");
emit contourColorRangeChanged(arg1);
}
void ContourTools::on_errorRangeSpin_valueChanged(double arg1)
{
emit contourWaveRangeChanged(arg1);
}
void ContourTools::on_LineColorBtn_clicked()
{
QColor color = QColorDialog::getColor(Qt::white);
QPalette pal = ui->lineColorDisplay->palette();
pal.setColor(QPalette::Window,color);
ui->lineColorDisplay->setPalette(pal);
ui->lineColorDisplay->setAutoFillBackground( true );
emit lineColorChanged(color);
}
//called when timer for edit expires.
void ContourTools::updateMinMax(){
emit newDisplayErrorRange(m_min,m_max);
}
void ContourTools::on_maxSB_valueChanged(double arg1)
{
m_max = arg1;
ui->errorRangeSpin->blockSignals(true);
ui->errorRangeSpin->setValue(m_max-m_min);
ui->errorRangeSpin->blockSignals(false);
m_minmaxEditTimer->start(1000);
}
void ContourTools::on_minSB_valueChanged(double arg1)
{
m_min = arg1;
ui->errorRangeSpin->blockSignals(true);
ui->errorRangeSpin->setValue(m_max-m_min);
ui->errorRangeSpin->blockSignals(false);
m_minmaxEditTimer->start(1000);
}