Skip to content
Permalink
Browse files

Merge pull request #7613 from wonder-sk/mesh-gui-fixes

Mesh layer fixes and improvements
  • Loading branch information
wonder-sk committed Aug 16, 2018
2 parents 0be9de5 + c0f190d commit f37aa8c6e346d3a2f27bbd27e45b5b62dc58037b
Showing with 1,107 additions and 493 deletions.
  1. +11 −0 python/core/auto_generated/mesh/qgsmeshdataprovider.sip.in
  2. +3 −56 python/core/auto_generated/mesh/qgsmeshlayer.sip.in
  3. +110 −2 python/core/auto_generated/mesh/qgsmeshrenderersettings.sip.in
  4. +28 −0 python/core/auto_generated/qgsmaplayerlegend.sip.in
  5. +15 −1 python/core/auto_generated/raster/qgscolorrampshader.sip.in
  6. +3 −7 src/app/mesh/qgsmeshdatasetgrouptreeview.cpp
  7. +10 −9 src/app/mesh/qgsmeshrendereractivedatasetwidget.cpp
  8. +10 −0 src/app/mesh/qgsmeshrendereractivedatasetwidget.h
  9. +5 −8 src/app/mesh/qgsmeshrenderermeshsettingswidget.cpp
  10. +12 −59 src/app/mesh/qgsmeshrendererscalarsettingswidget.cpp
  11. +4 −6 src/app/mesh/qgsmeshrendererscalarsettingswidget.h
  12. +8 −11 src/app/mesh/qgsmeshrenderervectorsettingswidget.cpp
  13. +4 −5 src/app/mesh/qgsmeshrenderervectorsettingswidget.h
  14. +36 −46 src/app/mesh/qgsrenderermeshpropertieswidget.cpp
  15. +1 −7 src/app/mesh/qgsrenderermeshpropertieswidget.h
  16. +2 −0 src/core/CMakeLists.txt
  17. +9 −0 src/core/mesh/qgsmeshdataprovider.h
  18. +105 −86 src/core/mesh/qgsmeshlayer.cpp
  19. +9 −50 src/core/mesh/qgsmeshlayer.h
  20. +16 −55 src/core/mesh/qgsmeshlayerrenderer.cpp
  21. +1 −5 src/core/mesh/qgsmeshlayerrenderer.h
  22. +119 −0 src/core/mesh/qgsmeshlayerutils.cpp
  23. +64 −0 src/core/mesh/qgsmeshlayerutils.h
  24. +9 −0 src/core/mesh/qgsmeshmemorydataprovider.cpp
  25. +2 −0 src/core/mesh/qgsmeshmemorydataprovider.h
  26. +182 −3 src/core/mesh/qgsmeshrenderersettings.cpp
  27. +80 −2 src/core/mesh/qgsmeshrenderersettings.h
  28. +56 −0 src/core/qgsmaplayerlegend.cpp
  29. +24 −0 src/core/qgsmaplayerlegend.h
  30. +65 −1 src/core/raster/qgscolorrampshader.cpp
  31. +13 −1 src/core/raster/qgscolorrampshader.h
  32. +2 −56 src/core/raster/qgsrastershader.cpp
  33. +1 −0 src/gui/raster/qgscolorrampshaderwidget.cpp
  34. +7 −0 src/providers/mdal/qgsmdalprovider.cpp
  35. +2 −0 src/providers/mdal/qgsmdalprovider.h
  36. +4 −0 tests/src/core/testqgsmeshlayer.cpp
  37. +75 −17 tests/src/core/testqgsmeshlayerrenderer.cpp
  38. BIN ...expected_quad_and_triangle_face_scalar_dataset/expected_quad_and_triangle_face_scalar_dataset.png
  39. BIN ...cted_quad_and_triangle_vertex_scalar_dataset/expected_quad_and_triangle_vertex_scalar_dataset.png
@@ -317,6 +317,11 @@ Datasets are grouped in the dataset groups. A dataset group represents a measure
Associate dataset with the mesh

emits dataChanged when successful
%End

virtual QStringList extraDatasets() const = 0;
%Docstring
Returns list of additional dataset file URIs added using addDataset() calls.
%End

virtual int datasetGroupCount( ) const = 0;
@@ -387,6 +392,12 @@ Ctor
Returns the extent of the layer

:return: QgsRectangle containing the extent of the layer
%End

signals:
void datasetGroupsAdded( int count );
%Docstring
Emitted when some new dataset groups have been added
%End
};

@@ -129,66 +129,13 @@ Returns the provider type for this layer



QgsMeshRendererMeshSettings rendererNativeMeshSettings() const;
QgsMeshRendererSettings rendererSettings() const;
%Docstring
Returns renderer settings
%End

