/**************************************************************************** ** ** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt 3D Studio. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef Q3DS_STUDIO_RENDERER_H #define Q3DS_STUDIO_RENDERER_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include "IStudioRenderer.h" #include "DispatchListeners.h" #include "Core.h" #include "Dispatch.h" #include "Q3DSEditCamera.h" #include "StudioPickValues.h" #include "Qt3DSDMGuides.h" #include "IDocumentEditor.h" #include "StudioEnums.h" #include "IDocSceneGraph.h" #include #include #include QT_BEGIN_NAMESPACE namespace Qt3DRender { class QRenderAspect; } class QPainter; QT_END_NAMESPACE namespace Q3DStudio { class Q3DSTranslation; class Q3DStudioRenderer : public QObject, public IStudioRenderer, public IDataModelListener, public IReloadListener, public CPresentationChangeListener, public CSceneDragListener, public CToolbarChangeListener, public ITextRenderer { Q_OBJECT public: Q3DStudioRenderer(bool sceneCameraMode); ~Q3DStudioRenderer() override; ITextRenderer *GetTextRenderer() override; QT3DSVec3 GetIntendedPosition(qt3dsdm::Qt3DSDMInstanceHandle inHandle, CPt inPoint) override; Q3DSRenderBufferManager *GetBufferManager() override; bool requestObjectAt(const QPoint &pt) override; IPathManager *GetPathManager() override; qt3ds::foundation::IStringTable *GetRenderStringTable() override; void RequestRender() override; void renderNow() override; bool IsInitialized() override; void initialize(QOpenGLWidget *widget, bool hasPresentation) override; void SetViewRect(const QRect &inRect, const QSize &size) override; void GetEditCameraList(QStringList &outCameras) override; void SetPolygonFillModeEnabled(bool inEnableFillMode) override; bool IsPolygonFillModeEnabled() const override; bool DoesEditCameraSupportRotation(QT3DSI32 inIndex) override; bool AreGuidesEnabled() const override; void SetGuidesEnabled(bool val) override; bool AreGuidesEditable() const override; void SetGuidesEditable(bool val) override; void SetEditCamera(QT3DSI32 inIndex) override; QT3DSI32 GetEditCamera() const override; void EditCameraZoomToFit() override; bool isMouseDown() const override; void Close() override; void RegisterSubpresentations( const QVector &subpresentations) override; void drawRulersAndGuides(QPainter *painter) override; QSharedPointer &engine(); QRect viewRect() const { return m_viewRect; } QPoint scenePoint(const QPoint &viewPoint); QPoint presentationPoint(const QPoint &viewPoint); Q_SIGNALS: void objectPicked(int instance); protected: void OnBeginDataModelNotifications() override; void OnEndDataModelNotifications() override; void OnImmediateRefreshInstanceSingle(qt3dsdm::Qt3DSDMInstanceHandle inInstance) override; void OnImmediateRefreshInstanceMultiple(qt3dsdm::Qt3DSDMInstanceHandle *inInstance, long inInstanceCount) override; void OnReloadEffectInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) override; void OnNewPresentation() override; void OnClosingPresentation() override; void OnSceneMouseDown(SceneDragSenderType::Enum inSenderType, QPoint inPoint, int) override; void OnSceneMouseDrag(SceneDragSenderType::Enum, QPoint inPoint, int inToolMode, int inFlags) override; void OnSceneMouseUp(SceneDragSenderType::Enum) override; void OnSceneMouseDblClick(SceneDragSenderType::Enum inSenderType, QPoint inPoint) override; void OnSceneMouseWheel(SceneDragSenderType::Enum inSenderType, short inDelta, int inToolMode) override; void OnToolbarChange() override; void onSelectionChange(Q3DStudio::SSelectedValue selectable); void onScenePick(); virtual void reloadFonts() override; virtual QVector &projectFontList() override; void setupTextRenderer(); private: bool editCameraEnabled() const { return m_editCameraIndex > -1 ? true : false; } void initEngineAndTranslation(); void createTranslation(); void sendResizeToQt3D(); void drawTickMarksOnHorizontalRects(QPainter &painter, int innerLeft, int innerRight, int innerBottom, int innerTop); void drawTickMarksOnVerticalRects(QPainter &painter, int innerLeft, int innerRight, int innerBottom, int innerTop); void performGuideDrag(qt3dsdm::Qt3DSDMGuideHandle guide, const QPoint &mousePoint); void checkGuideInPresentationRect(qt3dsdm::Qt3DSDMGuideHandle guide); PickTargetAreas getPickArea(const QPoint &point); qt3ds::foundation::Option pickRulers(const QPoint &inMouseCoords); SStudioPickValue pick(const QPoint &inMouseCoords, SelectMode inSelectMode, bool objectPick); void ensurePicker(); void handlePickResult(const SStudioPickValue &pickResult, bool objectPick); SStudioPickValue postScenePick(bool objectPick); void scheduleDirtySetUpdate(); CDispatch &m_dispatch; CDoc &m_doc; qt3dsdm::TSignalConnectionPtr m_selectionSignal; QSharedPointer m_engine; QSharedPointer m_presentation; QOpenGLWidget *m_widget = nullptr; Qt3DRender::QRenderAspect *m_renderAspect = nullptr; QScopedPointer m_viewportSettings; QScopedPointer m_translation; QVector m_editCameraInformation; QRect m_viewRect; QSize m_size; QColor m_rulerColor; QColor m_rulerTickColor; QColor m_guideColor; QColor m_guideSelectedColor; QColor m_guideFillColor; QColor m_guideSelectedFillColor; bool m_guidesEnabled = false; bool m_hasPresentation = false; int m_renderRequested = 0; bool m_setSubpresentationsCalled = false; int m_editCameraIndex = -1; int m_pendingEditCameraIndex = -1; SStudioPickValue m_dragPickResult; CUpdateableDocumentEditor m_updatableEditor; QPoint m_mouseDownPoint; bool m_mouseDown = false; QPoint m_previousMousePoint; MovementTypes m_lastDragToolMode = MovementTypes::Unknown; bool m_maybeDragStart = false; SEditCameraPersistentInformation m_mouseDownCameraInformation; int m_lastToolMode = 0; QScopedPointer m_scenePicker; QSet m_discardedPickers; bool m_objectPicking = false; QVector m_fonts; QVector m_systemFonts; QVector m_projectFonts; QVector m_subpresentations; bool m_dirtySetUpdate = false; bool m_resizeToQt3DSent = false; qreal m_parentPixelRatio = 1.0; QTimer m_asyncRenderTimer; bool m_sceneCameraMode = false; }; } #endif