Skip to content

Commit

Permalink
Make clip work for mockup
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 14, 2018
1 parent 681d44f commit e75ebad
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
7 changes: 7 additions & 0 deletions src/analysis/processing/qgsalgorithmclip.cpp
Expand Up @@ -26,6 +26,13 @@ QString QgsClipAlgorithm::name() const
return QStringLiteral( "clip" );
}

QgsProcessingAlgorithm::Flags QgsClipAlgorithm::flags() const
{
Flags f = QgsProcessingAlgorithm::flags();
f |= QgsProcessingAlgorithm::FlagSupportsInPlaceEdits;
return f;
}

QString QgsClipAlgorithm::displayName() const
{
return QObject::tr( "Clip" );
Expand Down
1 change: 1 addition & 0 deletions src/analysis/processing/qgsalgorithmclip.h
Expand Up @@ -45,6 +45,7 @@ class QgsClipAlgorithm : public QgsProcessingAlgorithm
QString shortHelpString() const override;
QgsClipAlgorithm *createInstance() const override SIP_FACTORY;

QgsProcessingAlgorithm::Flags flags() const override;
protected:

QVariantMap processAlgorithm( const QVariantMap &parameters,
Expand Down
38 changes: 20 additions & 18 deletions src/gui/processing/qgsprocessingtoolboxmodel.cpp
Expand Up @@ -721,24 +721,26 @@ bool QgsProcessingToolboxProxyModel::filterAcceptsRow( int sourceRow, const QMod
return false;

const QgsProcessingFeatureBasedAlgorithm *alg = dynamic_cast< const QgsProcessingFeatureBasedAlgorithm * >( mModel->algorithmForIndex( sourceIndex ) );

if ( !alg->inputLayerTypes().empty() &&
!alg->inputLayerTypes().contains( QgsProcessing::TypeVector ) &&
!alg->inputLayerTypes().contains( QgsProcessing::TypeVectorAnyGeometry ) &&
( ( mInPlaceGeometryType == QgsWkbTypes::PolygonGeometry && !alg->inputLayerTypes().contains( QgsProcessing::TypeVectorPolygon ) ) ||
( mInPlaceGeometryType == QgsWkbTypes::LineGeometry && !alg->inputLayerTypes().contains( QgsProcessing::TypeVectorLine ) ) ||
( mInPlaceGeometryType == QgsWkbTypes::PointGeometry && !alg->inputLayerTypes().contains( QgsProcessing::TypeVectorPoint ) ) ) )
return false;

QgsWkbTypes::Type type = QgsWkbTypes::Unknown;
if ( mInPlaceGeometryType == QgsWkbTypes::PointGeometry )
type = QgsWkbTypes::Point;
else if ( mInPlaceGeometryType == QgsWkbTypes::LineGeometry )
type = QgsWkbTypes::LineString;
else if ( mInPlaceGeometryType == QgsWkbTypes::PolygonGeometry )
type = QgsWkbTypes::Polygon;
if ( QgsWkbTypes::geometryType( alg->outputWkbType( type ) ) != mInPlaceGeometryType )
return false;
if ( alg )
{
if ( !alg->inputLayerTypes().empty() &&
!alg->inputLayerTypes().contains( QgsProcessing::TypeVector ) &&
!alg->inputLayerTypes().contains( QgsProcessing::TypeVectorAnyGeometry ) &&
( ( mInPlaceGeometryType == QgsWkbTypes::PolygonGeometry && !alg->inputLayerTypes().contains( QgsProcessing::TypeVectorPolygon ) ) ||
( mInPlaceGeometryType == QgsWkbTypes::LineGeometry && !alg->inputLayerTypes().contains( QgsProcessing::TypeVectorLine ) ) ||
( mInPlaceGeometryType == QgsWkbTypes::PointGeometry && !alg->inputLayerTypes().contains( QgsProcessing::TypeVectorPoint ) ) ) )
return false;

QgsWkbTypes::Type type = QgsWkbTypes::Unknown;
if ( mInPlaceGeometryType == QgsWkbTypes::PointGeometry )
type = QgsWkbTypes::Point;
else if ( mInPlaceGeometryType == QgsWkbTypes::LineGeometry )
type = QgsWkbTypes::LineString;
else if ( mInPlaceGeometryType == QgsWkbTypes::PolygonGeometry )
type = QgsWkbTypes::Polygon;
if ( QgsWkbTypes::geometryType( alg->outputWkbType( type ) ) != mInPlaceGeometryType )
return false;
}
}
if ( mFilters & FilterModeler )
{
Expand Down

0 comments on commit e75ebad

Please sign in to comment.