QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgspointcloudextentrendererwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudextentrendererwidget.cpp
3 ---------------------
4 begin : December 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
20#include "qgspointcloudlayer.h"
22#include "qgsdoublevalidator.h"
23#include "qgsfillsymbol.h"
24
26
27QgsPointCloudExtentRendererWidget::QgsPointCloudExtentRendererWidget( QgsPointCloudLayer *layer, QgsStyle *style )
28 : QgsPointCloudRendererWidget( layer, style )
29{
30 setupUi( this );
31
32 mSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
33
34 if ( layer )
35 {
36 setFromRenderer( layer->renderer() );
37 }
38 else
39 {
40 mSymbolButton->setSymbol( QgsPointCloudExtentRenderer::defaultFillSymbol() );
41 }
42
43 connect( mSymbolButton, &QgsSymbolButton::changed, this, &QgsPointCloudExtentRendererWidget::emitWidgetChanged );
44}
45
46QgsPointCloudRendererWidget *QgsPointCloudExtentRendererWidget::create( QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer * )
47{
48 return new QgsPointCloudExtentRendererWidget( layer, style );
49}
50
51QgsPointCloudRenderer *QgsPointCloudExtentRendererWidget::renderer()
52{
53 if ( !mLayer )
54 {
55 return nullptr;
56 }
57
58 std::unique_ptr< QgsPointCloudExtentRenderer > renderer = std::make_unique< QgsPointCloudExtentRenderer >();
59 renderer->setFillSymbol( mSymbolButton->clonedSymbol< QgsFillSymbol >() );
60 return renderer.release();
61}
62
63void QgsPointCloudExtentRendererWidget::emitWidgetChanged()
64{
65 if ( !mBlockChangedSignal )
66 emit widgetChanged();
67}
68
69void QgsPointCloudExtentRendererWidget::setFromRenderer( const QgsPointCloudRenderer *r )
70{
71 mBlockChangedSignal = true;
72 if ( const QgsPointCloudExtentRenderer *mbcr = dynamic_cast<const QgsPointCloudExtentRenderer *>( r ) )
73 {
74 mSymbolButton->setSymbol( mbcr->fillSymbol()->clone() );
75 }
76 else
77 {
78 mSymbolButton->setSymbol( QgsPointCloudExtentRenderer::defaultFillSymbol() );
79 }
80 mBlockChangedSignal = false;
81}
82
@ Fill
Fill symbol.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
A renderer for 2d visualisation of point clouds which shows the dataset's extents using a fill symbol...
static QgsFillSymbol * defaultFillSymbol()
Returns a new instance of the default fill symbol to use for showing point cloud extents.
Represents a map layer supporting display of point clouds.
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
Base class for point cloud 2D renderer settings widgets.
Abstract base class for 2d point cloud renderers.
void changed()
Emitted when the symbol's settings are changed.