[Kst] branches/work/kst/portto4/kst/src

Barth Netterfield netterfield at astro.utoronto.ca
Thu Jun 30 04:53:29 CEST 2011


SVN commit 1238831 by netterfield:

BUG: 272580
Fix the illusive Log mode range bug in psd's :-)
Directly edit parameters in plugin dialogs.
Fix plot selection in dialogs.



 M  +3 -2      libkst/vector.cpp  
 M  +1 -1      libkstmath/psd.cpp  
 M  +6 -3      widgets/curveplacement.cpp  
 M  +18 -3     widgets/scalarselector.cpp  


--- branches/work/kst/portto4/kst/src/libkst/vector.cpp #1238830:1238831
@@ -382,6 +382,7 @@
   double sum, sum2, last, first, v;
   double last_v;
   double dv2 = 0.0, dv, no_spike_max_dv;
+  const double epsilon=1e-300;
 
   _max = _min = sum = sum2 = _minPos = last = first = NOPOINT;
   _nsum = 0;
@@ -420,7 +421,7 @@
     _max = _min = _v[i0];
     sum = sum2 = 0.0;
 
-    if (_v[i0] > 0.0) {
+    if (_v[i0] > epsilon) {
       _minPos = _v[i0];
     } else {
       _minPos = 1.0E300;
@@ -452,7 +453,7 @@
         } else if (v < _min) {
           _min = v;
         }
-        if (v < _minPos && v > 0.0) {
+        if (v < _minPos && v > epsilon) {
           _minPos = v;
         }
       } else {
--- branches/work/kst/portto4/kst/src/libkstmath/psd.cpp #1238830:1238831
@@ -155,7 +155,7 @@
   for (i_samp = 0; i_samp < _PSDLength; ++i_samp) {
     f[i_samp] = i_samp * 0.5 * _Frequency / (_PSDLength - 1);
   }
-  f[0] = 0.0; // really 0! (this shouldn't be needed...
+  //f[0] = -1E-280; // really 0 (this shouldn't be needed...)
 
   _psdCalculator.calculatePowerSpectrum(iv->value(), v_len, psd, _PSDLength, _RemoveMean,  _interpolateHoles, _Average, _averageLength, _Apodize, _apodizeFxn, _gaussianSigma, _Output, _Frequency);
 
--- branches/work/kst/portto4/kst/src/widgets/curveplacement.cpp #1238830:1238831
@@ -140,12 +140,15 @@
 
 void CurvePlacement::setCurrentPlot(const PlotItemInterface *currentPlot) {
   if (currentPlot) {
-    int index = _plotList->findText(currentPlot->plotName());
-    if (index >= 0) {
-      _plotList->setCurrentIndex(index);
+    int n = _plotList->count();
+    for (int i=0; i<n; ++i ) {
+      if (qVariantValue<PlotItemInterface*>(_plotList->itemData(i))->plotName() == currentPlot->plotName()) {
+        _plotList->setCurrentIndex(i);
+        return;
     }
   }
 }
+}
 
 int CurvePlacement::gridColumns() const {
   return _gridColumns->value();
--- branches/work/kst/portto4/kst/src/widgets/scalarselector.cpp #1238830:1238831
@@ -67,8 +67,13 @@
 
 void ScalarSelector::setDefaultValue(double value) {
  QString string = QString::number(value);
+ int index = _scalar->findText(string);
+ if (index<0) {
  _scalar->addItem(string, qVariantFromValue(0));
  _scalar->setCurrentIndex(_scalar->findText(string));
+ } else {
+   _scalar->setCurrentIndex(index);
+ }
  _defaultsSet = true;
 }
 
@@ -149,13 +154,15 @@
       break;
     }
   }
-  Q_ASSERT(i != -1);
 
+  if (i==-1) {
+    setDefaultValue(selectedScalar->value());
+  } else {
   _scalar->setCurrentIndex(i);
   _defaultsSet = false;
 }
+}
 
-
 void ScalarSelector::newScalar() {
   QString scalarName;
   DialogLauncher::self()->showScalarDialog(scalarName, 0, true);
@@ -201,7 +208,9 @@
     ScalarPtr scalar = (*it);
 
     scalar->readLock();
+    if (!scalar->orphan()) {
     scalars.insert(scalar->sizeLimitedName(_scalar), scalar);
+    }
     scalar->unlock();
   }
 
@@ -209,6 +218,7 @@
 
   qSort(list);
 
+  QString current_text = _scalar->currentText();
   ScalarPtr current = qVariantValue<Scalar*>(_scalar->itemData(_scalar->currentIndex()));;
 
   _scalar->clear();
@@ -220,8 +230,13 @@
   _scalarListSelector->clear();
   _scalarListSelector->fillScalars(list);
 
-  if (current)
+  if (current) {
     setSelectedScalar(current);
+  } else {
+    _scalar->addItem(current_text, qVariantFromValue(0));
+    _scalar->setCurrentIndex(_scalar->findText(current_text));
+    _defaultsSet = true;
+  }
 
   _editScalar->setEnabled(_scalar->count() > 0);
   _selectScalar->setEnabled(_scalar->count() > 0);


More information about the Kst mailing list