[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Thu Nov 17 01:23:30 CET 2005


SVN commit 480904 by staikos:

keep the testcases compiling.  this can be removed once it's moved into a
common file in the testcases directory. -- after 1.2.0dr


 M  +37 -0     kstvector.cpp  
 M  +4 -0      kstvector.h  


--- trunk/extragear/graphics/kst/kst/kstvector.cpp #480903:480904
@@ -459,6 +459,43 @@
 }
 
 
+KstVectorPtr KstVector::generateVector(double x0, double x1, int n, const QString &tag) {
+  if (n < 2) {
+    n = 2;
+  }
+
+  if (x0 > x1) {
+    double tx;
+    tx = x0;
+    x0 = x1;
+    x1 = tx;
+  }
+
+  if (x0 == x1) {
+    x1 = x0 + 0.1;
+  }
+
+  QString t = tag;
+  if (t.isEmpty()) {
+    t = KST::suggestVectorName("X(" + QString::number(x0) + ".." + QString::number(x1) + ")");
+  }
+
+  KstVectorPtr xv = new KstVector(t, n);
+  KST::addVectorToList(xv);
+  xv->_saveable = false;
+
+  for (int i = 0; i < n; i++) {
+    xv->value()[i] = x0 + double(i) * (x1 - x0) / (n - 1);
+  }
+
+  xv->_scalars["min"]->setValue(x0);
+  xv->_scalars["max"]->setValue(x1);
+  xv->updateScalars();
+
+  return xv;
+}
+
+
 void KstVector::setProvider(KstObject* obj) {
   _provider = obj;
 }
--- trunk/extragear/graphics/kst/kst/kstvector.h #480903:480904
@@ -122,6 +122,10 @@
     /** Update the vector.  Return true if there was new data. */
     virtual UpdateType update(int update_counter = -1);
 
+    /** Generate a new vector [x0..x1] with n total points */
+    // #### Remove
+    static KstVectorPtr generateVector(double x0, double x1, int n, const QString& tag);
+
     virtual void setTagName(const QString& newTag);
 
     /** Return a pointer to the raw vector */


More information about the Kst mailing list