From 0ef00245ade5bfc69b6609c33cb54c74370424e4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 19 Dec 2019 15:55:08 +1100 Subject: [PATCH] added functions to override the resolution and matrix transform of the viewer widget While in most circumstances these shouldn't be used, they're useful for showing things like export previews --- app/widget/viewer/viewer.cpp | 10 ++++++++++ app/widget/viewer/viewer.h | 4 ++++ app/widget/viewer/viewerglwidget.cpp | 8 +++++++- app/widget/viewer/viewerglwidget.h | 12 ++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/widget/viewer/viewer.cpp b/app/widget/viewer/viewer.cpp index edda85eab..1d4932c87 100644 --- a/app/widget/viewer/viewer.cpp +++ b/app/widget/viewer/viewer.cpp @@ -185,6 +185,16 @@ void ViewerWidget::SetColorMenuEnabled(bool enabled) gl_widget_->SetColorMenuEnabled(enabled); } +void ViewerWidget::SetOverrideSize(int width, int height) +{ + SizeChangedSlot(width, height); +} + +void ViewerWidget::SetMatrix(const QMatrix4x4 &mat) +{ + gl_widget_->SetMatrix(mat); +} + void ViewerWidget::SetTexture(OpenGLTexturePtr tex) { if (tex == nullptr) { diff --git a/app/widget/viewer/viewer.h b/app/widget/viewer/viewer.h index b62e55ec8..7b2b930de 100644 --- a/app/widget/viewer/viewer.h +++ b/app/widget/viewer/viewer.h @@ -71,6 +71,10 @@ public: void SetColorMenuEnabled(bool enabled); + void SetOverrideSize(int width, int height); + + void SetMatrix(const QMatrix4x4& mat); + public slots: /** * @brief Set the texture to draw and draw it diff --git a/app/widget/viewer/viewerglwidget.cpp b/app/widget/viewer/viewerglwidget.cpp index aef5adafe..dda1f1a35 100644 --- a/app/widget/viewer/viewerglwidget.cpp +++ b/app/widget/viewer/viewerglwidget.cpp @@ -69,6 +69,12 @@ void ViewerGLWidget::DisconnectColorManager() ConnectColorManager(nullptr); } +void ViewerGLWidget::SetMatrix(const QMatrix4x4 &mat) +{ + matrix_ = mat; + update(); +} + void ViewerGLWidget::SetOCIODisplay(const QString &display) { ocio_display_ = display; @@ -135,7 +141,7 @@ void ViewerGLWidget::paintGL() f->glBindTexture(GL_TEXTURE_2D, texture_); // Blit using the pipeline retrieved in initializeGL() - olive::gl::OCIOBlit(pipeline_, ocio_lut_, true); + olive::gl::OCIOBlit(pipeline_, ocio_lut_, true, matrix_); // Release retrieved texture f->glBindTexture(GL_TEXTURE_2D, 0); diff --git a/app/widget/viewer/viewerglwidget.h b/app/widget/viewer/viewerglwidget.h index 37907d1c2..16ff87371 100644 --- a/app/widget/viewer/viewerglwidget.h +++ b/app/widget/viewer/viewerglwidget.h @@ -94,6 +94,13 @@ public: */ void DisconnectColorManager(); + /** + * @brief Set the transformation matrix to draw with + * + * Set this if you want the drawing to pass through some sort of transform (most of the time you won't want this). + */ + void SetMatrix(const QMatrix4x4& mat); + public slots: /** * @brief Set the texture to draw and draw it @@ -195,6 +202,11 @@ private: */ ColorProcessorPtr color_service_; + /** + * @brief Drawing matrix (defaults to identity) + */ + QMatrix4x4 matrix_; + bool color_menu_enabled_; private slots: