Skip to content
Permalink
Browse files

Add shell for 2d renderer config to layer styling dock

  • Loading branch information
nyalldawson committed Nov 16, 2020
1 parent 0557160 commit 1758ca143f8d5fd71bca95542ba4c907a1548365
@@ -10,7 +10,7 @@



class QgsPointCloudRendererPropertiesWidget : QgsPanelWidget
class QgsPointCloudRendererPropertiesWidget : QgsMapLayerConfigWidget
{
%Docstring
A generic widget for setting the 2D renderer for a point cloud layer.
@@ -33,6 +33,12 @@ Constructor for QgsPointCloudRendererPropertiesWidget, associated with the speci
Sets the ``context`` in which the widget is shown, e.g., the associated map canvas and expression contexts.
%End

virtual void syncToLayer( QgsMapLayer *layer );

public slots:

virtual void apply();

};


@@ -27,7 +27,7 @@ Constructor for QgsPointCloudRendererWidget, associated with the
specified ``layer`` and ``style`` database.
%End

virtual QgsPointCloudRenderer *renderer() /Factory/ = 0;
virtual QgsPointCloudRenderer *renderer() = 0 /Factory/;
%Docstring
Returns a new instance of a renderer as defined by the settings in the widget.

@@ -335,6 +335,7 @@
%Include auto_generated/numericformats/qgsnumericformatwidget.sip
%Include auto_generated/numericformats/qgsnumericformatguiregistry.sip
%Include auto_generated/pointcloud/qgspointcloudrendererwidget.sip
%Include auto_generated/pointcloud/qgspointcloudrendererpropertieswidget.sip
%Include auto_generated/processing/qgsprocessingaggregatewidgets.sip
%Include auto_generated/processing/qgsprocessingalgorithmconfigurationwidget.sip
%Include auto_generated/processing/qgsprocessingalgorithmdialogbase.sip
@@ -117,6 +117,7 @@ set(QGIS_APP_SRCS
decorations/qgsdecorationgriddialog.cpp

pointcloud/qgspointcloudlayerproperties.cpp
pointcloud/qgspointcloudlayerstylewidget.cpp

vectortile/qgsvectortilelayerproperties.cpp

@@ -25,6 +25,8 @@
#include "qgsapplication.h"
#include "qgsmetadatawidget.h"
#include "qgsmaplayerloadstyledialog.h"
#include "qgsmaplayerconfigwidgetfactory.h"
#include "qgsmaplayerconfigwidget.h"
#include <QFileDialog>
#include <QMenu>
#include <QMessageBox>
@@ -102,6 +104,25 @@ QgsPointCloudLayerProperties::QgsPointCloudLayerProperties( QgsPointCloudLayer *
restoreOptionsBaseUi( title );
}

void QgsPointCloudLayerProperties::addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory )
{
if ( !factory->supportsLayer( mLayer ) || !factory->supportLayerPropertiesDialog() )
{
return;
}

QgsMapLayerConfigWidget *page = factory->createWidget( mLayer, mMapCanvas, false, this );
mConfigWidgets << page;

const QString beforePage = factory->layerPropertiesPagePositionHint();
if ( beforePage.isEmpty() )
addPage( factory->title(), factory->title(), factory->icon(), page );
else
insertPage( factory->title(), factory->title(), factory->icon(), page, beforePage );

page->syncToLayer( mLayer );
}

#include "qgspointcloudrenderer.h"

void QgsPointCloudLayerProperties::apply()
@@ -27,14 +27,17 @@ class QgsMapCanvas;
class QgsMessageBar;
class QgsPointCloudLayer;
class QgsMetadataWidget;

class QgsMapLayerConfigWidgetFactory;
class QgsMapLayerConfigWidget;

class QgsPointCloudLayerProperties : public QgsOptionsDialogBase, private Ui::QgsPointCloudLayerPropertiesBase
{
Q_OBJECT
public:
QgsPointCloudLayerProperties( QgsPointCloudLayer *lyr, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent = nullptr, Qt::WindowFlags = QgsGuiUtils::ModalDialogFlags );

void addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory );

private slots:
void apply();
void onCancel();
@@ -73,6 +76,9 @@ class QgsPointCloudLayerProperties : public QgsOptionsDialogBase, private Ui::Qg
* was loaded but dialog is canceled.
*/
QgsMapLayerStyle mOldStyle;

QList<QgsMapLayerConfigWidget *> mConfigWidgets;

};

