3 #include "PlotWindowBestFitDialog.h" 7 #include <qwt_plot_spectrogram.h> 10 #include <QColorDialog> 12 #include <QGridLayout> 15 #include <QPushButton> 20 #include "ScatterPlotData.h" 36 QGridLayout *optionsLayout =
new QGridLayout;
39 QLabel *titleLabel =
new QLabel(
"Curve To Fit: ");
42 optionsLayout->addWidget(titleLabel, row, 0);
48 QLabel *equationTitleLabel =
new QLabel(
"Equation from Curve: ");
50 optionsLayout->addWidget(equationTitleLabel, row, 0);
54 QLabel *correlationTitleLabel =
new QLabel(
"Correlation Coefficient (r): ");
56 optionsLayout->addWidget(correlationTitleLabel, row, 0);
60 QLabel *determinationTitleLabel =
new QLabel(
61 "Coefficient of Determination (r<sup>2</sup>): ");
63 optionsLayout->addWidget(determinationTitleLabel, row, 0);
67 QHBoxLayout *applyButtonsLayout =
new QHBoxLayout;
68 applyButtonsLayout->addStretch();
78 QPushButton *cancel =
new QPushButton(
"&Cancel");
79 cancel->setIcon(QIcon::fromTheme(
"dialog-cancel"));
80 connect(cancel, SIGNAL(clicked()),
82 applyButtonsLayout->addWidget(cancel);
85 optionsHolder->setLayout(optionsLayout);
88 applyButtonsHolder->setLayout(applyButtonsLayout);
90 QVBoxLayout *mainLayout =
new QVBoxLayout;
91 mainLayout->addWidget(optionsHolder);
92 mainLayout->addWidget(applyButtonsHolder);
94 setLayout(mainLayout);
101 PlotWindowBestFitDialog::~PlotWindowBestFitDialog() {
128 int dataSize = selected->dataSize();
131 for (
int i = 0; i < dataSize; i++) {
132 data[i].setX(selected->sample(i).x());
133 data[i].setY(a + b * data[i].x());
136 newCurve->
setData(
new QwtPointSeriesData(data));
141 QPen pen(newCurve->pen());
142 pen.setStyle(Qt::SolidLine);
145 newCurve->setTitle(selected->title().text() +
" Best Fit");
173 int dataSize = rawXValues.size();
176 for (
int i = 0; i < dataSize; i++) {
177 data[i].setX(rawXValues[i]);
178 data[i].setY(a + b * data[i].x());
181 newCurve->
setData(
new QwtPointSeriesData(data));
186 QPen pen(newCurve->pen());
187 pen.setStyle(Qt::SolidLine);
190 newCurve->setTitle(selected->title().text() +
" Best Fit");
210 foreach (QwtPlotSpectrogram *spectrogram, spectrograms) {
211 if (dynamic_cast<ScatterPlotData *>(spectrogram->data())) {
212 m_curvesCombo->addItem( spectrogram->title().text(), qVariantFromValue(spectrogram) );
219 m_curvesCombo->addItem( curve->title().text(), qVariantFromValue(curve) );
231 bool canDeriveEquation =
false;
237 int dataSize = selected->dataSize();
238 for (
int dataPoint = 0; dataPoint < dataSize; dataPoint++) {
239 double x = selected->sample(dataPoint).x();
240 double y = selected->sample(dataPoint).y();
255 int binValue = scatterData->
binCount(i);
274 canDeriveEquation =
true;
283 IString(correlation * correlation).ToQt());
294 if (!canDeriveEquation) {
317 if (selected != NULL && curves.indexOf(selected) == -1) {
335 QwtPlotSpectrogram *selected = NULL;
339 m_curvesCombo->currentIndex()).value<QwtPlotSpectrogram *>();
344 if (selected != NULL && spectrograms.indexOf(selected) == -1) {
PlotWindowBestFitDialog(PlotWindow *windowWithCurves, QWidget *parent)
Create a PlotWindowBestFitDialog.
void createBestFitLine()
This is called when the user wants the best fit line.
const double Null
Value for an Isis Null pixel.
void copySource(const CubePlotCurve &other)
This copies the source data from another CubePlotCurve.
void refreshWidgetStates()
This updates all of the widgets in this window's visibility and text data based on what the user has ...
QPair< double, double > binXY(int binIndex) const
Get the center X/Y Dn values for the bin at index.
int binCount(int binIndex) const
Get the count (number of values) which fall into the bin at index.
QPointer< QLabel > m_correlationLabel
A label populated with the resulting correlation from a best fit.
Container of multivariate statistics.
QwtPlotSpectrogram * selectedSpectrogram()
If a spectrogram (scatter plot) is selected, this returns it.
QPointer< QComboBox > m_curvesCombo
A combo box for the user to select a curve/spectrogram to best fit.
QPointer< QPushButton > m_okayButton
The ok button which the user clicks to create the best fit curve.
QPointer< QLabel > m_equationLabel
A label populated with the resulting equation from a best fit.
This is a plot curve with information relating it to a particular cube or region of a cube...
QColor color() const
This method returns the color of the curve.
QPointer< QLabel > m_determinationLabel
A label populated with the resulting determination from a best fit.
bool IsSpecial(const double d)
Returns if the input pixel is special.
void setColor(const QColor &color)
Set the color of this curve and it's markers.
CubePlotCurve * selectedCurve()
If a curve is selected, this returns it.
Units xUnits() const
Get the units of the x-axis double data.
This is the QwtRasterData for a scatter plot.
QPointer< PlotWindow > m_plotWindowWithCurves
The plot window we're creating a best for line for.
QVector< double > discreteXValues() const
Get a list of all of the x-bin center values for this scatter plot.
int numberOfBins() const
Get the total number of bins (bin count in x * bin count in y).
void setData(QwtSeriesData< QPointF > *data)
This method sets the data for the curve, then sets the value for the markers associated with the curv...
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
void readCurvesFromWindow()
This populates the curve selection combo with all of the available information inside of the PlotWind...
void setPen(const QPen &pen)
Sets the plot pen to the passed-in pen.
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.
QScopedPointer< MultivariateStatistics > m_curveMultivariateStats
The MV stats which is doing our regression calculations.