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

Andrew Walker arwalker at sumusltd.com
Thu Dec 6 00:31:32 CET 2007


SVN commit 745324 by arwalker:

CCBUG:153153 fix hierarchical naming structure for spectra, histograms, and spectrograms

 M  +1 -1      libkstapp/kstcsddialog_i.cpp  
 M  +3 -3      libkstapp/ksteqdialog_i.cpp  
 M  +4 -1      libkstapp/ksthsdialog_i.cpp  
 M  +1 -1      libkstapp/kstpsddialog_i.cpp  
 M  +14 -1     libkstmath/kstcsd.cpp  
 M  +2 -0      libkstmath/kstcsd.h  
 M  +21 -28    libkstmath/kstequation.cpp  
 M  +14 -2     libkstmath/ksthistogram.cpp  
 M  +2 -0      libkstmath/ksthistogram.h  
 M  +19 -7     libkstmath/kstpsd.cpp  
 M  +8 -6      libkstmath/kstpsd.h  


--- branches/work/kst/1.6/kst/src/libkstapp/kstcsddialog_i.cpp #745323:745324
@@ -404,7 +404,7 @@
     }
 
     cp->writeLock();
-    cp->setTagName(KstObjectTag(tag_name, cp->tag().context())); // FIXME: doesn't allow changing tag context
+    cp->setTagName(tag_name);
     cp->unlock();
 
     // then edit the object
--- branches/work/kst/1.6/kst/src/libkstapp/ksteqdialog_i.cpp #745323:745324
@@ -113,7 +113,7 @@
   _w->_curvePlacement->hide();
   _legendText->hide();
   _legendLabel->hide();
-  
+
   adjustSize();
   resize(minimumSizeHint());
   setFixedHeight(height());
@@ -135,7 +135,7 @@
 
   // set the X Axis Vector to the X axis vector of 
   // the last curve on the global curve list...
-  if (curves.count() >0) {
+  if (curves.count() > 0) {
     _w->_xVectors->setSelection(curves.last()->xVTag().displayString());
   }
 
@@ -450,7 +450,7 @@
   _w->_doInterpolation->setTristate(true);
   _w->_doInterpolation->setNoChange();
   _w->_equation->setText("");
-  
+
   // and clean all the fields
   _equationDirty = false;
   _xVectorsDirty = false;
--- branches/work/kst/1.6/kst/src/libkstapp/ksthsdialog_i.cpp #745323:745324
@@ -425,8 +425,11 @@
       _tagName->setFocus();
       return false;
     }
-    hp->setTagName(KstObjectTag(tag_name, hp->tag().context())); // FIXME: doesn't allow changing tag context
 
+    hp->writeLock();
+    hp->setTagName(tag_name);
+    hp->unlock();
+
     // then edit the object
     _vectorDirty = true;
     _minDirty = true;
--- branches/work/kst/1.6/kst/src/libkstapp/kstpsddialog_i.cpp #745323:745324
@@ -418,7 +418,7 @@
     }
 
     pp->writeLock();
-    pp->setTagName(KstObjectTag(tag_name, pp->tag().context())); // FIXME: doesn't allow changing tag context
+    pp->setTagName(tag_name);
     pp->unlock();
 
     // then edit the object
--- branches/work/kst/1.6/kst/src/libkstmath/kstcsd.cpp #745323:745324
@@ -122,7 +122,7 @@
   _typeString = i18n("Spectrogram");
   _type = "Spectrogram";
   _inputVectors[INVECTOR] = in_V;
-  setTagName(KstObjectTag::fromString(in_tag));
+  KstObject::setTagName(KstObjectTag::fromString(in_tag));
   _frequency = in_freq;
   _average = in_average;
   _apodize = in_apodize;
@@ -162,6 +162,7 @@
   KST::matrixList.lock().unlock();
 }
 
+
 KstObject::UpdateType KstCSD::update(int update_counter) {
   Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
 
@@ -240,6 +241,7 @@
   return setLastUpdateResult(UPDATE);
 }
 
