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

Mike Fenton mike at staikos.net
Wed Nov 7 17:00:48 CET 2007


SVN commit 733929 by fenton:

Add Save/Restore for Curve.


 M  +1 -6      devel-docs/Kst2Specs/kstfile.txt  
 M  +2 -0      src/libkstapp/application.cpp  
 M  +1 -1      src/libkstapp/curvedialog.cpp  
 A             src/libkstmath/builtinrelations.cpp   [License: GPL (v2+)]
 A             src/libkstmath/builtinrelations.h   [License: GPL (v2+)]
 M  +47 -48    src/libkstmath/curve.cpp  
 M  +3 -1      src/libkstmath/curve.h  
 A             src/libkstmath/curvefactory.cpp   [License: GPL (v2+)]
 A             src/libkstmath/curvefactory.h   [License: GPL (v2+)]
 M  +4 -0      src/libkstmath/libkstmath.pro  


--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/kstfile.txt #733928:733929
@@ -33,12 +33,7 @@
     <eventmonitor tag="" equation="" description="" logdebug="" loglevel="" logemail="" logelog="" emailrecipients="" script=""></eventmonitor>
   </objects>
   <relations>
-    <xycurve name="" xvector="" yvector="">
-    </xycurve>
-    <xyzcurve name="" xvector="" yvector="" zvector="">
-    </xyzcurve>
-    <images?>
-    </images>
+    <curve tag="" xvector="" yvector="" legend="" errorxvector="" erroryvector="" errorxminusvector="" erroryminusvector="" color="" haslines="" linewidth="" linestyle="" haspoints="" pointtype="" pointdensity="" hasbars="" barstyle="" ignoreautoscale=""></curve>
   </relations>
   <graphics>
     <view name="">
--- branches/work/kst/portto4/kst/src/libkstapp/application.cpp #733928:733929
@@ -15,6 +15,7 @@
 #include "builtinprimitives.h"
 #include "builtinobjects.h"
 #include "builtingraphics.h"
+#include "builtinrelations.h"
 
 #include "datagui.h"
 #include "datacollection.h"
@@ -30,6 +31,7 @@
 
   Builtins::initPrimitives(); //libkst
   Builtins::initObjects();    //libkstmath
+  Builtins::initRelations();  //libkstmath
   Builtins::initGraphics();   //libkstapp
 
   //FIXME Set the datasource settings file...
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.cpp #733928:733929
@@ -181,7 +181,7 @@
   curve->setHasBars(_curveTab->curveAppearance()->showBars());
   curve->setLineWidth(_curveTab->curveAppearance()->lineWidth());
   curve->setLineStyle(_curveTab->curveAppearance()->lineStyle());
-  curve->pointType = _curveTab->curveAppearance()->pointType();
+  curve->setPointType(_curveTab->curveAppearance()->pointType());
   curve->setPointDensity(_curveTab->curveAppearance()->pointDensity());
   curve->setBarStyle(_curveTab->curveAppearance()->barStyle());
 
--- branches/work/kst/portto4/kst/src/libkstmath/curve.cpp #733928:733929
@@ -19,7 +19,7 @@
 #include "kst_i18n.h"
 #include <qdebug.h>
 #include <QPolygon>
-#include <QTextDocument>
+#include <QXmlStreamWriter>
 
 // application specific includes
 #include "dialoglauncher.h"
