initial implementation

This commit is contained in:
NEDJIMAbelgacem 2020-12-07 16:51:57 +01:00 committed by Martin Dobias
parent e3da221f7f
commit 14ff8e3489
9 changed files with 91 additions and 16 deletions

View File

@ -78,6 +78,20 @@ Sets the maximum screen ``error`` allowed when rendering the point cloud.
Larger values result in a faster render with less points rendered.
.. seealso:: :py:func:`maximumScreenError`
%End
bool showBoundingBoxes() const;
%Docstring
Returns whether bounding boxes will be visible when rendering the point cloud.
.. seealso:: :py:func:`setShowBoundingBoxes`
%End
void setShowBoundingBoxes( bool showBoundingBoxes );
%Docstring
Sets whether bounding boxes will be visible when rendering the point cloud.
.. seealso:: :py:func:`showBoundingBoxes`
%End
private:

View File

@ -112,7 +112,7 @@ Qt3DCore::QEntity *QgsPointCloudLayer3DRenderer::createEntity( const Qgs3DMapSet
if ( !mSymbol )
return nullptr;
return new QgsPointCloudLayerChunkedEntity( pcl->dataProvider()->index(), map, dynamic_cast<QgsPointCloud3DSymbol *>( mSymbol->clone() ), maximumScreenError() );
return new QgsPointCloudLayerChunkedEntity( pcl->dataProvider()->index(), map, dynamic_cast<QgsPointCloud3DSymbol *>( mSymbol->clone() ), maximumScreenError(), showBoundingBoxes() );
}
void QgsPointCloudLayer3DRenderer::setSymbol( QgsPointCloud3DSymbol *symbol )
@ -128,6 +128,7 @@ void QgsPointCloudLayer3DRenderer::writeXml( QDomElement &elem, const QgsReadWri
elem.setAttribute( QStringLiteral( "layer" ), mLayerRef.layerId );
elem.setAttribute( QStringLiteral( "max-screen-error" ), maximumScreenError() );
elem.setAttribute( QStringLiteral( "show-bounding-boxes" ), showBoundingBoxes() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
QDomElement elemSymbol = doc.createElement( QStringLiteral( "symbol" ) );
if ( mSymbol )
@ -146,6 +147,7 @@ void QgsPointCloudLayer3DRenderer::readXml( const QDomElement &elem, const QgsRe
const QString symbolType = elemSymbol.attribute( QStringLiteral( "type" ) );
mMaximumScreenError = elem.attribute( QStringLiteral( "max-screen-error" ), QStringLiteral( "1.0" ) ).toDouble();
mShowBoundingBoxes = elem.attribute( QStringLiteral( "show-bounding-boxes" ), "0" ).toInt();
if ( symbolType == QLatin1String( "single-color" ) )
mSymbol.reset( new QgsSingleColorPointCloud3DSymbol );
@ -176,3 +178,14 @@ void QgsPointCloudLayer3DRenderer::setMaximumScreenError( double error )
{
mMaximumScreenError = error;
}
bool QgsPointCloudLayer3DRenderer::showBoundingBoxes() const
{
return mShowBoundingBoxes;
}
void QgsPointCloudLayer3DRenderer::setShowBoundingBoxes( bool showBoundingBoxes )
{
mShowBoundingBoxes = showBoundingBoxes;
}

View File

@ -208,10 +208,25 @@ class _3D_EXPORT QgsPointCloudLayer3DRenderer : public QgsAbstract3DRenderer
*/
void setMaximumScreenError( double error );
/**
* Returns whether bounding boxes will be visible when rendering the point cloud.
*
* \see setShowBoundingBoxes()
*/
bool showBoundingBoxes() const;
/**
* Sets whether bounding boxes will be visible when rendering the point cloud.
*
* \see showBoundingBoxes()
*/
void setShowBoundingBoxes( bool showBoundingBoxes );
private:
QgsMapLayerRef mLayerRef; //!< Layer used to extract mesh data from
std::unique_ptr< QgsPointCloud3DSymbol > mSymbol;
double mMaximumScreenError = 1.0;
bool mShowBoundingBoxes = true;
private:
#ifdef SIP_RUN

View File

@ -196,12 +196,12 @@ QgsAABB nodeBoundsToAABB( QgsPointCloudDataBounds nodeBounds, QgsVector3D offset
}
QgsPointCloudLayerChunkedEntity::QgsPointCloudLayerChunkedEntity( QgsPointCloudIndex *pc, const Qgs3DMapSettings &map, QgsPointCloud3DSymbol *symbol, float maxScreenError )
QgsPointCloudLayerChunkedEntity::QgsPointCloudLayerChunkedEntity( QgsPointCloudIndex *pc, const Qgs3DMapSettings &map, QgsPointCloud3DSymbol *symbol, float maxScreenError, bool showBoundingBoxes )
: QgsChunkedEntity( maxScreenError,
new QgsPointCloudLayerChunkLoaderFactory( map, pc, symbol ), true )
{
setUsingAdditiveStrategy( true );
setShowBoundingBoxes( false );
setShowBoundingBoxes( showBoundingBoxes );
}
QgsPointCloudLayerChunkedEntity::~QgsPointCloudLayerChunkedEntity()

View File

@ -115,7 +115,7 @@ class QgsPointCloudLayerChunkedEntity : public QgsChunkedEntity
{
Q_OBJECT
public:
explicit QgsPointCloudLayerChunkedEntity( QgsPointCloudIndex *pc, const Qgs3DMapSettings &map, QgsPointCloud3DSymbol *symbol, float maxScreenError );
explicit QgsPointCloudLayerChunkedEntity( QgsPointCloudIndex *pc, const Qgs3DMapSettings &map, QgsPointCloud3DSymbol *symbol, float maxScreenError, bool showBoundingBoxes );
~QgsPointCloudLayerChunkedEntity();
};

View File

@ -100,6 +100,7 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
connect( mColorRampShaderMaxEdit, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::minMaxChanged );
connect( mMaxScreenErrorSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::maximumScreenErrorChanged );
connect( mShowBoundingBoxesCheckBox, &QCheckBox::stateChanged, this, &QgsPointCloud3DSymbolWidget::showBoundingBoxesChanged );
rampAttributeChanged();
@ -571,3 +572,22 @@ void QgsPointCloud3DSymbolWidget::maximumScreenErrorChanged( double maxScreenErr
mMaximumScreenError = maxScreenError;
emitChangedSignal();
}
void QgsPointCloud3DSymbolWidget::showBoundingBoxesChanged( int checkBoxState )
{
Q_UNUSED( checkBoxState );
bool showBoundingBoxes = mShowBoundingBoxesCheckBox->isChecked();
if ( showBoundingBoxes == mShowBoundingBoxes )
return;
mShowBoundingBoxes = showBoundingBoxes;
emitChangedSignal();
}
void QgsPointCloud3DSymbolWidget::setShowBoundingBoxes( bool showBoundingBoxes )
{
if ( showBoundingBoxes == mShowBoundingBoxes )
return;
mShowBoundingBoxesCheckBox->setChecked( showBoundingBoxes );
mShowBoundingBoxes = showBoundingBoxes;
emitChangedSignal();
}

View File

@ -36,6 +36,8 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
void setMaximumScreenError( double maxScreenError );
double maximumScreenError() const { return mMaximumScreenError; }
void setShowBoundingBoxes( bool showBoundingBoxes );
double showBoundingBoxes() const { return mShowBoundingBoxes; }
private slots:
void reloadColorRampShaderMinMax();
@ -55,6 +57,7 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
void greenAttributeChanged();
void blueAttributeChanged();
void maximumScreenErrorChanged( double maxScreenError );
void showBoundingBoxesChanged( int state );
signals:
void changed();
@ -70,6 +73,7 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
bool mBlockMinMaxChanged = false;
double mMaximumScreenError = 1.0f;
bool mShowBoundingBoxes = false;
double mProviderMin = std::numeric_limits< double >::quiet_NaN();
double mProviderMax = std::numeric_limits< double >::quiet_NaN();

View File

@ -44,6 +44,7 @@ void QgsPointCloudLayer3DRendererWidget::setRenderer( const QgsPointCloudLayer3D
{
mWidgetPointCloudSymbol->setSymbol( const_cast<QgsPointCloud3DSymbol *>( renderer->symbol() ) );
mWidgetPointCloudSymbol->setMaximumScreenError( renderer->maximumScreenError() );
mWidgetPointCloudSymbol->setShowBoundingBoxes( renderer->showBoundingBoxes() );
}
}
@ -54,6 +55,7 @@ QgsPointCloudLayer3DRenderer *QgsPointCloudLayer3DRendererWidget::renderer()
renderer->setSymbol( sym );
renderer->setLayer( qobject_cast<QgsPointCloudLayer *>( mLayer ) );
renderer->setMaximumScreenError( mWidgetPointCloudSymbol->maximumScreenError() );
renderer->setShowBoundingBoxes( mWidgetPointCloudSymbol->showBoundingBoxes() );
return renderer;
}

View File

@ -41,13 +41,6 @@
<property name="rightMargin">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblTransparency_4">
<property name="text">
<string>Point size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsDoubleSpinBox" name="mPointSizeSpinBox">
<property name="maximum">
@ -58,6 +51,13 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblTransparency_4">
<property name="text">
<string>Point size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="mMaxScreenErrorSpinBox">
<property name="maximum">
@ -75,6 +75,13 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="mShowBoundingBoxesCheckBox">
<property name="text">
<string>Show point cloud bounding boxes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -461,16 +468,16 @@ enhancement</string>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsPointCloudAttributeComboBox</class>
<extends>QComboBox</extends>
<header>qgspointcloudattributecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsPointCloudAttributeComboBox</class>
<extends>QComboBox</extends>
<header>qgspointcloudattributecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsColorRampShaderWidget</class>
<extends>QWidget</extends>