+
 void KstCSD::save(QTextStream &ts, const QString& indent) {
   QString l2 = indent + "  ";
   ts << indent << "<csdobject>" << endl;
@@ -474,3 +476,14 @@
   }
 }
 
+
+void KstCSD::setTagName(const QString &in_tag) {
+  KstObjectTag newTag(in_tag, tag().context());
+
+  if (newTag == tag()) {
+    return;
+  }
+
+  KstObject::setTagName(newTag);
+  (*_outMatrix)->setTagName(KstObjectTag("csd", tag()));
+}
--- branches/work/kst/1.6/kst/src/libkstmath/kstcsd.h #745323:745324
@@ -42,6 +42,8 @@
 
     virtual bool slaveVectorsUsed() const;
 
+    virtual void setTagName(const QString& tag);
+
     virtual void showNewDialog();
     virtual void showEditDialog();
 
--- branches/work/kst/1.6/kst/src/libkstmath/kstequation.cpp #745323:745324
@@ -15,10 +15,6 @@
  *                                                                         *
  ***************************************************************************/
 
-/** A class for handling equations for kst
- *@author C. Barth Netterfield
- */
-
 #include <assert.h>
 #include <math.h>
 #include <stdlib.h>
@@ -30,11 +26,11 @@
 #include <klocale.h>
 
 // application specific includes
+#include "defaultprimitivenames.h"
 #include "dialoglauncher.h"
 #include "enodes.h"
 #include "eparse-eh.h"
 #include "kstdatacollection.h"
-#include "defaultprimitivenames.h"
 #include "kstdebug.h"
 #include "kstequation.h"
 #include "kstsvector.h"
@@ -76,12 +72,12 @@
 
 KstEquation::KstEquation(const QDomElement &e)
 : KstDataObject(e) {
-  QString in_tag, equation;
-
-  int ns = -1;
-  double x0 = 0.0, x1 = 1.0;
   KstObjectTag xvtag = KstObjectTag::invalidTag;
+  QString in_tag, equation;
+  double x0 = 0.0;
+  double x1 = 1.0;
   bool haveVector = false;
+  int ns = -1;
 
   _doInterp = false;
 
@@ -117,7 +113,7 @@
       ns = 2;
     }
     if (x0 == x1) {
-      x1 = x0 + 2;
+      x1 = x0 + 2.0;
     }
 
     KstObjectTag vtag = KstObjectTag::invalidTag;
@@ -152,7 +148,7 @@
 
   KstVectorPtr xv = new KstVector(KstObjectTag("xsv", tag()), 2, this);
   _xOutVector = _outputVectors.insert(XOUTVECTOR, xv);
-    
+
   KstVectorPtr yv = new KstVector(KstObjectTag("sv", tag()), 2, this);
   _yOutVector = _outputVectors.insert(YOUTVECTOR, yv);
 
@@ -545,22 +541,21 @@
 
 
 void KstEquation::replaceDependency(KstDataObjectPtr oldObject, KstDataObjectPtr newObject) {
-  
   QString newExp = _equation;
-  
+
   // replace all occurences of outputVectors, outputScalars from oldObject
   for (KstVectorMap::Iterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) {
     QString oldTag = j.data()->tagName();
     QString newTag = ((newObject->outputVectors())[j.key()])->tagName();
     newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]");
   }
-  
+
   for (KstScalarMap::Iterator j = oldObject->outputScalars().begin(); j != oldObject->outputScalars().end(); ++j) {
     QString oldTag = j.data()->tagName();
     QString newTag = ((newObject->outputScalars())[j.key()])->tagName();
     newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]");
   }
-  
+
   // and dependencies on matrix stats (there won't be matrices themselves in the expression)
   for (KstMatrixMap::Iterator j = oldObject->outputMatrices().begin(); j != oldObject->outputMatrices().end(); ++j) {
     QDictIterator<KstScalar> scalarDictIter(j.data()->scalars());
@@ -570,7 +565,7 @@
       newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); 
     }
   }
