-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Conversation
…sing algorithm item
…nd attributes are changed
🎉 Ta-daaa, freshly created APKs are available for 615816b: arm64-android |
… capacity (inc. crucial rotation), fix qml warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic functionality, you are on fire @nirvn , well done :)
All good, i just have some cleanup comments.
@m-kuhn , @mohsenD98 , thanks for the pair of reviews guys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
int ProcessingAlgorithmParametersModelBase::rowCount( const QModelIndex &parent ) const | ||
{ | ||
if ( !parent.isValid() ) | ||
return mParameters.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'qsizetype' (aka 'long long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
return mParameters.size();
^
if ( index.row() >= mParameters.size() || index.row() < 0 || !mParameters.at( index.row() ) ) | ||
return QVariant(); | ||
|
||
switch ( role ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: switching on non-enum value without default case may not cover all cases [bugprone-switch-missing-default-case]
switch ( role )
^
if ( index.row() >= mParameters.size() || index.row() < 0 || !mParameters.at( index.row() ) ) | ||
return false; | ||
|
||
switch ( role ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: switching on non-enum value without default case may not cover all cases [bugprone-switch-missing-default-case]
switch ( role )
^
|
||
public: | ||
//! Available filter flags for filtering the model | ||
enum Filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: enum 'Filter' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
enum Filter
^
|
||
public: | ||
//!Roles of the model. | ||
enum Role |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: enum 'Role' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint16_t' (2 bytes) as the base type to reduce its size [performance-enum-size]
enum Role
^
int ProcessingAlgorithmsModelBase::rowCount( const QModelIndex &parent ) const | ||
{ | ||
if ( !parent.isValid() ) | ||
return mAlgorithms.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'qsizetype' (aka 'long long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
return mAlgorithms.size();
^
if ( index.row() >= mAlgorithms.size() || index.row() < 0 || !mAlgorithms.at( index.row() ).algorithm() ) | ||
return QVariant(); | ||
|
||
switch ( role ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: switching on non-enum value without default case may not cover all cases [bugprone-switch-missing-default-case]
switch ( role )
^
if ( index.row() >= mAlgorithms.size() || index.row() < 0 || !mAlgorithms.at( index.row() ).algorithm() ) | ||
return false; | ||
|
||
switch ( role ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: switching on non-enum value without default case may not cover all cases [bugprone-switch-missing-default-case]
switch ( role )
^
|
||
public: | ||
//! Available filter flags for filtering the model | ||
enum Filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: enum 'Filter' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
enum Filter
^
|
||
public: | ||
//!Roles to get the data of the model. | ||
enum Role |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: enum 'Role' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint16_t' (2 bytes) as the base type to reduce its size [performance-enum-size]
enum Role
^
} | ||
|
||
QgsProcessingContext context; | ||
context.setFlags( QgsProcessingContext::Flags() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually NO flags right now, you could drop this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nyalldawson , thanks, leftover.
-1, | ||
Qgis::ProcessingFeatureSourceDefinitionFlags(), | ||
Qgis::InvalidGeometryCheck(), | ||
QStringLiteral( "$id IN (%1)" ).arg( featureIds.join( ',' ) ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these features already selected? If so, you could just set the "selectedFeaturesOnly" argument to true and avoid the IN expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nyalldawson , na, the features are actually not selected on the layer itself, it's a different handling (a selected features model), hence why I need to filter by IDs here.
|
||
if ( !previewMode ) | ||
{ | ||
mInPlaceLayer->startEditing(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might consider mInPlaceLayer->beginEditCommand() here, if you want all the operations to undo-able in a single step
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nyalldawson , we don't use QGIS' internal buffer, so that's not needed ATM. But, that makes me think our own history handling should have a command-like concept to store multiple changes.
QgsProcessingFeatureBasedAlgorithm *alg = static_cast<QgsProcessingFeatureBasedAlgorithm *>( featureBasedAlgorithm->create( { { QStringLiteral( "IN_PLACE" ), true } } ) ); | ||
if ( !alg->prepare( parameters, context, &feedback ) ) | ||
{ | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a leak here -- I'd use unique_ptr for alg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nyalldawson , true true, thanks.
Another great leap forward: in-place processing algorithms support straight within QField. I apologizes for the size of the PR, but I think it's justified ;-P
Here's a screenshot showing the UI/UX integration into QField:
qfield_processing.mp4
~~ATM, only two algorithms - orthogonalize and rotation - are unlocked. I wanted to focus on those two as part of the initial PR. ~~
Note: yes, we have algorithm output preview, which I just love 😉