Skip to content
Permalink
Browse files

fix datadefined ui

  • Loading branch information
vcloarec authored and nyalldawson committed Nov 15, 2020
1 parent c54c2ee commit 8e4d9ca90546691ecdfec047e1690b503f7c1db5
@@ -14,4 +14,7 @@
QgsAbstractMaterialSettings.TrianglesFromModel = QgsMaterialSettingsRenderingTechnique.TrianglesFromModel
QgsAbstractMaterialSettings.TrianglesFromModel.__doc__ = "Triangle based rendering, using a model object source"
QgsMaterialSettingsRenderingTechnique.__doc__ = 'Material rendering techniques\n\n.. versionadded:: 3.16\n\n' + '* ``Triangles``: ' + QgsMaterialSettingsRenderingTechnique.Triangles.__doc__ + '\n' + '* ``Lines``: ' + QgsMaterialSettingsRenderingTechnique.Lines.__doc__ + '\n' + '* ``InstancedPoints``: ' + QgsMaterialSettingsRenderingTechnique.InstancedPoints.__doc__ + '\n' + '* ``Points``: ' + QgsMaterialSettingsRenderingTechnique.Points.__doc__ + '\n' + '* ``TrianglesWithFixedTexture``: ' + QgsMaterialSettingsRenderingTechnique.TrianglesWithFixedTexture.__doc__ + '\n' + '* ``TrianglesFromModel``: ' + QgsMaterialSettingsRenderingTechnique.TrianglesFromModel.__doc__
QgsAbstractMaterialSettings.TrianglesDataDefined = QgsMaterialSettingsRenderingTechnique.TrianglesDataDefined
QgsAbstractMaterialSettings.TrianglesDataDefined.__doc__ = "Triangle based rendering with possibility of datadefined color \since QGIS 3.18"
QgsMaterialSettingsRenderingTechnique.__doc__ = 'Material rendering techniques\n\n.. versionadded:: 3.16\n\n' + '* ``Triangles``: ' + QgsMaterialSettingsRenderingTechnique.Triangles.__doc__ + '\n' + '* ``Lines``: ' + QgsMaterialSettingsRenderingTechnique.Lines.__doc__ + '\n' + '* ``InstancedPoints``: ' + QgsMaterialSettingsRenderingTechnique.InstancedPoints.__doc__ + '\n' + '* ``Points``: ' + QgsMaterialSettingsRenderingTechnique.Points.__doc__ + '\n' + '* ``TrianglesWithFixedTexture``: ' + QgsMaterialSettingsRenderingTechnique.TrianglesWithFixedTexture.__doc__ + '\n' + '* ``TrianglesDataDefined``: ' + QgsMaterialSettingsRenderingTechnique.TrianglesDataDefined.__doc__
# --
@@ -19,6 +19,7 @@ enum class QgsMaterialSettingsRenderingTechnique
Points,
TrianglesWithFixedTexture,
TrianglesFromModel,
TrianglesDataDefined,
};


@@ -48,6 +48,7 @@ enum class QgsMaterialSettingsRenderingTechnique SIP_MONKEYPATCH_SCOPEENUM_UNNES
Points, //!< Point based rendering, requires point data
TrianglesWithFixedTexture, //!< Triangle based rendering, using a fixed, non-user-configurable texture (e.g. for terrain rendering)
TrianglesFromModel, //!< Triangle based rendering, using a model object source
TrianglesDataDefined, //!< Triangle based rendering with possibility of datadefined color \since QGIS 3.18
};