-  
+
   // only replace _inputVectors
   for (KstVectorMap::Iterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) {
     for (KstVectorMap::Iterator k = _inputVectors.begin(); k != _inputVectors.end(); ++k) {
@@ -587,7 +582,7 @@
       newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); 
     }
   }
-  
+
   setEquation(newExp);
 }
 
@@ -595,10 +590,10 @@
 void KstEquation::replaceDependency(KstVectorPtr oldVector, KstVectorPtr newVector) {
   QString oldTag = oldVector->tagName();
   QString newTag = newVector->tagName();
-  
+
   // replace all occurences of oldTag with newTag
   QString newExp = _equation.replace("["+oldTag+"]", "["+newTag+"]");
-  
+
   // also replace all occurences of scalar stats for the oldVector
   QDictIterator<KstScalar> scalarDictIter(oldVector->scalars());
   for (; scalarDictIter.current(); ++scalarDictIter) {
@@ -606,7 +601,7 @@
     QString newTag = ((newVector->scalars())[scalarDictIter.currentKey()])->tagName();
     newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); 
   }
-  
+
   setEquation(newExp);
 
   // do the dependency replacements for _inputVectors, but don't call parent function as it
@@ -614,15 +609,14 @@
   for (KstVectorMap::Iterator j = _inputVectors.begin(); j != _inputVectors.end(); ++j) {
     if (j.data() == oldVector) {
       _inputVectors[j.key()] = newVector;  
-    }      
+    }
   }
 }
 
 
 void KstEquation::replaceDependency(KstMatrixPtr oldMatrix, KstMatrixPtr newMatrix) {
-
   QString newExp = _equation;
-  
+
   // also replace all occurences of scalar stats for the oldMatrix
   QDictIterator<KstScalar> scalarDictIter(oldMatrix->scalars());
   for (; scalarDictIter.current(); ++scalarDictIter) {
@@ -630,13 +624,12 @@
     QString newTag = ((newMatrix->scalars())[scalarDictIter.currentKey()])->tagName();
     newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); 
   }
-  
+
   setEquation(newExp);
 }
 
 
 bool KstEquation::uses(KstObjectPtr p) const {
-  
   // check VectorsUsed in addition to _input*'s
   if (KstVectorPtr vect = kst_cast<KstVector>(p)) {
     for (KstVectorMap::ConstIterator j = VectorsUsed.begin(); j != VectorsUsed.end(); ++j) {
@@ -662,12 +655,12 @@
   for (KstScalarMap::iterator i = ScalarsUsed.begin(); i != ScalarsUsed.end(); ++i) {
     disconnect(i.data(), SIGNAL(tagChanged()), this, SLOT(reParse()));
     connect(i.data(), SIGNAL(tagChanged()), this, SLOT(reParse()));
-  } 
+  }
   for (KstVectorMap::iterator i = VectorsUsed.begin(); i != VectorsUsed.end(); ++i) {
     disconnect(i.data(), SIGNAL(tagChanged()), this, SLOT(reParse()));
     connect(i.data(), SIGNAL(tagChanged()), this, SLOT(reParse()));
-  } 
+  }
 }
 
 #include "kstequation.moc"
-// vim: ts=2 sw=2 et
+
--- branches/work/kst/1.6/kst/src/libkstmath/ksthistogram.cpp #745323:745324
@@ -106,8 +106,8 @@
   _NormMode = in_norm_mode;
   _Bins = 0L;
   _NBins = 0;
-  
-  setTagName(KstObjectTag::fromString(in_tag));
+
+  KstObject::setTagName(KstObjectTag::fromString(in_tag));
   _inputVectors[RAWVECTOR] = in_V;
 
   if (xmax_in>xmin_in) {
@@ -456,3 +456,15 @@
   return KstDataObjectPtr(histogram);
 }
 
