Panning now only works if the viewier is zoomed

This commit is contained in:
Thomas Wilshaw
2020-06-16 11:53:36 +01:00
parent 92eadc6854
commit f6c70f583f
5 changed files with 22 additions and 4 deletions
+14 -3
View File
@@ -47,7 +47,8 @@ ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) :
signal_cursor_color_(false),
gizmos_(nullptr),
gizmo_click_(false),
last_loaded_buffer_(nullptr)
last_loaded_buffer_(nullptr),
zoomed_(false)
{
}
@@ -68,6 +69,16 @@ void ViewerDisplayWidget::SetMatrixZoom(const QMatrix4x4 &mat)
update();
}
void ViewerDisplayWidget::SetZoomFlag(bool flag)
{
zoomed_ = flag;
// If not scaled reset translation matrix to identity
if (!flag) {
QMatrix4x4 mat;
SetMatrixTranslate(mat);
}
}
QMatrix4x4 ViewerDisplayWidget::GetCompleteMatrix()
{
QMatrix4x4 mat;
@@ -164,7 +175,7 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
}
// get current position in preperation for move event
if (event->button() == Qt::MiddleButton) {
if (event->button() == Qt::MiddleButton && zoomed_) {
position_ = event->pos();
return;
}
@@ -178,7 +189,7 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::MiddleButton) {
if (event->buttons() & Qt::MiddleButton && zoomed_) {
QPointF delta = event->pos() - position_;
// scale delta to widget size
delta.setX(delta.x() / width());