[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Tue Jan 27 03:54:31 CET 2004


CVS commit by staikos: 

Make datamode work on shifted vectors with an absolutely disgusting hack that
really should be removed ASAP.  SamplesPerFrame should be completely
encapsulated within the vector and curve I think, but it isn't presently which
means I need to pass it out via kstbasecurve and use it in kstview.  This
feels really wrong to me.

CCMAIL: 72204-done at bugs.kde.org


  M +2 -0      kstbasecurve.h   1.12
  M +16 -11    kstvcurve.cpp   1.23
  M +2 -0      kstvcurve.h   1.17
  M +9 -4      kstview.cpp   1.76


--- kdeextragear-2/kst/kst/kstbasecurve.h  #1.11:1.12
@@ -82,4 +82,6 @@ public:
   virtual bool xIsRising() const {return false;}
 
+  virtual int samplesPerFrame() const { return 1; }
+
   KstPoint Point;
 

--- kdeextragear-2/kst/kst/kstvcurve.cpp  #1.22:1.23
@@ -223,19 +223,19 @@ bool KstVCurve::hasYError() const {
 /** Save curve information */
 void KstVCurve::save(QTextStream &ts) {
-  ts << " <curve>\n";
-  ts << "  <tag>" << _tag << "</tag>\n";
-  ts << "  <xvectag>" << VX->tagName() << "</xvectag>\n";
-  ts << "  <yvectag>" << VY->tagName() << "</yvectag>\n";
+  ts << " <curve>" << endl;
+  ts << "  <tag>" << _tag << "</tag>" << endl;
+  ts << "  <xvectag>" << VX->tagName() << "</xvectag>" << endl;
+  ts << "  <yvectag>" << VY->tagName() << "</yvectag>" << endl;
   if (EX.data()) {
-    ts << "  <exVectag>" << EX->tagName() << "</exVectag>";
+    ts << "  <exVectag>" << EX->tagName() << "</exVectag>" << endl;
   }
   if (EY.data()) {
-    ts << "  <eyVectag>" << EY->tagName() << "</eyVectag>";
+    ts << "  <eyVectag>" << EY->tagName() << "</eyVectag>" << endl;
   }
-  ts << "  <color>" << Color.name() << "</color>\n";
-  ts << "  <hasLines>" << HasLines << "</hasLines>\n";
-  ts << "  <hasPoints>" << HasPoints << "</hasPoints>\n";
-  ts << "  <pointType>" << Point.getType() << "</pointType>\n";
-  ts << " </curve>\n";
+  ts << "  <color>" << Color.name() << "</color>" << endl;
+  ts << "  <hasLines>" << HasLines << "</hasLines>" << endl;
+  ts << "  <hasPoints>" << HasPoints << "</hasPoints>" << endl;
+  ts << "  <pointType>" << Point.getType() << "</pointType>" << endl;
+  ts << " </curve>" << endl;
 }
 
@@ -280,2 +280,7 @@ void KstVCurve::_showDialog() {
 }
 
+int KstVCurve::samplesPerFrame() const {
+  const KstRVector *rvp = dynamic_cast<const KstRVector*>(VY.data());
+  return rvp ? rvp->samplesPerFrame() : 1;
+}
+

--- kdeextragear-2/kst/kst/kstvcurve.h  #1.16:1.17
@@ -76,4 +76,6 @@ public:
   virtual double ns_minY()    const { return _ns_miny; }
 
+  virtual int samplesPerFrame() const;
+
 protected:
   virtual void _showDialog();

--- kdeextragear-2/kst/kst/kstview.cpp  #1.75:1.76
@@ -416,12 +416,17 @@ void KstView::updateMouse() {
 
       for (KstBaseCurveList::Iterator i = pPlot->Curves.begin(); i != pPlot->Curves.end(); ++i) {
+        int left = 0;
+        int right = left + (*i)->sampleCount();
         double xpt = 0.0, ypt = 0.0;
-        int pt = int((*i)->sampleCount() * xpos / ((*i)->maxX() - (*i)->minX()));
+        int pt = int((right - left) * xpos / ((*i)->maxX() - (*i)->minX()));
 
-        pt -= int((*i)->minX());
+        pt -= (*i)->samplesPerFrame() * int((*i)->minX());
+
+        //kdDebug() << "[" << (*i)->minX() << ".." << (*i)->maxX() << "] n=" << (*i)->sampleCount() << " SPF: " << (*i)->samplesPerFrame() << " GETTING POINT: " << pt << endl;
+        //kdDebug() << "LEFT: " << left << " RIGHT: " << right << endl;
 
         double ydiff, xdiff, nd;
 
-        if (pt >= 0 && pt < (*i)->sampleCount()) {
+        if (pt >= left && pt < right) {
           (*i)->getPoint(pt, xpt, ypt);
           ydiff = ypos - ypt;
@@ -439,5 +444,5 @@ void KstView::updateMouse() {
         // This doesn't help us with very vertical regions though.
         pt++;
-        if (pt >= (*i)->sampleCount() || pt < 0) {
+        if (pt >= right || pt < left) {
           continue;
         }





More information about the Kst mailing list