diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-03-01 11:26:51 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-03-20 08:48:22 +0000 |
commit | ae044e6ee37b228e109b19c7c13be5c260c0bb64 (patch) | |
tree | 928d8301782c7621902f87a457bab105b2e0a8b5 /src/Authoring/Studio/Palettes/scenecamera/scenecameraview.cpp | |
parent | 024a0a8082ee45ed5a50cbcd252abd5f054a134e (diff) |
Implement scene camera preview
Scene camera preview tab will use a completely separate renderer
from the main scene renderer. This essentially duplicates the
rendering overhead, but it is required as Qt3D underlying
the runtime will not respond to any scene changes without some
delay, making it impossible to render both preview and regular scene
with the same renderer in a timely manner.
Task-number: QT3DS-2070
Change-Id: I5e2c9f280990bf295ef84d83244c18a37f94aca3
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/scenecamera/scenecameraview.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/scenecamera/scenecameraview.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Authoring/Studio/Palettes/scenecamera/scenecameraview.cpp b/src/Authoring/Studio/Palettes/scenecamera/scenecameraview.cpp index b4470cd6..63da8ef2 100644 --- a/src/Authoring/Studio/Palettes/scenecamera/scenecameraview.cpp +++ b/src/Authoring/Studio/Palettes/scenecamera/scenecameraview.cpp @@ -36,6 +36,7 @@ #include "Q3DSPlayerWnd.h" #include "MouseCursor.h" #include "ResourceCache.h" +#include "Dispatch.h" #include <QtGui/qevent.h> #include <QtWidgets/qscrollbar.h> @@ -50,6 +51,8 @@ SceneCameraView::SceneCameraView(CMainFrame *mainFrame, QWidget *parent) : { m_ui->setupUi(this); + g_StudioApp.GetCore()->GetDispatch()->AddPresentationChangeListener(this); + m_cursorPan = CResourceCache::GetInstance()->GetCursor(CMouseCursor::CURSOR_EDIT_CAMERA_PAN); m_cursorZoom = CResourceCache::GetInstance()->GetCursor(CMouseCursor::CURSOR_EDIT_CAMERA_ZOOM); @@ -59,8 +62,6 @@ SceneCameraView::SceneCameraView(CMainFrame *mainFrame, QWidget *parent) : connect(m_ui->zoomSlider, &QSlider::valueChanged, this, &SceneCameraView::handleSliderValueChange); - connect(mainFrame->GetPlayerWnd(), &Q3DStudio::Q3DSPlayerWnd::newFrame, - this, &SceneCameraView::requestUpdate); connect(m_ui->scrollArea, &SceneCameraScrollArea::needUpdate, this, &SceneCameraView::requestUpdate); connect(&m_updateTimer, &QTimer::timeout, this, &SceneCameraView::doUpdate); @@ -68,9 +69,20 @@ SceneCameraView::SceneCameraView(CMainFrame *mainFrame, QWidget *parent) : SceneCameraView::~SceneCameraView() { + g_StudioApp.GetCore()->GetDispatch()->RemovePresentationChangeListener(this); delete m_ui; } +void SceneCameraView::OnNewPresentation() +{ + m_ui->scrollArea->setPresentationAvailable(true); +} + +void SceneCameraView::OnClosingPresentation() +{ + m_ui->scrollArea->setPresentationAvailable(false); +} + void SceneCameraView::wheelEvent(QWheelEvent *e) { m_zoomPoint = m_ui->scrollArea->viewport()->mapFrom(this, e->pos()); @@ -151,7 +163,7 @@ void SceneCameraView::doUpdate() // There is no event for presentation size change, so update every frame to catch the change m_ui->scrollArea->setPresentationSize( g_StudioApp.GetCore()->GetStudioProjectSettings()->getPresentationSize()); - m_ui->scrollArea->glWidget()->update(); + m_ui->scrollArea->glWidget()->requestRender(); } void SceneCameraView::requestUpdate() |