void setRendererNativeMeshSettings( const QgsMeshRendererMeshSettings &settings );
%Docstring
Sets new renderer settings, triggers repaint
%End

QgsMeshRendererMeshSettings rendererTriangularMeshSettings() const;
%Docstring
Returns renderer settings
%End

void setRendererTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings );
%Docstring
Sets new renderer settings, triggers repaint
%End

QgsMeshRendererScalarSettings rendererScalarSettings() const;
%Docstring
Returns renderer settings
%End

void setRendererScalarSettings( const QgsMeshRendererScalarSettings &settings );
%Docstring
Sets new renderer settings, triggers repaint
%End

QgsMeshRendererVectorSettings rendererVectorSettings() const;
%Docstring
Returns renderer settings
%End

void setRendererVectorSettings( const QgsMeshRendererVectorSettings &settings );
%Docstring
Sets new renderer settings, triggers repaint
%End

void setActiveScalarDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() );
%Docstring
Sets active scalar dataset for rendering

Triggers repaint
%End
QgsMeshDatasetIndex activeScalarDataset() const;
%Docstring
Returns active scalar dataset
%End

void setActiveVectorDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() );
%Docstring
Sets active vector dataset for rendering.

If dataset is not vector based, do nothing. Triggers repaint
%End
QgsMeshDatasetIndex activeVectorDataset() const;
void setRendererSettings( const QgsMeshRendererSettings &settings );
%Docstring
Returns active vector dataset
Sets new renderer settings
%End

QgsMeshDatasetValue datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point ) const;
@@ -53,6 +53,15 @@ Returns color used for rendering
void setColor( const QColor &color );
%Docstring
Sets color used for rendering of the mesh
%End

QDomElement writeXml( QDomDocument &doc ) const;
%Docstring
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem );
%Docstring
Reads configuration from the given DOM element
%End

};
@@ -83,10 +92,15 @@ Returns color ramp shader function
Sets color ramp shader function
%End

bool isEnabled() const;
QDomElement writeXml( QDomDocument &doc ) const;
%Docstring
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem );
%Docstring
Returns whether color ramp has any items assigned
Reads configuration from the given DOM element
%End

};

class QgsMeshRendererVectorSettings
@@ -106,6 +120,7 @@ Represents a mesh renderer settings for vector datasets
#include "qgsmeshrenderersettings.h"
%End
public:

enum ArrowScalingMethod
{

@@ -245,6 +260,99 @@ Returns ratio of the head length of the arrow (range 0-1)
void setArrowHeadLengthRatio( double arrowHeadLengthRatio );
%Docstring
Sets ratio of the head length of the arrow (range 0-1)
%End

QDomElement writeXml( QDomDocument &doc ) const;
%Docstring
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem );
%Docstring
Reads configuration from the given DOM element
%End

};


class QgsMeshRendererSettings
{
%Docstring

Represents all mesh renderer settings

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.4
%End

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

QgsMeshRendererMeshSettings nativeMeshSettings() const;
%Docstring
Returns renderer settings
%End
void setNativeMeshSettings( const QgsMeshRendererMeshSettings &settings );
%Docstring
Sets new renderer settings, triggers repaint
%End

QgsMeshRendererMeshSettings triangularMeshSettings() const;
%Docstring
Returns renderer settings
%End
void setTriangularMeshSettings( const QgsMeshRendererMeshSettings &settings );
%Docstring
Sets new renderer settings
%End

QgsMeshRendererScalarSettings scalarSettings( int groupIndex ) const;
%Docstring
Returns renderer settings
%End
void setScalarSettings( int groupIndex, const QgsMeshRendererScalarSettings &settings );
%Docstring
Sets new renderer settings
%End

QgsMeshRendererVectorSettings vectorSettings( int groupIndex ) const;
%Docstring
Returns renderer settings
%End
void setVectorSettings( int groupIndex, const QgsMeshRendererVectorSettings &settings );
%Docstring
Sets new renderer settings
%End

QgsMeshDatasetIndex activeScalarDataset() const;
%Docstring
Returns active scalar dataset
%End
void setActiveScalarDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() );
%Docstring
Sets active scalar dataset for rendering
%End

QgsMeshDatasetIndex activeVectorDataset() const;
%Docstring
Returns active vector dataset
%End
void setActiveVectorDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() );
%Docstring
Sets active vector dataset for rendering.
%End

QDomElement writeXml( QDomDocument &doc ) const;
%Docstring
Writes configuration to a new DOM element
%End
void readXml( const QDomElement &elem );
%Docstring
Reads configuration from the given DOM element
%End

};
@@ -61,6 +61,11 @@ Create new legend implementation for vector layer
static QgsMapLayerLegend *defaultRasterLegend( QgsRasterLayer *rl ) /Factory/;
%Docstring
Create new legend implementation for raster layer
%End

