1#include "PlotWindowBestFitDialog.h"
5#include <qwt_plot_spectrogram.h>
17#include "CubePlotCurve.h"
19#include "ScatterPlotData.h"
35 QGridLayout *optionsLayout =
new QGridLayout;
38 QLabel *titleLabel =
new QLabel(
"Curve To Fit: ");
41 optionsLayout->addWidget(titleLabel, row, 0);
47 QLabel *equationTitleLabel =
new QLabel(
"Equation from Curve: ");
49 optionsLayout->addWidget(equationTitleLabel, row, 0);
53 QLabel *correlationTitleLabel =
new QLabel(
"Correlation Coefficient (r): ");
55 optionsLayout->addWidget(correlationTitleLabel, row, 0);
59 QLabel *determinationTitleLabel =
new QLabel(
60 "Coefficient of Determination (r<sup>2</sup>): ");
62 optionsLayout->addWidget(determinationTitleLabel, row, 0);
66 QHBoxLayout *applyButtonsLayout =
new QHBoxLayout;
67 applyButtonsLayout->addStretch();
77 QPushButton *cancel =
new QPushButton(
"&Cancel");
78 cancel->setIcon(QIcon::fromTheme(
"dialog-cancel"));
79 connect(cancel, SIGNAL(clicked()),
81 applyButtonsLayout->addWidget(cancel);
84 optionsHolder->setLayout(optionsLayout);
87 applyButtonsHolder->setLayout(applyButtonsLayout);
89 QVBoxLayout *mainLayout =
new QVBoxLayout;
90 mainLayout->addWidget(optionsHolder);
91 mainLayout->addWidget(applyButtonsHolder);
93 setLayout(mainLayout);
100 PlotWindowBestFitDialog::~PlotWindowBestFitDialog() {
127 int dataSize = selected->dataSize();
130 for (
int i = 0; i < dataSize; i++) {
131 data[i].setX(selected->sample(i).x());
132 data[i].setY(a + b * data[i].x());
135 newCurve->
setData(
new QwtPointSeriesData(data));
140 QPen pen(newCurve->pen());
141 pen.setStyle(Qt::SolidLine);
144 newCurve->setTitle(selected->title().text() +
" Best Fit");
172 int dataSize = rawXValues.size();
175 for (
int i = 0; i < dataSize; i++) {
176 data[i].setX(rawXValues[i]);
177 data[i].setY(a + b * data[i].x());
180 newCurve->
setData(
new QwtPointSeriesData(data));
185 QPen pen(newCurve->pen());
186 pen.setStyle(Qt::SolidLine);
189 newCurve->setTitle(selected->title().text() +
" Best Fit");
209 foreach (QwtPlotSpectrogram *spectrogram, spectrograms) {
211 m_curvesCombo->addItem( spectrogram->title().text(), QVariant::fromValue(spectrogram) );
218 m_curvesCombo->addItem( curve->title().text(), QVariant::fromValue(curve) );
230 bool canDeriveEquation =
false;
236 int dataSize = selected->dataSize();
237 for (
int dataPoint = 0; dataPoint < dataSize; dataPoint++) {
238 double x = selected->sample(dataPoint).x();
239 double y = selected->sample(dataPoint).y();
254 int binValue = scatterData->
binCount(i);
273 canDeriveEquation =
true;
282 IString(correlation * correlation).ToQt());
293 if (!canDeriveEquation) {
316 if (selected != NULL && curves.indexOf(selected) == -1) {
334 QwtPlotSpectrogram *selected = NULL;
338 m_curvesCombo->currentIndex()).value<QwtPlotSpectrogram *>();
343 if (selected != NULL && spectrograms.indexOf(selected) == -1) {
This is a plot curve with information relating it to a particular cube or region of a cube.
void copySource(const CubePlotCurve &other)
This copies the source data from another CubePlotCurve.
Adds specific functionality to C++ strings.
Container of multivariate statistics.
void setColor(const QColor &color)
Set the color of this curve and it's markers.
QColor color() const
This method returns the color of the curve.
void setData(QwtSeriesData< QPointF > *data)
This method sets the data for the curve, then sets the value for the markers associated with the curv...
Units yUnits() const
Get the units of the y-axis double data.
void setMarkerSymbol(QwtSymbol::Style style)
This method sets the shape of the markers.
Units xUnits() const
Get the units of the x-axis double data.
void setPen(const QPen &pen)
Sets the plot pen to the passed-in pen.
QPointer< QLabel > m_equationLabel
A label populated with the resulting equation from a best fit.
QPointer< PlotWindow > m_plotWindowWithCurves
The plot window we're creating a best for line for.
QPointer< QLabel > m_correlationLabel
A label populated with the resulting correlation from a best fit.
PlotWindowBestFitDialog(PlotWindow *windowWithCurves, QWidget *parent)
Create a PlotWindowBestFitDialog.
QPointer< QPushButton > m_okayButton
The ok button which the user clicks to create the best fit curve.
QPointer< QComboBox > m_curvesCombo
A combo box for the user to select a curve/spectrogram to best fit.
void createBestFitLine()
This is called when the user wants the best fit line.
QScopedPointer< MultivariateStatistics > m_curveMultivariateStats
The MV stats which is doing our regression calculations.
void readCurvesFromWindow()
This populates the curve selection combo with all of the available information inside of the PlotWind...
QwtPlotSpectrogram * selectedSpectrogram()
If a spectrogram (scatter plot) is selected, this returns it.
void refreshWidgetStates()
This updates all of the widgets in this window's visibility and text data based on what the user has ...
QPointer< QLabel > m_determinationLabel
A label populated with the resulting determination from a best fit.
CubePlotCurve * selectedCurve()
If a curve is selected, this returns it.
This is the QwtRasterData for a scatter plot.
QVector< double > discreteXValues() const
Get a list of all of the x-bin center values for this scatter plot.
int binCount(int binIndex) const
Get the count (number of values) which fall into the bin at index.
QPair< double, double > binXY(int binIndex) const
Get the center X/Y Dn values for the bin at index.
int numberOfBins() const
Get the total number of bins (bin count in x * bin count in y).
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
const double Null
Value for an Isis Null pixel.
bool IsSpecial(const double d)
Returns if the input pixel is special.
This is free and unencumbered software released into the public domain.