[Kst] [Bug 94345] Click on a legend entry to edit a curve

George Staikos staikos at kde.org
Thu Jan 20 00:13:02 CET 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=94345         
staikos kde org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From staikos kde org  2005-01-20 00:12 -------
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);


More information about the Kst mailing list