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

Barth Netterfield netterfield at astro.utoronto.ca
Mon Aug 29 18:29:33 UTC 2011


SVN commit 1250197 by netterfield:

plot->rmb->edit can edit curves or images.

Plot dialog->range tab now works correctly in log mode.


 M  +22 -10    plotitem.cpp  
 M  +1 -0      plotitem.h  
 M  +0 -37     plotitemdialog.cpp  
 M  +19 -6     rangetab.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1250196:1250197
@@ -575,8 +575,7 @@
 }
 
 
-CurveList PlotItem::curveList() const
-{
+CurveList PlotItem::curveList() const {
   CurveList list;
   foreach (PlotRenderItem *renderer, renderItems()) {
     foreach (RelationPtr relation, renderer->relationList()) {
@@ -589,6 +588,18 @@
 }
 
 
+RelationList PlotItem::relationList() const {
+  RelationList list;
+  foreach (PlotRenderItem *renderer, renderItems()) {
+    foreach (RelationPtr relation, renderer->relationList()) {
+      list << relation;
+    }
+  }
+
+  return list;
+}
+
+
 void PlotItem::createFilterMenu() {
   if (_filterMenu) {
     delete _filterMenu;
@@ -613,9 +624,9 @@
   _editMenu = new QMenu;
   _editMenu->setTitle(tr("Edit"));
 
-  CurveList curves = curveList();
-  foreach (const CurvePtr& curve, curves) {
-    _editMenu->addAction(new QAction(curve->Name(), this));
+  RelationList relations = relationList();
+  foreach (const RelationPtr& relation, relations) {
+    _editMenu->addAction(new QAction(relation->Name(), this));
   }
   connect(_editMenu, SIGNAL(triggered(QAction*)), this, SLOT(showEditDialog(QAction*)));
 }
@@ -696,16 +707,17 @@
 
 
 void PlotItem::showEditDialog(QAction *action) {
-  CurveList curves = curveList();
-  int n = curves.size();
+  RelationList relations = relationList();
+  int n = relations.size();
   for (int i = 0; i<n; i++) {
-    CurvePtr curve = curves.at(i);
-    if (curve->Name() == action->text()) {
-      DialogLauncher::self()->showCurveDialog(curve);
+    RelationPtr relation = relations.at(i);
+    if (relation->Name() == action->text()) {
+      DialogLauncher::self()->showObjectDialog(relation);
     }
   }
 }
 
+
 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 #1250196:1250197
@@ -426,6 +426,7 @@
 
     void showFitFilterDialog(QAction* action, const QString& plugin);
     CurveList curveList() const;
+    RelationList relationList() const;
 
   private:
     QHash<PlotRenderItem::RenderType, PlotRenderItem*> _renderers;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #1250196:1250197
@@ -564,47 +564,16 @@
   qreal xRange = _rangeTab->xRangeDirty() ? _rangeTab->xRange() :fabs(item->xMax() - item->xMin());
   qreal xMax = _rangeTab->xMaxDirty() ? _rangeTab->xMax() :item->xMax();
   qreal xMin = _rangeTab->xMinDirty() ? _rangeTab->xMin() :item->xMin();
-  if (item->xAxis()->axisLog()) {
-    if (xMax != item->xMax()) {
-      xMax = pow(10, xMax);
-    } else {
-      xMax = item->projectionRect().right();
-    }
-    if (xMin != item->xMin()) {
-      xMin = pow(10, xMin);
-    } else {
-      xMin = item->projectionRect().left();
-    }
-  }
 
   qreal yRange = _rangeTab->yRangeDirty() ? _rangeTab->yRange() :fabs(item->yMax() - item->yMin());
   qreal yMax = _rangeTab->yMaxDirty() ? _rangeTab->yMax() :item->yMax();
   qreal yMin = _rangeTab->yMinDirty() ? _rangeTab->yMin() :item->yMin();
 
-  if (item->yAxis()->axisLog()) {
-    if (yMax != item->yMax()) {
-      yMax = pow(10, yMax);
-    } else {
-      yMax = item->projectionRect().bottom();
-    }
-    if (yMin != item->yMin()) {
-      yMin = pow(10, yMin);
-    } else {
-      yMin = item->projectionRect().top();
-    }
-  }
-
   zoomstate.item = item;
 
   if ((_rangeTab->xModeDirty() && _rangeTab->xMean()) || (!_rangeTab->xModeDirty() && zoomstate.xAxisZoomMode == PlotAxis::MeanCentered)) {
-    if (item->xAxis()->axisLog()) {
-      qreal min = (item->xMin() + item->xMax() - xRange) / 2.0;
-      newXMin = pow(10, min);
-      newXMax = pow(10, min+xRange);
-    } else {
       newXMax = xRange;
       newXMin = (item->xMin() + item->xMax() - newXMax)/2.0;
-    }
   } else {
     newXMin = qMin(xMax, xMin);
     newXMax = fabs(xMax - xMin);
@@ -612,14 +581,8 @@
   if (newXMax == 0.0) newXMax = 0.2;
 
   if ((_rangeTab->yModeDirty() && _rangeTab->yMean()) || (!_rangeTab->yModeDirty() && zoomstate.yAxisZoomMode == PlotAxis::MeanCentered)) {
-    if (item->yAxis()->axisLog()) {
-      qreal min = (item->yMin() + item->yMax() - yRange) / 2.0;
-      newYMin = pow(10, min);
-      newYMax = pow(10, min+yRange);
-    } else {
       newYMax = yRange;
       newYMin = (item->yMin() + item->yMax() - newYMax)/2.0;
-    }
   } else {
     newYMin = qMin(yMax, yMin);
     newYMax = fabs(yMax - yMin);
--- branches/work/kst/portto4/kst/src/libkstapp/rangetab.cpp #1250196:1250197
@@ -55,14 +55,27 @@
 void RangeTab::setupRange() {
   Q_ASSERT(_plotItem);
 
-  _xRange->setText(QString::number(fabs(_plotItem->xMax() - _plotItem->xMin()),'g', 13));
-  _xMin->setText(QString::number(_plotItem->xMin(),'g', 13));
-  _xMax->setText(QString::number(_plotItem->xMax(),'g', 13));
+  double xmax = _plotItem->xMax();
+  double xmin = _plotItem->xMin();
+  double ymax = _plotItem->yMax();
+  double ymin = _plotItem->yMin();
+  if (_plotItem->xAxis()->axisLog()) {
+    xmax = exp10(xmax);
+    xmin = exp10(xmin);
+  }
+  if (_plotItem->yAxis()->axisLog()) {
+    ymax = exp10(ymax);
+    ymin = exp10(ymin);
+  }
 
-  _yRange->setText(QString::number(fabs(_plotItem->yMax() - _plotItem->yMin()),'g', 13));
-  _yMin->setText(QString::number(_plotItem->yMin(),'g', 13));
-  _yMax->setText(QString::number(_plotItem->yMax(),'g', 13));
+  _xRange->setText(QString::number(fabs(xmax - xmin),'g', 13));
+  _xMin->setText(QString::number(xmin,'g', 13));
+  _xMax->setText(QString::number(xmax,'g', 13));
 
+  _yRange->setText(QString::number(fabs(ymax - ymin),'g', 13));
+  _yMin->setText(QString::number(ymin,'g', 13));
+  _yMax->setText(QString::number(ymax,'g', 13));
+
   switch (_plotItem->xAxis()->axisZoomMode()) {
     case PlotAxis::Auto:
       _xAuto->setChecked(true);


More information about the Kst mailing list