Skip to content
Permalink
Browse files

move QgsMeshLayerProperties to GUI

  • Loading branch information
vcloarec authored and nyalldawson committed Sep 14, 2020
1 parent c192b04 commit 09c73433ddbc99afad109f8ef7d67ec8dd4a7702
Showing with 262 additions and 127 deletions.
  1. +1 −0 python/CMakeLists.txt
  2. +50 −0 python/gui/auto_generated/mesh/qgsmeshlayerproperties.sip.in
  3. +1 −0 python/gui/gui_auto.sip
  4. +49 −18 src/app/3d/qgsmeshlayer3drendererwidget.cpp
  5. +14 −1 src/app/3d/qgsmeshlayer3drendererwidget.h
  6. +1 −11 src/app/CMakeLists.txt
  7. +7 −2 src/app/qgisapp.cpp
  8. +1 −1 src/app/qgslayerstylingwidget.cpp
  9. +25 −0 src/gui/CMakeLists.txt
  10. 0 src/{app → gui}/mesh/qgsmeshdatasetgrouptreeview.cpp
  11. +10 −8 src/{app → gui}/mesh/qgsmeshdatasetgrouptreeview.h
  12. 0 src/{app → gui}/mesh/qgsmeshdatasetgrouptreewidget.cpp
  13. +4 −2 src/{app → gui}/mesh/qgsmeshdatasetgrouptreewidget.h
  14. +37 −42 src/{app → gui}/mesh/qgsmeshlayerproperties.cpp
  15. +17 −2 src/{app → gui}/mesh/qgsmeshlayerproperties.h
  16. 0 src/{app → gui}/mesh/qgsmeshrenderer3daveragingwidget.cpp
  17. +4 −2 src/{app → gui}/mesh/qgsmeshrenderer3daveragingwidget.h
  18. 0 src/{app → gui}/mesh/qgsmeshrendereractivedatasetwidget.cpp
  19. +4 −2 src/{app → gui}/mesh/qgsmeshrendereractivedatasetwidget.h
  20. 0 src/{app → gui}/mesh/qgsmeshrenderermeshsettingswidget.cpp
  21. +4 −2 src/{app → gui}/mesh/qgsmeshrenderermeshsettingswidget.h
  22. 0 src/{app → gui}/mesh/qgsmeshrendererscalarsettingswidget.cpp
  23. +4 −2 src/{app → gui}/mesh/qgsmeshrendererscalarsettingswidget.h
  24. 0 src/{app → gui}/mesh/qgsmeshrenderervectorsettingswidget.cpp
  25. +4 −2 src/{app → gui}/mesh/qgsmeshrenderervectorsettingswidget.h
  26. 0 src/{app → gui}/mesh/qgsmeshstaticdatasetwidget.cpp
  27. +5 −3 src/{app → gui}/mesh/qgsmeshstaticdatasetwidget.h
  28. 0 src/{app → gui}/mesh/qgsmeshvariablestrokewidthwidget.cpp
  29. +4 −3 src/{app → gui}/mesh/qgsmeshvariablestrokewidthwidget.h
  30. 0 src/{app → gui}/mesh/qgsrenderermeshpropertieswidget.cpp
  31. +4 −2 src/{app → gui}/mesh/qgsrenderermeshpropertieswidget.h
  32. +3 −13 src/ui/mesh/qgsmeshlayerpropertiesbase.ui
  33. +0 −1 tests/src/app/CMakeLists.txt
  34. +3 −0 tests/src/gui/CMakeLists.txt
  35. +6 −8 tests/src/{app → gui}/testqgsmeshlayerpropertiesdialog.cpp
