1 #include "BinaryStretchType.h" 7 #include <QTableWidget> 10 #include "HistogramWidget.h" 25 const QString &name,
const QColor &color)
35 QGridLayout *sliderLayout =
new QGridLayout();
36 sliderLayout->setColumnStretch(1, 10);
38 QLabel *startLabel =
new QLabel(
"Start");
49 connect(
p_startEdit, SIGNAL(textChanged(
const QString &)),
51 sliderLayout->addWidget(startLabel, 0, 0);
55 QLabel *endLabel =
new QLabel(
"End");
67 connect(
p_endEdit, SIGNAL(textChanged(
const QString &)),
69 sliderLayout->addWidget(endLabel, 1, 0);
73 sliderWidget->setLayout(sliderLayout);
104 double switch1 = 0.0;
105 double switch2 = 1.0;
107 if(newStretch.
Pairs() == 2) {
118 switch1 = newStretch.
Input(0);
119 if(switch1 < p_cubeHist->Minimum())
122 interpretted.
AddPair(switch1, 0);
123 interpretted.
AddPair(switch1 + epsilon, 255);
125 switch2 = newStretch.
Input(1);
126 if(switch2 <= switch1 + epsilon)
127 switch2 = switch1 + epsilon + epsilon;
129 interpretted.
AddPair(switch2, 255);
130 interpretted.
AddPair(switch2 + epsilon, 0);
133 if(end <= switch2 + epsilon)
134 end = switch2 + epsilon + epsilon;
139 else if(newStretch.
Pairs() == 4) {
140 if(newStretch.
Output(0) > 127) {
143 switch1 = newStretch.
Input(1);
144 if(switch1 <= p_cubeHist->Minimum())
147 interpretted.
AddPair(switch1, 255);
148 interpretted.
AddPair(switch1 + epsilon, 0);
151 if(end <= switch1 + epsilon)
152 end = switch1 + epsilon + epsilon;
161 switch1 = newStretch.
Input(1);
162 if(switch1 < p_cubeHist->Minimum())
165 interpretted.
AddPair(switch1, 0);
166 interpretted.
AddPair(switch1 + epsilon, 255);
169 if(end <= switch1 + epsilon)
170 end = switch1 + epsilon + epsilon;
173 interpretted.
AddPair(end, 255);
177 else if(newStretch.
Pairs() == 6) {
180 switch1 = newStretch.
Input(1);
181 if(switch1 <= p_cubeHist->Minimum())
184 interpretted.
AddPair(switch1, 0);
185 interpretted.
AddPair(switch1 + epsilon, 255);
188 switch2 = newStretch.
Input(3);
189 if(switch2 <= switch1 + epsilon)
190 switch2 = switch1 + epsilon + epsilon;
192 interpretted.
AddPair(switch2, 255);
193 interpretted.
AddPair(switch2 + epsilon, 0);
196 if(end <= switch2 + epsilon)
197 end = switch2 + epsilon + epsilon;
202 if(!interpretted.
Pairs()) {
214 p_endEdit->setText(QString::number(switch2));
255 if(value >=
p_endEdit->text().toDouble()) {
261 int valuePos = (int)(percentage * 1000.0);
294 p_endEdit->setText(QString::number(value));
303 double value =
p_endEdit->text().toDouble();
305 if(value <= p_startEdit->text().
toDouble()) {
311 int valuePos = (int)(percentage * 1000.0);
349 startPt <= p_cubeHist->Minimum()) {
355 newStretch.
AddPair(startPt, 0);
356 newStretch.
AddPair(startPt + epsilon, 255);
360 double endPt =
p_endEdit->text().toDouble();
361 if(endPt <= startPt + epsilon) {
362 endPt = startPt + 2 * epsilon;
370 newStretch.
AddPair(endPt, 255);
371 newStretch.
AddPair(endPt + epsilon, 0);
double Input(const int index) const
Returns the value of the input side of the stretch pair at the specified index.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
void stretchChanged()
Emitted when a new Stretch object is available.
Stretch * p_stretch
Current stretch pairs stored here.
double toDouble(const QString &string)
Global function to convert from a string to a double.
void endSliderMoved(int)
This is called when the end point slider moves.
int Pairs() const
Returns the number of stretch pairs.
void startEditChanged(const QString &)
A new start point was typed in.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
QLineEdit * p_endEdit
End point edit.
virtual void setStretch(Stretch)
Given an arbitrary stretch, this will re-interpret it, as best as possible, into a binary stretch...
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
QSlider * p_endSlider
End point slider.
bool p_editOverride
This is used to let the edits be changed without updating the stretch.
Stretch calculateNewStretch()
This uses the GUI elements to calculate the current binary stretch.
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values...
~BinaryStretchType()
Destroys the binary stretch.
Container of a cube histogram.
QSlider * p_startSlider
Start point slider.
double Output(const int index) const
Returns the value of the output side of the stretch pair at the specified index.
void endEditChanged(const QString &)
A new end point was typed in.
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
QString Text() const
Converts stretch pair to a string.
BinaryStretchType(const Histogram &, const Stretch &, const QString &name, const QColor &color)
This constructs a binary stretch type.
double BinSize() const
Returns the size of an individual bin.
bool p_sliderOverride
This is used to let the edits be changed to where sliders cant go.
Namespace for ISIS/Bullet specific routines.
This is the base class for advanced stretches.
void startSliderMoved(int)
This is called when the start point slider moves.
Histogram * p_cubeHist
Visible area histogram.
QGridLayout * p_mainLayout
Main layout.
QLineEdit * p_startEdit
Start point edit.