Update comments.
This commit is contained in:
@@ -52,7 +52,7 @@ ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) :
|
||||
zoomed_(false)
|
||||
{
|
||||
connect(Core::instance(), &Core::ToolChanged, this, &ViewerDisplayWidget::ToolChanged);
|
||||
|
||||
// Initilises hand_tool_ based on currently selected tool.
|
||||
ToolChanged(Core::instance()->tool());
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ void ViewerDisplayWidget::SetMatrixZoom(const QMatrix4x4 &mat)
|
||||
void ViewerDisplayWidget::IsZoomed(bool flag)
|
||||
{
|
||||
zoomed_ = flag;
|
||||
// If the image is smaller than the container widget we disable translation
|
||||
// If the image is smaller than the container widget we reset the translation.
|
||||
if (!flag) {
|
||||
QMatrix4x4 mat;
|
||||
QMatrix4x4 mat; // defaults to identity matrix.
|
||||
SetMatrixTranslate(mat);
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,7 @@ void ViewerDisplayWidget::ToolChanged(Tool::Item tool)
|
||||
QMatrix4x4 ViewerDisplayWidget::GetCompleteMatrix()
|
||||
{
|
||||
QMatrix4x4 mat;
|
||||
// Images is scaled, the translated.
|
||||
return translate_matrix_ * scale_matrix_ * mat;
|
||||
}
|
||||
|
||||
@@ -183,13 +184,13 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
// reset translation
|
||||
// Reset translation.
|
||||
if (event->button() == Qt::MiddleButton && event->modifiers() & Qt::ControlModifier) {
|
||||
QMatrix4x4 mat;
|
||||
QMatrix4x4 mat; // Identity matrix
|
||||
SetMatrixTranslate(mat);
|
||||
}
|
||||
|
||||
// If translation is enabled get current position in preperation for move event
|
||||
// If translation is enabled get current position in preperation for move event.
|
||||
if ((event->button() == Qt::MiddleButton || hand_tool_) && zoomed_) {
|
||||
position_ = event->pos();
|
||||
return;
|
||||
|
||||
@@ -117,8 +117,17 @@ public slots:
|
||||
*/
|
||||
void SetImage(FramePtr in_buffer);
|
||||
|
||||
/**
|
||||
* @brief Set zoomed_ flag if the viewersizer has zoomed the image to be larger than the widget.
|
||||
*
|
||||
* If the image is smaller than the widget the translation is reset so the image is centered.
|
||||
*/
|
||||
void IsZoomed(bool flag);
|
||||
|
||||
/**
|
||||
* @brief Changes the pointer type if the tool is changed to the hand tool. Otherwise resets the pointer to it's
|
||||
* normal type.
|
||||
*/
|
||||
void ToolChanged(Tool::Item tool);
|
||||
|
||||
signals:
|
||||
@@ -208,10 +217,13 @@ private:
|
||||
bool zoomed_;
|
||||
|
||||
/**
|
||||
* @brief position of mouse to calculate delta from.
|
||||
* @brief Position of mouse to calculate delta from.
|
||||
*/
|
||||
QPoint position_;
|
||||
|
||||
/**
|
||||
* @brief Set if the hand tool is selected.
|
||||
*/
|
||||
bool hand_tool_;
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -65,6 +65,10 @@ public:
|
||||
|
||||
signals:
|
||||
void RequestMatrix(const QMatrix4x4& matrix);
|
||||
|
||||
/**
|
||||
* @brief Tells the viewerdisplay widget if the image is enlarged to be bigger than the widget or not.
|
||||
*/
|
||||
void IsZoomed(bool flag);
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user