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

Mike Fenton mike at staikos.net
Tue Jan 29 21:33:36 CET 2008


SVN commit 768342 by fenton:

Update DataMatrix to support configuration of xMin, yMin xStep and yStep.


 M  +33 -9     datamatrix.cpp  
 M  +8 -4      datamatrix.h  
 M  +6 -1      matrixfactory.cpp  


--- branches/work/kst/portto4/kst/src/libkst/datamatrix.cpp #768341:768342
@@ -40,9 +40,10 @@
 DataMatrix::DataMatrix(ObjectStore *store, DataSourcePtr file, const QString& field, const ObjectTag& tag,
                        int xStart, int yStart,
                        int xNumSteps, int yNumSteps,
-                       bool doAve, bool doSkip, int skip)
+                       bool doAve, bool doSkip, int skip,
+                       double minX, double minY, double stepX, double stepY)
     : Matrix(store, tag, 0L, 1, 1, 0,0,1,1) {
-  commonConstructor(file, field, xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip);
+  commonConstructor(file, field, xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip, minX, minY, stepX, stepY);
 }
 
 
@@ -58,6 +59,10 @@
   bool in_doAve = false;
   bool in_doSkip = false;
   int in_skip = 1;
+  double in_xMin = 0;
+  double in_yMin = 0;
+  double in_xStep = 1;
+  double in_yStep = 1;
 
   DataSourceList dsList;
   if (this->store()) {
@@ -91,6 +96,14 @@
         in_doSkip = (e.text() != "0");
       } else if (e.tagName() == "skip") {
         in_skip = e.text().toInt();
+      } else if (e.tagName() == "xmin") {
+        in_xMin = e.text().toDouble();
+      } else if (e.tagName() == "ymin") {
+        in_yMin = e.text().toDouble();
+      } else if (e.tagName() == "xstep") {
+        in_xStep = e.text().toDouble();
+      } else if (e.tagName() == "ystep") {
+        in_yStep = e.text().toDouble();
       }
     }
     n = n.nextSibling();
@@ -108,7 +121,7 @@
   setTagName(tag);
 
   // call common constructor
-  commonConstructor(in_file, in_field, in_xStart, in_yStart, in_xNumSteps, in_yNumSteps, in_doAve, in_doSkip, in_skip);
+  commonConstructor(in_file, in_field, in_xStart, in_yStart, in_xNumSteps, in_yNumSteps, in_doAve, in_doSkip, in_skip, in_xMin, in_yMin, in_xStep, in_yStep);
 }
 
 
@@ -135,6 +148,10 @@
     xml.writeAttribute("doave", QVariant(_doAve).toString());
     xml.writeAttribute("doskip", QVariant(_doSkip).toString());
     xml.writeAttribute("skip", QString::number(_skip));
+    xml.writeAttribute("xmin", QString::number(minX()));
+    xml.writeAttribute("ymin", QString::number(minY()));
+    xml.writeAttribute("xstep", QString::number(xStepSize()));
+    xml.writeAttribute("ystep", QString::number(yStepSize()));
     xml.writeEndElement();
   }
 }
@@ -147,10 +164,11 @@
 void DataMatrix::change(DataSourcePtr file, const QString &field,
                         int xStart, int yStart,
                         int xNumSteps, int yNumSteps,
-                        bool doAve, bool doSkip, int skip) {
+                        bool doAve, bool doSkip, int skip, double minX, double minY,
+                        double stepX, double stepY) {
   KstWriteLocker l(this);
 
-  commonConstructor(file, field, xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip);
+  commonConstructor(file, field, xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip, minX, minY, stepX, stepY);
 
   setDirty(true);
 }
@@ -158,10 +176,11 @@
 
 void DataMatrix::changeFrames(int xStart, int yStart,
                         int xNumSteps, int yNumSteps,
-                        bool doAve, bool doSkip, int skip) {
+                        bool doAve, bool doSkip, int skip, double minX, double minY,
+                        double stepX, double stepY) {
   KstWriteLocker l(this);
 
-  commonConstructor(_file, _field, xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip);
+  commonConstructor(_file, _field, xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip, minX, minY, stepX, stepY);
 
   setDirty(true);
 }
@@ -539,7 +558,7 @@
   DataMatrixPtr matrix = store()->createObject<DataMatrix>(ObjectTag::fromString(newTag));
 
   matrix->writeLock();