@@ -52,6 +52,7 @@
 namespace Kst {
 
 const QString Curve::staticTypeString = I18N_NOOP("Curve");
+const QString Curve::staticTypeTag = I18N_NOOP("curve");
 
 static const QLatin1String& COLOR_XVECTOR = QLatin1String("X");
 static const QLatin1String& COLOR_YVECTOR = QLatin1String("Y");
@@ -123,48 +124,48 @@
     if (!e.isNull()) { // the node was really an element.
       if (e.tagName() == "tag") {
         in_tag = e.text();
-      } else if (e.tagName() == "hasMinus") {
+      } else if (e.tagName() == "hasminus") {
         hasMinus = true;
-      } else if (e.tagName() == "xvectag") {
+      } else if (e.tagName() == "xvector") {
         xname = e.text();
-      } else if (e.tagName() == "yvectag") {
+      } else if (e.tagName() == "yvector") {
         yname = e.text();
-      } else if (e.tagName() == "exVectag") {
+      } else if (e.tagName() == "errorxvector") {
         exname = e.text();
         if (!hasMinus) {
           exminusname = e.text();
         }
-      } else if (e.tagName() == "eyVectag") {
+      } else if (e.tagName() == "erroryvector") {
         eyname = e.text();
         if (!hasMinus) {
           eyminusname = e.text();
         }
-      } else if (e.tagName() == "exMinusVectag") {
+      } else if (e.tagName() == "errorxminusvector") {
         exminusname = e.text();
-      } else if (e.tagName() == "eyMinusVectag") {
+      } else if (e.tagName() == "erroryminusvector") {
         eyminusname = e.text();
       } else if (e.tagName() == "color") {
         in_color.setNamedColor(e.text());
       } else if (e.tagName() == "legend") {
         setLegendText(e.text());
       // the following options are only needed to change from the default
-      } else if (e.tagName() == "hasLines") {
+      } else if (e.tagName() == "haslines") {
         HasLines = e.text() != "0";
-      } else if (e.tagName() == "hasPoints") {
+      } else if (e.tagName() == "haspoints") {
         HasPoints = e.text() != "0";
-      } else if (e.tagName() == "hasBars") {
+      } else if (e.tagName() == "hasbars") {
         HasBars = e.text() != "0";
-      } else if (e.tagName() == "pointType") {
+      } else if (e.tagName() == "pointtype") {
         pointType = e.text().toInt();
-      } else if (e.tagName() == "lineWidth") {
+      } else if (e.tagName() == "linewidth") {
         LineWidth = e.text().toInt();
-      } else if (e.tagName() == "lineStyle") {
+      } else if (e.tagName() == "linestyle") {
         LineStyle = e.text().toInt();
-      } else if (e.tagName() == "barStyle") {
+      } else if (e.tagName() == "barstyle") {
         BarStyle = e.text().toInt();
-      } else if (e.tagName() == "pointDensity") {
+      } else if (e.tagName() == "pointdensity") {
         PointDensity = e.text().toInt();
-      } else if (e.tagName() == "ignoreAutoScale") {
+      } else if (e.tagName() == "ignoreautoscale") {
         _ignoreAutoScale = true;
       }
     }
@@ -472,45 +473,37 @@
 }
 
 