@@ -43,6 +43,7 @@ bool QgsGoochMaterialSettings::supportsTechnique( QgsMaterialSettingsRenderingTe
case QgsMaterialSettingsRenderingTechnique::Triangles:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
return true;

case QgsMaterialSettingsRenderingTechnique::Lines:
@@ -94,12 +95,12 @@ Qt3DRender::QMaterial *QgsGoochMaterialSettings::toMaterial( QgsMaterialSettings
switch ( technique )
{
case QgsMaterialSettingsRenderingTechnique::Triangles:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel:
{
if ( dataDefinedProperties().hasActiveProperties() )
return dataDefinedMaterial();

Qt3DExtras::QGoochMaterial *material = new Qt3DExtras::QGoochMaterial;
material->setDiffuse( mDiffuse );
material->setWarm( mWarm );
@@ -44,6 +44,7 @@ bool QgsPhongMaterialSettings::supportsTechnique( QgsMaterialSettingsRenderingTe
case QgsMaterialSettingsRenderingTechnique::Points:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
return true;

case QgsMaterialSettingsRenderingTechnique::Lines:
@@ -90,6 +91,7 @@ Qt3DRender::QMaterial *QgsPhongMaterialSettings::toMaterial( QgsMaterialSettings
case QgsMaterialSettingsRenderingTechnique::Triangles:
case QgsMaterialSettingsRenderingTechnique::InstancedPoints:
case QgsMaterialSettingsRenderingTechnique::Points:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel:
{
@@ -37,6 +37,7 @@ bool QgsPhongTexturedMaterialSettings::supportsTechnique( QgsMaterialSettingsRen
switch ( technique )
{
case QgsMaterialSettingsRenderingTechnique::Triangles:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined: //technique is supported but color can't be datadefined
return true;

case QgsMaterialSettingsRenderingTechnique::Points:
@@ -120,6 +121,7 @@ Qt3DRender::QMaterial *QgsPhongTexturedMaterialSettings::toMaterial( QgsMaterial
case QgsMaterialSettingsRenderingTechnique::Points:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
{
bool fitsInCache = false;
QImage textureSourceImage = QgsApplication::imageCache()->pathAsImage( mDiffuseTexturePath, QSize(), true, 1.0, fitsInCache );
@@ -39,6 +39,7 @@ bool QgsSimpleLineMaterialSettings::supportsTechnique( QgsMaterialSettingsRender
case QgsMaterialSettingsRenderingTechnique::Points:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
return false;
}
return false;
@@ -73,6 +74,7 @@ Qt3DRender::QMaterial *QgsSimpleLineMaterialSettings::toMaterial( QgsMaterialSet
case QgsMaterialSettingsRenderingTechnique::Points:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
case QgsMaterialSettingsRenderingTechnique::TrianglesFromModel:
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
return nullptr;

case QgsMaterialSettingsRenderingTechnique::Lines:
@@ -314,7 +314,10 @@ Qt3DRender::QMaterial *QgsPolygon3DSymbolHandler::material( const QgsPolygon3DSy
materialContext.setIsSelected( isSelected );
materialContext.setSelectionColor( context.map().selectionColor() );

Qt3DRender::QMaterial *material = symbol->material()->toMaterial( QgsMaterialSettingsRenderingTechnique::Triangles, materialContext );
bool dataDefined = mSymbol->material()->dataDefinedProperties().hasActiveProperties();
Qt3DRender::QMaterial *material = symbol->material()->toMaterial( dataDefined ?
QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined : QgsMaterialSettingsRenderingTechnique::Triangles,
materialContext );
applyCullingMode( symbol->cullingMode(), material );
return material;
}
@@ -70,6 +70,32 @@ void QgsGoochMaterialWidget::setSettings( const QgsAbstractMaterialSettings *set
mSpecularDataDefinedButton->init( QgsAbstractMaterialSettings::Specular, settings->dataDefinedProperties(), settings->propertyDefinitions(), layer, true );
}

void QgsGoochMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique technique )
{
switch ( technique )
{
case QgsMaterialSettingsRenderingTechnique::Triangles:

case QgsMaterialSettingsRenderingTechnique::InstancedPoints:
case QgsMaterialSettingsRenderingTechnique::Points:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
mDiffuseDataDefinedButton->setVisible( false );
mWarmDataDefinedButton->setVisible( false );
mCoolDataDefinedButton->setVisible( false );
mSpecularDataDefinedButton->setVisible( false );
break;
case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
mDiffuseDataDefinedButton->setVisible( true );
mWarmDataDefinedButton->setVisible( true );
mCoolDataDefinedButton->setVisible( true );
mSpecularDataDefinedButton->setVisible( true );
break;
case QgsMaterialSettingsRenderingTechnique::Lines:
// not supported
break;
}
}

QgsAbstractMaterialSettings *QgsGoochMaterialWidget::settings()
{
std::unique_ptr< QgsGoochMaterialSettings > m = qgis::make_unique< QgsGoochMaterialSettings >();
@@ -32,6 +32,7 @@ class QgsGoochMaterialWidget : public QgsMaterialSettingsWidget, private Ui::Goo

static QgsMaterialSettingsWidget *create();
void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) override;
void setTechnique( QgsMaterialSettingsRenderingTechnique technique ) override;
QgsAbstractMaterialSettings *settings() override;

};
@@ -49,9 +49,9 @@ void QgsPhongMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique
{
lblDiffuse->setVisible( true );
btnDiffuse->setVisible( true );
mAmbientDataDefinedButton->setVisible( true );
mDiffuseDataDefinedButton->setVisible( true );
mSpecularDataDefinedButton->setVisible( true );
mAmbientDataDefinedButton->setVisible( false );
mDiffuseDataDefinedButton->setVisible( false );
mSpecularDataDefinedButton->setVisible( false );
break;
}
case QgsMaterialSettingsRenderingTechnique::InstancedPoints:
@@ -75,6 +75,16 @@ void QgsPhongMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique
break;
}

case QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined:
{
lblDiffuse->setVisible( true );
btnDiffuse->setVisible( true );
mAmbientDataDefinedButton->setVisible( true );
mDiffuseDataDefinedButton->setVisible( true );
mSpecularDataDefinedButton->setVisible( true );
break;
}

case QgsMaterialSettingsRenderingTechnique::Lines:
// not supported
break;
@@ -44,7 +44,7 @@ QgsPolygon3DSymbolWidget::QgsPolygon3DSymbolWidget( QWidget *parent )
connect( btnEdgeColor, &QgsColorButton::colorChanged, this, &QgsPolygon3DSymbolWidget::changed );
connect( spinEdgeWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPolygon3DSymbolWidget::changed );

widgetMaterial->setTechnique( QgsMaterialSettingsRenderingTechnique::Triangles );
widgetMaterial->setTechnique( QgsMaterialSettingsRenderingTechnique::TrianglesDataDefined );
}

Qgs3DSymbolWidget *QgsPolygon3DSymbolWidget::create( QgsVectorLayer * )

0 comments on commit 8e4d9ca

Please sign in to comment.
You can’t perform that action at this time.