@@ -156,6 +156,7 @@ IF (WITH_GUI)
${CMAKE_SOURCE_DIR}/src/gui/labeling
${CMAKE_SOURCE_DIR}/src/gui/layertree
${CMAKE_SOURCE_DIR}/src/gui/layout
${CMAKE_SOURCE_DIR}/src/gui/mesh
${CMAKE_SOURCE_DIR}/src/gui/locator
${CMAKE_SOURCE_DIR}/src/gui/numericformats
${CMAKE_SOURCE_DIR}/src/gui/processing
@@ -0,0 +1,50 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/mesh/qgsmeshlayerproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsMeshLayerProperties : QgsOptionsDialogBase
{
%Docstring
Property sheet for a mesh map layer.
Contains information, source and style tabs

.. versionadded:: 3.18
%End

%TypeHeaderCode
#include "qgsmeshlayerproperties.h"
%End
public:

QgsMeshLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent = 0, Qt::WindowFlags = QgsGuiUtils::ModalDialogFlags );
%Docstring
Constructor

:param lyr: Mesh map layer for which properties will be displayed
%End

void addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory );
%Docstring
Adds properties page from a factory

.. versionadded:: 3.18
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/mesh/qgsmeshlayerproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -321,6 +321,7 @@
%Include auto_generated/layout/qgslayoutviewtooltemporarymousepan.sip
%Include auto_generated/layout/qgslayoutviewtoolzoom.sip
%Include auto_generated/locator/qgslocatorwidget.sip
%Include auto_generated/mesh/qgsmeshlayerproperties.sip
%Include auto_generated/numericformats/qgsnumericformatselectorwidget.sip
%Include auto_generated/numericformats/qgsnumericformatwidget.sip
%Include auto_generated/numericformats/qgsnumericformatguiregistry.sip
@@ -42,11 +42,38 @@ QgsMeshLayer3DRendererWidget::QgsMeshLayer3DRendererWidget( QgsMeshLayer *layer,
connect( mWidgetMesh, &QgsMesh3dSymbolWidget::changed, this, &QgsMeshLayer3DRendererWidget::widgetChanged );
}

void QgsMeshLayer3DRendererWidget::setLayer( QgsMeshLayer *layer )
void QgsMeshLayer3DRendererWidget::setRenderer( const QgsMeshLayer3DRenderer *renderer )
{
mRenderer.reset( renderer ? renderer->clone() : nullptr );
whileBlocking( mChkEnabled )->setChecked( renderer ? renderer->symbol()->isEnabled() : false );
}

QgsMeshLayer3DRenderer *QgsMeshLayer3DRendererWidget::renderer()
{
std::unique_ptr< QgsMesh3DSymbol > sym = mWidgetMesh->symbol();
sym->setEnabled( mChkEnabled->isChecked() );
mRenderer.reset( new QgsMeshLayer3DRenderer( sym.release() ) );
mRenderer->setLayer( qobject_cast<QgsMeshLayer *>( mLayer ) );
return mRenderer.get();
}

void QgsMeshLayer3DRendererWidget::apply()
{
QgsMeshLayer3DRenderer *r = renderer();
mLayer->setRenderer3D( r ? r->clone() : nullptr );
}

void QgsMeshLayer3DRendererWidget::onEnabledClicked()
{
mLayer = layer;
mWidgetMesh->setEnabled( mChkEnabled->isChecked() );
emit widgetChanged();
}

mWidgetMesh->setLayer( layer );
void QgsMeshLayer3DRendererWidget::syncToLayer( QgsMapLayer *layer )
{
mLayer = layer ;
QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( layer );
mWidgetMesh->setLayer( meshLayer );
QgsAbstract3DRenderer *r = layer->renderer3D();
if ( r && r->type() == QLatin1String( "mesh" ) )
{
@@ -61,29 +88,33 @@ void QgsMeshLayer3DRendererWidget::setLayer( QgsMeshLayer *layer )
}
}

void QgsMeshLayer3DRendererWidget::setRenderer( const QgsMeshLayer3DRenderer *renderer )
QgsMeshLayer3DRendererWidgetFactory::QgsMeshLayer3DRendererWidgetFactory( QObject *parent ):
QObject( parent )
{
mRenderer.reset( renderer ? renderer->clone() : nullptr );
whileBlocking( mChkEnabled )->setChecked( renderer ? renderer->symbol()->isEnabled() : false );
setIcon( QIcon( ":/images/themes/default/3d.svg" ) );
setTitle( tr( "3D View" ) );
}

