7#include "fitshistogrameditor.h"
15#include "fitsviewer.h"
19#include <QtConcurrent>
28FITSHistogramEditor::FITSHistogramEditor(
QWidget * parent) :
QDialog(parent)
30 ui =
new histogramUI(
this);
32 minBoxes << ui->minREdit << ui->minGEdit << ui->minBEdit;
33 maxBoxes << ui->maxREdit << ui->maxGEdit << ui->maxBEdit;
34 sliders << ui->redSlider << ui->greenSlider << ui->blueSlider;
36 ui->histogramPlot->setProperty(
"linear", !Options::nonLinearHistogram());
47 rgbWidgets[RED_CHANNEL] << ui->RLabel << ui->minREdit << ui->redSlider
49 rgbWidgets[GREEN_CHANNEL] << ui->GLabel << ui->minGEdit << ui->greenSlider
51 rgbWidgets[BLUE_CHANNEL] << ui->BLabel << ui->minBEdit << ui->blueSlider
54 for (
int i = 0; i < 3; i++)
60 double value = qobject_cast<QDoubleSpinBox *>(w[1])->value();
61 w[2]->blockSignals(
true);
62 qobject_cast<ctkRangeSlider *>(w[2])->setMinimumPosition((value - m_ImageData->getMin(i))*sliderScale[i]);
63 w[2]->blockSignals(
false);
67 double value = qobject_cast<QDoubleSpinBox *>(w[3])->value();
68 w[2]->blockSignals(
true);
69 qobject_cast<ctkRangeSlider *>(w[2])->setMaximumPosition((value - m_ImageData->getMin(i) - sliderTick[i])*sliderScale[i]);
70 w[2]->blockSignals(
false);
76 qobject_cast<QDoubleSpinBox *>(w[1])->setValue(m_ImageData->getMin(i) + (position / sliderScale[i]));
80 qobject_cast<QDoubleSpinBox *>(w[3])->setValue(m_ImageData->getMin(i) + sliderTick[i] + (position / sliderScale[i]));
85void FITSHistogramEditor::showEvent(
QShowEvent * event)
100void FITSHistogramEditor::resizePlot()
102 ui->histogramPlot->resizePlot();
105void FITSHistogramEditor::syncGUI()
112 for (
int n = 0; n < m_ImageData->channels(); n++)
114 sliderTick << fabs(m_ImageData->getMax(n) - m_ImageData->getMin(n)) / 99.0;
115 sliderScale << 99.0 / (m_ImageData->getMax(n) - m_ImageData->getMin(n) - sliderTick[n]);
118 ui->histogramPlot->syncGUI();
120 bool isColor = m_ImageData->channels() > 1;
122 for (
auto w : rgbWidgets[RED_CHANNEL])
125 for (
auto w : rgbWidgets[GREEN_CHANNEL])
126 w->setEnabled(isColor);
128 for (
auto w : rgbWidgets[BLUE_CHANNEL])
129 w->setEnabled(isColor);
134 for (
int n = 0; n < m_ImageData->channels(); n++)
136 double median = m_ImageData->getMedian(n);
142 else if (median > .01)
144 else if (median > .0001)
149 minBoxes[n]->setDecimals(numDecimals[n]);
150 minBoxes[n]->setSingleStep(fabs(m_ImageData->getMax(n) - m_ImageData->getMin(n)) / 20.0);
151 minBoxes[n]->setMinimum(m_ImageData->getMin(n));
152 minBoxes[n]->setMaximum(m_ImageData->getMax(n) - sliderTick[n]);
153 minBoxes[n]->setValue(m_ImageData->getMin(n) + (sliders[n]->minimumValue() / sliderScale[n]));
155 maxBoxes[n]->setDecimals(numDecimals[n]);
156 maxBoxes[n]->setSingleStep(fabs(m_ImageData->getMax(n) - m_ImageData->getMin(n)) / 20.0);
157 maxBoxes[n]->setMinimum(m_ImageData->getMin(n) + sliderTick[n]);
158 maxBoxes[n]->setMaximum(m_ImageData->getMax(n));
159 maxBoxes[n]->setValue(m_ImageData->getMin(n) + sliderTick[n] + (sliders[n]->maximumValue() / sliderScale[n]));
162 ui->histogramPlot->syncGUI();
169void FITSHistogramEditor::applyScale()
171 QVector<double> min, max;
173 min << minBoxes[0]->
value() << minBoxes[1]->value() << minBoxes[2]->value();
174 max << maxBoxes[0]->
value() << maxBoxes[1]->value() << maxBoxes[2]->value();
180 emit newHistogramCommand(
new FITSHistogramCommand(m_ImageData,
this, type, min, max));
183void FITSHistogramEditor::applyFilter(FITSScale ftype)
185 QVector<double> min, max;
186 min.
append(ui->minREdit->value());
189 emit newHistogramCommand(
new FITSHistogramCommand(m_ImageData,
this, type, min, max));
195 ui->histogramPlot->setImageData(data);
197 connect(m_ImageData.data(), &FITSData::dataChanged, [
this]
void minimumValueChanged(int min)
This signal is emitted when the slider minimum value has changed, with the new slider value as argume...
void maximumValueChanged(int max)
This signal is emitted when the slider maximum value has changed, with the new slider value as argume...
void append(QList< T > &&value)
T value(qsizetype i) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
virtual bool event(QEvent *e)
QString number(double n, char format, int precision)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)