[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Jan 27 01:03:12 CET 2010
SVN commit 1080809 by netterfield:
CCBUG: 221749
optionally scale fonts when adding plots to pages.
M +5 -1 libkstapp/commandlineparser.cpp
M +3 -0 libkstapp/csddialog.cpp
M +3 -0 libkstapp/curvedialog.cpp
M +6 -13 libkstapp/datawizard.cpp
M +3 -0 libkstapp/equationdialog.cpp
M +3 -0 libkstapp/histogramdialog.cpp
M +3 -0 libkstapp/imagedialog.cpp
M +0 -1 libkstapp/labelrenderer.cpp
M +1 -1 libkstapp/labelrenderer.h
M +3 -0 libkstapp/powerspectrumdialog.cpp
M +23 -0 libkstapp/view.cpp
M +2 -0 libkstapp/view.h
M +25 -5 libkstmath/psd.cpp
M +3 -0 widgets/curveplacement.cpp
M +2 -0 widgets/curveplacement.h
M +11 -1 widgets/curveplacement.ui
M +0 -3 widgets/labelbuilder.ui
--- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.cpp #1080808:1080809
@@ -129,7 +129,8 @@
_doAve(false), _doSkip(false), _doConsecutivePlots(true), _useBargraph(false),
_useLines(true), _usePoints(false), _overrideStyle(false), _sampleRate(1.0),
_numFrames(-1), _startFrame(-1),
- _skip(0), _plotName(), _errorField(), _fileName(), _xField(QString("INDEX")), _pngFile(QString()){
+ _skip(0), _plotName(), _errorField(), _fileName(), _xField(QString("INDEX")),
+ _pngFile(QString()), _plotItem(0) {
Q_ASSERT(QCoreApplication::instance());
_arguments = QCoreApplication::instance()->arguments();
@@ -554,6 +555,9 @@
_fileNames.append(arg);
}
}
+ if (_plotItem) {
+ _plotItem->parentView()->resetPlotFontSizes();
+ }
UpdateManager::self()->doUpdates(true);
return (dataPlotted);
}
--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.cpp #1080808:1080809
@@ -248,6 +248,9 @@
cmd->createItem();
plotItem = static_cast<PlotItem*>(cmd->item());
+ if (_CSDTab->curvePlacement()->scaleFonts()) {
+ plotItem->parentView()->resetPlotFontSizes();
+ }
break;
}
default:
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.cpp #1080808:1080809
@@ -416,6 +416,9 @@
cmd->createItem();
plotItem = static_cast<PlotItem*>(cmd->item());
+ if (_curveTab->curvePlacement()->scaleFonts()) {
+ plotItem->parentView()->resetPlotFontSizes();
+ }
break;
}
default:
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1080808:1080809
@@ -944,20 +944,13 @@
double fontScale;
if (plotsInPage==0) {
- plotsInPage = plotList.count();
- if (separate_plots) {
- plotsInPage/=2;
+ int np = plotList.count();
+ if (np > 0) {
+ plotList.at(0)->parentView()->resetPlotFontSizes(); // set font sizes on first page.
+ if (plotList.at(np-1)->parentView() != plotList.at(0)->parentView()) { // and second, if there is one.
+ plotList.at(np-1)->parentView()->resetPlotFontSizes();
+ }
}
- if (plotsInPage==0) plotsInPage = 1;
- fontScale = _dialogDefaults->value("plot/globalFontScale",16.0).toDouble()/sqrt((double)plotsInPage);
- foreach (PlotItem* plot, plotList) {
- plot->setGlobalFontScale(fontScale);
- plot->leftLabelDetails()->setFontScale(fontScale);
- plot->rightLabelDetails()->setFontScale(fontScale);
- plot->topLabelDetails()->setFontScale(fontScale);
- plot->bottomLabelDetails()->setFontScale(fontScale);
- plot->numberLabelDetails()->setFontScale(fontScale);
- }
} else {
foreach (PlotItem* plot, plotList) {
_document->currentView()->configurePlotFontDefaults(plot); // copy plots already in window
--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.cpp #1080808:1080809
@@ -334,6 +334,9 @@
cmd->createItem();
plotItem = static_cast<PlotItem*>(cmd->item());
+ if (_equationTab->curvePlacement()->scaleFonts()) {
+ plotItem->parentView()->resetPlotFontSizes();
+ }
break;
}
default:
--- branches/work/kst/portto4/kst/src/libkstapp/histogramdialog.cpp #1080808:1080809
@@ -400,6 +400,9 @@
cmd->createItem();
plotItem = static_cast<PlotItem*>(cmd->item());
+ if (_histogramTab->curvePlacement()->scaleFonts()) {
+ plotItem->parentView()->resetPlotFontSizes();
+ }
break;
}
default:
--- branches/work/kst/portto4/kst/src/libkstapp/imagedialog.cpp #1080808:1080809
@@ -472,6 +472,9 @@
cmd->createItem();
plotItem = static_cast<PlotItem*>(cmd->item());
+ if (_imageTab->curvePlacement()->scaleFonts()) {
+ plotItem->parentView()->resetPlotFontSizes();
+ }
break;
}
default:
--- branches/work/kst/portto4/kst/src/libkstapp/labelrenderer.cpp #1080808:1080809
@@ -59,7 +59,6 @@
rc.size = Kst::ApplicationSettings::self()->minimumFontSize();
}
}
-
QFont f = rc.font();
if (rc.fontSize() != rc.size) {
f.setPointSizeF(rc.size);
--- branches/work/kst/portto4/kst/src/libkstapp/labelrenderer.h #1080808:1080809
@@ -72,7 +72,7 @@
inline void setFont(const QFont& f_in) {
QFont f = f_in;
- _fontSize = f.pixelSize();
+ _fontSize = f.pointSize();
if (p) {
p->setFont(f);
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #1080808:1080809
@@ -256,6 +256,9 @@
cmd->createItem();
plotItem = static_cast<PlotItem*>(cmd->item());
+ if (_powerSpectrumTab->curvePlacement()->scaleFonts()) {
+ plotItem->parentView()->resetPlotFontSizes();
+ }
break;
}
default:
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #1080808:1080809
@@ -546,7 +546,30 @@
return font;
}
+// 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(double pointSize) {
+ if (pointSize < 0.1) {
+ pointSize = _dialogDefaults->value("plot/globalFontScale",16.0).toDouble();
+ }
+ double count = PlotItemManager::self()->plotsForView(this).count();
+ double newPointSize = pointSize/sqrt(count) + ApplicationSettings::self()->minimumFontSize();
+ if (newPointSize<pointSize) {
+ pointSize = newPointSize;
+ }
+ foreach(PlotItem* plotItem, PlotItemManager::self()->plotsForView(this)) {
+ plotItem->setGlobalFontScale(pointSize);
+ plotItem->rightLabelDetails()->setFontScale(pointSize);
+ plotItem->leftLabelDetails()->setFontScale(pointSize);
+ plotItem->bottomLabelDetails()->setFontScale(pointSize);
+ plotItem->topLabelDetails()->setFontScale(pointSize);
+ plotItem->numberLabelDetails()->setFontScale(pointSize);
+ }
+}
+
+// copy the font settings of the first plotItem in the view into
+// plot, then break.
void View::configurePlotFontDefaults(PlotItem *plot) {
if (plot) {
bool configured = false;
--- branches/work/kst/portto4/kst/src/libkstapp/view.h #1080808:1080809
@@ -102,6 +102,8 @@
void configurePlotFontDefaults(PlotItem *plot);
+ void resetPlotFontSizes(double pointSize = 0);
+
void setFontRescale(double rescale) {_fontRescale = rescale;}
double fontRescale() const {return _fontRescale;}
--- branches/work/kst/portto4/kst/src/libkstmath/psd.cpp #1080808:1080809
@@ -407,19 +407,39 @@
switch (_Output) {
default:
case 0: // amplitude spectral density (default) [V/Hz^1/2]
- _sVector->setLabel(i18n("ASD \\[%1/%2^{1/2} \\]", _vectorUnits, _rateUnits));
+ if (_vectorUnits.isEmpty() || _rateUnits.isEmpty()) {
+ _sVector->setLabel(i18n("Spectral Density"));
+ } else {
+ _sVector->setLabel(i18n("Spectral Density \\[%1/%2^{1/2} \\]", _vectorUnits, _rateUnits));
+ }
break;
case 1: // power spectral density [V^2/Hz]
- _sVector->setLabel(i18n("PSD \\[%1^2/%2\\]", _vectorUnits, _rateUnits));
+ if (_vectorUnits.isEmpty() || _rateUnits.isEmpty()) {
+ _sVector->setLabel(i18n("PSD"));
+ } else {
+ _sVector->setLabel(i18n("PSD \\[%1^2/%2\\]", _vectorUnits, _rateUnits));
+ }
break;
case 2: // amplitude spectrum [V]
- _sVector->setLabel(i18n("Amplitude Spectrum\\[%1\\]", _vectorUnits));
+ if (_vectorUnits.isEmpty() || _rateUnits.isEmpty()) {
+ _sVector->setLabel(i18n("Amplitude Spectrum"));
+ } else {
+ _sVector->setLabel(i18n("Amplitude Spectrum\\[%1\\]", _vectorUnits));
+ }
break;
case 3: // power spectrum [V^2]
- _sVector->setLabel(i18n("Power Spectrum \\[%1^2\\]", _vectorUnits));
+ if (_vectorUnits.isEmpty() || _rateUnits.isEmpty()) {
+ _sVector->setLabel(i18n("Power Spectrum"));
+ } else {
+ _sVector->setLabel(i18n("Power Spectrum \\[%1^2\\]", _vectorUnits));
+ }
break;
}
- _fVector->setLabel(i18n("Frequency \\[%1\\]", _rateUnits));
+ if (_rateUnits.isEmpty()) {
+ _fVector->setLabel(i18n("Frequency"));
+ } else {
+ _fVector->setLabel(i18n("Frequency \\[%1\\]", _rateUnits));
+ }
}
QString PSD::_automaticDescriptiveName() const {
--- branches/work/kst/portto4/kst/src/widgets/curveplacement.cpp #1080808:1080809
@@ -71,6 +71,9 @@
}
}
+bool CurvePlacement::scaleFonts() const {
+ return _scaleFonts->isChecked();
+}
CurvePlacement::Layout CurvePlacement::layout() const {
if (_autoLayout->isChecked())
--- branches/work/kst/portto4/kst/src/widgets/curveplacement.h #1080808:1080809
@@ -32,6 +32,8 @@
Place place() const;
void setPlace(Place place);
+ bool scaleFonts() const;
+
PlotItemInterface *existingPlot() const;
void setExistingPlots(const QList<PlotItemInterface*> &existingPlots);
--- branches/work/kst/portto4/kst/src/widgets/curveplacement.ui #1080808:1080809
@@ -62,7 +62,7 @@
</property>
</widget>
</item>
- <item row="1" column="2">
+ <item row="1" column="2" colspan="2">
<widget class="QComboBox" name="_plotList">
<property name="enabled">
<bool>false</bool>
@@ -185,6 +185,16 @@
</property>
</widget>
</item>
+ <item row="2" column="3">
+ <widget class="QCheckBox" name="_scaleFonts">
+ <property name="text">
+ <string>Scale fonts</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
--- branches/work/kst/portto4/kst/src/widgets/labelbuilder.ui #1080808:1080809
@@ -16,9 +16,6 @@
<height>16777215</height>
</size>
</property>
- <property name="whatsThis">
- <string>Select a string to utilize. If you wish to create a new string, select the icon to the right.</string>
- </property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
More information about the Kst
mailing list