1 /*************************************************************************** 2 qgspreviewquad.h 3 -------------------------------------- 4 Date : August 2020 5 Copyright : (C) 2020 by Belgacem Nedjima 6 Email : gb underscore nedjima at esi dot dz 7 *************************************************************************** 8 * * 9 * This program is free software; you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation; either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 ***************************************************************************/ 15 16 #ifndef QGSPREVIEWQUAD_H 17 #define QGSPREVIEWQUAD_H 18 19 #include <Qt3DCore/QEntity> 20 #include <Qt3DRender/QMaterial> 21 #include <Qt3DRender/QParameter> 22 #include <Qt3DRender/QEffect> 23 24 #define SIP_NO_FILE 25 26 /** 27 * \ingroup 3d 28 * \brief Material component for QgsPreviewQuad object 29 * 30 * \note Not available in Python bindings 31 * \since QGIS 3.16 32 */ 33 class QgsPreviewQuadMaterial : public Qt3DRender::QMaterial 34 { 35 public: 36 //! Constructor 37 QgsPreviewQuadMaterial( Qt3DRender::QAbstractTexture *texture, const QMatrix4x4 &modelMatrix, QVector<Qt3DRender::QParameter *> additionalShaderParameters = QVector<Qt3DRender::QParameter *>(), QNode *parent = nullptr ); 38 39 //! Sets the model matrix of the quad 40 void setModelMatrix( const QMatrix4x4 &modelMatrix ); 41 private: 42 Qt3DRender::QEffect *mEffect = nullptr; 43 Qt3DRender::QParameter *mTextureParameter = nullptr; 44 Qt3DRender::QParameter *mTextureTransformParameter = nullptr; 45 }; 46 47 /** 48 * \ingroup 3d 49 * \brief Rectangular quad entity used for debugging depth maps 50 * 51 * \note Not available in Python bindings 52 * \since QGIS 3.16 53 */ 54 class QgsPreviewQuad : public Qt3DCore::QEntity 55 { 56 public: 57 58 /** 59 * \brief Construct an object that displays a texture for debugging purposes (example: depth buffer) 60 * \param texture The texture to be rendered 61 * \param centerNDC The center of the texture in opnegl normalized device coordinates 62 * ie. Bottom left of the viewport is (-1, -1), the top right of the viewport is (1, 1) 63 * \param size The size of the displayed rectangle 64 * \param additionalShaderParameters More parameters to pass to the shader 65 * \param parent The parent of the quad 66 */ 67 QgsPreviewQuad( Qt3DRender::QAbstractTexture *texture, const QPointF ¢erNDC, const QSizeF &size, QVector<Qt3DRender::QParameter *> additionalShaderParameters = QVector<Qt3DRender::QParameter *>(), Qt3DCore::QEntity *parent = nullptr ); 68 69 //! Sets where the quad will be located on the scene 70 void setViewPort( const QPointF ¢erNDC, const QSizeF &size ); 71 private: 72 QgsPreviewQuadMaterial *mMaterial = nullptr; 73 }; 74 75 #endif // QGSPREVIEWQUAD_H 76