37 if ( !rendererAbstractMetadata )
40 if ( !rendererMetadata )
45 if ( !iconName.isEmpty() )
54static void _initRendererWidgetFunctions()
56 static bool sInitialized =
false;
60 _initRenderer( QStringLiteral(
"extent" ), QgsPointCloudExtentRendererWidget::create, QStringLiteral(
"styleicons/pointcloudextent.svg" ) );
61 _initRenderer( QStringLiteral(
"rgb" ), QgsPointCloudRgbRendererWidget::create, QStringLiteral(
"styleicons/multibandcolor.svg" ) );
62 _initRenderer( QStringLiteral(
"ramp" ), QgsPointCloudAttributeByRampRendererWidget::create, QStringLiteral(
"styleicons/singlebandpseudocolor.svg" ) );
63 _initRenderer( QStringLiteral(
"classified" ), QgsPointCloudClassifiedRendererWidget::create, QStringLiteral(
"styleicons/paletted.svg" ) );
75 layout()->setContentsMargins( 0, 0, 0, 0 );
78 _initRendererWidgetFunctions();
82 for (
const QString &name : renderers )
85 cboRenderers->addItem( m->icon(), m->visibleName(), name );
88 cboRenderers->setCurrentIndex( -1 );
93 connect( cboRenderers,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::rendererChanged );
95 connect( mBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
101 connect( mPointSizeSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
110 mMaxErrorSpinBox->setClearValue( 0.3 );
112 mEdlStrength->setClearValue( 1000 );
113 mEdlDistance->setClearValue( 0.5 );
118 connect( mMaxErrorSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
121 connect( mPointStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
122 connect( mDrawOrderComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
123 connect( mDrawOrderComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ]
125 mEdlWarningLabel->setVisible( mDrawOrderComboBox->currentIndex() == 0 );
127 connect( mEyeDomeLightingGroupBox, &QGroupBox::toggled,
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
128 connect( mEdlStrength, qOverload<int>( &QSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
129 connect( mEdlDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
146 mLayer = qobject_cast< QgsPointCloudLayer * >( layer );
148 mBlockChangedSignal =
true;
149 mOpacityWidget->setOpacity( mLayer->
opacity() );
151 mBlendModeComboBox->setBlendMode( mLayer->
blendMode() );
156 const QString rendererName = mLayer->
renderer()->
type();
158 const int rendererIdx = cboRenderers->findData( rendererName );
159 cboRenderers->setCurrentIndex( rendererIdx );
162 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
168 mPointStyleComboBox->setCurrentIndex( mPointStyleComboBox->findData(
static_cast< int >( mLayer->
renderer()->
pointSymbol() ) ) );
169 mDrawOrderComboBox->setCurrentIndex( mDrawOrderComboBox->findData(
static_cast< int >( mLayer->
renderer()->
drawOrder2d() ) ) );
181 mBlockChangedSignal =
false;
193 mLayer->
setOpacity( mOpacityWidget->opacity() );
194 mLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
198 else if ( !cboRenderers->currentData().toString().isEmpty() )
219void QgsPointCloudRendererPropertiesWidget::rendererChanged()
221 if ( cboRenderers->currentIndex() == -1 )
223 QgsDebugMsg( QStringLiteral(
"No current item -- this should never happen!" ) );
227 const QString rendererName = cboRenderers->currentData().toString();
230 std::unique_ptr< QgsPointCloudRenderer > oldRenderer;
231 std::unique_ptr< QgsPointCloudRenderer > newRenderer;
233 newRenderer.reset( mActiveWidget->
renderer() );
237 oldRenderer = std::move( newRenderer );
247 stackedWidget->removeWidget( mActiveWidget );
249 delete mActiveWidget;
250 mActiveWidget =
nullptr;
255 if ( rendererMetadata )
262 mActiveWidget = widget;
263 stackedWidget->addWidget( mActiveWidget );
264 stackedWidget->setCurrentWidget( mActiveWidget );
266 if ( mMapCanvas || mMessageBar )
281 stackedWidget->setCurrentWidget( pageNoWidget );
286void QgsPointCloudRendererPropertiesWidget::emitWidgetChanged()
288 if ( !mBlockChangedSignal )
PointCloudSymbol
Rendering symbols for point cloud points.
@ Circle
Renders points as circles.
@ Square
Renders points as squares.
PointCloudDrawOrder
Pointcloud rendering order for 2d views.
@ BottomToTop
Draw points with larger Z values last.
@ Default
Draw points in the order they are stored.
@ TopToBottom
Draw points with larger Z values first.
static QgsPointCloudRendererRegistry * pointCloudRendererRegistry()
Returns the application's point cloud renderer registry, used for managing point cloud layer 2D rende...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Base class for all map layer types.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
Represents a map layer supporting display of point clouds.
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
void setRenderer(QgsPointCloudRenderer *renderer)
Sets the 2D renderer for the point cloud.
Registry of 2D renderers for point clouds.
QgsPointCloudRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
QStringList renderersList() const
Returns a list of available renderers.
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when rendering the point cloud.
void setPointSizeUnit(const QgsUnitTypes::RenderUnit units)
Sets the units used for the point size.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting effect will be used.
const QgsMapUnitScale & pointSizeMapUnitScale() const
Returns the map unit scale used for the point size.
void setPointSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the point size.
QgsUnitTypes::RenderUnit eyeDomeLightingDistanceUnit() const
Returns unit for the eye dome lighting distance.
void setPointSize(double size)
Sets the point size.
virtual QString type() const =0
Returns the identifier of the renderer type.
QgsUnitTypes::RenderUnit maximumScreenErrorUnit() const
Returns the unit for the maximum screen error allowed when rendering the point cloud.
virtual QgsPointCloudRenderer * clone() const =0
Create a deep copy of this renderer.
void setDrawOrder2d(Qgis::PointCloudDrawOrder order)
Sets the drawing order used by the renderer for drawing points.
QgsUnitTypes::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
void setEyeDomeLightingDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets unit for the eye dome lighting distance.
void setPointSymbol(Qgis::PointCloudSymbol symbol)
Sets the symbol used by the renderer for drawing points.
void setEyeDomeLightingDistance(double distance)
Sets the eye dome lighting distance.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the point cloud.
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
void setMaximumScreenErrorUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the point cloud.
bool eyeDomeLightingEnabled() const
Returns whether eye dome lighting effect will be used.
Qgis::PointCloudSymbol pointSymbol() const
Returns the symbol used by the renderer for drawing points.
Qgis::PointCloudDrawOrder drawOrder2d() const
Returns the drawing order used by the renderer for drawing points.
double eyeDomeLightingStrength() const
Returns the eye dome lighting strength value.
double pointSize() const
Returns the point size.
double eyeDomeLightingDistance() const
Returns the eye dome lighting distance.
static bool layerIsContainedInGroupLayer(QgsProject *project, QgsMapLayer *layer)
Returns true if the specified layer is a child layer from any QgsGroupLayer in the given project.
static QgsProject * instance()
Returns the QgsProject singleton instance.
The class is used as a container of context for various read/write operations on other objects.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPoints
Points (e.g., for font sizes)
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
#define QgsDebugMsgLevel(str, level)
QgsPointCloudRendererWidget *(* QgsPointCloudRendererWidgetFunc)(QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer *)