[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Thu Apr 15 20:56:12 CEST 2004


CVS commit by arwalker: 

Some minor improvements to data mode:

* remove the flicker when the mouse is moved, but the same data point remains selected
* draw the data mode indicator more efficiently

Also, if the x vector is not monotonic then we are stuck doing a linear search (N) for the nearest point. It might be worthwhile to do a quicksort of the vector (NlogN) which would initially be more costly but subsequent mouse moves would be much quicker. Given that there will generally be a lot of mouse moves while in data mode it will most likely be more efficient in the long run.


  M +5 -7      kstplot.cpp   1.44
  M +18 -10    kstview.cpp   1.91


--- kdeextragear-2/kst/kst/kstplot.cpp  #1.43:1.44
@@ -888,12 +888,10 @@ void KstPlot::drawDotAt(QPainter& p, dou
   Y1 = int(PlotRegion.height() * (y_max - y) / (y_max - y_min) + PlotRegion.top());
 
-  if (!PlotRegion.contains(X1, Y1)) {
-    return;
-  }
+  if (PlotRegion.contains(X1, Y1)) {
+    p.setPen(QPen(QColor(255,0,0), 2));
+    p.drawArc((int)X1 - 2, (int)Y1 - 2, 4, 4, 0, 5760);
   p.setPen(QPen(QColor(0,0,0), 0));
   p.drawArc((int)X1 - 3, (int)Y1 - 3, 6, 6, 0, 5760);
-  p.setPen(QPen(QColor(255,0,0), 0));
-  p.drawArc((int)X1 - 2, (int)Y1 - 2, 4, 4, 0, 5760);
-  p.drawArc((int)X1 - 1, (int)Y1 - 1, 2, 2, 0, 5760);
+  }
 }
 

--- kdeextragear-2/kst/kst/kstview.cpp  #1.90:1.91
@@ -440,4 +440,7 @@ void KstView::update() {
   needrecreate = true;
   paintEvent(NULL);
+  
+  _copy_x = KST::NOPOINT;
+  _copy_y = KST::NOPOINT;
   updateMouse();
 }
@@ -491,7 +494,4 @@ void KstView::updateMouse() {
       int i_near_x;
       KstBaseCurvePtr curve;
-      msg = "";
-      repaint(false);
-      QPainter p(this);
 
       for (KstBaseCurveList::Iterator i = pPlot->Curves.begin();
@@ -509,4 +509,6 @@ void KstView::updateMouse() {
       if (curve.data()) {
         msg = i18n("%3 (%1, %2)").arg(newxpos).arg(newypos,0,'G').arg(curve->tagName());
+        if( _copy_x != newxpos ||
+            _copy_y != newypos ) {
         _copy_x = newxpos;
         _copy_y = newypos;
@@ -516,6 +518,10 @@ void KstView::updateMouse() {
         pPlot->drawDotAt(p, newxpos, newypos);
         emit newDataMsg(msg);
+        }
         return;
       }
+      
+      _copy_x = KST::NOPOINT;
+      _copy_y = KST::NOPOINT;
       repaint(false);
       emit newDataMsg(QString::null);
@@ -1581,4 +1587,6 @@ void KstView::cleanupLayout() {
 void KstView::setDataMode(bool on) {
   _dataMode = on;
+  _copy_x = KST::NOPOINT;
+  _copy_y = KST::NOPOINT;
   updateMouse();
 }





More information about the Kst mailing list