+
+void KstHistogram::setTagName(const QString &in_tag) {
+  KstObjectTag newTag(in_tag, tag().context());
+
+  if (newTag == tag()) {
+    return;
+  }
+
+  KstObject::setTagName(newTag);
+  (*_bVector)->setTagName(KstObjectTag("bins", tag()));
+  (*_hVector)->setTagName(KstObjectTag("sv", tag()));
+}
--- branches/work/kst/1.6/kst/src/libkstmath/ksthistogram.h #745323:745324
@@ -59,6 +59,8 @@
 
   static void AutoBin(const KstVectorPtr, int *n, double *max, double *min);
 
+  virtual void setTagName(const QString& tag);
+
   virtual void showNewDialog();
   virtual void showEditDialog();
 
--- branches/work/kst/1.6/kst/src/libkstmath/kstpsd.cpp #745323:745324
@@ -15,26 +15,26 @@
  *                                                                         *
  ***************************************************************************/
 
-/** A class for handling power spectra for kst
- *@author C. Barth Netterfield
- */
-
 #include <assert.h>
 #include <math.h>
 
+// include files for Qt
 #include <qstylesheet.h>
 
+// include files for KDE
 #include <kglobal.h>
 #include <klocale.h>
 #include "ksdebug.h"
 
+// application specific includes
 #include "dialoglauncher.h"
 #include "kstdatacollection.h"
 #include "kstdebug.h"
+#include "kstobjectdefaults.h"
 #include "kstpsd.h"
 #include "psdcalculator.h"
-#include "kstobjectdefaults.h"
 
+
 extern "C" void rdft(int n, int isgn, double *a);
 
 const QString& KstPSD::INVECTOR = KGlobal::staticQString("I");
@@ -139,7 +139,7 @@
   if (in_V) {
     _inputVectors[INVECTOR] = in_V;
   }
-  setTagName(KstObjectTag::fromString(in_tag));
+  KstObject::setTagName(KstObjectTag::fromString(in_tag));
   _Freq = in_freq;
   _Average = in_average;
   _Apodize = in_apodize;
@@ -454,7 +454,7 @@
   }
 }
 
- 
+
 KstDataObjectPtr KstPSD::makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap) {
   QString name(tagName() + '\'');
   while (KstData::self()->dataTagNameNotUnique(name, false)) {
@@ -499,3 +499,15 @@
   (*_fVector)->setLabel(i18n("Frequency \\[%1\\]").arg(_rUnits));
 }
 
+
+void KstPSD::setTagName(const QString &in_tag) {
+  KstObjectTag newTag(in_tag, tag().context());
+
+  if (newTag == tag()) {
+    return;
+  }
+
+  KstObject::setTagName(newTag);
+  (*_sVector)->setTagName(KstObjectTag("sv", tag()));
+  (*_fVector)->setTagName(KstObjectTag("freq", tag()));
+}
--- branches/work/kst/1.6/kst/src/libkstmath/kstpsd.h #745323:745324
@@ -39,13 +39,13 @@
 
     virtual void save(QTextStream& ts, const QString& indent = QString::null);
     virtual QString propertyString() const;
-    
+
     bool apodize() const;
     void setApodize(bool in_apodize);
-    
+
     ApodizeFunction apodizeFxn() const;
     void setApodizeFxn(ApodizeFunction in_apodizeFxn);
-    
+
     double gaussianSigma() const;
     void setGaussianSigma(double in_gaussianSigma);
 
@@ -66,7 +66,7 @@
 
     const QString& vUnits() const;
     void setVUnits(const QString& units);
-    
+
     const QString& rUnits() const;
     void setRUnits(const QString& units);
 
@@ -78,6 +78,8 @@
 
     virtual bool slaveVectorsUsed() const;
 
+    virtual void setTagName(const QString& tag);
+
     virtual void showNewDialog();
     virtual void showEditDialog();
 
@@ -88,7 +90,7 @@
     KstVectorPtr vY() const { return *_sVector; }
 
     const KstCurveHintList *curveHints() const;
-    
+
     virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap);
 
   private:
@@ -129,4 +131,4 @@
 typedef KstObjectList<KstPSDPtr> KstPSDList;
 
 #endif
-// vim: ts=2 sw=2 et
+


More information about the Kst mailing list