Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add processing algorithms/toolbox functionality #5388

Merged
merged 27 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f558005
Add the skeleton of a processing algorithms model, register native al…
nirvn Jun 21, 2024
a3267fc
Add a bit more model roles
nirvn Jun 21, 2024
e3f9f09
Add proxy model to do proper sorting as well as unlocking filtering
nirvn Jun 21, 2024
403b978
Add in-place processing algorithm filtering
nirvn Jun 21, 2024
5a698a6
Add filtering by vector layer capability to the processing algorithms…
nirvn Jun 22, 2024
66503bf
Add QGIS patches needed
nirvn Jun 22, 2024
e59b243
Properly expose processing algorithms list as part of the features list
nirvn Jun 22, 2024
07c9ef6
Some more work integrating processing into the features list
nirvn Jun 22, 2024
3de8de4
Add a processing algorithm parameters model
nirvn Jun 22, 2024
369ecd4
Rename processing algorthms model classes to get rid of proxy
nirvn Jun 22, 2024
25a1f48
Add a processing algorithm form item
nirvn Jun 22, 2024
8dd95b3
Only show general vs. advanced parameters when the latter is present
nirvn Jun 22, 2024
87404c6
Make the navigation bar reflect processing list / picked alg
nirvn Jun 22, 2024
480d3d3
Add a processing algorithm item to manage preview and running of algs
nirvn Jun 23, 2024
6853c25
Implement the processing algorithm run functionality
nirvn Jun 23, 2024
540f230
Fix processing number parameter widget not working when typing in tex…
nirvn Jun 23, 2024
0fb8eb3
Revisit architecture, don't force a model requirement onto the proces…
nirvn Jun 23, 2024
5358425
Make sure the selected features property is updated when geometries a…
nirvn Jun 23, 2024
5d25387
Add processing algorithm result preview
nirvn Jun 23, 2024
b75d31f
Update processing patch to catch another API protected->public change
nirvn Jun 23, 2024
01f9ab8
Fix cppcheck
nirvn Jun 23, 2024
5a80a31
Don't be shy,show everything we proudly support so far
nirvn Jun 24, 2024
0833723
Implement a favorites filtering of supported algorithms
nirvn Jun 24, 2024
0b87e81
Fix algorithms list sorting, allow for a few more algorithms based on…
nirvn Jun 24, 2024
03e02d9
Address review
nirvn Jun 25, 2024
632b95e
Implement and respect parameter configurations
nirvn Jun 25, 2024
615816b
Address QML/JS review
nirvn Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmake/qgis-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,9 @@ if(TRUE) # Should possibly have a "static only" check
Qt::DBus
)
endif()

find_package(GSL REQUIRED)

