1#include "SawtoothStretchType.h"
9#include "CubeViewport.h"
10#include "HistogramWidget.h"
11#include "Statistics.h"
13#include "CubeStretch.h"
25 const Stretch &stretch,
const QString &name,
const QColor &color) :
34 QGridLayout *sliderLayout =
new QGridLayout();
35 sliderLayout->setColumnStretch(1, 10);
37 QLabel *startLabel =
new QLabel(
"Offset");
50 connect(
p_offsetEdit, SIGNAL(textChanged(
const QString &)),
52 sliderLayout->addWidget(startLabel, 0, 0);
56 QLabel *widthLabel =
new QLabel(
"Width");
66 connect(
p_widthEdit, SIGNAL(textChanged(
const QString &)),
68 sliderLayout->addWidget(widthLabel, 1, 0);
72 sliderWidget->setLayout(sliderLayout);
108 bool changed =
false;
111 if(newStretch.Pairs() < 3) {
116 offset = newStretch.Input(1);
119 if(newStretch.Output(1) > 127)
120 offset = newStretch.Input(2);
122 width = (newStretch.Input(2) - newStretch.Input(0)) / 2;
126 double deltaOffset = fabs(
p_offsetEdit->text().toDouble() - offset);
129 double deltaWidth = fabs(
p_widthEdit->text().toDouble() - width);
144 emit stretchChanged();
177 int valuePos = (int)(percentage * 1000.0);
187 emit stretchChanged();
207 (highVal - lowVal) / 1000.0;
223 double percentage = value - lowVal;
224 percentage /= (highVal - lowVal);
225 int valuePos = (int)(percentage * 1000.0);
235 emit stretchChanged();
256 if(width < p_cubeHist->BinSize())
260 if(width <= 0)
return Stretch();
266 double leftPoint = offset;
269 while(leftPoint < p_cubeHist->Minimum() - width) {
280 double currPoint = leftPoint;
282 bool terminated =
false;
284 int outValue = (high) ? 255 : 0;
Stores stretch information for a cube.
Container of a cube histogram.
double BinSize() const
Returns the size of an individual bin.
double Median() const
Returns the median.
void widthSliderMoved(int)
This is called when the sawtooth width slider moves.
virtual void setStretch(Stretch)
Given an arbitrary stretch, this will re-interpret it, as best as possible, into a sawtooth stretch.
virtual CubeStretch getStretch()
Gets the CubeStretch for this Sawtooth Stretch.
QLineEdit * p_widthEdit
Width edit.
SawtoothStretchType(const Histogram &, const Stretch &, const QString &name, const QColor &color)
This initializes a sawtooth stretch type.
void offsetEditChanged(const QString &)
This is called when the the sawtooth offset edit changes.
void widthEditChanged(const QString &)
This is called when the the sawtooth width edit changes.
QLineEdit * p_offsetEdit
Offset edit.
Stretch calculateNewStretch()
This calculates a new stretch using the GUI edits.
void offsetSliderMoved(int)
This is called when the sawtooth offset slider moves.
bool p_sliderOverride
This is used to let the edits be changed to where sliders cant go.
~SawtoothStretchType()
Destructor.
QSlider * p_widthSlider
Width slider.
QSlider * p_offsetSlider
Offset slider.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
QString Text() const
Converts stretch pair to a string.
This is the base class for advanced stretches.
Stretch * p_stretch
Current stretch pairs stored here.
Histogram * p_cubeHist
Visible area histogram.
QGridLayout * p_mainLayout
Main layout.
This is free and unencumbered software released into the public domain.
double toDouble(const QString &string)
Global function to convert from a string to a double.