3 #include "PlotWindowBestFitDialog.h" 
    7 #include <qwt_plot_spectrogram.h> 
   10 #include <QColorDialog> 
   12 #include <QGridLayout> 
   15 #include <QPushButton> 
   18 #include "CubePlotCurve.h" 
   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) {
 
  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;
 
  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) {