[Kst] branches/work/kst/portto4/kst/src/libkstapp

Barth Netterfield netterfield at astro.utoronto.ca
Thu Aug 25 15:44:28 UTC 2011


SVN commit 1249511 by netterfield:

BUG:

fix double click to it actually selects the closest curve.

Feature:
Add rmb->edit curve menu to plots.



 M  +34 -0     plotitem.cpp  
 M  +3 -2      plotitem.h  
 M  +1 -1      plotrenderitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1249510:1249511
@@ -96,6 +96,7 @@
   _zoomMenu(0),
   _filterMenu(0),
   _fitMenu(0),
+  _editMenu(0),
   _sharedAxisBoxMenu(0),
   _sharedBox(0),
   _axisLabelsDirty(true),
@@ -283,6 +284,8 @@
   delete _numberLabelDetails;
   delete _zoomMenu;
   delete _filterMenu;
+  delete _fitMenu;
+  delete _editMenu;
 
   PlotItemManager::self()->removePlot(this);
 }
@@ -602,6 +605,22 @@
 }
 
 
+void PlotItem::createEditMenu() {
+  if (_editMenu) {
+    delete _editMenu;
+  }
+
+  _editMenu = new QMenu;
+  _editMenu->setTitle(tr("Edit"));
+
+  CurveList curves = curveList();
+  foreach (const CurvePtr& curve, curves) {
+    _editMenu->addAction(new QAction(curve->Name(), this));
+  }
+  connect(_editMenu, SIGNAL(triggered(QAction*)), this, SLOT(showEditDialog(QAction*)));
+}
+
+
 void PlotItem::createFitMenu() {
   if (_fitMenu) {
     delete _fitMenu;
@@ -669,9 +688,24 @@
     createFitMenu();
     menu.addMenu(_fitMenu);
   }
+  if (curveList().size()>0) {
+    createEditMenu();
+    menu.addMenu(_editMenu);
 }
+}
 
 
+void PlotItem::showEditDialog(QAction *action) {
+  CurveList curves = curveList();
+  int n = curves.size();
+  for (int i = 0; i<n; i++) {
+    CurvePtr curve = curves.at(i);
+    if (curve->Name() == action->text()) {
+      DialogLauncher::self()->showCurveDialog(curve);
+    }
+  }
+}
+
 void PlotItem::showFitFilterDialog(QAction* action, const QString& plugin) {
   CurveList curves = curveList();
   foreach (const CurvePtr& curve, curves) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #1249510:1249511
@@ -343,6 +343,7 @@
 
     void showFilterDialog(QAction*);
     void showFitDialog(QAction*);
+    void showEditDialog(QAction *action);
 
     void setLeftLabelDirty() { _leftLabel.dirty = true; setPlotPixmapDirty(); }
     void setRightLabelDirty() { _rightLabel.dirty = true; setPlotPixmapDirty(); }
@@ -358,6 +359,7 @@
     void createZoomMenu();
     void createFilterMenu();
     void createFitMenu();
+    void createEditMenu();
     void createSharedAxisBoxMenu();
 
     void resetSelectionRect();
@@ -531,9 +533,8 @@
     QAction *_adjustImageColorscale;
 
     QMenu *_filterMenu;
-    QAction *_filterAction;
     QMenu *_fitMenu;
-    QAction *_fitAction;
+    QMenu *_editMenu;
     QMenu *_sharedAxisBoxMenu;
     QAction *_shareBoxShareX;
     QAction *_shareBoxShareY;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #1249510:1249511
@@ -526,7 +526,7 @@
 
 void PlotRenderItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
   const QPointF point = plotItem()->mapToProjection(event->pos());
-  qreal range = qMax(plotItem()->xMax() - plotItem()->xMin(), plotItem()->yMax() - plotItem()->yMin());
+  qreal range = 4.0*(plotItem()->xMax() - plotItem()->xMin())/double(rect().width());
   double distance = 1000;
   bool first = true;
   RelationPtr closestRelation = 0;


More information about the Kst mailing list