SVN commit 1325235 by netterfield: BUG: Fix regression in which re-scaling font sizes when adding plots didn't work. M +2 -1 csddialog.cpp M +2 -1 curvedialog.cpp M +11 -7 datawizard.cpp M +2 -1 equationdialog.cpp M +2 -1 filterfitdialog.cpp M +2 -1 histogramdialog.cpp M +2 -1 imagedialog.cpp M +2 -1 powerspectrumdialog.cpp M +6 -6 view.cpp M +1 -1 view.h --- branches/work/kst/portto4/kst/src/libkstapp/csddialog.cpp #1325234:1325235 @@ -259,7 +259,8 @@ plotItem = static_cast(cmd->item()); if (_CSDTab->curvePlacement()->scaleFonts()) { - plotItem->view()->resetPlotFontSizes(); + plotItem->view()->resetPlotFontSizes(1); + plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window } break; } --- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.cpp #1325234:1325235 @@ -452,7 +452,8 @@ plotItem = static_cast(cmd->item()); if (_curveTab->curvePlacement()->scaleFonts()) { - plotItem->view()->resetPlotFontSizes(); + plotItem->view()->resetPlotFontSizes(1); + plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window } break; } --- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1325234:1325235 @@ -1188,17 +1188,21 @@ if (relayout) { if (plotsInPage==0 || _pagePlot->rescaleFonts()) { int np = plotList.count(); - if (np > 0) { - plotList.at(0)->view()->resetPlotFontSizes(); // set font sizes on first page. - if (plotList.at(np-1)->view() != plotList.at(0)->view()) { // and second, if there is one. - plotList.at(np-1)->view()->resetPlotFontSizes(); + int n_add = np; + bool two_pages = (plotList.at(np-1)->view() != plotList.at(0)->view()); + if (two_pages) { + n_add/=2; } + if (np > 0) { // don't crash if there are no plots + plotList.at(0)->view()->resetPlotFontSizes(n_add); // set font sizes on first page. + if (two_pages) { // and second, if there is one. + plotList.at(np-1)->view()->resetPlotFontSizes(n_add); } - } else { + } + } foreach (PlotItem* plot, plotList) { - _document->currentView()->configurePlotFontDefaults(plot); // copy plots already in window + plot->view()->configurePlotFontDefaults(plot); // copy plots already in window } - } CurvePlacement::Layout layout_type = _pagePlot->layout(); int num_columns = _pagePlot->gridColumns(); --- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.cpp #1325234:1325235 @@ -361,7 +361,8 @@ plotItem = static_cast(cmd->item()); if (_equationTab->curvePlacement()->scaleFonts()) { - plotItem->view()->resetPlotFontSizes(); + plotItem->view()->resetPlotFontSizes(1); + plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window } break; } --- branches/work/kst/portto4/kst/src/libkstapp/filterfitdialog.cpp #1325234:1325235 @@ -236,7 +236,8 @@ plotItem = static_cast(cmd->item()); if (_filterFitTab->curvePlacement()->scaleFonts()) { - plotItem->view()->resetPlotFontSizes(); + plotItem->view()->resetPlotFontSizes(1); + plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window } plotItem->view()->appendToLayout(_filterFitTab->curvePlacement()->layout(), plotItem, _filterFitTab->curvePlacement()->gridColumns()); --- branches/work/kst/portto4/kst/src/libkstapp/histogramdialog.cpp #1325234:1325235 @@ -424,7 +424,8 @@ plotItem = static_cast(cmd->item()); if (_histogramTab->curvePlacement()->scaleFonts()) { - plotItem->view()->resetPlotFontSizes(); + plotItem->view()->resetPlotFontSizes(1); + plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window } break; } --- branches/work/kst/portto4/kst/src/libkstapp/imagedialog.cpp #1325234:1325235 @@ -492,7 +492,8 @@ plotItem = static_cast(cmd->item()); if (_imageTab->curvePlacement()->scaleFonts()) { - plotItem->view()->resetPlotFontSizes(); + plotItem->view()->resetPlotFontSizes(1); + plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window } break; } --- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #1325234:1325235 @@ -273,7 +273,8 @@ plotItem = static_cast(cmd->item()); if (_powerSpectrumTab->curvePlacement()->scaleFonts()) { - plotItem->view()->resetPlotFontSizes(); + plotItem->view()->resetPlotFontSizes(1); + plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window } break; } --- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #1325234:1325235 @@ -603,17 +603,16 @@ // Set the font sizes of all plots in the view to a default size, scaled // by the default global font scale, and the application minimum font scale. -void View::resetPlotFontSizes(qreal pointSize) { - if (pointSize < 0.1) { - pointSize = _dialogDefaults->value("plot/globalFontScale",16.0).toDouble(); - } - qreal count = PlotItemManager::self()->plotsForView(this).count(); +double View::resetPlotFontSizes(int num_adding) { + qreal pointSize = _dialogDefaults->value("plot/globalFontScale",16.0).toDouble(); + + qreal count = PlotItemManager::self()->plotsForView(this).count() + num_adding; qreal newPointSize = pointSize/sqrt(count) + ApplicationSettings::self()->minimumFontSize(); if (newPointSizeminimumFontSize()); - + qDebug() << "reset plot font size to" << pointSize << " for " << PlotItemManager::self()->plotsForView(this).size(); foreach(PlotItem* plotItem, PlotItemManager::self()->plotsForView(this)) { plotItem->setGlobalFontScale(pointSize); plotItem->rightLabelDetails()->setFontScale(pointSize); @@ -625,6 +624,7 @@ plotItem->legend()->setFontScale(legendPointSize); } } + return pointSize; } // copy the font settings of the first plotItem in the view into --- branches/work/kst/portto4/kst/src/libkstapp/view.h #1325234:1325235 @@ -111,7 +111,7 @@ void configurePlotFontDefaults(PlotItem *plot); - void resetPlotFontSizes(qreal pointSize = 0); + double resetPlotFontSizes(int num_adding=0); void setFontRescale(qreal rescale) {_fontRescale = rescale;} qreal fontRescale() const {return _fontRescale;}