Commit e334cc71 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Add a button to freeze the rotation

In the instrument viewer render tab, in the Full 3D projection, adds a
checkbox to freeze the rotation, so that only translation and zoom remains.
Left-clicking then translate, as right-clicking.
This is useful for Mac users, for whom translation is hard to do by
default.
parent c2597509
......@@ -55,6 +55,8 @@ public:
/// disabled() signal.
virtual void onDisabled() { emit disabled(); }
virtual void freezeRotation(bool) {}
/// Returns true if a surface using this controller can show
/// a context menu on right-click
bool canShowContextMenu() const { return m_canShowContextMenu; }
......@@ -82,6 +84,7 @@ public:
void mouseMoveEvent(QMouseEvent * /*unused*/) override;
void mouseReleaseEvent(QMouseEvent * /*unused*/) override;
void wheelEvent(QWheelEvent * /*unused*/) override;
void freezeRotation(bool) override;
signals:
/// Init zooming. x and y is the zoom starting point on the screen.
......@@ -103,6 +106,7 @@ signals:
private:
bool m_isButtonPressed;
bool m_isRotationFrozen = false;
};
/**
......
......@@ -39,10 +39,11 @@ void InputController3DMove::mousePressEvent(QMouseEvent *event) {
if (event->buttons() & Qt::MidButton) {
emit initZoom(event->x(), event->y());
m_isButtonPressed = true;
} else if (event->buttons() & Qt::LeftButton) {
} else if ((event->buttons() & Qt::LeftButton) && !m_isRotationFrozen) {
emit initRotation(event->x(), event->y());
m_isButtonPressed = true;
} else if (event->buttons() & Qt::RightButton) {
} else if ((event->buttons() & Qt::RightButton) ||
((event->buttons() & Qt::LeftButton) && m_isRotationFrozen)) {
emit initTranslation(event->x(), event->y());
m_isButtonPressed = true;
}
......@@ -53,9 +54,10 @@ void InputController3DMove::mousePressEvent(QMouseEvent *event) {
* Send out surface movement signals.
*/
void InputController3DMove::mouseMoveEvent(QMouseEvent *event) {
if (event->buttons() & Qt::LeftButton) {
if ((event->buttons() & Qt::LeftButton) && !m_isRotationFrozen) {
emit rotate(event->x(), event->y());
} else if (event->buttons() & Qt::RightButton) {
} else if ((event->buttons() & Qt::RightButton) ||
((event->buttons() & Qt::LeftButton) && m_isRotationFrozen)) {
emit translate(event->x(), event->y());
} else if (event->buttons() & Qt::MidButton) {
emit zoom(event->x(), event->y());
......@@ -79,6 +81,10 @@ void InputController3DMove::wheelEvent(QWheelEvent *event) {
emit wheelZoom(event->x(), event->y(), event->delta());
}
void InputController3DMove::freezeRotation(bool freeze) {
m_isRotationFrozen = freeze;
}
//--------------------------------------------------------------------------------
/**
......
......@@ -220,6 +220,7 @@ public slots:
void setViewDirection(const QString & /*input*/);
void pickBackgroundColor();
void freezeRotation(bool);
void saveImage(QString filename);
void setInfoText(const QString & /*text*/);
void set3DAxesState(bool /*on*/);
......
......@@ -117,6 +117,7 @@ private: // members
QCheckBox *m_flipCheckBox;
QPushButton *m_peakOverlaysButton;
QCheckBox *m_autoscaling;
QCheckBox *m_freezeRotation;
QActionGroup *m_surfaceTypeActionGroup;
QAction *m_full3D;
......
......@@ -148,6 +148,7 @@ public:
virtual std::string saveToProject() const;
void setCurrentTab(QString currentTab) { m_currentTab = currentTab; }
void freezeRotation(bool freeze);
//-----------------------------------
// Mask methods
......
......@@ -830,6 +830,10 @@ void InstrumentWidget::pickBackgroundColor() {
setBackgroundColor(color);
}
void InstrumentWidget::freezeRotation(bool freeze) {
getSurface()->freezeRotation(freeze);
}
/**
* Saves the current image buffer as a png file.
* @param filename Optional filename. Empty string raises a save dialog
......
......@@ -324,11 +324,18 @@ QFrame *InstrumentWidgetRenderTab::setupAxisFrame() {
mAxisCombo->addItem("Y-");
axisViewLayout->addWidget(mAxisCombo);
axisViewLayout->addWidget(new QLabel("Freeze rotation"));
m_freezeRotation = new QCheckBox();
axisViewLayout->addWidget(m_freezeRotation);
m_resetViewFrame->setLayout(axisViewLayout);
connect(mAxisCombo, SIGNAL(currentIndexChanged(const QString &)),
m_instrWidget, SLOT(setViewDirection(const QString &)));
connect(m_freezeRotation, SIGNAL(toggled(bool)), m_instrWidget,
SLOT(freezeRotation(bool)));
return m_resetViewFrame;
}
......
......@@ -670,6 +670,10 @@ InputController *ProjectionSurface::getController() const {
return controller;
}
void ProjectionSurface::freezeRotation(bool freeze) {
getController()->freezeRotation(freeze);
}
// --- Shape2D manipulation --- //
void ProjectionSurface::startCreatingShape2D(const QString &type,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment