Bug 125299 - when axes are reversed, mouse zooming is borked
Summary: when axes are reversed, mouse zooming is borked
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-10 18:51 UTC by Matthew Truch
Modified: 2006-06-07 20:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Truch 2006-04-10 18:51:10 UTC
Version:           1.2.1 (using KDE KDE 3.5.1)
Installed from:    Fedora RPMs
OS:                Linux

Example:

Plot an image (fits image, for example).
Reverse one of the axes (like the x axis).
Zoom into a part of the plot with either x zoom mode or y zoom mode.
Note how it zoomed into the wrong region (nearly opposite of what you wanted).  
xy zoom seems to work correctly.

If you un-reverse the axis, further zooming will work ok.
Comment 1 Duncan Hanson 2006-05-08 22:42:41 UTC
fixed- copy and paste from the XY_ZOOMBOX case in Kst2DPlot::mouseReleaseEvent.

I don't have the permission bits to close this bug right now. I will do it when I get them.
Comment 2 Duncan Hanson 2006-05-11 21:10:48 UTC
*** Bug has been marked as fixed ***.
Comment 3 Duncan Hanson 2006-06-07 19:22:17 UTC
This bug can still apply if axes are logarithmic.
Comment 4 Duncan Hanson 2006-06-07 19:43:04 UTC
SVN commit 549185 by dhanson:

CCBUG:125299 partial fix. change the way that dx_per_pix is calculated slightly. redo calculation of dy_per_pix. there will still be problems with 1) clicking on lines in logarithmic graphs. I don't see an easy way to solve this.

 M  +19 -10    kst2dplot.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #549184:549185
@@ -6081,6 +6081,7 @@
 
 
 void Kst2DPlot::mouseDoubleClickEvent(QWidget *view, QMouseEvent *e) {
+  // allow user to edit a curve if click was close enough.
   Q_UNUSED(view)
   KstBaseCurvePtr curve;
   QRect pr = GetPlotRegion();
@@ -6091,28 +6092,36 @@
 
   getCursorPos(pos, xpos, ypos, xmin, xmax, ymin, ymax);
 
-  // convert 1 pixel to plot units.
-  double dx_per_pix = double(pos.x() + 2 - pr.left()) / double(pr.width()) * (xmax - xmin) + xmin;
-  if (isXLog()) {
-    dx_per_pix = pow(_xLogBase, dx_per_pix);
+  // calculate max x distance.
+  double dx_per_pix;
+  if (!isXLog()) {
+    dx_per_pix = (xmax - xmin)/pr.width();
+  } else {
+    dx_per_pix = xpos*log(_xLogBase)*(xmax - xmin)/pr.width();
   }
-  dx_per_pix -= xpos;
-  double dx = 5*dx_per_pix;
+  double dx = fabs(5.0*dx_per_pix); //~5 pixels.
 
+  // calculate max y distance.
+  double dy_per_pix;
+  if (!isYLog()) {
+    dy_per_pix = (ymin - ymax)/pr.height();
+  } else {
+    dy_per_pix = ypos*log(_yLogBase)*(ymin - ymax)/pr.height();
+  }
+  double dy = fabs(5.0*dy_per_pix); //~5 pixels.
+
   for (KstBaseCurveList::Iterator i = Curves.begin(); i != Curves.end(); ++i) {
     (*i)->readLock();
     double distance = (*i)->distanceToPoint(xpos, dx, ypos);
     (*i)->readUnlock();
-    if (isYLog()) {
-      distance = log(distance);
-    }
+
     if (distance < best_distance || !curve) {
       best_distance = distance;
       curve = *i;
     }
   }
 
-  if (curve && fabs(best_distance * pr.height() / (ymax - ymin)) <= 5) {
+  if (curve && fabs(best_distance) <= dy) {
     curve->readLock();
     KstDataObjectPtr provider = curve->providerDataObject();
     if (provider) {
Comment 5 Duncan Hanson 2006-06-07 20:07:18 UTC
last two comments actually apply to BUG117822.