1 #include "SawtoothStretchType.h" 7 #include <QTableWidget> 10 #include "HistogramWidget.h" 24 const Stretch &stretch,
const QString &name,
const QColor &color) :
33 QGridLayout *sliderLayout =
new QGridLayout();
34 sliderLayout->setColumnStretch(1, 10);
36 QLabel *startLabel =
new QLabel(
"Offset");
49 connect(
p_offsetEdit, SIGNAL(textChanged(
const QString &)),
51 sliderLayout->addWidget(startLabel, 0, 0);
55 QLabel *widthLabel =
new QLabel(
"Width");
65 connect(
p_widthEdit, SIGNAL(textChanged(
const QString &)),
67 sliderLayout->addWidget(widthLabel, 1, 0);
71 sliderWidget->setLayout(sliderLayout);
107 bool changed =
false;
109 if(newStretch.
Pairs() < 3) {
118 offset = newStretch.
Input(1);
121 if(newStretch.
Output(1) > 127)
122 offset = newStretch.
Input(2);
124 width = (newStretch.
Input(2) - newStretch.
Input(0)) / 2;
128 double deltaOffset = fabs(
p_offsetEdit->text().toDouble() - offset);
131 double deltaWidth = fabs(
p_widthEdit->text().toDouble() - width);
179 int valuePos = (int)(percentage * 1000.0);
209 (highVal - lowVal) / 1000.0;
225 double percentage = value - lowVal;
226 percentage /= (highVal - lowVal);
227 int valuePos = (int)(percentage * 1000.0);
258 if(width < p_cubeHist->BinSize())
262 if(width <= 0)
return Stretch();
268 double leftPoint = offset;
271 while(leftPoint < p_cubeHist->Minimum() - width) {
282 double currPoint = leftPoint;
284 bool terminated =
false;
286 int outValue = (high) ? 255 : 0;
void widthSliderMoved(int)
This is called when the sawtooth width slider moves.
QLineEdit * p_widthEdit
Width edit.
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.
QSlider * p_offsetSlider
Offset slider.
void stretchChanged()
Emitted when a new Stretch object is available.
void offsetSliderMoved(int)
This is called when the sawtooth offset slider moves.
void offsetEditChanged(const QString &)
This is called when the the sawtooth offset edit changes.
Stretch * p_stretch
Current stretch pairs stored here.
double toDouble(const QString &string)
Global function to convert from a string to a double.
int Pairs() const
Returns the number of stretch pairs.
QLineEdit * p_offsetEdit
Offset edit.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
bool p_sliderOverride
This is used to let the edits be changed to where sliders cant go.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
void widthEditChanged(const QString &)
This is called when the the sawtooth width edit changes.
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values...
Container of a cube histogram.
double Output(const int index) const
Returns the value of the output side of the stretch pair at the specified index.
virtual void setStretch(Stretch)
Given an arbitrary stretch, this will re-interpret it, as best as possible, into a sawtooth stretch...
QString Text() const
Converts stretch pair to a string.
double BinSize() const
Returns the size of an individual bin.
Stretch calculateNewStretch()
This calculates a new stretch using the GUI edits.
QSlider * p_widthSlider
Width slider.
SawtoothStretchType(const Histogram &, const Stretch &, const QString &name, const QColor &color)
This initializes a sawtooth stretch type.
Namespace for ISIS/Bullet specific routines.
This is the base class for advanced stretches.
~SawtoothStretchType()
Destructor.
double Median() const
Returns the median.
Histogram * p_cubeHist
Visible area histogram.
QGridLayout * p_mainLayout
Main layout.