QgsMeshLayer3DRenderer *QgsMeshLayer3DRendererWidget::renderer()
QgsMapLayerConfigWidget *QgsMeshLayer3DRendererWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const
{
std::unique_ptr< QgsMesh3DSymbol > sym = mWidgetMesh->symbol();
sym->setEnabled( mChkEnabled->isChecked() );
mRenderer.reset( new QgsMeshLayer3DRenderer( sym.release() ) );
mRenderer->setLayer( qobject_cast<QgsMeshLayer *>( mLayer ) );
return mRenderer.get();
Q_UNUSED( dockWidget )
QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( layer );
if ( !meshLayer )
return nullptr;
return new QgsMeshLayer3DRendererWidget( meshLayer, canvas, parent );
}

void QgsMeshLayer3DRendererWidget::apply()
bool QgsMeshLayer3DRendererWidgetFactory::supportLayerPropertiesDialog() const
{
QgsMeshLayer3DRenderer *r = renderer();
mLayer->setRenderer3D( r ? r->clone() : nullptr );
return true;
}

void QgsMeshLayer3DRendererWidget::onEnabledClicked()
bool QgsMeshLayer3DRendererWidgetFactory::supportsLayer( QgsMapLayer *layer ) const
{
mWidgetMesh->setEnabled( mChkEnabled->isChecked() );
emit widgetChanged();
return layer->type() == QgsMapLayerType::MeshLayer;
}

QString QgsMeshLayer3DRendererWidgetFactory::layerPropertiesPagePositionHint() const
{
return QStringLiteral( "mOptsPage_Rendering" );
}
@@ -20,6 +20,7 @@

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

class QCheckBox;

@@ -35,7 +36,7 @@ class QgsMeshLayer3DRendererWidget : public QgsMapLayerConfigWidget
public:
explicit QgsMeshLayer3DRendererWidget( QgsMeshLayer *layer, QgsMapCanvas *canvas, QWidget *parent = nullptr );

void setLayer( QgsMeshLayer *layer );
void syncToLayer( QgsMapLayer *layer ) override;

//! no transfer of ownership
void setRenderer( const QgsMeshLayer3DRenderer *renderer );
@@ -54,4 +55,16 @@ class QgsMeshLayer3DRendererWidget : public QgsMapLayerConfigWidget
std::unique_ptr<QgsMeshLayer3DRenderer> mRenderer;
};

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

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

#endif // QGSMESHLAYER3DRENDERERWIDGET_H
@@ -217,18 +217,7 @@ SET(QGIS_APP_SRCS
qgsvariantdelegate.cpp
qgscrashhandler.cpp

mesh/qgsmeshlayerproperties.cpp
mesh/qgsrenderermeshpropertieswidget.cpp
mesh/qgsmeshdatasetgrouptreewidget.cpp
mesh/qgsmeshrenderer3daveragingwidget.cpp
mesh/qgsmeshrenderermeshsettingswidget.cpp
mesh/qgsmeshrendererscalarsettingswidget.cpp
mesh/qgsmeshrenderervectorsettingswidget.cpp
mesh/qgsmeshrendereractivedatasetwidget.cpp
mesh/qgsmeshdatasetgrouptreeview.cpp
mesh/qgsmeshcalculatordialog.cpp
mesh/qgsmeshstaticdatasetwidget.cpp
mesh/qgsmeshvariablestrokewidthwidget.cpp
)

