Bug 94345 - Click on a legend entry to edit a curve
Summary: Click on a legend entry to edit a curve
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.0.0
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-03 20:13 UTC by D. V. Wiebe
Modified: 2005-01-20 00:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch to implement something like this feature (2.92 KB, patch)
2005-01-17 08:42 UTC, George Staikos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description D. V. Wiebe 2004-12-03 20:13:25 UTC
Version:           1.0.0 (using KDE 3.3.1, compiled sources)
Compiler:          gcc version 3.3.4
OS:                Linux (i686) release 2.6.9

When not in label editor mode, I find myself clicking on curves in the legend box in a vain attempt to pull up the edit curve dialog.  This would be a convenient shortcut in place of having to use the context menu.
Comment 1 Andrew Walker 2004-12-14 00:49:00 UTC
One problem would be that left-click is reserved for zooming and right-click for the context menu. To achieve the desired effect we'd either have to disallow a zoom operation which starts under the legend, or use a modifier key with a right-click, as the left-click + modifier are all used for zooming.

Its seem doubtful that a modifier key with a right-click is any longer much of a shortcut.
Comment 2 George Staikos 2004-12-14 01:28:43 UTC
  Let's wait until we have view labels.  Legends will change then and we can 
redesign it as we need.

Comment 3 Netterfield 2005-01-11 04:12:27 UTC
I agree with all points, including the original poster... I have often done the same thing, even though I know it won't work.

We can
i) use double click: it's not currently assigned to anything, and is sort of a 'select' kind of action.
ii) close the bug as wontfix for the reasons outlined by Andrew

Opinions?
Comment 4 George Staikos 2005-01-17 08:42:15 UTC
Created attachment 9133 [details]
patch to implement something like this feature

This patch makes it so that a double click that is close to a curve (not in the
legend, but inside the plot itself) opens the curve properties or the data
object properties, depending on which seems more applicable.  The same code
could easily be applied to legends if desired, but the legend needs a way to
map an entry back to its curve object.
Comment 5 George Staikos 2005-01-20 00:12:57 UTC
CVS commit by staikos: 

Double click near a curve (within 5 pixels) opens an editor for the best-guessed
properties of that curve.  For instance, equation editor, PSD editor, Plugin
editor, or curve editor.  There is a little bug with log plots I think.  Blast
folks say this is sufficient as an alternative for clicking on the legend.
FEATURE: 94345


  M +63 -0     kst2dplot.cpp   1.359
  M +1 -0      kst2dplot.h   1.141


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.358:1.359
@@ -6461,4 +6461,67 @@ QString Kst2DPlot::menuTitle() const {
 }
 
+
+void Kst2DPlot::mouseDoubleClickEvent(QWidget *view, QMouseEvent *e) {
+  Q_UNUSED(view)
+  KstBaseCurvePtr curve;
+  QRect pr = GetPlotRegion();
+  QPoint pos = e->pos();
+  int i_near_x;
+  double best_distance = 1.0E300;
+  double xmin, ymin, xmax, ymax;
+  getLScale(xmin, ymin, xmax, ymax);
+
+  // find mouse location in plot units
+  double xpos = double(pos.x() - pr.left())/double(pr.width()) * (xmax - xmin) + xmin;
+  if (isXLog()) {
+    xpos = pow(10.0, xpos);
+  }
+
+  double ypos = double(pos.y() - pr.top()) / double(pr.height()) * (ymin - ymax) + ymax;
+
+  if (isYLog()) {
+    ypos = pow(10.0, ypos);
+  }
+
+  // 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(10.0, dx_per_pix);
+  }
+  dx_per_pix -= xpos;
+
+  for (KstBaseCurveList::Iterator i = Curves.begin(); i != Curves.end(); ++i) {
+    i_near_x = (*i)->getIndexNearXY(xpos, dx_per_pix, ypos);
+    double near_x, near_y;
+    (*i)->point(i_near_x, near_x, near_y);
+    double distance = fabs(ypos - near_y);
+    if (distance < best_distance || curve.data() == 0L) {
+      best_distance = distance;
+      curve = *i;
+    }
+  }
+
+  if (curve && best_distance/fabs((ymax - ymin) / pr.height()) <= 5) {
+    KST::vectorList.lock().readLock();
+    KstVectorPtr vp = *KST::vectorList.findTag(curve->yVTag());
+    KST::vectorList.lock().readUnlock();
+    KstDataObjectPtr provider;
+    if (vp) {
+      vp->readLock();
+      provider = kst_cast<KstDataObject>(vp->provider());
+      vp->readUnlock();
+    }
+
+    if (provider) {
+      provider->showDialog();
+    } else {
+      curve->showDialog();
+    }
+  }
+
+  e->accept();
+}
+
+
 #undef LABEL_PRECISION
 #include "kst2dplot.moc"

--- kdeextragear-2/kst/kst/kst2dplot.h  #1.140:1.141
@@ -193,4 +193,5 @@ public:
   virtual void mouseMoveEvent(QWidget *view, QMouseEvent *e);
   virtual void mousePressEvent(QWidget *view, QMouseEvent *e);
+  virtual void mouseDoubleClickEvent(QWidget *view, QMouseEvent *e);
   virtual void mouseReleaseEvent(QWidget *view, QMouseEvent *e);
   virtual void keyPressEvent(QWidget *view, QKeyEvent *e);