-  matrix->change(_file, _field, _reqXStart, _reqYStart, _reqNX, _reqNY, _doAve, _doSkip, _skip);
+  matrix->change(_file, _field, _reqXStart, _reqYStart, _reqNX, _reqNY, _doAve, _doSkip, _skip, _minX, _minY, _stepX, _stepY);
   matrix->update(0);
   matrix->unlock();
 
@@ -549,7 +568,8 @@
 
 void DataMatrix::commonConstructor(DataSourcePtr file, const QString &field,
                                    int reqXStart, int reqYStart, int reqNX, int reqNY,
-                                   bool doAve, bool doSkip, int skip) {
+                                   bool doAve, bool doSkip, int skip, double minX, double minY,
+                                   double stepX, double stepY) {
 //  qDebug() << "constructing DataMatrix " << tag().displayString() << " from file " << file->tag().displayString() << " (" << (void*)(&(*file)) << ")" << endl;
   _reqXStart = reqXStart;
   _reqYStart = reqYStart;
@@ -560,6 +580,10 @@
   _doAve = doAve;
   _doSkip = doSkip;
   _skip = skip;
+  _minX = minX;
+  _minY = minY;
+  _stepX = stepX;
+  _stepY = stepY;
 
   _saveable = true;
   _editable = true;
--- branches/work/kst/portto4/kst/src/libkst/datamatrix.h #768341:768342
@@ -35,10 +35,12 @@
     void change(DataSourcePtr file, const QString &field,
                 int xStart, int yStart,
                 int xNumSteps, int yNumSteps,
-                bool doAve, bool doSkip, int skip);
+                bool doAve, bool doSkip, int skip,
+                double minX, double minY, double stepX, double stepY);
     void changeFrames(int xStart, int yStart,
                 int xNumSteps, int yNumSteps,
-                bool doAve, bool doSkip, int skip);
+                bool doAve, bool doSkip, int skip,
+                double minX, double minY, double stepX, double stepY);
 
     // return properties of DataMatrix
     int reqXStart() const;
@@ -82,7 +84,8 @@
     // constructor
     DataMatrix(ObjectStore *store, DataSourcePtr file, const QString &field,
         const ObjectTag& tag, int xStart, int yStart,
-        int xNumSteps, int yNumSteps, bool doAve, bool doSkip, int skip);
+        int xNumSteps, int yNumSteps, bool doAve, bool doSkip, int skip,
+        double minX = 0, double minY = 0, double stepX = 1, double stepY = 1);
 
     // constructor to create a saved DataMatrix
     DataMatrix(ObjectStore *store, const QDomElement &e);
@@ -94,7 +97,8 @@
   private:
     void commonConstructor(DataSourcePtr file, const QString &field,
                            int reqXStart, int reqYStart, int reqNX, int reqNY,
-                           bool doAve, bool doSkip, int skip);
+                           bool doAve, bool doSkip, int skip,
+                           double minX, double minY, double stepX, double stepY);
 
     // internal update function, called by update()
     Object::UpdateType doUpdate(bool force = false);
--- branches/work/kst/portto4/kst/src/libkst/matrixfactory.cpp #768341:768342
@@ -167,6 +167,7 @@
 
   bool doAve, doSkip;
   int requestedXStart, requestedYStart, requestedXCount, requestedYCount, skip;
+  double minX, minY, stepX, stepY;
   QString provider, file, field;
 
   while (!xml.atEnd()) {
@@ -185,6 +186,10 @@
         doAve = attrs.value("doave").toString() == "true" ? true : false;
         doSkip = attrs.value("doskip").toString() == "true" ? true : false;
         skip = attrs.value("skip").toString().toInt();
+        minX = attrs.value("xmin").toString().toDouble();
+        minY = attrs.value("ymin").toString().toDouble();
+        stepX = attrs.value("xstep").toString().toDouble();
+        stepY = attrs.value("ystep").toString().toDouble();
       } else {
         return 0;
       }
@@ -211,7 +216,7 @@
   }
 
   DataMatrixPtr matrix = store->createObject<DataMatrix>(tag);
-  matrix->change(dataSource, field, requestedXStart, requestedYStart, requestedXCount, requestedYCount, doAve, doSkip, skip);
+  matrix->change(dataSource, field, requestedXStart, requestedYStart, requestedXCount, requestedYCount, doAve, doSkip, skip, minX, minY, stepX, stepY);
 
   matrix->writeLock();
   matrix->update(0);


More information about the Kst mailing list