Bug 72206 - Data Mode should have visual feedback
Summary: Data Mode should have visual feedback
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: George Staikos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-09 01:30 UTC by Netterfield
Modified: 2004-01-17 15:26 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Netterfield 2004-01-09 01:30:36 UTC
Version:           0.95-devel (using KDE 3.1.3)
Compiler:          gcc version 3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk)
OS:          Linux (i686) release 2.4.22-10mdk

Data Mode should provide visual feedback as to what point is being displayed - perhaps a small secondary x cursor over the point?
Comment 1 George Staikos 2004-01-09 04:11:25 UTC
Subject: Re: [Kst]  New: Data Mode should have visual feedback

On Thursday 08 January 2004 19:30, netterfield@astro.utoronto.ca wrote:
> Data Mode should provide visual feedback as to what point is being
> displayed - perhaps a small secondary x cursor over the point?

  Hm I had started on this at one time but I guess I never finished it.  I'll 
put it back on my list.

Comment 2 George Staikos 2004-01-17 15:26:21 UTC
Subject: kdeextragear-2/kst/kst

CVS commit by staikos: 


after a marathon session of tuning and tweaking the coordinates, I finally have
the datamode cursor working.  It isn't pretty and it flickers a little bit, but
it works.
CCMAIL: 72206-done@bugs.kde.org


  M +2 -0      kstbasecurve.cpp   1.7
  M +120 -90   kstplot.cpp   1.34
  M +1 -0      kstplot.h   1.19
  M +6 -1      kstview.cpp   1.74


--- kdeextragear-2/kst/kst/kstbasecurve.cpp  #1.6:1.7
@@ -46,2 +46,4 @@ KstBaseCurve::~KstBaseCurve() {
 }
 
+
+// vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kstplot.cpp  #1.33:1.34
@@ -19,4 +19,6 @@
 #include <limits.h>
 
+#include <kdebug.h>
+
 #include <qpainter.h>
 #include <qrect.h>
@@ -876,4 +878,28 @@ void KstPlot::setBorders(double &xleft_b
 }
 
+
+void KstPlot::drawDotAt(QPainter& p, double x, double y) {
+  if (XLog) {
+    x = x > 0 ? log10(x) : -350;
+  }
+  if (YLog) {
+    y = y > 0 ? log10(y) : -350;
+  }
+
+  double x_min, x_max, y_min, y_max;
+  double X1, Y1;
+  getLScale(x_min, y_min, x_max, y_max);
+
+  X1 = PlotRegion.width() * (x - x_min) / (x_max - x_min) + PlotRegion.left();
+  Y1 = PlotRegion.height() * (y_max - y) / (y_max - y_min) + PlotRegion.top();
+
+  p.setPen(QPen(QColor(0,0,0), 0));
+  p.drawArc(X1 - 3, Y1 - 3, 6, 6, 0, 5760);
+  p.setPen(QPen(QColor(255,0,0), 0));
+  p.drawArc(X1 - 2, Y1 - 2, 4, 4, 0, 5760);
+  p.drawArc(X1 - 1, Y1 - 1, 2, 2, 0, 5760);
+}
+
+
 void KstPlot::paint(QPainter &p, double in_xleft_bdr_px, bool printMode) {
   double XTick, YTick, Xorg, Yorg; // Tick interval and position
@@ -1661,2 +1690,3 @@ void KstPlot::setTied(bool in_tied) {
 }
 
+// vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kstplot.h  #1.18:1.19
@@ -62,4 +62,5 @@ public:
 
   void paint(QPainter &pd, double X_LeftBorder=0, bool printMode = false);
+  void drawDotAt(QPainter& p, double x, double y);
   double getXBorder(QPainter &p);
   void addCurve(KstBaseCurve *curve);

--- kdeextragear-2/kst/kst/kstview.cpp  #1.73:1.74
@@ -419,5 +419,5 @@ void KstView::updateMouse() {
         int pt = int((*i)->sampleCount() * xpos / ((*i)->maxX() - (*i)->minX()));
 
-        pt -= (*i)->minX();
+        pt -= int((*i)->minX());
 
         if (pt < 0) {
@@ -438,7 +438,12 @@ void KstView::updateMouse() {
         _copy_x = newxpos;
         _copy_y = newypos;
+        
+        repaint(false);
+        QPainter p(this);
+        pPlot->drawDotAt(p, newxpos, newypos);
         emit newDataMsg(msg);
         return;
       }
+      repaint(false);
       emit newDataMsg(QString::null);
       return;