| Summary: | when axes are reversed, mouse zooming is borked | ||
|---|---|---|---|
| Product: | [Applications] kst | Reporter: | Matthew Truch <matt> |
| Component: | general | Assignee: | kst |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | kst |
| Priority: | NOR | ||
| Version First Reported In: | 1.x | ||
| Target Milestone: | --- | ||
| Platform: | Fedora RPMs | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Matthew Truch
2006-04-10 18:51:10 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. *** Bug has been marked as fixed ***. This bug can still apply if axes are logarithmic. 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) {
|