23#include <Qt3DRender/QBlendEquation>
24#include <Qt3DRender/QBlendEquationArguments>
25#include <Qt3DRender/QCamera>
26#include <Qt3DRender/QEffect>
27#include <Qt3DRender/QGraphicsApiFilter>
28#include <Qt3DRender/QParameter>
29#include <Qt3DRender/QRenderPass>
30#include <Qt3DRender/QTechnique>
35QgsLineMaterial::QgsLineMaterial()
36 : mParameterThickness( new
Qt3DRender::QParameter(
"THICKNESS", 10, this ) )
37 , mParameterMiterLimit( new
Qt3DRender::QParameter(
"MITER_LIMIT", -1, this ) )
38 , mParameterLineColor( new
Qt3DRender::QParameter(
"lineColor", QColor( 0, 255, 0 ), this ) )
39 , mParameterUseVertexColors( new
Qt3DRender::QParameter(
"useVertexColors", false, this ) )
40 , mParameterWindowScale( new
Qt3DRender::QParameter(
"WIN_SCALE", QSizeF(), this ) )
42 addParameter( mParameterThickness );
43 addParameter( mParameterMiterLimit );
44 addParameter( mParameterLineColor );
45 addParameter( mParameterUseVertexColors );
46 addParameter( mParameterWindowScale );
51 Qt3DRender::QShaderProgram *shaderProgram =
new Qt3DRender::QShaderProgram(
this );
52 shaderProgram->setVertexShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( QStringLiteral(
"qrc:/shaders/lines.vert" ) ) ) );
53 shaderProgram->setFragmentShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( QStringLiteral(
"qrc:/shaders/lines.frag" ) ) ) );
54 shaderProgram->setGeometryShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( QStringLiteral(
"qrc:/shaders/lines.geom" ) ) ) );
56 Qt3DRender::QRenderPass *renderPass =
new Qt3DRender::QRenderPass(
this );
57 renderPass->setShaderProgram( shaderProgram );
60 Qt3DRender::QFilterKey *filterKey =
new Qt3DRender::QFilterKey;
61 filterKey->setName( QStringLiteral(
"renderingStyle" ) );
62 filterKey->setValue(
"forward" );
64 Qt3DRender::QTechnique *technique =
new Qt3DRender::QTechnique;
65 technique->addFilterKey( filterKey );
66 technique->addRenderPass( renderPass );
67 technique->graphicsApiFilter()->setApi( Qt3DRender::QGraphicsApiFilter::OpenGL );
68 technique->graphicsApiFilter()->setProfile( Qt3DRender::QGraphicsApiFilter::CoreProfile );
69 technique->graphicsApiFilter()->setMajorVersion( 3 );
70 technique->graphicsApiFilter()->setMinorVersion( 1 );
72 Qt3DRender::QEffect *effect =
new Qt3DRender::QEffect(
this );
73 effect->addTechnique( technique );
78void QgsLineMaterial::setLineColor(
const QColor &color )
80 mParameterLineColor->setValue( color );
83QColor QgsLineMaterial::lineColor()
const
85 return mParameterLineColor->value().value<QColor>();
88void QgsLineMaterial::setUseVertexColors(
bool enabled )
90 mParameterUseVertexColors->setValue( enabled );
93bool QgsLineMaterial::useVertexColors()
const
95 return mParameterUseVertexColors->value().toBool();
98void QgsLineMaterial::setLineWidth(
float width )
100 mParameterThickness->setValue( width );
103float QgsLineMaterial::lineWidth()
const
105 return mParameterThickness->value().toFloat();
108void QgsLineMaterial::setViewportSize(
const QSizeF &viewportSize )
110 mParameterWindowScale->setValue( viewportSize );