20#include <QApplication>
24#include <QItemSelectionModel>
36 m_isLogXTheta (
false),
37 m_isLogYRadius (
false),
38 m_significantDigits (mainWindow->modelMainWindow().significantDigits ())
45 "This window applies a curve fit to the currently selected curve.\n\n"
46 "If drag-and-drop is disabled, a rectangular set of cells may be selected by clicking and dragging. Otherwise, if "
47 "drag-and-drop is enabled, a rectangular set of cells may be selected using Click then Shift+Click, since click and drag "
48 "starts the dragging operation. Drag-and-drop mode is set in the Main Window settings"));
52 createWidgets (mainWindow);
61void FittingWindow::calculateCurveFitAndStatistics ()
72 qFloor (m_significantDigits));
74 m_lblMeanSquareError->setText (QString::number (
mse));
75 m_lblRootMeanSquare->setText (QString::number (
rms));
76 m_lblRSquared->setText (QString::number (
rSquared));
79 if (m_pointsConvenient.size () > 0) {
80 int last = m_pointsConvenient.size () - 1;
82 m_pointsConvenient [0].x(),
83 m_pointsConvenient [
last].x (),
95 for (
int row = 0,
order = m_model->rowCount () - 1;
row < m_model->rowCount ();
row++,
order--) {
104 m_labelY->setText (
"");
105 m_model->setRowCount (0);
106 m_lblMeanSquareError->setText (
"");
107 m_lblRootMeanSquare->setText (
"");
108 m_lblRSquared->setText (
"");
118void FittingWindow::createWidgets (
MainWindow *mainWindow)
136 layout->addWidget (m_cmbOrder,
row++, 1, 1, 1);
139 m_labelY =
new QLabel;
140 layout->addWidget (m_labelY,
row++, 0, 1, 1);
144 m_model->setColumnCount (2);
148 mainWindow,
SLOT (slotTableStatusChange ()));
150 layout->addWidget (m_view,
row++, 0, 1, 2);
156 m_lblMeanSquareError =
new QLineEdit;
157 m_lblMeanSquareError->setReadOnly (
true);
158 m_lblMeanSquareError->setWhatsThis (
tr (
"Calculated mean square error statistic"));
159 layout->addWidget (m_lblMeanSquareError,
row++, 1, 1, 1);
164 m_lblRootMeanSquare =
new QLineEdit;
165 m_lblRootMeanSquare->setReadOnly (
true);
166 m_lblRootMeanSquare->setWhatsThis (
tr (
"Calculated root mean square statistic. This is calculated as the square root of the mean square error"));
167 layout->addWidget (m_lblRootMeanSquare,
row++, 1, 1, 1);
172 m_lblRSquared =
new QLineEdit;
173 m_lblRSquared->setReadOnly (
true);
174 m_lblRSquared->setWhatsThis (
tr (
"Calculated R squared statistic"));
175 layout->addWidget (m_lblRSquared,
row++, 1, 1, 1);
184 if (!
text.isEmpty ()) {
187 QApplication::clipboard ()->setText (
text);
192void FittingWindow::initializeOrder ()
197 m_cmbOrder->setCurrentIndex (index);
200int FittingWindow::maxOrder ()
const
202 return m_cmbOrder->currentData().toInt();
205void FittingWindow::refreshTable ()
207 int order = m_cmbOrder->currentData().toInt();
212 calculateCurveFitAndStatistics ();
215void FittingWindow::resizeTable (
int order)
219 m_model->setRowCount (
order + 1);
223 .arg (m_curveSelected)
224 .arg (m_curveSelected.isEmpty () ?
227 .
arg (m_isLogYRadius ?
230 m_labelY->setText (
yTerm);
250void FittingWindow::slotCmbOrder(
int )
271 m_pointsConvenient.clear ();
280 if (
curve->numPoints() > 0) {
284 Points::const_iterator
itr;
285 for (
itr = points.begin ();
itr != points.end ();
itr++) {
295 double x =
qLn (posGraph.x()) /
qLn (10.0);
298 if (m_isLogYRadius) {
299 double y =
qLn (posGraph.y()) /
qLn (10.0);
303 m_pointsConvenient.append (posGraph);
313 return dynamic_cast<QTableView*
> (m_view);
const int INNER_RADIUS_MIN
#define ENGAUGE_CHECK_PTR(ptr)
#endif
const int COLUMN_POLYNOMIAL_TERMS
const int MAX_POLYNOMIAL_ORDER
const int COLUMN_POLYNOMIAL_TERMS
const int COLUMN_COEFFICIENTS
log4cpp::Category * mainCat
Container for one set of digitized Points.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
This class does the math to compute statistics for FittingWindow.
void calculateCurveFitAndStatistics(unsigned int order, const FittingPointsConvenient &pointsConvenient, FittingCurveCoefficients &coefficients, double &mse, double &rms, double &rSquared, int significantDigits)
Compute the curve fit and the statistics for that curve fit.
virtual void clear()
Clear stale information.
virtual void doCopy()
Copy the current selection to the clipboard.
FittingWindow(MainWindow *mainWindow)
Single constructor. Parent is needed or else this widget cannot be redocked after being undocked.
virtual void update(const CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow, const QString &curveSelected, const Transformation &transformation)
Populate the table with the specified Curve.
virtual void closeEvent(QCloseEvent *event)
Catch close event so corresponding menu item in MainWindow can be updated accordingly.
void signalCurveFit(FittingCurveCoefficients, double, double, bool, bool)
Signal containing coefficients from curve fit.
virtual QTableView * view() const
QTableView-based class used by child class.
void signalFittingWindowClosed()
Signal that this QDockWidget was just closed.
Model for DlgSettingsMainWindow.
bool dragDropExport() const
Get method for drag and drop export.
int significantDigits() const
Get method for significant digits.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
Dockable widget abstract base class.
QString selectionAsText(ExportDelimiter delimiter) const
Convert the selection into exportable text which is good for text editors.
void setDelimiter(ExportDelimiter delimiter)
Save output delimiter.
Table view class with support for both drag-and-drop and copy-and-paste.
#define LOG4CPP_INFO_S(logger)