IF (WITH_GEOREFERENCER)
@@ -459,6 +448,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/gui/auth
${CMAKE_SOURCE_DIR}/src/gui/devtools
${CMAKE_SOURCE_DIR}/src/gui/labeling
${CMAKE_SOURCE_DIR}/src/gui/mesh
${CMAKE_SOURCE_DIR}/src/gui/numericformats
${CMAKE_SOURCE_DIR}/src/gui/ogr
${CMAKE_SOURCE_DIR}/src/gui/numericformats
@@ -112,6 +112,7 @@
#include "layout/qgslayout3dmapwidget.h"
#include "layout/qgslayoutviewrubberband.h"
#include "qgsvectorlayer3drendererwidget.h"
#include "qgsmeshlayer3drendererwidget.h"
#include "qgs3dapputils.h"
#endif

@@ -1314,6 +1315,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
registerMapLayerPropertiesFactory( new QgsVectorLayerDigitizingPropertiesFactory( this ) );
#ifdef HAVE_3D
registerMapLayerPropertiesFactory( new QgsVectorLayer3DRendererWidgetFactory( this ) );
registerMapLayerPropertiesFactory( new QgsMeshLayer3DRendererWidgetFactory( this ) );
#endif

activateDeactivateLayerRelatedActions( nullptr ); // after members were created
case QgsMapLayerType::MeshLayer:
{
QgsMeshLayerProperties meshLayerPropertiesDialog( mapLayer, mMapCanvas, this );
if ( !page.isEmpty() )
meshLayerPropertiesDialog.setCurrentPage( page );

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

mMapStyleWidget->blockUpdates( true );
if ( meshLayerPropertiesDialog.exec() )
@@ -612,7 +612,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
mMesh3DWidget->setDockMode( true );
connect( mMesh3DWidget, &QgsMeshLayer3DRendererWidget::widgetChanged, this, &QgsLayerStylingWidget::autoApply );
}
mMesh3DWidget->setLayer( meshLayer );
mMesh3DWidget->syncToLayer( meshLayer );
mWidgetStack->setMainPanel( mMesh3DWidget );
break;
}
@@ -257,6 +257,18 @@ SET(QGIS_GUI_SRCS

locator/qgslocatorwidget.cpp

mesh/qgsmeshlayerproperties.cpp
mesh/qgsrenderermeshpropertieswidget.cpp
mesh/qgsmeshdatasetgrouptreewidget.cpp
mesh/qgsmeshrenderer3daveragingwidget.cpp
mesh/qgsmeshrenderermeshsettingswidget.cpp
mesh/qgsmeshrendererscalarsettingswidget.cpp
mesh/qgsmeshrenderervectorsettingswidget.cpp
mesh/qgsmeshrendereractivedatasetwidget.cpp
mesh/qgsmeshdatasetgrouptreeview.cpp
mesh/qgsmeshstaticdatasetwidget.cpp
mesh/qgsmeshvariablestrokewidthwidget.cpp

numericformats/qgsnumericformatselectorwidget.cpp
numericformats/qgsnumericformatwidget.cpp
numericformats/qgsnumericformatguiregistry.cpp
@@ -998,6 +1010,18 @@ SET(QGIS_GUI_HDRS

locator/qgslocatorwidget.h

mesh/qgsmeshlayerproperties.h
mesh/qgsrenderermeshpropertieswidget.h
mesh/qgsmeshdatasetgrouptreeview.h
mesh/qgsmeshdatasetgrouptreewidget.h
mesh/qgsmeshrenderer3daveragingwidget.h
mesh/qgsmeshrenderermeshsettingswidget.h
mesh/qgsmeshrendererscalarsettingswidget.h
mesh/qgsmeshrenderervectorsettingswidget.h
mesh/qgsmeshrendereractivedatasetwidget.h
mesh/qgsmeshstaticdatasetwidget.h
mesh/qgsmeshvariablestrokewidthwidget.h

numericformats/qgsnumericformatselectorwidget.h
numericformats/qgsnumericformatwidget.h
numericformats/qgsnumericformatguiregistry.h
@@ -1250,6 +1274,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/gui/labeling
${CMAKE_SOURCE_DIR}/src/gui/layertree
${CMAKE_SOURCE_DIR}/src/gui/layout
${CMAKE_SOURCE_DIR}/src/gui/mesh
${CMAKE_SOURCE_DIR}/src/gui/numericformats
${CMAKE_SOURCE_DIR}/src/gui/ogr
${CMAKE_SOURCE_DIR}/src/gui/processing
@@ -16,7 +16,7 @@
#ifndef QGSMESHDATASETGROUPTREE_H
#define QGSMESHDATASETGROUPTREE_H

#include "qgis_app.h"
#include "qgis_gui.h"

#include <QObject>
#include <QTreeView>
@@ -31,6 +31,8 @@
#include <memory>
#include "qgsmeshdataset.h"

SIP_NO_FILE

class QgsMeshLayer;

class QgsMeshDatasetGroupSaveMenu: public QObject
@@ -54,7 +56,7 @@ class QgsMeshDatasetGroupSaveMenu: public QObject
/**
* Item Model for QgsMeshDatasetGroupTreeItem
*/
class APP_NO_EXPORT QgsMeshDatasetGroupTreeModel : public QAbstractItemModel
class QgsMeshDatasetGroupTreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
@@ -111,7 +113,7 @@ class APP_NO_EXPORT QgsMeshDatasetGroupTreeModel : public QAbstractItemModel

};

class APP_NO_EXPORT QgsMeshAvailableDatasetGroupTreeModel: public QgsMeshDatasetGroupTreeModel
class QgsMeshAvailableDatasetGroupTreeModel: public QgsMeshDatasetGroupTreeModel
{
public:
QgsMeshAvailableDatasetGroupTreeModel( QObject *parent = nullptr );
@@ -127,7 +129,7 @@ class APP_NO_EXPORT QgsMeshAvailableDatasetGroupTreeModel: public QgsMeshDataset
QColor backGroundColor( const QModelIndex &index ) const;
};

class APP_NO_EXPORT QgsMeshDatasetGroupProxyModel: public QSortFilterProxyModel
class QgsMeshDatasetGroupProxyModel: public QSortFilterProxyModel
{
public:
QgsMeshDatasetGroupProxyModel( QAbstractItemModel *sourceModel );
@@ -161,7 +163,7 @@ class APP_NO_EXPORT QgsMeshDatasetGroupProxyModel: public QSortFilterProxyModel
/**
* Delegate to display tree item with a contours and vector selector
*/
class APP_EXPORT QgsMeshDatasetGroupTreeItemDelagate: public QStyledItemDelegate
class GUI_EXPORT QgsMeshDatasetGroupTreeItemDelagate: public QStyledItemDelegate
{
Q_OBJECT
public:
@@ -185,7 +187,7 @@ class APP_EXPORT QgsMeshDatasetGroupTreeItemDelagate: public QStyledItemDelegate
QRect iconRect( const QRect &rect, int pos ) const;
};

class APP_EXPORT QgsMeshDatasetGroupTreeView: public QTreeView
class GUI_EXPORT QgsMeshDatasetGroupTreeView: public QTreeView
{
Q_OBJECT
public:
@@ -223,7 +225,7 @@ class APP_EXPORT QgsMeshDatasetGroupTreeView: public QTreeView
*
* One dataset group is selected (active)
*/
class APP_EXPORT QgsMeshActiveDatasetGroupTreeView : public QTreeView
class GUI_EXPORT QgsMeshActiveDatasetGroupTreeView : public QTreeView
{
Q_OBJECT

@@ -266,7 +268,7 @@ class APP_EXPORT QgsMeshActiveDatasetGroupTreeView : public QTreeView
QgsMeshLayer *mMeshLayer = nullptr; // not owned
};

class APP_EXPORT QgsMeshDatasetGroupListModel: public QAbstractListModel
class GUI_EXPORT QgsMeshDatasetGroupListModel: public QAbstractListModel
{
public:
explicit QgsMeshDatasetGroupListModel( QObject *parent ): QAbstractListModel( parent )

0 comments on commit 09c7343

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