[Kst] extragear/graphics/kst/kst/datasources/ascii

Rick Chern rchern at interchange.ubc.ca
Thu Jul 14 01:53:33 CEST 2005


SVN commit 434407 by rchern:

Changes to AsciiSource test implementation for matrix functions

 M  +21 -24    ascii.cpp  
 M  +1 -4      ascii.h  


--- trunk/extragear/graphics/kst/kst/datasources/ascii/ascii.cpp #434406:434407
@@ -161,7 +161,6 @@
   _valid = false;
   _haveHeader = false;
   _fieldListComplete = false;
-  _matrixListComplete = false;
   if (!type.isEmpty() && type != "ASCII") {
     return;
   }
@@ -210,7 +209,6 @@
 
   _haveHeader = false;
   _fieldListComplete = false;
-  _matrixListComplete = false;
   _fieldList.clear();
 
   update(); // Yuck - same problem as in the constructor presently.
@@ -349,25 +347,23 @@
 }
 
 
-bool AsciiSource::matrixListIsComplete() const {
-  return _matrixListComplete;  
-}
-
-
 bool AsciiSource::matrixDimensions(const QString& matrix, int* xDim, int* yDim) {
+  
   if (!isValidMatrix(matrix)) {
     return false;  
   }
+
   // total frames in the matrix
   int totalFrames = frameCount(matrix);
+  
   // y dimension is in the matrix name
-  *yDim = matrix.section(' ', 1).toInt();
+  *yDim = matrix.section(',', 1,1).toInt();
   *xDim = totalFrames / (*yDim); // the last row doesn't count
   return true;
 }
 
 
-int AsciiSource::readMatrix(double *z, const QString& matrix, int xStart, int yStart, int xNumSteps, int yNumSteps, double* xMin, double* yMin, double* xStepSize, double* yStepSize) {
+int AsciiSource::readMatrix(KstMatrixData* data, const QString& matrix, int xStart, int yStart, int xNumSteps, int yNumSteps) {
   
   if (!isValidMatrix(matrix)) {
     return 0;  
@@ -377,14 +373,14 @@
   if (xNumSteps == 0 || yNumSteps == 0) {
     return 0;  
   }
-
+  
   // first get matrix parameters - for ascii, this is just in the field name in the
   // form [MATRIX,Y,x,y,w,l]
-  int mYDimension = matrix.section(',', 1).toInt();
-  double mXMin = matrix.section(',', 2).toDouble();
-  double mYMin = matrix.section(',', 3).toDouble();
-  double mXStepSize = matrix.section(',', 4).toDouble();
-  QString mYStepSizeString = matrix.section(',', 5);
+  int mYDimension = matrix.section(',', 1,1).toInt();
+  double mXMin = matrix.section(',', 2,2).toDouble();
+  double mYMin = matrix.section(',', 3,3).toDouble();
+  double mXStepSize = matrix.section(',', 4,4).toDouble();
+  QString mYStepSizeString = matrix.section(',', 5,5);
   mYStepSizeString.truncate(mYStepSizeString.length() - 1);
   double mYStepSize = mYStepSizeString.toDouble();
   
@@ -408,18 +404,20 @@
   } 
   // use readField to read the specified matrix range 
   // (for AsciiSource, all matrix fields are vector fields as well)
-  double* zPos = z;
+  double* zPos = data->z;
   int totalSamples = 0;
-  for (int i = xStart*mYDimension; i < xNumSteps * yNumSteps; i++) {
-    totalSamples += readField(zPos, matrix, 1 + i*mYDimension, yNumSteps);
-    zPos += totalSamples;
+  
+  for (int i = 0; i < xNumSteps; i++) {
+    int samples = readField(zPos, matrix, xStart*mYDimension + i*mYDimension + yStart, yNumSteps);
+    totalSamples += samples;
+    zPos += samples;
   }
   
   // set the suggested matrix transform params
-  *xMin = mXMin;
-  *yMin = mYMin;
-  *xStepSize = mXStepSize;
-  *yStepSize = mYStepSize;
+  data->xMin = mXMin + xStart*mXStepSize;
+  data->yMin = mYMin + yStart*mYStepSize;
+  data->xStepSize = mXStepSize;
+  data->yStepSize = mYStepSize;
   
   return totalSamples;
 }
@@ -689,7 +687,6 @@
     //       w = x step size
     //       l = y step size
     _matrixList = fieldList().grep(QRegExp("^\\[\\w*,\\S*,\\S*,\\S*,\\S*,\\S*\\]$"));
-    _matrixListComplete = _matrixList.count() > 1;
   }
   
   return _matrixList;
--- trunk/extragear/graphics/kst/kst/datasources/ascii/ascii.h #434406:434407
@@ -33,7 +33,7 @@
 
     int readField(double *v, const QString &field, int s, int n);
     
-    virtual int readMatrix(double *z, const QString& matrix, int xStart, int yStart, int xNumSteps, int yNumSteps, double* xMin, double* yMin, double* xStepSize, double* yStepSize);
+    virtual int readMatrix(KstMatrixData* data, const QString& matrix, int xStart, int yStart, int xNumSteps, int yNumSteps);
     
     bool matrixDimensions(const QString& matrix, int* xDim, int* yDim);
     
@@ -62,8 +62,6 @@
     int sampleForTime(const QDateTime& time, bool *ok);
 
     bool fieldListIsComplete() const;
-    
-    bool matrixListIsComplete() const;
 
     bool reset();
 
@@ -82,7 +80,6 @@
     uint _tmpBufSize;
     bool _haveHeader;
     mutable bool _fieldListComplete;
-    mutable bool _matrixListComplete;
 };
 
 


More information about the Kst mailing list