37 if ( !rendererAbstractMetadata )
40 if ( !rendererMetadata )
45 if ( !iconName.isEmpty() )
54 static 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 connect( mMaxErrorSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
115 connect( mPointStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
116 connect( mDrawOrderComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
132 mLayer = qobject_cast< QgsPointCloudLayer * >( layer );
134 mBlockChangedSignal =
true;
135 mOpacityWidget->setOpacity( mLayer->
opacity() );
137 mBlendModeComboBox->setBlendMode( mLayer->
blendMode() );
142 const QString rendererName = mLayer->
renderer()->
type();
144 const int rendererIdx = cboRenderers->findData( rendererName );
145 cboRenderers->setCurrentIndex( rendererIdx );
148 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
154 mPointStyleComboBox->setCurrentIndex( mPointStyleComboBox->findData( mLayer->
renderer()->
pointSymbol() ) );
155 mDrawOrderComboBox->setCurrentIndex( mDrawOrderComboBox->findData(
static_cast< int >( mLayer->
renderer()->
drawOrder2d() ) ) );
161 mBlockChangedSignal =
false;
173 mLayer->
setOpacity( mOpacityWidget->opacity() );
174 mLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
178 else if ( !cboRenderers->currentData().toString().isEmpty() )
195 void QgsPointCloudRendererPropertiesWidget::rendererChanged()
197 if ( cboRenderers->currentIndex() == -1 )
199 QgsDebugMsg( QStringLiteral(
"No current item -- this should never happen!" ) );
203 const QString rendererName = cboRenderers->currentData().toString();
206 std::unique_ptr< QgsPointCloudRenderer > oldRenderer;
207 std::unique_ptr< QgsPointCloudRenderer > newRenderer;
209 newRenderer.reset( mActiveWidget->
renderer() );
213 oldRenderer = std::move( newRenderer );
223 stackedWidget->removeWidget( mActiveWidget );
225 delete mActiveWidget;
226 mActiveWidget =
nullptr;
231 if ( rendererMetadata )
238 mActiveWidget = widget;
239 stackedWidget->addWidget( mActiveWidget );
240 stackedWidget->setCurrentWidget( mActiveWidget );
242 if ( mMapCanvas || mMessageBar )
257 stackedWidget->setCurrentWidget( pageNoWidget );
262 void QgsPointCloudRendererPropertiesWidget::emitWidgetChanged()
264 if ( !mBlockChangedSignal )
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.
const QgsMapUnitScale & pointSizeMapUnitScale() const
Returns the map unit scale used for the point size.
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.
DrawOrder
Pointcloud rendering order for 2d views /since QGIS 3.24.
@ 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.
PointSymbol pointSymbol() const
Returns the symbol used by the renderer for drawing points.
DrawOrder drawOrder2d() const
Returns the drawing order used by the renderer for drawing points.
void setPointSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the point size.
virtual QgsPointCloudRenderer * clone() const =0
Create a deep copy of this renderer.
void setPointSize(double size)
Sets the point size.
PointSymbol
Rendering symbols for points.
@ Square
Renders points as squares.
@ Circle
Renders points as circles.
virtual QString type() const =0
Returns the identifier of the renderer type.
void setPointSymbol(PointSymbol symbol)
Sets the symbol used by the renderer for drawing points.
QgsUnitTypes::RenderUnit maximumScreenErrorUnit() const
Returns the unit for the maximum screen error allowed when rendering the point cloud.
QgsUnitTypes::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the point cloud.
void setMaximumScreenErrorUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the point cloud.
double pointSize() const
Returns the point size.
void setDrawOrder2d(DrawOrder order)
Sets the drawing order used by the renderer for drawing points.
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 *)