Skip to content
Permalink
Browse files

Add 3D rendering enable checkbox

  • Loading branch information
NEDJIMAbelgacem committed Nov 14, 2020
1 parent 69d89ce commit 623f6cde256e792fd63fc5fb022e109e715c3255
@@ -32,14 +32,13 @@ QgsPointCloudLayer3DRendererWidget::QgsPointCloudLayer3DRendererWidget( QgsPoint
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );

// TODO: add enabled checkbox
// mChkEnabled = new QCheckBox( tr( "Enable 3D Renderer" ), this );
// layout->addWidget( mChkEnabled );
mChkEnabled = new QCheckBox( tr( "Enable 3D Renderer" ), this );
layout->addWidget( mChkEnabled );

mWidgetPointCloudSymbol = new QgsPointCloud3DSymbolWidget( layer, this );
layout->addWidget( mWidgetPointCloudSymbol );

// connect( mChkEnabled, &QCheckBox::clicked, this, &QgsPointCloudLayer3DRendererWidget::onEnabledClicked );
connect( mChkEnabled, &QCheckBox::clicked, this, &QgsPointCloudLayer3DRendererWidget::onEnabledClicked );
connect( mWidgetPointCloudSymbol, &QgsPointCloud3DSymbolWidget::changed, this, &QgsPointCloudLayer3DRendererWidget::widgetChanged );
}

@@ -48,7 +47,7 @@ void QgsPointCloudLayer3DRendererWidget::setRenderer( const QgsPointCloudLayer3D
mRenderer.reset( renderer ? renderer->clone() : nullptr );
if ( renderer != nullptr )
mWidgetPointCloudSymbol->setSymbol( const_cast<QgsPointCloud3DSymbol *>( renderer->symbol() ) );
// whileBlocking( mChkEnabled )->setChecked( renderer ? renderer->symbol()->isEnabled() : false );
whileBlocking( mChkEnabled )->setChecked( renderer ? renderer->symbol()->isEnabled() : false );
}

QgsPointCloudLayer3DRenderer *QgsPointCloudLayer3DRendererWidget::renderer()
@@ -64,17 +63,21 @@ QgsPointCloudLayer3DRenderer *QgsPointCloudLayer3DRendererWidget::renderer()

void QgsPointCloudLayer3DRendererWidget::apply()
{
QgsPointCloudLayer3DRenderer *r = renderer();
if ( r )
r->setSymbol( mWidgetPointCloudSymbol->symbol() );
mLayer->setRenderer3D( r ? r->clone() : nullptr );
QgsPointCloudLayer3DRenderer *r = nullptr;
if ( mChkEnabled->isChecked() )
{
r = renderer()->clone();
if ( r )
r->setSymbol( mWidgetPointCloudSymbol->symbol() );
}
mLayer->setRenderer3D( r );
}

//void QgsPointCloudLayer3DRendererWidget::onEnabledClicked()
//{
// mWidgetPointCloudSymbol->setEnabled( mChkEnabled->isChecked() );
// emit widgetChanged();
//}
void QgsPointCloudLayer3DRendererWidget::onEnabledClicked()
{
mWidgetPointCloudSymbol->setEnabled( mChkEnabled->isChecked() );
emit widgetChanged();
}

void QgsPointCloudLayer3DRendererWidget::syncToLayer( QgsMapLayer *layer )
{
@@ -109,7 +112,10 @@ QgsMapLayerConfigWidget *QgsPointCloudLayer3DRendererWidgetFactory::createWidget
QgsPointCloudLayer *pointCloudLayer = qobject_cast<QgsPointCloudLayer *>( layer );
if ( !pointCloudLayer )
return nullptr;
return new QgsPointCloudLayer3DRendererWidget( pointCloudLayer, canvas, parent );
QgsPointCloudLayer3DRendererWidget *widget = new QgsPointCloudLayer3DRendererWidget( pointCloudLayer, canvas, parent );
if ( pointCloudLayer )
widget->setRenderer( dynamic_cast<QgsPointCloudLayer3DRenderer *>( pointCloudLayer->renderer3D() ) );
return widget;
}

bool QgsPointCloudLayer3DRendererWidgetFactory::supportLayerPropertiesDialog() const
@@ -46,10 +46,10 @@ class QgsPointCloudLayer3DRendererWidget : public QgsMapLayerConfigWidget
void apply() override;

private slots:
// void onEnabledClicked();
void onEnabledClicked();

private:
// QCheckBox *mChkEnabled = nullptr;
QCheckBox *mChkEnabled = nullptr;
QgsPointCloud3DSymbolWidget *mWidgetPointCloudSymbol = nullptr;
std::unique_ptr<QgsPointCloudLayer3DRenderer> mRenderer;
};
@@ -30,6 +30,9 @@
#include <QMessageBox>
#include <QDesktopServices>

#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerconfigwidgetfactory.h"

QgsPointCloudLayerProperties::QgsPointCloudLayerProperties( QgsPointCloudLayer *lyr, QgsMapCanvas *canvas, QgsMessageBar *, QWidget *parent, Qt::WindowFlags flags )
: QgsOptionsDialogBase( QStringLiteral( "PointCloudLayerProperties" ), parent, flags )
, mLayer( lyr )

0 comments on commit 623f6cd

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