QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
19 #include "qgscontrastenhancement.h"
20 #include "qgspointcloudlayer.h"
22 #include "qgsdoublevalidator.h"
23 #include "qgsfillsymbol.h"
24 
26 
27 QgsPointCloudExtentRendererWidget::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 
46 QgsPointCloudRendererWidget *QgsPointCloudExtentRendererWidget::create( QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer * )
47 {
48  return new QgsPointCloudExtentRendererWidget( layer, style );
49 }
50 
51 QgsPointCloudRenderer *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 
63 void QgsPointCloudExtentRendererWidget::emitWidgetChanged()
64 {
65  if ( !mBlockChangedSignal )
66  emit widgetChanged();
67 }
68 
69 void 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 
QgsPointCloudRendererWidget
Base class for point cloud 2D renderer settings widgets.
Definition: qgspointcloudrendererwidget.h:36
QgsSymbolButton::changed
void changed()
Emitted when the symbol's settings are changed.
Qgis::SymbolType::Fill
@ Fill
Fill symbol.
QgsPointCloudLayer
Represents a map layer supporting display of point clouds.
Definition: qgspointcloudlayer.h:45
qgscontrastenhancement.h
QgsPointCloudExtentRenderer
A renderer for 2d visualisation of point clouds which shows the dataset's extents using a fill symbol...
Definition: qgspointcloudextentrenderer.h:33
qgspointcloudextentrendererwidget.h
QgsPointCloudLayer::renderer
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
Definition: qgspointcloudlayer.cpp:706
qgspointcloudlayer.h
qgspointcloudextentrenderer.h
QgsPointCloudExtentRenderer::defaultFillSymbol
static QgsFillSymbol * defaultFillSymbol()
Returns a new instance of the default fill symbol to use for showing point cloud extents.
Definition: qgspointcloudextentrenderer.cpp:119
QgsStyle
Definition: qgsstyle.h:159
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:29
QgsPointCloudRenderer
Abstract base class for 2d point cloud renderers.
Definition: qgspointcloudrenderer.h:296
qgsdoublevalidator.h
qgsfillsymbol.h