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

Mike Fenton mike at staikos.net
Tue Nov 6 16:40:59 CET 2007


SVN commit 733532 by fenton:

Update to save/restore for Equations.


 M  +1 -3      devel-docs/Kst2Specs/kstfile.txt  
 M  +2 -1      src/libkstmath/equation.cpp  
 M  +1 -0      src/libkstmath/equation.h  
 M  +12 -4     src/libkstmath/equationfactory.cpp  


--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/kstfile.txt #733531:733532
@@ -26,9 +26,7 @@
     </editablematrix>
   </variables>
   <objects>
-    <equation name="" xvector="" interpolate="true" output="">
-       equationtext
-    </equation>
+    <equation tag="" expression="" xvector="" interpolate=""></equation>
     <psd name="">
     </psd>
   </objects>
--- branches/work/kst/portto4/kst/src/libkstmath/equation.cpp #733531:733532
@@ -43,6 +43,7 @@
 namespace Kst {
 
 const QString Equation::staticTypeString = I18N_NOOP("Equation");
+const QString Equation::staticTypeTag = I18N_NOOP("equation");
 
 const QString Equation::XINVECTOR = "X";
 const QString Equation::XOUTVECTOR = "XO"; // Output (slave) vector
@@ -183,7 +184,7 @@
 
 
 void Equation::save(QXmlStreamWriter &s) {
-  s.writeStartElement("equation");
+  s.writeStartElement(staticTypeTag);
   s.writeAttribute("tag", tag().tagString());
   // Reparse the equation, then write it back out in text so that we can update
   // any vectors or scalars that had name changes, but we don't get affected by
--- branches/work/kst/portto4/kst/src/libkstmath/equation.h #733531:733532
@@ -43,6 +43,7 @@
   public:
     static const QString staticTypeString;
     const QString& typeString() const { return staticTypeString; }
+    static const QString staticTypeTag;
 
     void attach();
     UpdateType update(int update_counter = -1);
--- branches/work/kst/portto4/kst/src/libkstmath/equationfactory.cpp #733531:733532
@@ -20,7 +20,7 @@
 
 EquationFactory::EquationFactory()
 : ObjectFactory() {
-  registerFactory("equation", this);
+  registerFactory(Equation::staticTypeTag, this);
 }
 
 
@@ -31,7 +31,6 @@
 DataObjectPtr EquationFactory::generateObject(ObjectStore *store, QXmlStreamReader& xml) {
   QString tag, expression, xVector, output;
   bool interpolate = false;
-
   while (!xml.atEnd()) {
     const QString n = xml.name().toString();
     if (xml.isStartElement()) {
@@ -73,8 +72,17 @@
     return 0;
   }
 
-  EquationPtr ep = new Equation(store, ObjectTag::fromString(tag), expression, vector, interpolate);
-  return ep.data();
+  EquationPtr equation = store->createObject<Equation>(ObjectTag::fromString(tag));
+  Q_ASSERT(equation);
+
+  equation->setEquation(expression);
+  equation->setExistingXVector(vector, interpolate);
+
+  equation->writeLock();
+  equation->update(0);
+  equation->unlock();
+
+  return equation;
 }
 
 }


More information about the Kst mailing list