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();
 
  128        QVector<QPointF> data(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));
 
  136        newCurve->setColor(selected->
color());
 
  138        newCurve->setMarkerSymbol(QwtSymbol::NoSymbol);
 
  140        QPen pen(newCurve->pen());
 
  141        pen.setStyle(Qt::SolidLine);
 
  142        newCurve->setPen(pen);
 
  144        newCurve->setTitle(selected->title().text() + 
" Best Fit");
 
  145        newCurve->copySource(*selected);
 
  170        QVector<double> rawXValues = scatterData->discreteXValues();
 
  172        int dataSize = rawXValues.size();
 
  173        QVector<QPointF> data(dataSize);
 
  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));
 
  181        newCurve->setColor(Qt::red);
 
  183        newCurve->setMarkerSymbol(QwtSymbol::NoSymbol);
 
  185        QPen pen(newCurve->pen());
 
  186        pen.setStyle(Qt::SolidLine);
 
  187        newCurve->setPen(pen);
 
  189        newCurve->setTitle(selected->title().text() + 
" Best Fit");
 
 
  206      QList<QwtPlotSpectrogram *> spectrograms =
 
  209      foreach (QwtPlotSpectrogram *spectrogram, spectrograms) {
 
  211          m_curvesCombo->addItem( spectrogram->title().text(), qVariantFromValue(spectrogram) );
 
  218          m_curvesCombo->addItem( curve->title().text(), qVariantFromValue(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();
 
  251        for (
int i = 0; i < scatterData->numberOfBins(); i++) {
 
  252          QPair<double, double> pointXY = scatterData->
binXY(i);
 
  254          int binValue = scatterData->binCount(i);
 
  273        canDeriveEquation = 
true;
 
  293    if (!canDeriveEquation) {
 
 
  316      if (selected != NULL && curves.indexOf(selected) == -1) {
 
 
  334    QwtPlotSpectrogram *selected = NULL;
 
  338          m_curvesCombo->currentIndex()).value<QwtPlotSpectrogram *>();
 
  340      QList<QwtPlotSpectrogram *> spectrograms =
 
  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.
 
Adds specific functionality to C++ strings.
 
QString ToQt() const
Retuns the object string as a QString.
 
Container of multivariate statistics.
 
QColor color() const
This method returns the color of the curve.
 
Units yUnits() const
Get the units of the y-axis double data.
 
Units xUnits() const
Get the units of the x-axis double data.
 
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.
 
QPair< double, double > binXY(int binIndex) const
Get the center X/Y Dn values for the bin at index.
 
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.