Skip to content

Commit

Permalink
add missing save & load operations
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Dec 7, 2020
1 parent 85e0e76 commit cef12d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/3d/qgspointcloudlayer3drenderer.cpp
Expand Up @@ -114,6 +114,7 @@ void QgsPointCloudLayer3DRenderer::writeXml( QDomElement &elem, const QgsReadWri
QDomDocument doc = elem.ownerDocument();

elem.setAttribute( QStringLiteral( "layer" ), mLayerRef.layerId );
elem.setAttribute( QStringLiteral( "max-screen-error" ), maximumScreenError() );

QDomElement elemSymbol = doc.createElement( QStringLiteral( "symbol" ) );
if ( mSymbol )
Expand All @@ -131,6 +132,8 @@ void QgsPointCloudLayer3DRenderer::readXml( const QDomElement &elem, const QgsRe
QDomElement elemSymbol = elem.firstChildElement( QStringLiteral( "symbol" ) );

const QString symbolType = elemSymbol.attribute( QStringLiteral( "type" ) );
mMaximumScreenError = elem.attribute( QStringLiteral( "max-screen-error" ), QStringLiteral( "5.0" ) ).toDouble();

if ( symbolType == QLatin1String( "single-color" ) )
mSymbol.reset( new QgsSingleColorPointCloud3DSymbol );
else if ( symbolType == QLatin1String( "color-ramp" ) )
Expand Down
16 changes: 14 additions & 2 deletions src/app/3d/qgspointcloud3dsymbolwidget.cpp
Expand Up @@ -86,6 +86,7 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
if ( symbol )
setSymbol( symbol );


connect( mPointSizeSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::emitChangedSignal );
connect( mRenderingStyleComboBox, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), this, &QgsPointCloud3DSymbolWidget::onRenderingStyleChanged );
connect( mScalarRecalculateMinMaxButton, &QPushButton::clicked, this, &QgsPointCloud3DSymbolWidget::setMinMaxFromLayer );
Expand All @@ -96,6 +97,8 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
connect( mColorRampShaderMinEdit, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::minMaxChanged );
connect( mColorRampShaderMaxEdit, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::minMaxChanged );

connect( mMaxScreenErrorSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::maximumScreenErrorChanged );

rampAttributeChanged();
}

Expand Down Expand Up @@ -528,7 +531,16 @@ void QgsPointCloud3DSymbolWidget::blueAttributeChanged()
}
}

double QgsPointCloud3DSymbolWidget::maximumScreenError() const
void QgsPointCloud3DSymbolWidget::setMaximumScreenError( double maxScreenError )
{
return mMaxScreenErrorSpinBox->value();
mMaxScreenErrorSpinBox->setValue( maxScreenError );
mMaximumScreenError = maxScreenError;
}

void QgsPointCloud3DSymbolWidget::maximumScreenErrorChanged( double maxScreenError )
{
if ( maxScreenError == mMaximumScreenError )
return;
mMaximumScreenError = maxScreenError;
emitChangedSignal();
}
6 changes: 5 additions & 1 deletion src/app/3d/qgspointcloud3dsymbolwidget.h
Expand Up @@ -32,7 +32,9 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
void setSymbol( QgsPointCloud3DSymbol *symbol );

QgsPointCloud3DSymbol *symbol() const;
double maximumScreenError() const;

void setMaximumScreenError( double maxScreenError );
double maximumScreenError() const { return mMaximumScreenError; }

private slots:
void reloadColorRampShaderMinMax();
Expand All @@ -51,6 +53,7 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
void redAttributeChanged();
void greenAttributeChanged();
void blueAttributeChanged();
void maximumScreenErrorChanged( double maxScreenError );

signals:
void changed();
Expand All @@ -64,6 +67,7 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
QgsPointCloudLayer *mLayer = nullptr;

bool mBlockMinMaxChanged = false;
double mMaximumScreenError = 5.0f;

double mProviderMin = std::numeric_limits< double >::quiet_NaN();
double mProviderMax = std::numeric_limits< double >::quiet_NaN();
Expand Down
3 changes: 3 additions & 0 deletions src/app/3d/qgspointcloudlayer3drendererwidget.cpp
Expand Up @@ -41,7 +41,10 @@ QgsPointCloudLayer3DRendererWidget::QgsPointCloudLayer3DRendererWidget( QgsPoint
void QgsPointCloudLayer3DRendererWidget::setRenderer( const QgsPointCloudLayer3DRenderer *renderer )
{
if ( renderer != nullptr )
{
mWidgetPointCloudSymbol->setSymbol( const_cast<QgsPointCloud3DSymbol *>( renderer->symbol() ) );
mWidgetPointCloudSymbol->setMaximumScreenError( renderer->maximumScreenError() );
}
}

QgsPointCloudLayer3DRenderer *QgsPointCloudLayer3DRendererWidget::renderer()
Expand Down

0 comments on commit cef12d9

Please sign in to comment.