[Kst] branches/work/kst/portto4/kst/src/libkstapp
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Nov 7 06:19:18 CET 2007
SVN commit 733707 by netterfield:
Add up and down zoom changes.
M +68 -0 plotrenderitem.cpp
M +24 -0 plotrenderitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #733706:733707
@@ -448,6 +448,16 @@
registerShortcut(_zoomYMaximum);
connect(_zoomYMaximum, SIGNAL(triggered()), this, SLOT(zoomYMaximum()));
+ _zoomYUp= new QAction(tr("Y-Zoom Up"), this);
+ _zoomYUp->setShortcut(Qt::Key_Up);
+ registerShortcut(_zoomYUp);
+ connect(_zoomYUp, SIGNAL(triggered()), this, SLOT(zoomYUp()));
+
+ _zoomYDown= new QAction(tr("Y-Zoom Down"), this);
+ _zoomYDown->setShortcut(Qt::Key_Down);
+ registerShortcut(_zoomYDown);
+ connect(_zoomYDown, SIGNAL(triggered()), this, SLOT(zoomYDown()));
+
_zoomYOut = new QAction(tr("Y-Zoom Out"), this);
_zoomYOut->setShortcut(Qt::SHIFT+Qt::Key_Up);
registerShortcut(_zoomYOut);
@@ -500,6 +510,8 @@
zoom.addAction(_zoomYLocalMaximum);
zoom.addAction(_zoomYMaximum);
+ zoom.addAction(_zoomYUp);
+ zoom.addAction(_zoomYDown);
zoom.addAction(_zoomYOut);
zoom.addAction(_zoomYIn);
zoom.addAction(_zoomNormalizeYtoX);
@@ -737,6 +749,20 @@
}
+void PlotRenderItem::zoomYUp() {
+ qDebug() << "zoomYUp" << endl;
+ ZoomCommand *cmd = new ZoomYUpCommand(this);
+ cmd->redo();
+}
+
+
+void PlotRenderItem::zoomYDown() {
+ qDebug() << "zoomYDown" << endl;
+ ZoomCommand *cmd = new ZoomYDownCommand(this);
+ cmd->redo();
+}
+
+
void PlotRenderItem::zoomYOut() {
qDebug() << "zoomYOut" << endl;
ZoomCommand *cmd = new ZoomYOutCommand(this);
@@ -1279,6 +1305,48 @@
/*
+ * Y axis zoom up. If the Y zoom mode is not
+ * Mean Centered, change to Fixed (expression).
+ * new_ymin = ymin + (ymax - ymin)*0.1;
+ * new_ymax = ymax + (ymax - ymin)*0.1;
+ */
+void ZoomYUpCommand::applyZoomTo(PlotRenderItem *item) {
+ if (item->yAxisZoomMode() != PlotRenderItem::MeanCentered)
+ item->setYAxisZoomMode(PlotRenderItem::FixedExpression);
+
+ QRectF compute = item->projectionRect();
+
+ qreal dy = compute.height() * 0.1;
+ compute.setTop(compute.top() + dy);
+ compute.setBottom(compute.bottom() + dy);
+
+ item->setProjectionRect(compute);
+ item->update();
+}
+
+
+/*
+ * Y axis zoom down. If the Y zoom mode is not
+ * Mean Centered, change to Fixed (expression).
+ * new_ymin = ymin - (ymax - ymin)*0.10;
+ * new_ymax = ymax - (ymax - ymin)*0.10;
+ */
+void ZoomYDownCommand::applyZoomTo(PlotRenderItem *item) {
+ if (item->yAxisZoomMode() != PlotRenderItem::MeanCentered)
+ item->setYAxisZoomMode(PlotRenderItem::FixedExpression);
+
+ QRectF compute = item->projectionRect();
+
+ qreal dy = compute.height() * 0.10;
+ compute.setTop(compute.top() - dy);
+ compute.setBottom(compute.bottom() - dy);
+
+ item->setProjectionRect(compute);
+ item->update();
+}
+
+
+/*
* Y axis zoom increased. If the Y zoom mode is not
* Mean Centered, change to Fixed (expression).
* new_ymin = ymin - (ymax - ymin)*0.25;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #733706:733707
@@ -113,6 +113,8 @@
void zoomLogX();
void zoomYLocalMaximum();
void zoomYMaximum();
+ void zoomYUp();
+ void zoomYDown();
void zoomYOut();
void zoomYIn();
void zoomNormalizeYtoX();
@@ -182,6 +184,8 @@
QAction *_zoomLogX;
QAction *_zoomYLocalMaximum;
QAction *_zoomYMaximum;
+ QAction *_zoomYUp;
+ QAction *_zoomYDown;
QAction *_zoomYOut;
QAction *_zoomYIn;
QAction *_zoomNormalizeYtoX;
@@ -334,6 +338,26 @@
virtual void applyZoomTo(PlotRenderItem *item);
};
+class KST_EXPORT ZoomYUpCommand : public ZoomCommand
+{
+ public:
+ ZoomYUpCommand(PlotRenderItem *item)
+ : ZoomCommand(item, QObject::tr("Zoom Y Up")) {}
+ virtual ~ZoomYUpCommand() {}
+
+ virtual void applyZoomTo(PlotRenderItem *item);
+};
+
+class KST_EXPORT ZoomYDownCommand : public ZoomCommand
+{
+ public:
+ ZoomYDownCommand(PlotRenderItem *item)
+ : ZoomCommand(item, QObject::tr("Zoom Y Down")) {}
+ virtual ~ZoomYDownCommand() {}
+
+ virtual void applyZoomTo(PlotRenderItem *item);
+};
+
class KST_EXPORT ZoomYOutCommand : public ZoomCommand
{
public:
More information about the Kst
mailing list