-void Curve::save(QTextStream &ts, const QString& indent) {
-  QString l2 = indent + "  ";
-  ts << indent << "<curve>" << endl;
-  ts << l2 << "<tag>" << Qt::escape(tag().tagString()) << "</tag>" << endl;
-  ts << l2 << "<xvectag>" << Qt::escape(_inputVectors[COLOR_XVECTOR]->tag().tagString()) << "</xvectag>" << endl;
-  ts << l2 << "<yvectag>" << Qt::escape(_inputVectors[COLOR_YVECTOR]->tag().tagString()) << "</yvectag>" << endl;
-  ts << l2 << "<legend>" << Qt::escape(legendText()) << "</legend>" << endl;
-  ts << l2 << "<hasMinus/>" << endl;
+void Curve::save(QXmlStreamWriter &s) {
+  s.writeStartElement(staticTypeTag);
+  s.writeAttribute("tag", tag().tagString());
+  s.writeAttribute("xvector", _inputVectors[COLOR_XVECTOR]->tag().tagString());
+  s.writeAttribute("yvector", _inputVectors[COLOR_YVECTOR]->tag().tagString());
+  s.writeAttribute("legend", legendText());
   if (_inputVectors.contains(EXVECTOR)) {
-    ts << l2 << "<exVectag>" << Qt::escape(_inputVectors[EXVECTOR]->tag().tagString()) << "</exVectag>" << endl;
+    s.writeAttribute("errorxvector", _inputVectors[EXVECTOR]->tag().tagString());
   }
   if (_inputVectors.contains(EYVECTOR)) {
-    ts << l2 << "<eyVectag>" << Qt::escape(_inputVectors[EYVECTOR]->tag().tagString()) << "</eyVectag>" << endl;
+    s.writeAttribute("erroryvector", _inputVectors[EYVECTOR]->tag().tagString());
   }
   if (_inputVectors.contains(EXMINUSVECTOR)) {
-    ts << l2 << "<exMinusVectag>" << Qt::escape(_inputVectors[EXMINUSVECTOR]->tag().tagString()) << "</exMinusVectag>" << endl;
+    s.writeAttribute("errorxminusvector", _inputVectors[EXMINUSVECTOR]->tag().tagString());
   }
   if (_inputVectors.contains(EYMINUSVECTOR)) {
-    ts << l2 << "<eyMinusVectag>" << Qt::escape(_inputVectors[EYMINUSVECTOR]->tag().tagString()) << "</eyMinusVectag>" << endl;
+    s.writeAttribute("erroryminusvector", _inputVectors[EYMINUSVECTOR]->tag().tagString());
   }
-  ts << l2 << "<color>" << Color.name() << "</color>" << endl;
-  if (HasLines) {
-    ts << l2 << "<hasLines/>" << endl;
-  }
-  ts << l2 << "<lineWidth>" << LineWidth << "</lineWidth>" << endl;
-  ts << l2 << "<lineStyle>" << LineStyle << "</lineStyle>" << endl;
-  if (HasPoints) {
-    ts << l2 << "<hasPoints/>" << endl;
-  }
-  ts << l2 << "<pointType>" << pointType << "</pointType>" << endl;
-  ts << l2 << "<pointDensity>" << PointDensity << "</pointDensity>" << endl;
-  if (HasBars) {
-    ts << l2 << "<hasBars/>" << endl;
-  }
-  ts << l2 << "<barStyle>" << BarStyle << "</barStyle>" << endl;
-  if (_ignoreAutoScale) {
-    ts << l2 << "<ignoreAutoScale/>" << endl;
-  }
-  ts << indent << "</curve>" << endl;
+  s.writeAttribute("color", Color.name());
+
+  s.writeAttribute("haslines", QVariant(HasLines).toString());
+  s.writeAttribute("linewidth", QString::number(LineWidth));
+  s.writeAttribute("linestyle", QString::number(LineStyle));
+
+  s.writeAttribute("haspoints", QVariant(HasPoints).toString());
+  s.writeAttribute("pointtype", QString::number(pointType));
+  s.writeAttribute("pointdensity", QString::number(PointDensity));
+
+  s.writeAttribute("hasbars", QVariant(HasBars).toString());
+  s.writeAttribute("barstyle", QString::number(BarStyle));
+  s.writeAttribute("ignoreautoscale", QVariant(_ignoreAutoScale).toString());
 }
 
 
@@ -803,6 +796,12 @@
 }
 
 
+void Curve::setPointType(int in_PointType) {
+  pointType = in_PointType;
+  setDirty();
+}
+
+
 void Curve::setColor(const QColor& new_c) {
   setDirty();
   Color = new_c;
--- branches/work/kst/portto4/kst/src/libkstmath/curve.h #733928:733929
@@ -37,6 +37,7 @@
   public:
     static const QString staticTypeString;
     const QString& typeString() const { return staticTypeString; }
+    static const QString staticTypeTag;
 
     virtual UpdateType update(int update_counter = -1);
     virtual QString propertyString() const;
@@ -72,7 +73,7 @@
     void setYMinusError(VectorPtr new_ey);
 
     /** Save curve information */
-    void save(QTextStream &ts, const QString& indent = QString::null);
+    void save(QXmlStreamWriter &s);
 
     QString xLabel() const;
     QString yLabel() const;
@@ -110,6 +111,7 @@
     virtual void setLineStyle(int in_LineStyle);
     virtual void setBarStyle( int in_BarStyle);
     virtual void setPointDensity(int in_PointDensity);
+    virtual void setPointType(int in_PointType);
 
     virtual int lineWidth()     const { return LineWidth; }
     virtual int lineStyle()     const { return LineStyle; }
--- branches/work/kst/portto4/kst/src/libkstmath/libkstmath.pro #733928:733929
@@ -24,10 +24,12 @@
 SOURCES += \
     basicplugin.cpp \
     builtinobjects.cpp \
+    builtinrelations.cpp \
     colorsequence.cpp \
     csd.cpp \
     csdfactory.cpp \
     curve.cpp \
+    curvefactory.cpp \
     curvehint.cpp \
     curvepointsymbol.cpp \
     dataobject.cpp \
@@ -64,10 +66,12 @@
 HEADERS += \
     basicplugin.h \
     builtinobjects.h \
+    builtinrelations.h \
     colorsequence.h \
     csd.h \
     csdfactory.h \
     curve.h \
+    curvefactory.h \
     curvehint.h \
     curvepointsymbol.h \
     dialoglauncher.h \


More information about the Kst mailing list