Commit f9866b4e authored by Stefan Gerlach's avatar Stefan Gerlach

[locale] fit dock and plot dock fixes

parent 928e7506
......@@ -30,6 +30,7 @@
#define RANGE_H
#include <QString>
#include <QLocale>
//! Auxiliary class for a data range
/**
......@@ -69,7 +70,7 @@ public:
//! Return a string in the format '[min, max]'
QString toString() const {
return "[" + QString::number(m_min) + ", " + QString::number(m_max) + "]";
return "[" + QLocale().toString(m_min) + ", " + QLocale().toString(m_max) + "]";
}
//TODO: touches(), merge(), subtract(), split(), etc. (see Interval)
......
......@@ -790,7 +790,7 @@ void CartesianPlotDock::addXBreak() {
for (auto* plot : m_plotList)
plot->setXRangeBreaks(breaks);
ui.cbXBreak->addItem(QString::number(ui.cbXBreak->count()+1));
ui.cbXBreak->addItem(QString::number(ui.cbXBreak->count() + 1));
ui.cbXBreak->setCurrentIndex(ui.cbXBreak->count()-1);
}
......@@ -824,9 +824,9 @@ void CartesianPlotDock::currentXBreakChanged(int index) {
m_initializing = true;
const CartesianPlot::RangeBreak rangeBreak = m_plot->xRangeBreaks().list.at(index);
QString str = std::isnan(rangeBreak.start) ? QString() : QString::number(rangeBreak.start);
QString str = std::isnan(rangeBreak.start) ? QString() : QLocale().toString(rangeBreak.start);
ui.leXBreakStart->setText(str);
str = std::isnan(rangeBreak.end) ? QString() : QString::number(rangeBreak.end);
str = std::isnan(rangeBreak.end) ? QString() : QLocale().toString(rangeBreak.end);
ui.leXBreakEnd->setText(str);
ui.sbXBreakPosition->setValue(rangeBreak.position*100);
ui.cbXBreakStyle->setCurrentIndex((int)rangeBreak.style);
......@@ -911,12 +911,12 @@ void CartesianPlotDock::addYBreak() {
for (auto* plot : m_plotList)
plot->setYRangeBreaks(breaks);
ui.cbYBreak->addItem(QString::number(ui.cbYBreak->count()+1));
ui.cbYBreak->addItem(QString::number(ui.cbYBreak->count() + 1));
ui.cbYBreak->setCurrentIndex(ui.cbYBreak->count()-1);
}
void CartesianPlotDock::removeYBreak() {
ui.bRemoveYBreak->setVisible(m_plot->yRangeBreaks().list.size()>1);
ui.bRemoveYBreak->setVisible(m_plot->yRangeBreaks().list.size() > 1);
int index = ui.cbYBreak->currentIndex();
CartesianPlot::RangeBreaks breaks = m_plot->yRangeBreaks();
breaks.list.takeAt(index);
......@@ -945,9 +945,9 @@ void CartesianPlotDock::currentYBreakChanged(int index) {
m_initializing = true;
const CartesianPlot::RangeBreak rangeBreak = m_plot->yRangeBreaks().list.at(index);
QString str = std::isnan(rangeBreak.start) ? QString() : QString::number(rangeBreak.start);
QString str = std::isnan(rangeBreak.start) ? QString() : QLocale().toString(rangeBreak.start);
ui.leYBreakStart->setText(str);
str = std::isnan(rangeBreak.end) ? QString() : QString::number(rangeBreak.end);
str = std::isnan(rangeBreak.end) ? QString() : QLocale().toString(rangeBreak.end);
ui.leYBreakEnd->setText(str);
ui.sbYBreakPosition->setValue(rangeBreak.position*100);
ui.cbYBreakStyle->setCurrentIndex((int)rangeBreak.style);
......@@ -1399,13 +1399,13 @@ void CartesianPlotDock::plotRangeTypeChanged(CartesianPlot::RangeType type) {
void CartesianPlotDock::plotRangeFirstValuesChanged(int value) {
m_initializing = true;
ui.leRangeFirst->setText(QString::number(value));
ui.leRangeFirst->setText(QLocale().toString(value));
m_initializing = false;
}
void CartesianPlotDock::plotRangeLastValuesChanged(int value) {
m_initializing = true;
ui.leRangeLast->setText(QString::number(value));
ui.leRangeLast->setText(QLocale().toString(value));
m_initializing = false;
}
......@@ -1658,8 +1658,8 @@ void CartesianPlotDock::load() {
break;
}
rangeTypeChanged();
ui.leRangeFirst->setText( QString::number(m_plot->rangeFirstValues()) );
ui.leRangeLast->setText( QString::number(m_plot->rangeLastValues()) );
ui.leRangeFirst->setText( QLocale().toString(m_plot->rangeFirstValues()) );
ui.leRangeLast->setText( QLocale().toString(m_plot->rangeLastValues()) );
ui.chkAutoScaleX->setChecked(m_plot->autoScaleX());
ui.leXMin->setText(QLocale().toString(m_plot->xMin()));
......@@ -1687,7 +1687,7 @@ void CartesianPlotDock::load() {
//x-range breaks, show the first break
ui.chkXBreak->setChecked(m_plot->xRangeBreakingEnabled());
this->toggleXBreak(m_plot->xRangeBreakingEnabled());
ui.bRemoveXBreak->setVisible(m_plot->xRangeBreaks().list.size()>1);
ui.bRemoveXBreak->setVisible(m_plot->xRangeBreaks().list.size() > 1);
ui.cbXBreak->clear();
if (!m_plot->xRangeBreaks().list.isEmpty()) {
for (int i = 1; i <= m_plot->xRangeBreaks().list.size(); ++i)
......@@ -1699,7 +1699,7 @@ void CartesianPlotDock::load() {
//y-range breaks, show the first break
ui.chkYBreak->setChecked(m_plot->yRangeBreakingEnabled());
this->toggleYBreak(m_plot->yRangeBreakingEnabled());
ui.bRemoveYBreak->setVisible(m_plot->yRangeBreaks().list.size()>1);
ui.bRemoveYBreak->setVisible(m_plot->yRangeBreaks().list.size() > 1);
ui.cbYBreak->clear();
if (!m_plot->yRangeBreaks().list.isEmpty()) {
for (int i = 1; i <= m_plot->yRangeBreaks().list.size(); ++i)
......
......@@ -1206,7 +1206,7 @@ void XYFitCurveDock::showFitResult() {
for (int row = 0; row < uiGeneralTab.twLog->rowCount(); ++row)
uiGeneralTab.twLog->item(row, 1)->setText(QString());
const XYFitCurve::FitResult& fitResult = m_fitCurve->fitResult();
const auto& fitResult = m_fitCurve->fitResult();
if (!fitResult.available) {
DEBUG(" fit result not available");
......@@ -1223,19 +1223,19 @@ void XYFitCurveDock::showFitResult() {
// used confidence interval
double confidenceInterval = m_fitData.confidenceInterval;
uiGeneralTab.twParameters->horizontalHeaderItem(6)->setToolTip(i18n("%1\% lower confidence level", QString::number(confidenceInterval, 'g', 7)));
uiGeneralTab.twParameters->horizontalHeaderItem(7)->setToolTip(i18n("%1\% upper confidence level", QString::number(confidenceInterval, 'g', 7)));
uiGeneralTab.twParameters->horizontalHeaderItem(6)->setToolTip(i18n("%1\% lower confidence level", QLocale().toString(confidenceInterval, 'g', 7)));
uiGeneralTab.twParameters->horizontalHeaderItem(7)->setToolTip(i18n("%1\% upper confidence level", QLocale().toString(confidenceInterval, 'g', 7)));
// log
uiGeneralTab.twLog->item(1, 1)->setText(QString::number(fitResult.iterations));
uiGeneralTab.twLog->item(2, 1)->setText(QString::number(m_fitData.eps));
uiGeneralTab.twLog->item(1, 1)->setText(QLocale().toString(fitResult.iterations));
uiGeneralTab.twLog->item(2, 1)->setText(QLocale().toString(m_fitData.eps));
if (fitResult.elapsedTime > 1000)
uiGeneralTab.twLog->item(3, 1)->setText(QString::number(fitResult.elapsedTime/1000) + " s");
uiGeneralTab.twLog->item(3, 1)->setText(QLocale().toString(fitResult.elapsedTime/1000) + " s");
else
uiGeneralTab.twLog->item(3, 1)->setText(QString::number(fitResult.elapsedTime) + " ms");
uiGeneralTab.twLog->item(3, 1)->setText(QLocale().toString(fitResult.elapsedTime) + " ms");
uiGeneralTab.twLog->item(4, 1)->setText(QString::number(fitResult.dof));
uiGeneralTab.twLog->item(5, 1)->setText(QString::number(fitResult.paramValues.size()));
uiGeneralTab.twLog->item(4, 1)->setText(QLocale().toString(fitResult.dof));
uiGeneralTab.twLog->item(5, 1)->setText(QLocale().toString(fitResult.paramValues.size()));
uiGeneralTab.twLog->item(6, 1)->setText(m_fitData.fitRange.toString());
// show all iterations
......@@ -1262,14 +1262,14 @@ void XYFitCurveDock::showFitResult() {
auto* item = new QTableWidgetItem(m_fitData.paramNamesUtf8.at(i));
item->setBackground(QApplication::palette().color(QPalette::Window));
uiGeneralTab.twParameters->setItem(i, 0, item);
item = new QTableWidgetItem(QString::number(paramValue));
item = new QTableWidgetItem(QLocale().toString(paramValue));
uiGeneralTab.twParameters->setItem(i, 1, item);
if (!m_fitData.paramFixed.at(i)) {
if (!std::isnan(errorValue)) {
item = new QTableWidgetItem(QString::number(errorValue, 'g', 6));
item = new QTableWidgetItem(QLocale().toString(errorValue));
uiGeneralTab.twParameters->setItem(i, 2, item);
item = new QTableWidgetItem(QString::number(100.*errorValue/std::abs(paramValue), 'g', 3));
item = new QTableWidgetItem(QLocale().toString(100.*errorValue/std::abs(paramValue), 'g', 3));
uiGeneralTab.twParameters->setItem(i, 3, item);
} else {
item = new QTableWidgetItem(UTF8_QSTRING("∞"));
......@@ -1281,7 +1281,7 @@ void XYFitCurveDock::showFitResult() {
// t values
QString tdistValueString;
if (fitResult.tdist_tValues.at(i) < std::numeric_limits<double>::max())
tdistValueString = QString::number(fitResult.tdist_tValues.at(i), 'g', 3);
tdistValueString = QLocale().toString(fitResult.tdist_tValues.at(i), 'g', 3);
else
tdistValueString = UTF8_QSTRING("∞");
item = new QTableWidgetItem(tdistValueString);
......@@ -1289,7 +1289,7 @@ void XYFitCurveDock::showFitResult() {
// p values
const double p = fitResult.tdist_pValues.at(i);
item = new QTableWidgetItem(QString::number(p, 'g', 3));
item = new QTableWidgetItem(QLocale().toString(p, 'g', 3));
// color p values depending on value
if (p > 0.05)
item->setForeground(QBrush(QApplication::palette().color(QPalette::LinkVisited)));
......@@ -1309,33 +1309,33 @@ void XYFitCurveDock::showFitResult() {
//TODO: if (fitResult.tdist_tValues.at(i) > 1.e6)
// item = new QTableWidgetItem(i18n("too small"));
item = new QTableWidgetItem(QString::number(paramValue - margin));
item = new QTableWidgetItem(QLocale().toString(paramValue - margin));
uiGeneralTab.twParameters->setItem(i, 6, item);
item = new QTableWidgetItem(QString::number(paramValue + margin));
item = new QTableWidgetItem(QLocale().toString(paramValue + margin));
uiGeneralTab.twParameters->setItem(i, 7, item);
}
}
}
// Goodness of fit
uiGeneralTab.twGoodness->item(0, 1)->setText(QString::number(fitResult.sse));
uiGeneralTab.twGoodness->item(0, 1)->setText(QLocale().toString(fitResult.sse));
if (fitResult.dof != 0) {
uiGeneralTab.twGoodness->item(1, 1)->setText(QString::number(fitResult.rms));
uiGeneralTab.twGoodness->item(2, 1)->setText(QString::number(fitResult.rsd));
uiGeneralTab.twGoodness->item(1, 1)->setText(QLocale().toString(fitResult.rms));
uiGeneralTab.twGoodness->item(2, 1)->setText(QLocale().toString(fitResult.rsd));
uiGeneralTab.twGoodness->item(3, 1)->setText(QString::number(fitResult.rsquare, 'g'));
uiGeneralTab.twGoodness->item(4, 1)->setText(QString::number(fitResult.rsquareAdj, 'g'));
uiGeneralTab.twGoodness->item(3, 1)->setText(QLocale().toString(fitResult.rsquare));
uiGeneralTab.twGoodness->item(4, 1)->setText(QLocale().toString(fitResult.rsquareAdj));
// chi^2 and F test p-values
uiGeneralTab.twGoodness->item(5, 1)->setText(QString::number(fitResult.chisq_p, 'g', 3));
uiGeneralTab.twGoodness->item(6, 1)->setText(QString::number(fitResult.fdist_F, 'g', 3));
uiGeneralTab.twGoodness->item(7, 1)->setText(QString::number(fitResult.fdist_p, 'g', 3));
uiGeneralTab.twGoodness->item(9, 1)->setText(QString::number(fitResult.aic, 'g', 3));
uiGeneralTab.twGoodness->item(10, 1)->setText(QString::number(fitResult.bic, 'g', 3));
uiGeneralTab.twGoodness->item(5, 1)->setText(QLocale().toString(fitResult.chisq_p, 'g', 3));
uiGeneralTab.twGoodness->item(6, 1)->setText(QLocale().toString(fitResult.fdist_F, 'g', 3));
uiGeneralTab.twGoodness->item(7, 1)->setText(QLocale().toString(fitResult.fdist_p, 'g', 3));
uiGeneralTab.twGoodness->item(9, 1)->setText(QLocale().toString(fitResult.aic, 'g', 3));
uiGeneralTab.twGoodness->item(10, 1)->setText(QLocale().toString(fitResult.bic, 'g', 3));
}
uiGeneralTab.twGoodness->item(8, 1)->setText(QString::number(fitResult.mae));
uiGeneralTab.twGoodness->item(8, 1)->setText(QLocale().toString(fitResult.mae));
//resize the table headers to fit the new content
uiGeneralTab.twLog->resizeColumnsToContents();
......
......@@ -142,8 +142,8 @@ void FitOptionsWidget::autoRangeChanged() {
m_fitData->fitRange.setRange(xMin, xMax);
if (!m_dateTimeRange) {
ui.leMin->setText(QString::number(xMin));
ui.leMax->setText(QString::number(xMax));
ui.leMin->setText(QLocale().toString(xMin));
ui.leMax->setText(QLocale().toString(xMax));
} else {
ui.dateTimeEditMin->setDateTime(QDateTime::fromMSecsSinceEpoch(xMin));
ui.dateTimeEditMax->setDateTime(QDateTime::fromMSecsSinceEpoch(xMax));
......@@ -189,17 +189,11 @@ void FitOptionsWidget::autoEvalRangeChanged() {
}
void FitOptionsWidget::fitRangeMinChanged() {
//TODO
const double xMin = ui.leMin->text().toDouble();
m_fitData->fitRange.setMin(xMin);
SET_DOUBLE_FROM_LE(m_fitData->fitRange.min(), ui.leMin);
changed();
}
void FitOptionsWidget::fitRangeMaxChanged() {
//TODO
const double xMax = ui.leMax->text().toDouble();
m_fitData->fitRange.setMax(xMax);
SET_DOUBLE_FROM_LE(m_fitData->fitRange.max(), ui.leMax);
changed();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment