16#include "moc_qgspointcloudrendererpropertieswidget.cpp"
36#include "qgsvirtualpointcloudprovider.h"
41 if ( !rendererAbstractMetadata )
44 if ( !rendererMetadata )
49 if ( !iconName.isEmpty() )
58void QgsPointCloudRendererPropertiesWidget::initRendererWidgetFunctions()
60 static bool sInitialized =
false;
64 initPointCloudRenderer( QStringLiteral(
"extent" ), QgsPointCloudExtentRendererWidget::create, QStringLiteral(
"styleicons/pointcloudextent.svg" ) );
65 initPointCloudRenderer( QStringLiteral(
"rgb" ), QgsPointCloudRgbRendererWidget::create, QStringLiteral(
"styleicons/multibandcolor.svg" ) );
66 initPointCloudRenderer( QStringLiteral(
"ramp" ), QgsPointCloudAttributeByRampRendererWidget::create, QStringLiteral(
"styleicons/singlebandpseudocolor.svg" ) );
67 initPointCloudRenderer( QStringLiteral(
"classified" ), QgsPointCloudClassifiedRendererWidget::create, QStringLiteral(
"styleicons/paletted.svg" ) );
79 layout()->setContentsMargins( 0, 0, 0, 0 );
82 initRendererWidgetFunctions();
86 for (
const QString &name : renderers )
89 cboRenderers->addItem( m->icon(), m->visibleName(), name );
92 cboRenderers->setCurrentIndex( -1 );
97 connect( cboRenderers,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::rendererChanged );
99 connect( mBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
104 connect( mPointSizeSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
112 mMaxErrorSpinBox->setClearValue( 0.3 );
114 mHorizontalTriangleThresholdSpinBox->setClearValue( 5.0 );
117 connect( mMaxErrorSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
120 connect( mPointStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
121 connect( mDrawOrderComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
123 connect( mTriangulateGroupBox, &QGroupBox::toggled,
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
124 connect( mHorizontalTriangleCheckBox, &QCheckBox::clicked,
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
125 connect( mHorizontalTriangleThresholdSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
131 mLabelOptions->setDialogTitle( tr(
"Customize label text" ) );
132 mLabelOptions->setText( tr(
"Label format" ) );
133 connect( mLabels, &QCheckBox::stateChanged,
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
134 connect( mLabelOptions, &
QgsFontButton::changed,
this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
137 if (
const QgsVirtualPointCloudProvider *vpcProvider =
dynamic_cast<QgsVirtualPointCloudProvider *
>( mLayer->
dataProvider() ) )
139 if ( vpcProvider->overview() )
147 mZoomOutOptions->setEnabled(
false );
150 connect( mZoomOutOptions, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
153 case Qgis::PointCloudZoomOutRenderBehavior::RenderOverview:
154 mLabels->setEnabled( false );
155 mLabelOptions->setEnabled( false );
157 case Qgis::PointCloudZoomOutRenderBehavior::RenderExtents:
158 case Qgis::PointCloudZoomOutRenderBehavior::RenderOverviewAndExtents:
159 mLabels->setEnabled( true );
160 mLabelOptions->setEnabled( true );
167 mVpcGroupBox->setVisible(
false );
185 mLayer = qobject_cast<QgsPointCloudLayer *>( layer );
187 mBlockChangedSignal =
true;
188 mOpacityWidget->setOpacity( mLayer->
opacity() );
190 mBlendModeComboBox->setBlendMode( mLayer->
blendMode() );
195 const QString rendererName = mLayer->
renderer()->
type();
197 const int rendererIdx = cboRenderers->findData( rendererName );
198 if ( cboRenderers->currentIndex() != rendererIdx )
200 cboRenderers->setCurrentIndex( rendererIdx );
208 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
214 mPointStyleComboBox->setCurrentIndex( mPointStyleComboBox->findData( QVariant::fromValue( mLayer->
renderer()->
pointSymbol() ) ) );
215 mDrawOrderComboBox->setCurrentIndex( mDrawOrderComboBox->findData( QVariant::fromValue( mLayer->
renderer()->
drawOrder2d() ) ) );
229 mZoomOutOptions->setCurrentIndex( mZoomOutOptions->findData( QVariant::fromValue( mLayer->
renderer()->
zoomOutBehavior() ) ) );
233 mLabels->setEnabled(
false );
234 mLabelOptions->setEnabled(
false );
237 mLabels->setEnabled(
true );
238 mLabelOptions->setEnabled(
true );
243 mBlockChangedSignal =
false;
255 mLayer->
setOpacity( mOpacityWidget->opacity() );
256 mLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
260 else if ( !cboRenderers->currentData().toString().isEmpty() )
286void QgsPointCloudRendererPropertiesWidget::rendererChanged()
288 if ( cboRenderers->currentIndex() == -1 )
290 QgsDebugError( QStringLiteral(
"No current item -- this should never happen!" ) );
294 const QString rendererName = cboRenderers->currentData().toString();
297 std::unique_ptr<QgsPointCloudRenderer> oldRenderer;
298 std::unique_ptr<QgsPointCloudRenderer> newRenderer;
300 newRenderer.reset( mActiveWidget->
renderer() );
304 oldRenderer = std::move( newRenderer );
314 stackedWidget->removeWidget( mActiveWidget );
316 delete mActiveWidget;
317 mActiveWidget =
nullptr;
322 if ( rendererMetadata )
329 mActiveWidget = widget;
330 stackedWidget->addWidget( mActiveWidget );
331 stackedWidget->setCurrentWidget( mActiveWidget );
333 if ( mMapCanvas || mMessageBar )
348 stackedWidget->setCurrentWidget( pageNoWidget );
353void QgsPointCloudRendererPropertiesWidget::emitWidgetChanged()
355 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.
PointCloudZoomOutRenderBehavior
Point cloud zoom out options.
@ RenderOverviewAndExtents
Render point cloud extents over overview point cloud.
@ RenderExtents
Render only point cloud extents when zoomed out.
@ RenderOverview
Render overview point cloud when zoomed out.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
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....
virtual QVector< QgsPointCloudSubIndex > subIndexes()
Returns a list of sub indexes available if the provider supports multiple indexes,...
Represents a map layer supporting display of point clouds.
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
QgsPointCloudDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
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.
Qgis::PointCloudZoomOutRenderBehavior zoomOutBehavior() const
Returns the renderer behavior when zoomed out.
bool renderAsTriangles() const
Returns whether points are triangulated to render solid surface.
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when rendering the point cloud.
QgsTextFormat labelTextFormat() const
Returns the text format renderer is using for rendering labels.
void setMaximumScreenErrorUnit(Qgis::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the point cloud.
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.
void setPointSize(double size)
Sets the point size.
bool horizontalTriangleFilter() const
Returns whether large triangles will get rendered.
virtual QString type() const =0
Returns the identifier of the renderer type.
void setHorizontalTriangleFilterThreshold(double threshold)
Sets threshold for filtering of triangles.
void setHorizontalTriangleFilterUnit(Qgis::RenderUnit unit)
Sets units of the threshold for filtering of triangles.
bool showLabels() const
Returns whether the renderer shows file labels inside the extent rectangle.
virtual QgsPointCloudRenderer * clone() const =0
Create a deep copy of this renderer.
Qgis::RenderUnit maximumScreenErrorUnit() const
Returns the unit for the maximum screen error allowed when rendering the point cloud.
void setDrawOrder2d(Qgis::PointCloudDrawOrder order)
Sets the drawing order used by the renderer for drawing points.
void setPointSizeUnit(const Qgis::RenderUnit units)
Sets the units used for the point size.
Qgis::RenderUnit horizontalTriangleFilterUnit() const
Returns units of the threshold for filtering of triangles.
void setRenderAsTriangles(bool asTriangles)
Sets whether points are triangulated to render solid surface.
void setPointSymbol(Qgis::PointCloudSymbol symbol)
Sets the symbol used by the renderer for drawing points.
void setLabelTextFormat(const QgsTextFormat &textFormat)
Sets the text format renderers should use for rendering labels.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the point cloud.
void setShowLabels(const bool show)
Set whether the renderer should also render file labels inside extent.
Qgis::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
double horizontalTriangleFilterThreshold() const
Returns threshold for filtering of triangles.
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.
void setHorizontalTriangleFilter(bool enabled)
Sets whether large triangles will get rendered.
double pointSize() const
Returns the point size.
void setZoomOutBehavior(const Qgis::PointCloudZoomOutRenderBehavior behavior)
Sets the renderer behavior when zoomed out.
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.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QgsPointCloudRendererWidget *(* QgsPointCloudRendererWidgetFunc)(QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer *)