[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Thu May 15 21:26:52 CEST 2008
SVN commit 808135 by fenton:
Add new XRange / YRange zoom to allow tied zoom to function as desired using CTRL/SHIFT mouse zoom.
M +32 -0 plotitem.cpp
M +32 -0 plotitem.h
M +8 -1 plotrenderitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #808134:808135
@@ -1684,6 +1684,20 @@
}
+void PlotItem::zoomXRange(const QRectF &projection) {
+ qDebug() << "zoomXRange" << endl;
+ ZoomCommand *cmd = new ZoomXRangeCommand(this, projection);
+ cmd->redo();
+}
+
+
+void PlotItem::zoomYRange(const QRectF &projection) {
+ qDebug() << "zoomYRange" << endl;
+ ZoomCommand *cmd = new ZoomYRangeCommand(this, projection);
+ cmd->redo();
+}
+
+
void PlotItem::zoomMaximum() {
qDebug() << "zoomMaximum" << endl;
ZoomCommand *cmd = new ZoomMaximumCommand(this);
@@ -2071,6 +2085,24 @@
/*
+ * X axis zoom to Range.
+ */
+void ZoomXRangeCommand::applyZoomTo(PlotItem *item) {
+ item->xAxis()->setAxisZoomMode(PlotAxis::FixedExpression);
+ item->setProjectionRect(QRect(_fixed.x(), item->projectionRect().y(), _fixed.width(), item->projectionRect().height()));
+}
+
+
+/*
+ * Y axis zoom to Range.
+ */
+void ZoomYRangeCommand::applyZoomTo(PlotItem *item) {
+ item->yAxis()->setAxisZoomMode(PlotAxis::FixedExpression);
+ item->setProjectionRect(QRect(item->projectionRect().x(), _fixed.y(), item->projectionRect().width(), _fixed.height()));
+}
+
+
+/*
* X axis zoom to Auto, Y axis zoom to AutoBorder.
*/
void ZoomMaximumCommand::applyZoomTo(PlotItem *item) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #808134:808135
@@ -172,6 +172,8 @@
public Q_SLOTS:
void zoomFixedExpression(const QRectF &projection);
+ void zoomXRange(const QRectF &projection);
+ void zoomYRange(const QRectF &projection);
void zoomMaximum();
void zoomMaxSpikeInsensitive();
void zoomYMeanCentered();
@@ -384,6 +386,7 @@
QList<ZoomState> _originalStates;
};
+
class KST_EXPORT ZoomFixedExpressionCommand : public ZoomCommand
{
public:
@@ -397,6 +400,35 @@
QRectF _fixed;
};
+
+class KST_EXPORT ZoomXRangeCommand : public ZoomCommand
+{
+ public:
+ ZoomXRangeCommand(PlotItem *item, const QRectF &fixed)
+ : ZoomCommand(item, QObject::tr("Zoom X Range Expression")), _fixed(fixed) {}
+ virtual ~ZoomXRangeCommand() {}
+
+ virtual void applyZoomTo(PlotItem *item);
+
+ private:
+ QRectF _fixed;
+};
+
+
+class KST_EXPORT ZoomYRangeCommand : public ZoomCommand
+{
+ public:
+ ZoomYRangeCommand(PlotItem *item, const QRectF &fixed)
+ : ZoomCommand(item, QObject::tr("Zoom X Range Expression")), _fixed(fixed) {}
+ virtual ~ZoomYRangeCommand() {}
+
+ virtual void applyZoomTo(PlotItem *item);
+
+ private:
+ QRectF _fixed;
+};
+
+
class KST_EXPORT ZoomMaximumCommand : public ZoomCommand
{
public:
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #808134:808135
@@ -390,7 +390,14 @@
const QRectF projection = plotItem()->mapToProjection(_selectionRect.rect());
_selectionRect.reset();
- plotItem()->zoomFixedExpression(projection);
+ const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
+ if (modifiers & Qt::ShiftModifier) {
+ plotItem()->zoomYRange(projection);
+ } else if (modifiers & Qt::ControlModifier) {
+ plotItem()->zoomXRange(projection);
+ } else {
+ plotItem()->zoomFixedExpression(projection);
+ }
}
More information about the Kst
mailing list