target_link_libraries(QGIS::Analysis INTERFACE QGIS::Core)
target_link_libraries(QGIS::Analysis INTERFACE GSL::gsl)
endif()
1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<file>themes/qfield/nodpi/ic_pause_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_play_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_pin_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_processing_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_internal_receiver_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_bluetooth_receiver_black_24dp.svg</file>
<file>themes/qfield/nodpi/ic_tcp_receiver_black_24dp.svg</file>
Expand Down
4 changes: 4 additions & 0 deletions images/themes/qfield/nodpi/ic_processing_black_24dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ set(QFIELD_CORE_SRCS
positioning/udpreceiver.cpp
positioning/positioning.cpp
positioning/positioningdevicemodel.cpp
processing/processingalgorithm.cpp
processing/processingalgorithmparametersmodel.cpp
processing/processingalgorithmsmodel.cpp
appcoordinateoperationhandlers.cpp
appinterface.cpp
attributeformmodel.cpp
Expand Down Expand Up @@ -145,6 +148,9 @@ set(QFIELD_CORE_HDRS
positioning/nmeagnssreceiver.h
positioning/tcpreceiver.h
positioning/udpreceiver.h
processing/processingalgorithm.h
processing/processingalgorithmparametersmodel.h
processing/processingalgorithmsmodel.h
appcoordinateoperationhandlers.h
appinterface.h
attributeformmodel.h
Expand Down Expand Up @@ -303,7 +309,8 @@ target_include_directories(
${CMAKE_SOURCE_DIR}/src/core/platforms
${CMAKE_SOURCE_DIR}/src/core/qgsquick
${CMAKE_SOURCE_DIR}/src/core/utils
${CMAKE_SOURCE_DIR}/src/core/positioning)
${CMAKE_SOURCE_DIR}/src/core/positioning
${CMAKE_SOURCE_DIR}/src/core/processing)
if(ANDROID)
string(REPLACE "_" "_1" APP_PACKAGE_JNI_NAME "${APP_PACKAGE_NAME}")
configure_file(platforms/android/qfield_android.h.in
Expand Down
15 changes: 10 additions & 5 deletions src/core/multifeaturelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,36 @@ int MultiFeatureListModel::selectedCount() const
return mSourceModel->selectedCount();
}

bool MultiFeatureListModel::canEditAttributesSelection()
bool MultiFeatureListModel::canEditAttributesSelection() const
{
return mSourceModel->canEditAttributesSelection();
}

bool MultiFeatureListModel::canMergeSelection()
bool MultiFeatureListModel::canMergeSelection() const
{
return mSourceModel->canMergeSelection();
}

bool MultiFeatureListModel::canDeleteSelection()
bool MultiFeatureListModel::canDeleteSelection() const
{
return mSourceModel->canDeleteSelection();
}

bool MultiFeatureListModel::canDuplicateSelection()
bool MultiFeatureListModel::canDuplicateSelection() const
{
return mSourceModel->canDuplicateSelection();
}

bool MultiFeatureListModel::canMoveSelection()
bool MultiFeatureListModel::canMoveSelection() const
{
return mSourceModel->canMoveSelection();
}

bool MultiFeatureListModel::canProcessSelection() const
{
return mSourceModel->canProcessSelection();
}

bool MultiFeatureListModel::mergeSelection()
{
return mSourceModel->mergeSelection();
Expand Down
14 changes: 9 additions & 5 deletions src/core/multifeaturelistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class MultiFeatureListModel : public QSortFilterProxyModel
Q_PROPERTY( bool canDeleteSelection READ canDeleteSelection NOTIFY selectedCountChanged )
Q_PROPERTY( bool canDuplicateSelection READ canDuplicateSelection NOTIFY selectedCountChanged )
Q_PROPERTY( bool canMoveSelection READ canMoveSelection NOTIFY selectedCountChanged )
Q_PROPERTY( bool canProcessSelection READ canProcessSelection NOTIFY selectedCountChanged )

public:
enum FeatureListRoles
Expand Down Expand Up @@ -94,19 +95,22 @@ class MultiFeatureListModel : public QSortFilterProxyModel
int selectedCount() const;

//! Returns TRUE if the selected features can have their attributes value changed
bool canEditAttributesSelection();
bool canEditAttributesSelection() const;

//! Returns TRUE if the selected features can be merged
bool canMergeSelection();
bool canMergeSelection() const;

//! Returns TRUE if the selected features can be deleted
bool canDeleteSelection();
bool canDeleteSelection() const;

//! Returns TRUE if the selected features can be duplicated onto their associated layer
bool canDuplicateSelection();
bool canDuplicateSelection() const;

//! Returns TRUE if the selected features' geometry can be moved
bool canMoveSelection();
bool canMoveSelection() const;

//! Returns TRUE if the selected features can run processing algorithms
bool canProcessSelection() const;

/**
* Merges selected features by updating the first seleted feature's geometry
Expand Down
46 changes: 41 additions & 5 deletions src/core/multifeaturelistmodelbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ int MultiFeatureListModelBase::selectedCount() const
return static_cast<int>( mSelectedFeatures.size() );
}

bool MultiFeatureListModelBase::canEditAttributesSelection()
bool MultiFeatureListModelBase::canEditAttributesSelection() const
{
if ( mSelectedFeatures.isEmpty() )
return false;
Expand All @@ -327,7 +327,7 @@ bool MultiFeatureListModelBase::canEditAttributesSelection()
return !vlayer->readOnly() && ( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
}

bool MultiFeatureListModelBase::canMergeSelection()
bool MultiFeatureListModelBase::canMergeSelection() const
{
if ( mSelectedFeatures.isEmpty() )
return false;
Expand All @@ -336,7 +336,7 @@ bool MultiFeatureListModelBase::canMergeSelection()
return !vlayer->readOnly() && QgsWkbTypes::isMultiType( vlayer->wkbType() ) && ( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures ) && ( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeGeometries ) && !vlayer->customProperty( QStringLiteral( "QFieldSync/is_geometry_locked" ), false ).toBool();
}

bool MultiFeatureListModelBase::canDeleteSelection()
bool MultiFeatureListModelBase::canDeleteSelection() const
{
if ( mSelectedFeatures.isEmpty() )
return false;
Expand All @@ -345,7 +345,7 @@ bool MultiFeatureListModelBase::canDeleteSelection()
return !vlayer->readOnly() && ( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures ) && !vlayer->customProperty( QStringLiteral( "QFieldSync/is_geometry_locked" ), false ).toBool();
}

bool MultiFeatureListModelBase::canDuplicateSelection()
bool MultiFeatureListModelBase::canDuplicateSelection() const
{
if ( mSelectedFeatures.isEmpty() )
return false;
Expand All @@ -354,7 +354,39 @@ bool MultiFeatureListModelBase::canDuplicateSelection()
return !vlayer->readOnly() && ( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures ) && !vlayer->customProperty( QStringLiteral( "QFieldSync/is_geometry_locked" ), false ).toBool();
}

bool MultiFeatureListModelBase::canMoveSelection()
bool MultiFeatureListModelBase::canMoveSelection() const
{
if ( mSelectedFeatures.isEmpty() )
return false;

QgsVectorLayer *vlayer = mSelectedFeatures[0].first;
if ( !vlayer || vlayer->readOnly() || !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeGeometries ) || vlayer->customProperty( QStringLiteral( "QFieldSync/is_geometry_locked" ), false ).toBool() )
return false;

const bool geometryLockedExpressionActive = vlayer->customProperty( QStringLiteral( "QFieldSync/is_geometry_locked_expression_active" ), false ).toBool();
if ( geometryLockedExpressionActive )
{
const QString geometryLockedExpression = vlayer->customProperty( QStringLiteral( "QFieldSync/geometry_locked_expression" ), QString() ).toString().trimmed();
if ( !geometryLockedExpression.isEmpty() )
{
QgsExpressionContext expressionContext = vlayer->createExpressionContext();
for ( const QPair<QgsVectorLayer *, QgsFeature> &selectedFeature : std::as_const( mSelectedFeatures ) )
{
expressionContext.setFeature( selectedFeature.second );
QgsExpression expression( geometryLockedExpression );
expression.prepare( &expressionContext );
if ( !expression.evaluate( &expressionContext ).toBool() )
{
return false;
}
}
}
}

return true;
}

bool MultiFeatureListModelBase::canProcessSelection() const
{
if ( mSelectedFeatures.isEmpty() )
return false;
Expand Down Expand Up @@ -674,6 +706,8 @@ void MultiFeatureListModelBase::attributeValueChanged( QgsFeatureId fid, int idx
break;
}
}

emit selectedCountChanged();
}

void MultiFeatureListModelBase::geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry )
Expand Down Expand Up @@ -703,4 +737,6 @@ void MultiFeatureListModelBase::geometryChanged( QgsFeatureId fid, const QgsGeom
break;
}
}

emit selectedCountChanged();
nirvn marked this conversation as resolved.
Show resolved Hide resolved
}
13 changes: 8 additions & 5 deletions src/core/multifeaturelistmodelbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,22 @@ class MultiFeatureListModelBase : public QAbstractItemModel
int selectedCount() const;

//! \copydoc MultiFeatureListModel::canEditAttributesSelection
bool canEditAttributesSelection();
bool canEditAttributesSelection() const;

//! \copydoc MultiFeatureListModel::canMergeSelection
bool canMergeSelection();
bool canMergeSelection() const;

//! \copydoc MultiFeatureListModel::canDeleteSelection
bool canDeleteSelection();
bool canDeleteSelection() const;

//! \copydoc MultiFeatureListModel::canDuplicateSelection
bool canDuplicateSelection();
bool canDuplicateSelection() const;

//! \copydoc MultiFeatureListModel::canMoveSelection
bool canMoveSelection();
bool canMoveSelection() const;

//! \copydoc MultiFeatureListModel::canProcessSelection
bool canProcessSelection() const;

//! \copydoc MultiFeatureListModel::mergeSelection
bool mergeSelection();
Expand Down
Loading
Loading