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

Barth Netterfield netterfield at astro.utoronto.ca
Tue Nov 6 23:09:17 CET 2007


SVN commit 733630 by netterfield:

Add Left and Right to the zoom options (I forgot these in the spec).

This easy to work with!

cbn



 M  +61 -0     plotrenderitem.cpp  
 M  +24 -0     plotrenderitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #733629:733630
@@ -407,6 +407,16 @@
   registerShortcut(_zoomXMaximum);
   connect(_zoomXMaximum, SIGNAL(triggered()), this, SLOT(zoomXMaximum()));
 
+  _zoomXRight = new QAction(tr("X-Zoom Right"), this);
+  _zoomXRight->setShortcut(Qt::Key_Right);
+  registerShortcut(_zoomXRight);
+  connect(_zoomXRight, SIGNAL(triggered()), this, SLOT(zoomXRight()));
+
+  _zoomXLeft= new QAction(tr("X-Zoom Left"), this);
+  _zoomXLeft->setShortcut(Qt::Key_Left);
+  registerShortcut(_zoomXLeft);
+  connect(_zoomXLeft, SIGNAL(triggered()), this, SLOT(zoomXLeft()));
+
   _zoomXOut = new QAction(tr("X-Zoom Out"), this);
   _zoomXOut->setShortcut(Qt::SHIFT+Qt::Key_Right);
   registerShortcut(_zoomXOut);
@@ -479,6 +489,8 @@
   zoom.addSeparator();
 
   zoom.addAction(_zoomXMaximum);
+  zoom.addAction(_zoomXRight);
+  zoom.addAction(_zoomXLeft);
   zoom.addAction(_zoomXOut);
   zoom.addAction(_zoomXIn);
   zoom.addAction(_zoomNormalizeXtoY);
@@ -664,6 +676,20 @@
 }
 
 
+void PlotRenderItem::zoomXRight() {
+  qDebug() << "zoomXRight" << endl;
+  ZoomCommand *cmd = new ZoomXRightCommand(this);
+  cmd->redo();
+}
+
+
+void PlotRenderItem::zoomXLeft() {
+  qDebug() << "zoomXLeft" << endl;
+  ZoomCommand *cmd = new ZoomXLeftCommand(this);
+  cmd->redo();
+}
+
+
 void PlotRenderItem::zoomXOut() {
   qDebug() << "zoomXOut" << endl;
   ZoomCommand *cmd = new ZoomXOutCommand(this);
@@ -1103,8 +1129,43 @@
   item->update();
 }
 
+/*
+ * X axis zoom changed to fixed and shifted to right:
+ *       new_xmin = xmin + (xmax - xmin)*0.10;
+ *       new_xmax = xmax + (xmax – xmin)*0.10;
+ */
+void ZoomXRightCommand::applyZoomTo(PlotRenderItem *item) {
+  item->setXAxisZoomMode(PlotRenderItem::FixedExpression);
 
+  QRectF compute = item->projectionRect();
+
+  qreal dx = compute.width() * 0.1;
+  compute.setLeft(compute.left() + dx);
+  compute.setRight(compute.right() + dx);
+
+  item->setProjectionRect(compute);
+  item->update();
+}
+
 /*
+ * X axis zoom changed to fixed and shifted to :
+ *       new_xmin = xmin - (xmax - xmin)*0.10;
+ *       new_xmax = xmax - (xmax – xmin)*0.10;
+ */
+void ZoomXLeftCommand::applyZoomTo(PlotRenderItem *item) {
+  item->setXAxisZoomMode(PlotRenderItem::FixedExpression);
+
+  QRectF compute = item->projectionRect();
+
+  qreal dx = compute.width() * 0.1;
+  compute.setLeft(compute.left() - dx);
+  compute.setRight(compute.right() - dx);
+
+  item->setProjectionRect(compute);
+  item->update();
+}
+
+/*
  * X axis zoom changed to fixed and increased:
  *       new_xmin = xmin - (xmax - xmin)*0.25;
  *       new_xmax = xmax + (xmax – xmin)*0.25;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #733629:733630
@@ -105,6 +105,8 @@
     void zoomMaxSpikeInsensitive();
     void zoomYMeanCentered();
     void zoomXMaximum();
+    void zoomXRight();
+    void zoomXLeft();
     void zoomXOut();
     void zoomXIn();
     void zoomNormalizeXtoY();
@@ -172,6 +174,8 @@
     QAction *_zoomPrevious;
     QAction *_zoomYMeanCentered;
     QAction *_zoomXMaximum;
+    QAction *_zoomXRight;
+    QAction *_zoomXLeft;
     QAction *_zoomXOut;
     QAction *_zoomXIn;
     QAction *_zoomNormalizeXtoY;
@@ -260,6 +264,26 @@
     virtual void applyZoomTo(PlotRenderItem *item);
 };
 
+class KST_EXPORT ZoomXRightCommand : public ZoomCommand
+{
+  public:
+    ZoomXRightCommand(PlotRenderItem *item)
+        : ZoomCommand(item, QObject::tr("Scroll X Right")) {}
+    virtual ~ZoomXRightCommand() {}
+
+    virtual void applyZoomTo(PlotRenderItem *item);
+};
+
+class KST_EXPORT ZoomXLeftCommand : public ZoomCommand
+{
+  public:
+    ZoomXLeftCommand(PlotRenderItem *item)
+        : ZoomCommand(item, QObject::tr("Scroll X Left")) {}
+    virtual ~ZoomXLeftCommand() {}
+
+    virtual void applyZoomTo(PlotRenderItem *item);
+};
+
 class KST_EXPORT ZoomXOutCommand : public ZoomCommand
 {
   public:


More information about the Kst mailing list