[Kst] branches/work/kst/portto4/kst/src/libkstapp
Peter Kümmel
syntheticpp at gmx.net
Sun Sep 26 17:08:15 CEST 2010
SVN commit 1179931 by kuemmel:
add X/Y only mode
move new tab to File menu
M +53 -24 mainwindow.cpp
M +8 -7 mainwindow.h
M +16 -0 plotitem.cpp
M +12 -12 plotrenderitem.cpp
M +12 -0 view.cpp
M +5 -0 view.h
M +1 -0 viewitem.cpp
M +5 -0 viewitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1179930:1179931
@@ -140,7 +140,8 @@
_dataMode = dataMode;
}
-void MainWindow::setXZoomMode() {
+void MainWindow::changeZoomOnlyMode(QAction* act) {
+ tabWidget()->currentView()->setZoomOnly((View::ZoomOnlyMode)act->data().toInt());
}
void MainWindow::toggleTiedZoom() {
@@ -664,6 +665,11 @@
_saveAsAct->setIcon(QPixmap(":document-save-as.png"));
connect(_saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
+ _closeAct = new QAction(tr("C&lose"), this);
+ _closeAct->setStatusTip(tr("Close current session"));
+ _closeAct->setIcon(QPixmap(":draw-eraser.png"));
+ connect(_closeAct, SIGNAL(triggered()), this, SLOT(newDoc()));
+
_reloadAct = new QAction(tr("Reload all Data Sources"), this);
_reloadAct->setStatusTip(tr("Reload all data sources"));
_reloadAct->setIcon(QPixmap(":kst_reload.png"));
@@ -679,16 +685,16 @@
_exportGraphicsAct->setIcon(QPixmap(":document-export.png"));
connect(_exportGraphicsAct, SIGNAL(triggered()), this, SLOT(showExportGraphicsDialog()));
+ _newTabAct = new QAction(tr("&New Tab"), this);
+ _newTabAct->setStatusTip(tr("Create a new tab"));
+ _newTabAct->setIcon(QPixmap(":tab-new.png"));
+ connect(_newTabAct, SIGNAL(triggered()), tabWidget(), SLOT(createView()));
+
_closeTabAct = new QAction(tr("&Close Tab"), this);
_closeTabAct->setStatusTip(tr("Close the current tab"));
_closeTabAct->setIcon(QPixmap(":tab-close.png"));
connect(_closeTabAct, SIGNAL(triggered()), tabWidget(), SLOT(closeCurrentView()));
- _clearSession = new QAction(tr("C&lear Session"), this);
- _clearSession->setStatusTip(tr("Clear current session"));
- _clearSession->setIcon(QPixmap(":draw-eraser.png"));
- connect(_clearSession, SIGNAL(triggered()), this, SLOT(newDoc()));
-
_exitAct = new QAction(tr("E&xit"), this);
_exitAct->setShortcut(tr("Ctrl+Q"));
_exitAct->setStatusTip(tr("Exit the application"));
@@ -755,11 +761,6 @@
connect(_changeDataSampleDialogAct, SIGNAL(triggered()), this, SLOT(showChangeDataSampleDialog()));
// ************************ Create Actions ************************** //
- _newTabAct = new QAction(tr("&New Tab"), this);
- _newTabAct->setStatusTip(tr("Create a new tab"));
- _newTabAct->setIcon(QPixmap(":tab-new.png"));
- connect(_newTabAct, SIGNAL(triggered()), tabWidget(), SLOT(createView()));
-
_createPlotAct = new QAction(tr("&Plot"), this);
_createPlotAct->setStatusTip(tr("Create a plot for the current view"));
_createPlotAct->setIcon(QPixmap(":office-chart-area-stacked.png"));
@@ -853,12 +854,34 @@
_tiedZoomAct->setShortcut(QString("t"));
connect(_tiedZoomAct, SIGNAL(triggered()), this, SLOT(toggleTiedZoom()));
- _dataXZoomAct = new QAction(tr("&X only Zoom"), this);
- _dataXZoomAct->setStatusTip(tr("Zoom only in X direction"));
- //_dataModeAct->setIcon(QPixmap(":kst_datamode.png"));
- //_dataModeAct->setCheckable(true);
- connect(_dataXZoomAct, SIGNAL(triggered()), this, SLOT(setXZoomMode()));
+ QActionGroup* _dataZoomOnlyGroup = new QActionGroup(this);
+ _dataZoomOnlyDisabledAct = _dataZoomOnlyGroup->addAction(tr("Free Zoom/Scroll"));
+ _dataZoomOnlyDisabledAct->setStatusTip(tr("Zoom &arbitray in X- or Y-direction"));
+ //TODO _dataZoomOnlyDisabledAct->setShortcut(QString("a"));
+ _dataZoomOnlyDisabledAct->setCheckable(true);
+ _dataZoomOnlyDisabledAct->setData(View::ZoomOnlyDisabled);
+ //TODO _dataZoomOnlyDisabledAct->setIcon(QPixmap(":kst_datamode.png"));
+
+ _dataZoomOnlyXAct = _dataZoomOnlyGroup->addAction(tr("&X-only Zoom"));
+ _dataZoomOnlyXAct->setStatusTip(tr("Zoom only in X direction"));
+ //TODO _dataZoomOnlyXAct->setShortcut(QString("x"));
+ _dataZoomOnlyXAct->setCheckable(true);
+ _dataZoomOnlyXAct->setData(View::ZoomOnlyX);
+ //TODO _dataZoomOnlyXAct->setIcon(QPixmap(":kst_datamode.png"));
+
+ _dataZoomOnlyYAct = _dataZoomOnlyGroup->addAction(tr("&Y-only Zoom"));
+ _dataZoomOnlyYAct->setStatusTip(tr("Zoom only in X direction"));
+ //TODO _dataZoomOnlyYAct->setShortcut(QString("y"));
+ _dataZoomOnlyYAct->setData(View::ZoomOnlyY);
+ _dataZoomOnlyYAct->setCheckable(true);
+ //TODO _dataZoomOnlyYAct->setIcon(QPixmap(":kst_datamode.png"));
+
+ _dataZoomOnlyGroup->setExclusive(true);
+ _dataZoomOnlyDisabledAct->setChecked(true);
+ connect(_dataZoomOnlyGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeZoomOnlyMode(QAction*)));
+
+
_createSharedAxisBoxAct = new QAction(tr("&Shared Axis Box"), this);
_createSharedAxisBoxAct->setStatusTip(tr("Create a shared axis box for the current item"));
_createSharedAxisBoxAct->setIcon(QPixmap(":kst_gfx_sharedaxisbox.png"));
@@ -928,10 +951,11 @@
void MainWindow::createMenus() {
_fileMenu = menuBar()->addMenu(tr("&File"));
- // File operations
+ // Session operations
_fileMenu->addAction(_openAct);
_fileMenu->addAction(_saveAct);
_fileMenu->addAction(_saveAsAct);
+ _fileMenu->addAction(_closeAct);
_fileMenu->addSeparator();
// Reload, isolate it a bit frmo the other entries to avoid inadvertent triggering
_fileMenu->addAction(_reloadAct);
@@ -940,9 +964,11 @@
_fileMenu->addAction(_printAct);
_fileMenu->addAction(_exportGraphicsAct);
_fileMenu->addSeparator();
- // Close/exit
+ // Tabs
+ _fileMenu->addAction(_newTabAct);
_fileMenu->addAction(_closeTabAct);
- _fileMenu->addAction(_clearSession);
+ _fileMenu->addSeparator();
+ // exit
_fileMenu->addAction(_exitAct);
_editMenu = menuBar()->addMenu(tr("&Edit"));
@@ -969,7 +995,6 @@
_createMenu = menuBar()->addMenu(tr("&Create"));
// Containers
- _createMenu->addAction(_newTabAct);
_createMenu->addAction(_createPlotAct);
_createMenu->addSeparator();
// Data objects
@@ -1016,10 +1041,12 @@
_modeMenu = menuBar()->addMenu(tr("&Mode"));
// Zoom/axes stuff
_modeMenu->addAction(_tiedZoomAct);
+ _modeMenu->addAction(_createSharedAxisBoxAct);
// Zoom X-only or Y-only will come here
- // modeMenu->addAction(_dataXZoomAct);
- // modeMenu->addAction(_dataYZoomAct);
- _modeMenu->addAction(_createSharedAxisBoxAct);
+ _modeMenu->addSeparator()->setText(tr("Zoom only X or Y"));
+ _modeMenu->addAction(_dataZoomOnlyDisabledAct);
+ _modeMenu->addAction(_dataZoomOnlyXAct);
+ _modeMenu->addAction(_dataZoomOnlyYAct);
_modeMenu->addSeparator();
// Interaction options: data mode on/off, layout mode toggle
_modeMenu->addAction(_dataModeAct);
@@ -1067,7 +1094,9 @@
// _layoutToggleToolBar = addToolBar(tr("Mode"));
_modeToolBar = addToolBar(tr("Mode"));
_modeToolBar->addAction(_tiedZoomAct);
- // FIXME: add X-only + Y-only here, or in a separate "zoom" toolbar
+ _modeToolBar->addAction(_dataZoomOnlyDisabledAct);
+ _modeToolBar->addAction(_dataZoomOnlyXAct);
+ _modeToolBar->addAction(_dataZoomOnlyYAct);
_modeToolBar->addAction(_createSharedAxisBoxAct);
_modeToolBar->addAction(_dataModeAct);
_modeToolBar->addAction(_layoutModeAct);
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #1179930:1179931
@@ -127,7 +127,7 @@
void toggleTiedZoom();
void setDataMode(bool dataMode);
- void setXZoomMode();
+ void changeZoomOnlyMode(QAction*);
protected:
void closeEvent(QCloseEvent *e);
@@ -199,17 +199,17 @@
QAction *_createSharedAxisBoxAct;
QAction *_aboutAct;
- QAction *_closeTabAct;
QAction *_dataManagerAct;
QAction *_debugDialogAct;
QAction *_exitAct;
QAction *_exportGraphicsAct;
- QAction *_newTabAct;
- QAction *_clearSession;
QAction *_openAct;
- QAction *_printAct;
QAction *_saveAct;
QAction *_saveAsAct;
+ QAction *_closeAct;
+ QAction *_printAct;
+ QAction *_newTabAct;
+ QAction *_closeTabAct;
QAction *_scalarEditorAct;
QAction *_vectorEditorAct;
QAction *_matrixEditorAct;
@@ -218,8 +218,9 @@
QAction *_layoutModeAct;
QAction *_tiedZoomAct;
QAction *_dataModeAct;
- QAction *_dataXZoomAct;
- QAction *_dataYZoomAct;
+ QAction *_dataZoomOnlyDisabledAct;
+ QAction *_dataZoomOnlyXAct;
+ QAction *_dataZoomOnlyYAct;
QAction *_settingsDialogAct;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1179930:1179931
@@ -3001,6 +3001,10 @@
void PlotItem::zoomXRight(bool force) {
+ if (zoomOnlyMode() == View::ZoomOnlyX) {
+ zoomXOut(force);
+ return;
+ }
#if DEBUG_ZOOM
qDebug() << "zoomXRight" << endl;
#endif
@@ -3015,6 +3019,10 @@
void PlotItem::zoomXLeft(bool force) {
+ if (zoomOnlyMode() == View::ZoomOnlyX) {
+ zoomXIn(force);
+ return;
+ }
#if DEBUG_ZOOM
qDebug() << "zoomXLeft" << endl;
#endif
@@ -3151,6 +3159,10 @@
void PlotItem::zoomYUp(bool force) {
+ if (zoomOnlyMode() == View::ZoomOnlyY) {
+ zoomYOut(force);
+ return;
+ }
#if DEBUG_ZOOM
qDebug() << "zoomYUp" << endl;
#endif
@@ -3165,6 +3177,10 @@
void PlotItem::zoomYDown(bool force) {
+ if (zoomOnlyMode() == View::ZoomOnlyY) {
+ zoomYIn(force);
+ return;
+ }
#if DEBUG_ZOOM
qDebug() << "zoomYDown" << endl;
#endif
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #1179930:1179931
@@ -373,10 +373,10 @@
}
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
- if (modifiers & Qt::ShiftModifier) {
+ if (modifiers & Qt::SHIFT) {
// show cursor as Qt::SizeVerCursor only on mouse events
// because shift is also used for arrow key controlled zooming
- } else if (modifiers & Qt::ControlModifier) {
+ } else if (modifiers & Qt::CTRL) {
parentView()->setCursor(Qt::SizeHorCursor);
}
@@ -392,9 +392,9 @@
return;
}
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
- if (modifiers & Qt::ShiftModifier) {
+ if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
parentView()->setCursor(Qt::SizeVerCursor);
- } else if (modifiers & Qt::ControlModifier) {
+ } else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
parentView()->setCursor(Qt::SizeHorCursor);
} else {
parentView()->setCursor(Qt::CrossCursor);
@@ -428,10 +428,10 @@
const QPointF p = event->pos();
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
- if (modifiers & Qt::ShiftModifier) {
+ if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
parentView()->setCursor(Qt::SizeVerCursor);
_selectionRect.setTo(QPointF(rect().right(), p.y()));
- } else if (modifiers & Qt::ControlModifier) {
+ } else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
_selectionRect.setTo(QPointF(p.x(), rect().bottom()));
} else {
_selectionRect.setTo(p);
@@ -479,11 +479,11 @@
const QPointF p = event->pos();
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
- if (modifiers & Qt::ShiftModifier) {
+ if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
parentView()->setCursor(Qt::SizeVerCursor);
_selectionRect.setFrom(QPointF(rect().left(), p.y()));
_selectionRect.setTo(QPointF(rect().right(), p.y()));
- } else if (modifiers & Qt::ControlModifier) {
+ } else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
parentView()->setCursor(Qt::SizeHorCursor);
_selectionRect.setFrom(QPointF(p.x(), rect().top()));
_selectionRect.setTo(QPointF(p.x(), rect().bottom()));
@@ -504,9 +504,9 @@
_selectionRect.reset();
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
- if (modifiers & Qt::ShiftModifier) {
+ if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
plotItem()->zoomYRange(projection);
- } else if (modifiers & Qt::ControlModifier) {
+ } else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
plotItem()->zoomXRange(projection);
} else {
plotItem()->zoomFixedExpression(projection);
@@ -526,13 +526,13 @@
QPointF p = event->pos();
_hoverPos = p;
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
- if (modifiers & Qt::ShiftModifier) {
+ if (modifiers & Qt::SHIFT || zoomOnlyMode() == View::ZoomOnlyY) {
_lastPos = p;
parentView()->setCursor(Qt::SizeVerCursor);
_selectionRect.setFrom(QPointF(rect().left(), p.y()));
_selectionRect.setTo(QPointF(rect().right(), p.y()));
update(); //FIXME should optimize instead of redrawing entire curve!
- } else if (modifiers & Qt::ControlModifier) {
+ } else if (modifiers & Qt::CTRL || zoomOnlyMode() == View::ZoomOnlyX) {
_lastPos = p;
parentView()->setCursor(Qt::SizeHorCursor);
_selectionRect.setFrom(QPointF(p.x(), rect().top()));
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #1179930:1179931
@@ -202,6 +202,18 @@
emit mouseModeChanged(oldMode);
}
+void View::setZoomOnly(ZoomOnlyMode zoomMode)
+{
+ QList<PlotItem*> plots = PlotItemManager::plotsForView(this);
+ foreach (PlotItem* plot, plots) {
+ plot->setZoomOnly(zoomMode);
+ // should we overload setZoomOnly?
+ QList<PlotRenderItem*> renderers = plot->renderItems();
+ foreach (PlotRenderItem* renderer, renderers) {
+ renderer->setZoomOnly(zoomMode);
+ }
+ }
+}
QPolygonF View::creationPolygon(CreationEvents events) const {
if (events == View::MousePress)
--- branches/work/kst/portto4/kst/src/libkstapp/view.h #1179930:1179931
@@ -18,6 +18,7 @@
#include "curveplacement.h"
+
class QUndoStack;
class QXmlStreamWriter;
@@ -33,6 +34,7 @@
public:
enum ViewMode { Data, Layout };
enum MouseMode { Default, Move, Create, Resize, Scale, Rotate };
+ enum ZoomOnlyMode { ZoomOnlyDisabled, ZoomOnlyX, ZoomOnlyY };
enum CreationEvent {
MousePress = 0x0,
MouseRelease =0x1,
@@ -125,7 +127,10 @@
void viewChanged();
void forceChildResize(QRectF oldRect, QRectF newRect);
void processResize(QSize size);
+ void setZoomOnly(ZoomOnlyMode);
+
+
protected:
bool event(QEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1179930:1179931
@@ -63,6 +63,7 @@
_allowedGripModes(Move | Resize | Rotate /*| Scale*/),
_creationState(None),
_typeName("View Item"),
+ _zoomOnlyMode(View::ZoomOnlyDisabled),
_supportsTiedZoom(false),
_fixedSize(false),
_lockAspectRatio(false),
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #1179930:1179931
@@ -192,6 +192,10 @@
virtual bool supportsTiedZoom() const { return _supportsTiedZoom; }
virtual void setSupportsTiedZoom(const bool supports);
+
+ View::ZoomOnlyMode zoomOnlyMode() const { return _zoomOnlyMode; }
+ void setZoomOnly(View::ZoomOnlyMode val) { _zoomOnlyMode = val; }
+
CreationState creationState() const { return _creationState; }
virtual void setItemPen(const QPen & pen) { setPen(pen); };
@@ -291,6 +295,7 @@
GripModes _allowedGripModes;
CreationState _creationState;
QString _typeName;
+ View::ZoomOnlyMode _zoomOnlyMode;
bool _supportsTiedZoom;
bool _fixedSize;
bool _lockAspectRatio;
More information about the Kst
mailing list