Skip to content

Commit

Permalink
Working gui for setting point cloud opacity and blend mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 16, 2020
1 parent 1758ca1 commit 1951489
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
Expand Up @@ -35,10 +35,12 @@ Sets the ``context`` in which the widget is shown, e.g., the associated map canv

virtual void syncToLayer( QgsMapLayer *layer );


public slots:

virtual void apply();


};


Expand Down
8 changes: 8 additions & 0 deletions src/app/pointcloud/qgspointcloudlayerproperties.cpp
Expand Up @@ -131,12 +131,17 @@ void QgsPointCloudLayerProperties::apply()

// TODO -- move to proper widget classes!

#if 0
std::unique_ptr< QgsDummyPointCloudRenderer > renderer = qgis::make_unique< QgsDummyPointCloudRenderer >();
renderer->setAttribute( mAttributeComboBox->currentAttribute() );
renderer->setZMin( mMinZSpin->value() );
renderer->setZMax( mMaxZSpin->value() );
renderer->setColorRamp( mBtnColorRamp->colorRamp() );
mLayer->setRenderer( renderer.release() );
#endif

for ( QgsMapLayerConfigWidget *w : mConfigWidgets )
w->apply();

mLayer->triggerRepaint();
}
Expand Down Expand Up @@ -176,6 +181,9 @@ void QgsPointCloudLayerProperties::syncToLayer()
mMaxZSpin->setValue( renderer->zMax() );
mBtnColorRamp->setColorRamp( renderer->colorRamp() );
}

for ( QgsMapLayerConfigWidget *w : mConfigWidgets )
w->syncToLayer( mLayer );
}


Expand Down
28 changes: 26 additions & 2 deletions src/gui/pointcloud/qgspointcloudrendererpropertieswidget.cpp
Expand Up @@ -78,9 +78,11 @@ QgsPointCloudRendererPropertiesWidget::QgsPointCloudRendererPropertiesWidget( Qg
// connect layer opacity slider and spin box
//connect( cboRenderers, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsPointCloudRendererPropertiesWidget::rendererChanged );

//syncToLayer();
}
connect( mBlendModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );

syncToLayer( layer );
}

void QgsPointCloudRendererPropertiesWidget::setContext( const QgsSymbolWidgetContext &context )
{
Expand All @@ -92,3 +94,25 @@ void QgsPointCloudRendererPropertiesWidget::setContext( const QgsSymbolWidgetCon
}
}

void QgsPointCloudRendererPropertiesWidget::syncToLayer( QgsMapLayer *layer )
{
mLayer = qobject_cast< QgsPointCloudLayer * >( layer );

mBlockChangedSignal = true;
mOpacityWidget->setOpacity( mLayer->opacity() );
mBlendModeComboBox->setBlendMode( mLayer->blendMode() );
mBlockChangedSignal = false;
}

void QgsPointCloudRendererPropertiesWidget::apply()
{
mLayer->setOpacity( mOpacityWidget->opacity() );
mLayer->setBlendMode( mBlendModeComboBox->blendMode() );
}

void QgsPointCloudRendererPropertiesWidget::emitWidgetChanged()
{
if ( !mBlockChangedSignal )
emit widgetChanged();
}

10 changes: 8 additions & 2 deletions src/gui/pointcloud/qgspointcloudrendererpropertieswidget.h
Expand Up @@ -51,11 +51,15 @@ class GUI_EXPORT QgsPointCloudRendererPropertiesWidget : public QgsMapLayerConfi
*/
void setContext( const QgsSymbolWidgetContext &context );

void syncToLayer( QgsMapLayer *layer ) override { Q_UNUSED( layer ) }
void syncToLayer( QgsMapLayer *layer ) override;

public slots:

void apply() override {}
void apply() override;

private slots:

void emitWidgetChanged();

private:

Expand All @@ -67,6 +71,8 @@ class GUI_EXPORT QgsPointCloudRendererPropertiesWidget : public QgsMapLayerConfi
QgsMapCanvas *mMapCanvas = nullptr;
QgsMessageBar *mMessageBar = nullptr;

bool mBlockChangedSignal = false;

};


Expand Down

0 comments on commit 1951489

Please sign in to comment.