Skip to content
Permalink
Browse files

Consistently pass layer to 3d symbol widgets

  • Loading branch information
nyalldawson committed Jul 29, 2020
1 parent fd28523 commit fbdc6766a57c376a6db69b0291a0018a3472cf64
@@ -572,7 +572,7 @@ Qgs3DRendererRulePropsWidget::Qgs3DRendererRulePropsWidget( QgsRuleBased3DRender
mSymbol.reset( QgsApplication::symbol3DRegistry()->defaultSymbolForGeometryType( layer->geometryType() ) );
}

mSymbolWidget = new QgsSymbol3DWidget( this );
mSymbolWidget = new QgsSymbol3DWidget( layer, this );
mSymbolWidget->setSymbol( mSymbol.get(), layer );
QVBoxLayout *l = new QVBoxLayout;
l->addWidget( mSymbolWidget );
@@ -31,8 +31,9 @@
#include <QMessageBox>


QgsSymbol3DWidget::QgsSymbol3DWidget( QWidget *parent )
QgsSymbol3DWidget::QgsSymbol3DWidget( QgsVectorLayer *layer, QWidget *parent )
: QWidget( parent )
, mLayer( layer )
{
widgetUnsupported = new QLabel( tr( "Sorry, this symbol is not supported." ), this );
widgetLine = new QgsLine3DSymbolWidget( this );
@@ -83,7 +84,8 @@ std::unique_ptr<QgsAbstract3DSymbol> QgsSymbol3DWidget::symbol()
void QgsSymbol3DWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *vlayer )
{
int pageIndex;
switch ( vlayer->geometryType() )
mLayer = vlayer;
switch ( mLayer->geometryType() )
{
case QgsWkbTypes::PointGeometry:
pageIndex = 2;
@@ -139,11 +141,11 @@ void QgsSymbol3DWidget::setSymbolFromStyle( const QString &name )
return;

if ( s->type() == QStringLiteral( "point" ) )
widgetPoint->setSymbol( s.release(), nullptr );
widgetPoint->setSymbol( s.release(), mLayer );
else if ( s->type() == QStringLiteral( "line" ) )
widgetLine->setSymbol( s.release(), nullptr );
widgetLine->setSymbol( s.release(), mLayer );
else if ( s->type() == QStringLiteral( "polygon" ) )
widgetPolygon->setSymbol( s.release(), nullptr );
widgetPolygon->setSymbol( s.release(), mLayer );
}

void QgsSymbol3DWidget::saveSymbol()
@@ -38,7 +38,7 @@ class QgsSymbol3DWidget : public QWidget
Q_OBJECT

public:
QgsSymbol3DWidget( QWidget *parent = nullptr );
QgsSymbol3DWidget( QgsVectorLayer *layer, QWidget *parent = nullptr );

//! Returns a new symbol instance or NULLPTR
std::unique_ptr< QgsAbstract3DSymbol > symbol();
@@ -64,6 +64,8 @@ class QgsSymbol3DWidget : public QWidget

QgsStyleItemsListWidget *mStyleWidget = nullptr;

QgsVectorLayer *mLayer = nullptr;

};


@@ -34,10 +34,11 @@



QgsSingleSymbol3DRendererWidget::QgsSingleSymbol3DRendererWidget( QWidget *parent )
QgsSingleSymbol3DRendererWidget::QgsSingleSymbol3DRendererWidget( QgsVectorLayer *layer, QWidget *parent )
: QWidget( parent )
, mLayer( layer )
{
widgetSymbol = new QgsSymbol3DWidget( this );
widgetSymbol = new QgsSymbol3DWidget( mLayer, this );

QVBoxLayout *layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );
@@ -90,7 +91,7 @@ QgsVectorLayer3DRendererWidget::QgsVectorLayer3DRendererWidget( QgsMapLayer *lay
layout->addWidget( widgetBaseProperties );

widgetNoRenderer = new QLabel;
widgetSingleSymbolRenderer = new QgsSingleSymbol3DRendererWidget( this );
widgetSingleSymbolRenderer = new QgsSingleSymbol3DRendererWidget( qobject_cast< QgsVectorLayer *>( layer ), this );
widgetRuleBasedRenderer = new QgsRuleBased3DRendererWidget( this );

widgetRendererStack->addWidget( widgetNoRenderer );
@@ -39,7 +39,7 @@ class QgsSingleSymbol3DRendererWidget : public QWidget
{
Q_OBJECT
public:
QgsSingleSymbol3DRendererWidget( QWidget *parent = nullptr );
QgsSingleSymbol3DRendererWidget( QgsVectorLayer *layer, QWidget *parent = nullptr );

//! no transfer of ownership
void setLayer( QgsVectorLayer *layer );
@@ -52,6 +52,7 @@ class QgsSingleSymbol3DRendererWidget : public QWidget

private:
QgsSymbol3DWidget *widgetSymbol = nullptr;
QgsVectorLayer *mLayer = nullptr;

};

@@ -489,7 +489,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
{
if ( !mVector3DWidget )
{
mVector3DWidget = new QgsVectorLayer3DRendererWidget( nullptr, mMapCanvas, mWidgetStack );
mVector3DWidget = new QgsVectorLayer3DRendererWidget( vlayer, mMapCanvas, mWidgetStack );
mVector3DWidget->setDockMode( true );
connect( mVector3DWidget, &QgsVectorLayer3DRendererWidget::widgetChanged, this, &QgsLayerStylingWidget::autoApply );
}

0 comments on commit fbdc676

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