#endif // QGSPOINTCLOUDLAYERPROPERTIES_H
@@ -0,0 +1,53 @@
/***************************************************************************
qgspointcloudlayerstylewidget.cpp
---------------------
begin : November 2020
copyright : (C) 2020 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgspointcloudlayerstylewidget.h"
#include "qgspointcloudrendererpropertieswidget.h"
#include "qgsstyle.h"
#include "qgsapplication.h"
#include "qgsmaplayer.h"
#include "qgspointcloudlayer.h"

QgsPointCloudRendererWidgetFactory::QgsPointCloudRendererWidgetFactory( QObject *parent )
: QObject( parent )
{
setIcon( QgsApplication::getThemeIcon( QStringLiteral( "propertyicons/symbology.svg" ) ) );
setTitle( tr( "Symbology" ) );
}

QgsMapLayerConfigWidget *QgsPointCloudRendererWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *, bool, QWidget *parent ) const
{
return new QgsPointCloudRendererPropertiesWidget( qobject_cast< QgsPointCloudLayer * >( layer ), QgsStyle::defaultStyle(), parent );
}

bool QgsPointCloudRendererWidgetFactory::supportLayerPropertiesDialog() const
{
return true;
}

bool QgsPointCloudRendererWidgetFactory::supportsStyleDock() const
{
return true;
}

bool QgsPointCloudRendererWidgetFactory::supportsLayer( QgsMapLayer *layer ) const
{
return layer->type() == QgsMapLayerType::PointCloudLayer;
}

QString QgsPointCloudRendererWidgetFactory::layerPropertiesPagePositionHint() const
{
return QStringLiteral( "mOptsPage_Metadata" );
}
@@ -0,0 +1,37 @@
/***************************************************************************
qgspointcloudlayerstylewidget.h
---------------------
begin : November 2020
copyright : (C) 2020 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSPOINTCLOUDLAYERSTYLEWIDGET_H
#define QGSPOINTCLOUDLAYERSTYLEWIDGET_H

#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerconfigwidgetfactory.h"

class QgsPointCloudRendererWidgetFactory : public QObject, public QgsMapLayerConfigWidgetFactory
{
Q_OBJECT
public:
explicit QgsPointCloudRendererWidgetFactory( QObject *parent = nullptr );

QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const override;
bool supportLayerPropertiesDialog() const override;
bool supportsStyleDock() const override;
bool supportsLayer( QgsMapLayer *layer ) const override;
QString layerPropertiesPagePositionHint() const override;
};



#endif // QGSPOINTCLOUDLAYERSTYLEWIDGET_H
@@ -398,6 +398,8 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgssublayersdialog.h"
#include "ogr/qgsvectorlayersaveasdialog.h"

#include "pointcloud/qgspointcloudlayerstylewidget.h"

#ifdef ENABLE_MODELTEST
#include "modeltest.h"
#endif
@@ -1338,6 +1340,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
registerMapLayerPropertiesFactory( new QgsMeshLayer3DRendererWidgetFactory( this ) );
#endif

registerMapLayerPropertiesFactory( new QgsPointCloudRendererWidgetFactory( this ) );

activateDeactivateLayerRelatedActions( nullptr ); // after members were created

connect( QgsGui::mapLayerActionRegistry(), &QgsMapLayerActionRegistry::changed, this, &QgisApp::refreshActionFeatureAction );
if ( !page.isEmpty() )
pointCloudLayerPropertiesDialog.setCurrentPage( page );

for ( QgsMapLayerConfigWidgetFactory *factory : qgis::as_const( mMapLayerPanelFactories ) )
{
pointCloudLayerPropertiesDialog.addPropertiesPageFactory( factory );
}

mMapStyleWidget->blockUpdates( true );
if ( pointCloudLayerPropertiesDialog.exec() )
{
@@ -676,11 +676,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()

case QgsMapLayerType::PointCloudLayer:
{
QgsPointCloudLayer *pcLayer = qobject_cast<QgsPointCloudLayer *>( mCurrentLayer );
( void )pcLayer;

//TODO
mStackedWidget->setCurrentIndex( mNotSupportedPage );
// everything is handled by factories for this layer type!
break;
}

@@ -109,7 +109,7 @@ QgsPointCloudRenderer *QgsDummyPointCloudRenderer::clone() const
res->mZMin = zMin();
res->mZMax = zMax();
res->mPenWidth = penWidth();
res->mColorRamp.reset( colorRamp()->clone() );
res->mColorRamp.reset( colorRamp() ? colorRamp()->clone() : QgsStyle::defaultStyle()->colorRamp( QStringLiteral( "Viridis" ) ) );
res->mAttribute = attribute();

return res.release();
@@ -53,6 +53,7 @@ bool QgsMapLayerProxyModel::layerMatchesFilters( const QgsMapLayer *layer, const
( filters.testFlag( VectorLayer ) && layer->type() == QgsMapLayerType::VectorLayer ) ||
( filters.testFlag( MeshLayer ) && layer->type() == QgsMapLayerType::MeshLayer ) ||
( filters.testFlag( VectorTileLayer ) && layer->type() == QgsMapLayerType::VectorTileLayer ) ||
( filters.testFlag( PointCloudLayer ) && layer->type() == QgsMapLayerType::PointCloudLayer ) ||
( filters.testFlag( PluginLayer ) && layer->type() == QgsMapLayerType::PluginLayer ) )
return true;

@@ -288,6 +288,7 @@ set(QGIS_GUI_SRCS
ogr/qgsvectorlayersaveasdialog.cpp

pointcloud/qgspointcloudrendererwidget.cpp
pointcloud/qgspointcloudrendererpropertieswidget.cpp

processing/qgsprocessingaggregatewidgets.cpp
processing/qgsprocessingaggregatewidgetwrapper.cpp
@@ -1059,6 +1060,7 @@ set(QGIS_GUI_HDRS
ogr/qgsvectorlayersaveasdialog.h

pointcloud/qgspointcloudrendererwidget.h
pointcloud/qgspointcloudrendererpropertieswidget.h

processing/qgsprocessingaggregatewidgets.h
processing/qgsprocessingaggregatewidgetwrapper.h
@@ -18,6 +18,7 @@
#include "qgsapplication.h"
#include "qgssymbolwidgetcontext.h"
#include "qgspointcloudrendererwidget.h"
#include "qgspointcloudlayer.h"

static bool _initRenderer( const QString &name, QgsPointCloudRendererWidgetFunc f, const QString &iconName = QString() )
{
@@ -52,10 +53,9 @@ static void _initRendererWidgetFunctions()
}

QgsPointCloudRendererPropertiesWidget::QgsPointCloudRendererPropertiesWidget( QgsPointCloudLayer *layer, QgsStyle *style, QWidget *parent )
: QgsPanelWidget( parent )
: QgsMapLayerConfigWidget( layer, nullptr, parent )
, mLayer( layer )
, mStyle( style )

{
setupUi( this );
mLayerRenderingGroupBox->setSettingGroup( QStringLiteral( "layerRenderingGroupBox" ) );
@@ -20,6 +20,7 @@
#include "qgis_gui.h"

#include "ui_qgspointcloudrendererpropsdialogbase.h"
#include "qgsmaplayerconfigwidget.h"

class QgsPointCloudLayer;
class QgsStyle;
@@ -34,7 +35,7 @@ class QgsMessageBar;
*
* \since QGIS 3.18
*/
class GUI_EXPORT QgsPointCloudRendererPropertiesWidget : public QgsPanelWidget, private Ui::QgsPointCloudRendererPropsDialogBase
class GUI_EXPORT QgsPointCloudRendererPropertiesWidget : public QgsMapLayerConfigWidget, private Ui::QgsPointCloudRendererPropsDialogBase
{
Q_OBJECT

@@ -50,6 +51,12 @@ class GUI_EXPORT QgsPointCloudRendererPropertiesWidget : public QgsPanelWidget,
*/
void setContext( const QgsSymbolWidgetContext &context );

void syncToLayer( QgsMapLayer *layer ) override { Q_UNUSED( layer ) }

public slots:

void apply() override {}

private:

QgsPointCloudLayer *mLayer = nullptr;
@@ -49,7 +49,7 @@ class GUI_EXPORT QgsPointCloudRendererWidget : public QgsPanelWidget
*
* Caller takes ownership of the returned object.
*/
virtual QgsPointCloudRenderer *renderer() SIP_FACTORY = 0;
virtual QgsPointCloudRenderer *renderer() = 0 SIP_FACTORY;

/**
* Sets the \a context in which the renderer widget is shown, e.g., the associated map canvas and expression contexts.

0 comments on commit 1758ca1

Please sign in to comment.
You can’t perform that action at this time.