static QgsMapLayerLegend *defaultMeshLegend( QgsMeshLayer *ml ) /Factory/;
%Docstring
Create new legend implementation for mesh layer
%End

signals:
@@ -192,6 +197,29 @@ Default legend implementation for raster layers
};


class QgsDefaultMeshLayerLegend : QgsMapLayerLegend
{
%Docstring
Default legend implementation for mesh layers

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgsmaplayerlegend.h"
%End
public:
explicit QgsDefaultMeshLayerLegend( QgsMeshLayer *ml );
%Docstring
Creates an instance for the given mesh layer
%End

virtual QList<QgsLayerTreeModelLegendNode *> createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer ) /Factory/;


};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -82,7 +82,7 @@ Returns the custom colormap.
Returns the color ramp type.
%End

QString colorRampTypeAsQString();
QString colorRampTypeAsQString() const;
%Docstring
Returns the color ramp type as a string.
%End
@@ -160,6 +160,20 @@ Generates and new RGB value based on original RGB value
virtual void legendSymbologyItems( QList< QPair< QString, QColor > > &symbolItems /Out/ ) const;


QDomElement writeXml( QDomDocument &doc ) const;
%Docstring
Writes configuration to a new DOM element

.. versionadded:: 3.4
%End

void readXml( const QDomElement &elem );
%Docstring
Reads configuration from the given DOM element

.. versionadded:: 3.4
%End

void setClassificationMode( ClassificationMode classificationMode );
%Docstring
Sets classification mode
@@ -272,21 +272,17 @@ int QgsMeshDatasetGroupTreeView::setActiveGroupFromActiveDataset()
QgsMeshDatasetIndex activeDataset;
if ( mMeshLayer )
{
activeDataset = mMeshLayer->activeScalarDataset();
const QgsMeshRendererSettings rendererSettings = mMeshLayer->rendererSettings();
activeDataset = rendererSettings.activeScalarDataset();
if ( !activeDataset.isValid() )
activeDataset = mMeshLayer->activeVectorDataset();
activeDataset = rendererSettings.activeVectorDataset();
}

// find group that contains active dataset
if ( activeDataset.isValid() && activeDataset.group() < mGroups.size() )
{
group = activeDataset.group();
}
else if ( !mGroups.empty() )
{
// not found, select first item
group = 0;
}

if ( mActiveGroup != group )
{
@@ -30,14 +30,8 @@ QgsMeshRendererActiveDatasetWidget::QgsMeshRendererActiveDatasetWidget( QWidget

void QgsMeshRendererActiveDatasetWidget::setLayer( QgsMeshLayer *layer )
{
if ( layer != mMeshLayer )
{
mMeshLayer = layer;
}

mMeshLayer = layer;
mDatasetGroupTreeView->setLayer( layer );
setEnabled( mMeshLayer );
syncToLayer();
}

QgsMeshDatasetIndex QgsMeshRendererActiveDatasetWidget::activeScalarDataset() const
@@ -73,6 +67,8 @@ void QgsMeshRendererActiveDatasetWidget::onActiveGroupChanged()

mDatasetSlider->setValue( val );
onActiveDatasetChanged( val );
mActiveDatasetGroup = mDatasetGroupTreeView->activeGroup();
emit activeDatasetGroupChanged( mActiveDatasetGroup );
}

void QgsMeshRendererActiveDatasetWidget::onActiveDatasetChanged( int value )
@@ -161,15 +157,20 @@ QgsMeshDatasetIndex QgsMeshRendererActiveDatasetWidget::datasetIndex() const

void QgsMeshRendererActiveDatasetWidget::syncToLayer()
{
setEnabled( mMeshLayer );

whileBlocking( mDatasetGroupTreeView )->syncToLayer();

if ( mMeshLayer )
{
mActiveScalarDataset = mMeshLayer->activeScalarDataset();
mActiveVectorDataset = mMeshLayer->activeVectorDataset();
const QgsMeshRendererSettings rendererSettings = mMeshLayer->rendererSettings();
mActiveDatasetGroup = mDatasetGroupTreeView->activeGroup();
mActiveScalarDataset = rendererSettings.activeScalarDataset();
mActiveVectorDataset = rendererSettings.activeVectorDataset();
}
else
{
mActiveDatasetGroup = -1;
mActiveScalarDataset = QgsMeshDatasetIndex();
mActiveVectorDataset = QgsMeshDatasetIndex();
}

0 comments on commit f37aa8c

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