[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Jun 26 17:05:27 UTC 2013
SVN commit 1358364 by netterfield:
Un-break font size rescaling when adding plots to views.
M +1 -0 cmake/src/datasources/CMakeLists.txt
M +1 -1 src/libkstapp/csddialog.cpp
M +1 -1 src/libkstapp/curvedialog.cpp
M +2 -2 src/libkstapp/datawizard.cpp
M +1 -1 src/libkstapp/equationdialog.cpp
M +1 -1 src/libkstapp/filterfitdialog.cpp
M +1 -1 src/libkstapp/histogramdialog.cpp
M +1 -1 src/libkstapp/imagedialog.cpp
M +1 -1 src/libkstapp/powerspectrumdialog.cpp
M +16 -4 src/libkstapp/view.cpp
M +3 -1 src/libkstapp/view.h
--- branches/work/kst/portto4/kst/cmake/src/datasources/CMakeLists.txt #1358363:1358364
@@ -24,6 +24,7 @@
if(cfitsio)
include_directories(${CFITSIO_INCLUDE_DIR})
kst_add_plugin(. fitsimage)
+ #kst_add_plugin(. healpix)
kst_link(${CFITSIO_LIBRARIES})
endif()
--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.cpp #1358363:1358364
@@ -259,7 +259,7 @@
plotItem = static_cast<PlotItem*>(cmd->item());
if (_CSDTab->curvePlacement()->scaleFonts()) {
- plotItem->view()->resetPlotFontSizes(1);
+ plotItem->view()->resetPlotFontSizes(plotItem);
plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window
}
break;
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.cpp #1358363:1358364
@@ -454,7 +454,7 @@
plotItem = static_cast<PlotItem*>(cmd->item());
if (_curveTab->curvePlacement()->scaleFonts()) {
- plotItem->view()->resetPlotFontSizes(1);
+ plotItem->view()->resetPlotFontSizes(plotItem);
plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window
}
break;
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1358363:1358364
@@ -1198,9 +1198,9 @@
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.
+ plotList.at(0)->view()->resetPlotFontSizes(plotList.mid(0, 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);
+ plotList.at(np-1)->view()->resetPlotFontSizes(plotList.mid(n_add, n_add));
}
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.cpp #1358363:1358364
@@ -362,7 +362,7 @@
plotItem = static_cast<PlotItem*>(cmd->item());
if (_equationTab->curvePlacement()->scaleFonts()) {
- plotItem->view()->resetPlotFontSizes(1);
+ plotItem->view()->resetPlotFontSizes(plotItem);
plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window
}
break;
--- branches/work/kst/portto4/kst/src/libkstapp/filterfitdialog.cpp #1358363:1358364
@@ -236,7 +236,7 @@
plotItem = static_cast<PlotItem*>(cmd->item());
if (_filterFitTab->curvePlacement()->scaleFonts()) {
- plotItem->view()->resetPlotFontSizes(1);
+ plotItem->view()->resetPlotFontSizes(plotItem);
plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window
}
plotItem->view()->appendToLayout(_filterFitTab->curvePlacement()->layout(), plotItem,
--- branches/work/kst/portto4/kst/src/libkstapp/histogramdialog.cpp #1358363:1358364
@@ -425,7 +425,7 @@
plotItem = static_cast<PlotItem*>(cmd->item());
if (_histogramTab->curvePlacement()->scaleFonts()) {
- plotItem->view()->resetPlotFontSizes(1);
+ plotItem->view()->resetPlotFontSizes(plotItem);
plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window
}
break;
--- branches/work/kst/portto4/kst/src/libkstapp/imagedialog.cpp #1358363:1358364
@@ -492,7 +492,7 @@
plotItem = static_cast<PlotItem*>(cmd->item());
if (_imageTab->curvePlacement()->scaleFonts()) {
- plotItem->view()->resetPlotFontSizes(1);
+ plotItem->view()->resetPlotFontSizes(plotItem);
plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window
}
break;
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #1358363:1358364
@@ -274,7 +274,7 @@
plotItem = static_cast<PlotItem*>(cmd->item());
if (_powerSpectrumTab->curvePlacement()->scaleFonts()) {
- plotItem->view()->resetPlotFontSizes(1);
+ plotItem->view()->resetPlotFontSizes(plotItem);
plotItem->view()->configurePlotFontDefaults(plotItem); // copy plots already in window
}
break;
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #1358363:1358364
@@ -614,16 +614,28 @@
// 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.
-double View::resetPlotFontSizes(int num_adding) {
+double View::resetPlotFontSizes(PlotItem* plot) {
+ QList<PlotItem*> plots;
+ plots.append(plot);
+ return resetPlotFontSizes(plots);
+}
+
+double View::resetPlotFontSizes(QList<PlotItem*> new_plots) {
+ QList<PlotItem*> plots(new_plots);
+ plots.append(PlotItemManager::self()->plotsForView(this));
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();
+ // the 6 in the line below is a magic number that impedes scaling until you
+ // have more than a couple of rows/columns. A 1 would make it scale more
+ // agressively. The behavior looks pretty good to me with 6.
+ qreal count = qMax(plots.count()-6, 1);
+
+ qreal newPointSize = qMax(pointSize/sqrt(count) , ApplicationSettings::self()->minimumFontSize());
if (newPointSize<pointSize) {
pointSize = newPointSize;
}
qreal legendPointSize = qMax(pointSize*qreal(0.6), ApplicationSettings::self()->minimumFontSize());
- foreach(PlotItem* plotItem, PlotItemManager::self()->plotsForView(this)) {
+ foreach(PlotItem* plotItem, plots) {
plotItem->setGlobalFontScale(pointSize);
plotItem->rightLabelDetails()->setFontScale(pointSize);
plotItem->leftLabelDetails()->setFontScale(pointSize);
--- branches/work/kst/portto4/kst/src/libkstapp/view.h #1358363:1358364
@@ -111,8 +111,10 @@
void configurePlotFontDefaults(PlotItem *plot);
- double resetPlotFontSizes(int num_adding=0);
+ double resetPlotFontSizes(PlotItem* plot);
+ double resetPlotFontSizes(QList<PlotItem*> new_plots = QList<PlotItem*>());
+
void setFontRescale(qreal rescale) {_fontRescale = rescale;}
qreal fontRescale() const {return _fontRescale;}
More information about the Kst
mailing list