[Kst] extragear/graphics/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Sat Oct 21 06:54:29 CEST 2006
SVN commit 597630 by netterfield:
Several (subtle) UI enhancements:
-New Curve dialog makes better guesses for the X axis
(use the X vector for the last curve in the curve list)
-Data wizard makes better guesses about whether you want to use
an existing vector as the X vector...
-When the data wizard makes plots in a new window, use a larger font
based on the number of plots
-Fix a connect in the legend dialog
M +5 -5 libkst/kstmatrix.cpp
M +1 -0 libkstapp/datawizard.ui
M +54 -11 libkstapp/datawizard.ui.h
M +14 -0 libkstapp/kst2dplot.cpp
M +3 -2 libkstapp/kst2dplot.h
M +6 -0 libkstapp/kstcurvedialog_i.cpp
M +11 -10 libkstapp/kstviewlegend.cpp
M +2 -2 libkstapp/view2dplotwidget.ui.h
--- trunk/extragear/graphics/kst/src/libkst/kstmatrix.cpp #597629:597630
@@ -173,7 +173,7 @@
int n_list;
int max_n = 50000; // the most samples we will look at...
double n_skip;
- double x;
+ double x=0;
int n_notnan;
int i,j, k;
@@ -193,12 +193,12 @@
}
per *= (double)n_notnan/(double)_NS;
- max_n *= (double)_NS/(double)n_notnan;
+ max_n *= int((double)_NS/(double)n_notnan);
n_skip = (double)_NS/max_n;
if (n_skip<1.0) n_skip = 1.0;
- n_list = _NS*per/n_skip;
+ n_list = int(double(_NS)*per/n_skip);
min_list = (double *)malloc(n_list * sizeof(double));
max_list = (double *)malloc(n_list * sizeof(double));
@@ -206,7 +206,7 @@
// prefill the list
for (i=0; i<n_list; i++) {
- j = i*n_skip;
+ j = int(i*n_skip);
min_list[i] = 1E+300;
max_list[i] = -1E+300;
}
@@ -214,7 +214,7 @@
max_of_min = 1E+300;
i = n_list;
- for (j=0; j<_NS; j=i*n_skip, i++) {
+ for (j=0; j<_NS; j=int(i*n_skip), i++) {
if (_z[j] < max_of_min) { // member for the min list
// replace max of min with the new value
for (k=0; k<n_list; k++) {
--- trunk/extragear/graphics/kst/src/libkstapp/datawizard.ui #597629:597630
@@ -1602,6 +1602,7 @@
<functions>
<function returnType="bool">xVectorOk()</function>
<function returnType="bool">yVectorsOk()</function>
+ <function returnType="double">getFontSize(int count)</function>
<function>showPage( QWidget * page )</function>
<function>saveSettings()</function>
<function>loadSettings()</function>
--- trunk/extragear/graphics/kst/src/libkstapp/datawizard.ui.h #597629:597630
@@ -229,8 +229,12 @@
_xVector->setCurrentText(defaultX);
} else {
_xVector->setCurrentItem(0);
- }
+ }
_file = file;
+ // we probably don't want to use an
+ //existing vector since the data source just changed...
+ _xAxisCreateFromField->setChecked(true);
+
} else {
_fileType->setText(QString::null);
setNextEnabled(_pageDataSource, false);
@@ -282,11 +286,10 @@
QString save = _filterList->currentText();
_filterList->clear();
} else if (page == _pagePlot) {
- QString vectorName = _xAxisCreateFromField->isChecked() ?
- _xVector->currentText() : _xVectorExisting->selectedVector();
- KST::vectorDefaults.setWizardXVector(_xVector->currentText());
- KST::vectorDefaults.sync();
-
+ if (_xAxisCreateFromField->isChecked()) {
+ KST::vectorDefaults.setWizardXVector(_xVector->currentText());
+ KST::vectorDefaults.sync();
+ }
// count the vectors we are about to make, so we can guess defaults
int n_curves = _vectorsToPlot->childCount();
@@ -468,9 +471,8 @@
uint n_steps = 0;
int ptype = 0;
int prg = 0;
-
- saveSettings();
-
+ int fontSize;
+
KstDataSourcePtr ds = *KST::dataSourceList.findReusableFileName(_file);
if (!ds) {
for (KstDataSourceList::Iterator i = _sourceCache.begin(); i != _sourceCache.end(); ++i) {
@@ -612,6 +614,11 @@
xv = *(KST::vectorList.findTag(_xVectorExisting->selectedVector()));
app->slotUpdateProgress(n_steps, prg, i18n("Creating vectors..."));
}
+ // Next time we use the wizard this session, we probably will want to use the
+ // same X vector, so... lets set that as the default.
+ _xAxisUseExisting->setChecked(true);
+ _xVectorExisting->update();
+ _xVectorExisting->setSelection(xv->tagName());
// create the y-vectors
{
@@ -665,6 +672,8 @@
return;
}
+ fontSize = getFontSize(l.count());
+
// create the necessary plots
app->slotUpdateProgress(n_steps, prg, i18n("Creating plots..."));
KstViewObjectList plots;
@@ -699,7 +708,7 @@
for (uint i = 0; i < l.count(); ++i) {
p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createObject<Kst2DPlot>(KST::suggestPlotName(), false)));
plots.append(p.data());
- p->setXAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
+ p->setXAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
p->setYAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
}
}
@@ -728,7 +737,7 @@
for (int i = 0; i < _plotNumber->value(); ++i) {
p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createObject<Kst2DPlot>(KST::suggestPlotName(), false)));
plots.append(p.data());
- p->setXAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
+ p->setXAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
p->setYAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
}
}
@@ -903,6 +912,7 @@
continue;
}
pp->generateDefaultLabels(xl, yl, tl);
+
if (_legendsOn->isChecked()) {
pp->getOrCreateLegend();
} else if (_legendsAuto->isChecked()) {
@@ -910,6 +920,8 @@
pp->getOrCreateLegend();
}
}
+ pp->setPlotLabelFontSizes(fontSize);
+
++pit;
}
@@ -929,6 +941,9 @@
if (!wasPaused) {
app->setPaused(false);
}
+
+ saveSettings();
+
}
@@ -1310,4 +1325,32 @@
updateVectorPageButtons();
}
+double DataWizard::getFontSize(int count) {
+ double size;
+ double rows, cols;
+
+ if (_cycleThrough->isChecked()) {
+ count = _plotNumber->value();
+ } else if (!_multiplePlots->isChecked()) {
+ count = 1;
+ }
+
+ size = (double)KstSettings::globalSettings()->plotFontSize;
+
+ if (_reGrid->isChecked()) {
+ cols = _plotColumns->value();
+ } else {
+ cols = floor(sqrt(double(count)));
+ }
+ rows = cols + int(count - cols * cols) / int(cols);
+
+ size *= (rows + cols)/(cols/rows + rows/cols);
+ size -= (double)KstSettings::globalSettings()->plotFontSize;
+ size *=0.7;
+
+ if (size>22) size = 22;
+
+ return size;
+}
+
// vim: ts=8 sw=4 noet
--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #597629:597630
@@ -6912,6 +6912,20 @@
return f;
}
+/** adjust the font size of all plot labels at once */
+void Kst2DPlot::setPlotLabelFontSizes(int size){
+ xLabel()->setFontSize(size);
+ yLabel()->setFontSize(size);
+ topLabel()->setFontSize(size);
+ xTickLabel()->setFontSize(size);
+ fullTickLabel()->setFontSize(size);
+ yTickLabel()->setFontSize(size);
+ if (KstViewLegendPtr vl = legend()) {
+ vl->setFontSize(size);
+ }
+}
+
+
/****************************
* 2dplot edit dialog stuff */
--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.h #597629:597630
@@ -188,8 +188,9 @@
KstPlotLabel *xTickLabel() const;
KstPlotLabel *yTickLabel() const;
KstPlotLabel *fullTickLabel() const;
+ void setPlotLabelFontSizes(int size);
+
-
QRect GetPlotRegion() const;
QRect GetWinRegion() const;
QRect GetTieBoxRegion() const;
@@ -564,7 +565,7 @@
QRect PlotAndAxisRegion;
void updateScale();
- void adjustFontSize();
+ //void adjustFontSize();
KstMouse _mouse;
QMap<int, QString> _curveEditMap, _curveFitMap, _curveRemoveMap, _objectEditMap;
--- trunk/extragear/graphics/kst/src/libkstapp/kstcurvedialog_i.cpp #597629:597630
@@ -176,6 +176,12 @@
_legendText->setText(defaultTag);
_w->_curvePlacement->update();
+ // set the X Axis Vector to the X axis vector of
+ // the last curve on the global curve list...
+ if (curves.count() >0) {
+ _w->_xVector->setSelection(curves.last()->xVTag());
+ }
+
// for some reason the lower widget needs to be shown first to prevent overlapping?
_w->_curveAppearance->hide();
_w->_curvePlacement->show();
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #597629:597630
@@ -643,6 +643,16 @@
legends = globalLegendList();
}
+ // apply the curve list, but only to this legend!
+ KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
+ _curves.clear();
+ for (unsigned i = 0; i < widget->DisplayedCurveList->count(); i++) {
+ KstBaseCurveList::Iterator it = allCurves.findTag(widget->DisplayedCurveList->text(i));
+ if (it != allCurves.end()) {
+ _curves.append(*it);
+ }
+ }
+
for (uint i = 0; i < legends.size(); i++) {
legendExtra = legends[i];
@@ -658,15 +668,6 @@
legendExtra->setLegendMargin(widget->_margin->value());
legendExtra->setVertical(widget->_vertical->isChecked());
legendExtra->setTrackContents(widget->TrackContents->isChecked());
-
- KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
- legendExtra->_curves.clear();
- for (unsigned i = 0; i < widget->DisplayedCurveList->count(); i++) {
- KstBaseCurveList::Iterator it = allCurves.findTag(widget->DisplayedCurveList->text(i));
- if (it != allCurves.end()) {
- legendExtra->_curves.append(*it);
- }
- }
}
setDirty();
@@ -697,7 +698,7 @@
connect(widget->_margin->child("qt_spinbox_edit"), SIGNAL(textChanged(const QString&)), parent, SLOT(modified()));
connect(widget->_border, SIGNAL(valueChanged(int)), parent, SLOT(modified()));
connect(widget->_border->child("qt_spinbox_edit"), SIGNAL(textChanged(const QString&)), parent, SLOT(modified()));
- connect(widget->_thisLegend, SIGNAL(changed()), parent, SLOT(modified()));
+ connect(widget->_thisLegend, SIGNAL(stateChanged(int)), parent, SLOT(modified()));
}
--- trunk/extragear/graphics/kst/src/libkstapp/view2dplotwidget.ui.h #597629:597630
@@ -811,10 +811,10 @@
plotExtra->xTickLabel()->setFontName(FontComboBox->currentText());
plotExtra->xTickLabel()->setFontSize(NumberFontSize->value());
plotExtra->xTickLabel()->setRotation(_spinBoxXAngle->value());
-
+
plotExtra->fullTickLabel()->setFontName(FontComboBox->currentText());
plotExtra->fullTickLabel()->setFontSize(NumberFontSize->value());
-
+
plotExtra->yTickLabel()->setFontName(FontComboBox->currentText());
plotExtra->yTickLabel()->setFontSize(NumberFontSize->value());
plotExtra->yTickLabel()->setRotation(_spinBoxYAngle->value());
More information about the Kst
mailing list