34#include <QApplication>
35#include <QGraphicsSceneHoverEvent>
42#include <QSvgRenderer>
44#include "moc_qgsmodelcomponentgraphicitem.cpp"
46using namespace Qt::StringLiterals;
50QgsModelComponentGraphicItem::QgsModelComponentGraphicItem( QgsProcessingModelComponent *component, QgsProcessingModelAlgorithm *model, QGraphicsItem *parent )
51 : QGraphicsObject( parent )
52 , mComponent( component )
55 setAcceptHoverEvents(
true );
56 setFlag( QGraphicsItem::ItemIsSelectable,
true );
57 setFlag( QGraphicsItem::ItemSendsGeometryChanges,
true );
58 setZValue( QgsModelGraphicsScene::ZValues::ModelComponent );
60 mFont.setPixelSize( 12 );
64 QPainter painter( &editPicture );
65 svg.render( &painter );
67 mEditButton =
new QgsModelDesignerFlatButtonGraphicItem(
this, editPicture, QPointF( 0, 0 ) );
68 connect( mEditButton, &QgsModelDesignerFlatButtonGraphicItem::clicked,
this, &QgsModelComponentGraphicItem::editComponent );
71 QPicture deletePicture;
72 painter.begin( &deletePicture );
73 svg2.render( &painter );
75 mDeleteButton =
new QgsModelDesignerFlatButtonGraphicItem(
this, deletePicture, QPointF( 0, 0 ) );
76 connect( mDeleteButton, &QgsModelDesignerFlatButtonGraphicItem::clicked,
this, &QgsModelComponentGraphicItem::deleteComponent );
78 updateButtonPositions();
81QgsModelComponentGraphicItem::Flags QgsModelComponentGraphicItem::flags()
const
83 return QgsModelComponentGraphicItem::Flags();
86QgsModelComponentGraphicItem::~QgsModelComponentGraphicItem() =
default;
88QgsProcessingModelComponent *QgsModelComponentGraphicItem::component()
90 return mComponent.get();
93const QgsProcessingModelComponent *QgsModelComponentGraphicItem::component()
const
95 return mComponent.get();
98QgsProcessingModelAlgorithm *QgsModelComponentGraphicItem::model()
103const QgsProcessingModelAlgorithm *QgsModelComponentGraphicItem::model()
const
108QgsModelGraphicsView *QgsModelComponentGraphicItem::view()
110 if ( scene()->views().isEmpty() )
113 return qobject_cast<QgsModelGraphicsView *>( scene()->views().first() );
116QFont QgsModelComponentGraphicItem::font()
const
121void QgsModelComponentGraphicItem::setFont(
const QFont &font )
127void QgsModelComponentGraphicItem::moveComponentBy( qreal dx, qreal dy )
129 setPos( mComponent->position().x() + dx, mComponent->position().y() + dy );
130 mComponent->setPosition( pos() );
132 emit aboutToChange( tr(
"Move %1" ).arg( mComponent->description() ) );
133 updateStoredComponentPosition( pos(), mComponent->size() );
136 emit sizePositionChanged();
137 emit updateArrowPaths();
140void QgsModelComponentGraphicItem::previewItemMove( qreal dx, qreal dy )
142 setPos( mComponent->position().x() + dx, mComponent->position().y() + dy );
143 emit updateArrowPaths();
146void QgsModelComponentGraphicItem::setItemRect( QRectF rect )
148 rect = rect.normalized();
150 if ( rect.width() < MIN_COMPONENT_WIDTH )
151 rect.setWidth( MIN_COMPONENT_WIDTH );
152 if ( rect.height() < MIN_COMPONENT_HEIGHT )
153 rect.setHeight( MIN_COMPONENT_HEIGHT );
155 setPos( rect.center() );
156 prepareGeometryChange();
158 emit aboutToChange( tr(
"Resize %1" ).arg( mComponent->description() ) );
160 mComponent->setPosition( pos() );
161 mComponent->setSize( rect.size() );
162 updateStoredComponentPosition( pos(), mComponent->size() );
164 updateButtonPositions();
167 emit updateArrowPaths();
168 emit sizePositionChanged();
171QRectF QgsModelComponentGraphicItem::previewItemRectChange( QRectF rect )
173 rect = rect.normalized();
175 if ( rect.width() < MIN_COMPONENT_WIDTH )
176 rect.setWidth( MIN_COMPONENT_WIDTH );
177 if ( rect.height() < MIN_COMPONENT_HEIGHT )
178 rect.setHeight( MIN_COMPONENT_HEIGHT );
180 setPos( rect.center() );
181 prepareGeometryChange();
183 mTempSize = rect.size();
185 updateButtonPositions();
186 emit updateArrowPaths();
191void QgsModelComponentGraphicItem::finalizePreviewedItemRectChange( QRectF )
193 mComponent->setPosition( pos() );
194 prepareGeometryChange();
195 mComponent->setSize( mTempSize );
196 mTempSize = QSizeF();
198 emit aboutToChange( tr(
"Resize %1" ).arg( mComponent->description() ) );
199 updateStoredComponentPosition( pos(), mComponent->size() );
201 updateButtonPositions();
205 emit sizePositionChanged();
206 emit updateArrowPaths();
211 if ( view() && view()->tool() && view()->tool()->allowItemInteraction() )
212 updateToolTip( mapFromScene( event->
modelPoint() ) );
217 if ( view() && view()->tool() && view()->tool()->allowItemInteraction() )
218 updateToolTip( mapFromScene( event->
modelPoint() ) );
223 if ( view() && view()->tool() && view()->tool()->allowItemInteraction() )
225 setToolTip( QString() );
230 emit repaintArrows();
237 if ( view() && view()->tool() && view()->tool()->allowItemInteraction() )
241void QgsModelComponentGraphicItem::mouseDoubleClickEvent( QGraphicsSceneMouseEvent * )
243 if ( view() && view()->tool() && view()->tool()->allowItemInteraction() )
247void QgsModelComponentGraphicItem::hoverEnterEvent( QGraphicsSceneHoverEvent *event )
249 if ( view() && view()->tool() && view()->tool()->allowItemInteraction() )
250 updateToolTip( event->pos() );
253void QgsModelComponentGraphicItem::hoverMoveEvent( QGraphicsSceneHoverEvent *event )
255 if ( view() && view()->tool() && view()->tool()->allowItemInteraction() )
256 updateToolTip( event->pos() );
259void QgsModelComponentGraphicItem::hoverLeaveEvent( QGraphicsSceneHoverEvent * )
261 modelHoverLeaveEvent(
nullptr );
264QVariant QgsModelComponentGraphicItem::itemChange( QGraphicsItem::GraphicsItemChange change,
const QVariant &value )
268 case QGraphicsItem::ItemSelectedChange:
270 emit repaintArrows();
274 case QGraphicsItem::ItemSceneChange:
279 if ( linkPointCount( Qt::TopEdge ) )
281 mExpandTopButton =
new QgsModelDesignerFoldButtonGraphicItem(
this, mComponent->linksCollapsed( Qt::TopEdge ), QPointF( 0, 0 ) );
282 connect( mExpandTopButton, &QgsModelDesignerFoldButtonGraphicItem::folded,
this, [
this](
bool folded ) { fold( Qt::TopEdge, folded ); } );
284 for (
int idx = 0; idx < linkPointCount( Qt::TopEdge ); ++idx )
286 mInSockets.append(
new QgsModelDesignerSocketGraphicItem(
this, mComponent.get(), idx, QPointF( 0, 0 ), Qt::TopEdge ) );
289 if ( linkPointCount( Qt::BottomEdge ) )
291 mExpandBottomButton =
new QgsModelDesignerFoldButtonGraphicItem(
this, mComponent->linksCollapsed( Qt::BottomEdge ), QPointF( 0, 0 ) );
292 connect( mExpandBottomButton, &QgsModelDesignerFoldButtonGraphicItem::folded,
this, [
this](
bool folded ) { fold( Qt::BottomEdge, folded ); } );
294 for (
int idx = 0; idx < linkPointCount( Qt::BottomEdge ); ++idx )
296 mOutSockets.append(
new QgsModelDesignerSocketGraphicItem(
this, mComponent.get(), idx, QPointF( 0, 0 ), Qt::BottomEdge ) );
300 updateButtonPositions();
309 return QGraphicsObject::itemChange( change, value );
312QRectF QgsModelComponentGraphicItem::boundingRect()
const
314 const QFontMetricsF fm( mFont );
315 const int linksAbove = linkPointCount( Qt::TopEdge );
316 const int linksBelow = linkPointCount( Qt::BottomEdge );
318 const double hUp = linksAbove == 0 ? 0 : fm.height() * 1.2 * ( ( mComponent->linksCollapsed( Qt::TopEdge ) ? 0 : linksAbove ) + 2 );
319 const double hDown = linksBelow == 0 ? 0 : fm.height() * 1.2 * ( ( mComponent->linksCollapsed( Qt::BottomEdge ) ? 0 : linksBelow ) + 2 );
320 return QRectF( -( itemSize().width() ) / 2 - RECT_PEN_SIZE, -( itemSize().height() ) / 2 - hUp - RECT_PEN_SIZE, itemSize().width() + 2 * RECT_PEN_SIZE, itemSize().height() + hDown + hUp + 2 * RECT_PEN_SIZE );
323bool QgsModelComponentGraphicItem::contains(
const QPointF &point )
const
325 const QRectF paintingBounds = boundingRect();
326 if ( point.x() < paintingBounds.left() + RECT_PEN_SIZE )
328 if ( point.x() > paintingBounds.right() - RECT_PEN_SIZE )
330 if ( point.y() < paintingBounds.top() + RECT_PEN_SIZE )
332 if ( point.y() > paintingBounds.bottom() - RECT_PEN_SIZE )
338void QgsModelComponentGraphicItem::paint( QPainter *painter,
const QStyleOptionGraphicsItem *, QWidget * )
340 const QRectF rect = itemRect();
344 if ( mComponent->color().isValid() )
346 color = mComponent->color();
350 color = color.darker( 110 );
353 color = color.darker( 105 );
359 stroke = color.darker( 110 );
360 foreColor = color.lightness() > 150 ? QColor( 0, 0, 0 ) : QColor( 255, 255, 255 );
364 color = fillColor( state() );
365 stroke = strokeColor( state() );
366 foreColor = textColor( state() );
369 QPen strokePen = QPen( stroke, 0 );
370 strokePen.setStyle( strokeStyle( state() ) );
371 painter->setPen( strokePen );
372 painter->setBrush( QBrush( color, Qt::SolidPattern ) );
373 painter->drawRect( rect );
374 painter->setFont( font() );
375 painter->setPen( QPen( foreColor ) );
379 const QSizeF componentSize = itemSize();
381 const QFontMetricsF fm( font() );
382 double h = fm.ascent();
383 QPointF pt( -componentSize.width() / 2 + 25, componentSize.height() / 2.0 - h + 1 );
385 if ( iconPicture().isNull() && iconPixmap().isNull() )
387 const QRectF labelRect = QRectF( rect.left() + TEXT_MARGIN, rect.top() + TEXT_MARGIN, rect.width() - 2 * TEXT_MARGIN - mButtonSize.width() - BUTTON_MARGIN, rect.height() - 2 * TEXT_MARGIN );
389 painter->drawText( labelRect, Qt::TextWordWrap | titleAlignment(), text );
393 const QRectF labelRect = QRectF( rect.left() + 21 + TEXT_MARGIN, rect.top() + TEXT_MARGIN, rect.width() - 2 * TEXT_MARGIN - mButtonSize.width() - BUTTON_MARGIN - 21, rect.height() - 2 * TEXT_MARGIN );
395 painter->drawText( labelRect, Qt::TextWordWrap | Qt::AlignVCenter, text );
398 painter->setPen( QPen( QApplication::palette().color( QPalette::Text ) ) );
400 if ( linkPointCount( Qt::TopEdge ) )
402 h = -( fm.height() * 1.2 );
403 h = h - componentSize.height() / 2.0 + 5;
404 pt = QPointF( -componentSize.width() / 2 + 25, h );
405 painter->drawText( pt, QObject::tr(
"In" ) );
407 if ( !mComponent->linksCollapsed( Qt::TopEdge ) )
409 for (
int idx = 0; idx < linkPointCount( Qt::TopEdge ); ++idx )
411 text = linkPointText( Qt::TopEdge, idx );
412 h = -( fm.height() * 1.2 ) * ( i + 1 );
413 h = h - componentSize.height() / 2.0 + 5;
414 pt = QPointF( -componentSize.width() / 2 + 33, h );
415 painter->drawText( pt, text );
420 if ( linkPointCount( Qt::BottomEdge ) )
422 h = fm.height() * 1.1;
423 h = h + componentSize.height() / 2.0;
424 pt = QPointF( -componentSize.width() / 2 + 25, h );
425 painter->drawText( pt, QObject::tr(
"Out" ) );
426 if ( !mComponent->linksCollapsed( Qt::BottomEdge ) )
428 for (
int idx = 0; idx < linkPointCount( Qt::BottomEdge ); ++idx )
430 text = linkPointText( Qt::BottomEdge, idx );
431 h = fm.height() * 1.2 * ( idx + 2 );
432 h = h + componentSize.height() / 2.0;
433 pt = QPointF( -componentSize.width() / 2 + 33, h );
434 painter->drawText( pt, text );
439 const QPixmap px = iconPixmap();
442 painter->drawPixmap( QPointF( -( componentSize.width() / 2.0 ) + 3, -8 ), px );
446 const QPicture pic = iconPicture();
449 painter->drawPicture( QPointF( -( componentSize.width() / 2.0 ) + 3, -8 ), pic );
454QRectF QgsModelComponentGraphicItem::itemRect(
bool storedRect )
const
458 return QRectF( mComponent->position().x() - ( mComponent->size().width() ) / 2.0, mComponent->position().y() - ( mComponent->size().height() ) / 2.0, mComponent->size().width(), mComponent->size().height() );
461 return QRectF( -( itemSize().width() ) / 2.0, -( itemSize().height() ) / 2.0, itemSize().width(), itemSize().height() );
464QString QgsModelComponentGraphicItem::truncatedTextForItem(
const QString &text )
const
466 const QFontMetricsF fm( mFont );
467 double width = fm.boundingRect( text ).width();
468 if ( width < itemSize().width() - 25 - mButtonSize.width() )
472 t = t.left( t.length() - 3 ) + QChar( 0x2026 );
473 width = fm.boundingRect( t ).width();
474 while ( width > itemSize().width() - 25 - mButtonSize.width() )
476 if ( t.length() < 5 )
479 t = t.left( t.length() - 4 ) + QChar( 0x2026 );
480 width = fm.boundingRect( t ).width();
485Qt::PenStyle QgsModelComponentGraphicItem::strokeStyle( QgsModelComponentGraphicItem::State )
const
487 return Qt::SolidLine;
490Qt::Alignment QgsModelComponentGraphicItem::titleAlignment()
const
492 return Qt::AlignLeft;
495QPicture QgsModelComponentGraphicItem::iconPicture()
const
500QPixmap QgsModelComponentGraphicItem::iconPixmap()
const
506void QgsModelComponentGraphicItem::updateButtonPositions()
508 mEditButton->setPosition( QPointF( itemSize().width() / 2.0 - mButtonSize.width() / 2.0 - BUTTON_MARGIN, itemSize().height() / 2.0 - mButtonSize.height() / 2.0 - BUTTON_MARGIN ) );
509 mDeleteButton->setPosition( QPointF( itemSize().width() / 2.0 - mButtonSize.width() / 2.0 - BUTTON_MARGIN, mButtonSize.height() / 2.0 - itemSize().height() / 2.0 + BUTTON_MARGIN ) );
511 if ( mExpandBottomButton )
513 const QPointF pt = linkPoint( Qt::BottomEdge, -1,
false );
514 mExpandBottomButton->setPosition( QPointF( 0, pt.y() ) );
516 bool collapsed = mComponent->linksCollapsed( Qt::BottomEdge );
517 for ( QgsModelDesignerSocketGraphicItem *socket : std::as_const( mOutSockets ) )
519 const QPointF pt = linkPoint( Qt::BottomEdge, socket->index(),
false );
520 socket->setPosition( pt );
521 socket->setVisible( !collapsed );
526 if ( mExpandTopButton )
528 const QPointF pt = linkPoint( Qt::TopEdge, -1,
true );
529 mExpandTopButton->setPosition( QPointF( 0, pt.y() ) );
531 bool collapsed = mComponent->linksCollapsed( Qt::TopEdge );
532 for ( QgsModelDesignerSocketGraphicItem *socket : std::as_const( mInSockets ) )
534 const QPointF pt = linkPoint( Qt::TopEdge, socket->index(),
true );
535 socket->setPosition( pt );
536 socket->setVisible( !collapsed );
542QSizeF QgsModelComponentGraphicItem::itemSize()
const
544 return !mTempSize.isValid() ? mComponent->size() : mTempSize;
547void QgsModelComponentGraphicItem::updateToolTip(
const QPointF &pos )
549 const bool prevHoverStatus = mIsHovering;
550 if ( itemRect().contains( pos ) )
552 setToolTip( mLabel );
557 setToolTip( QString() );
560 if ( mIsHovering != prevHoverStatus )
563 emit repaintArrows();
567void QgsModelComponentGraphicItem::fold( Qt::Edge edge,
bool folded )
569 emit aboutToChange( !folded ? tr(
"Expand Item" ) : tr(
"Collapse Item" ) );
570 mComponent->setLinksCollapsed( edge, folded );
574 if ( QgsProcessingModelChildAlgorithm *child =
dynamic_cast<QgsProcessingModelChildAlgorithm *
>( mComponent.get() ) )
576 mModel->childAlgorithm( child->childId() ).setLinksCollapsed( edge, folded );
578 else if ( QgsProcessingModelParameter *param =
dynamic_cast<QgsProcessingModelParameter *
>( mComponent.get() ) )
580 mModel->parameterComponent( param->parameterName() ).setLinksCollapsed( edge, folded );
582 else if ( QgsProcessingModelOutput *output =
dynamic_cast<QgsProcessingModelOutput *
>( mComponent.get() ) )
584 mModel->childAlgorithm( output->childId() ).modelOutput( output->name() ).setLinksCollapsed( edge, folded );
587 updateButtonPositions();
588 prepareGeometryChange();
589 emit updateArrowPaths();
594QString QgsModelComponentGraphicItem::label()
const
599void QgsModelComponentGraphicItem::setLabel(
const QString &label )
605QgsModelComponentGraphicItem::State QgsModelComponentGraphicItem::state()
const
609 else if ( mIsHovering )
615int QgsModelComponentGraphicItem::linkPointCount( Qt::Edge )
const
620QString QgsModelComponentGraphicItem::linkPointText( Qt::Edge,
int )
const
625QPointF QgsModelComponentGraphicItem::linkPoint( Qt::Edge edge,
int index,
bool incoming )
const
631 if ( linkPointCount( Qt::BottomEdge ) )
634 if ( mComponent->linksCollapsed( Qt::BottomEdge ) )
638 const int pointIndex = !mComponent->linksCollapsed( Qt::BottomEdge ) ? index : -1;
639 const QString text = truncatedTextForItem( linkPointText( Qt::BottomEdge, index ) );
640 const QFontMetricsF fm( mFont );
641 const double w = fm.boundingRect( text ).width();
642 const double h = fm.height() * 1.2 * ( pointIndex + 1 ) + fm.height() / 2.0;
643 const double y = h + itemSize().height() / 2.0 + 6.4;
644 const double x = !mComponent->linksCollapsed( Qt::BottomEdge ) ? ( -itemSize().width() / 2 + 33 + w + 10 ) : 10.4;
645 return QPointF( incoming ? -itemSize().width() / 2 + offsetX : x, y );
652 if ( linkPointCount( Qt::TopEdge ) )
655 int paramIndex = index;
656 if ( mComponent->linksCollapsed( Qt::TopEdge ) )
661 const QFontMetricsF fm( mFont );
662 const QString text = truncatedTextForItem( linkPointText( Qt::TopEdge, index ) );
663 const double w = fm.boundingRect( text ).width();
664 double h = -( fm.height() * 1.2 ) * ( paramIndex + 2 ) - fm.height() / 2.0 + 8;
665 h = h - itemSize().height() / 2.0;
666 return QPointF( incoming ? -itemSize().width() / 2 + offsetX : ( !mComponent->linksCollapsed( Qt::TopEdge ) ? ( -itemSize().width() / 2 + 33 + w + 5 ) : 10 ), h );
678QPointF QgsModelComponentGraphicItem::calculateAutomaticLinkPoint( QgsModelComponentGraphicItem *other, Qt::Edge &edge )
const
681 const QgsRectangle otherRect( other->itemRect().translated( other->pos() ) );
683 const QPointF leftPoint = pos() + QPointF( -itemSize().width() / 2.0, 0 );
684 const double distLeft = otherRect.distance(
QgsPointXY( leftPoint ) );
686 const QPointF rightPoint = pos() + QPointF( itemSize().width() / 2.0, 0 );
687 const double distRight = otherRect.distance(
QgsPointXY( rightPoint ) );
689 const QPointF topPoint = pos() + QPointF( 0, -itemSize().height() / 2.0 );
690 const double distTop = otherRect.distance(
QgsPointXY( topPoint ) );
692 const QPointF bottomPoint = pos() + QPointF( 0, itemSize().height() / 2.0 );
693 const double distBottom = otherRect.distance(
QgsPointXY( bottomPoint ) );
695 if ( distLeft <= distRight && distLeft <= distTop && distLeft <= distBottom )
700 else if ( distRight <= distTop && distRight <= distBottom )
702 edge = Qt::RightEdge;
705 else if ( distBottom <= distTop )
707 edge = Qt::BottomEdge;
717QPointF QgsModelComponentGraphicItem::calculateAutomaticLinkPoint(
const QPointF &point, Qt::Edge &edge )
const
721 const QPointF leftPoint = pos() + QPointF( -itemSize().width() / 2.0, 0 );
722 const double distLeft = otherPt.distance(
QgsPointXY( leftPoint ) );
724 const QPointF rightPoint = pos() + QPointF( itemSize().width() / 2.0, 0 );
725 const double distRight = otherPt.distance(
QgsPointXY( rightPoint ) );
727 const QPointF topPoint = pos() + QPointF( 0, -itemSize().height() / 2.0 );
728 const double distTop = otherPt.distance(
QgsPointXY( topPoint ) );
730 const QPointF bottomPoint = pos() + QPointF( 0, itemSize().height() / 2.0 );
731 const double distBottom = otherPt.distance(
QgsPointXY( bottomPoint ) );
733 if ( distLeft <= distRight && distLeft <= distTop && distLeft <= distBottom )
738 else if ( distRight <= distTop && distRight <= distBottom )
740 edge = Qt::RightEdge;
743 else if ( distBottom <= distTop )
745 edge = Qt::BottomEdge;
755QgsModelDesignerSocketGraphicItem *QgsModelComponentGraphicItem::outSocketAt(
int index )
const
757 if ( index < 0 || index >= mOutSockets.size() )
761 return mOutSockets.at( index );
764QgsModelParameterGraphicItem::QgsModelParameterGraphicItem( QgsProcessingModelParameter *parameter, QgsProcessingModelAlgorithm *model, QGraphicsItem *parent )
765 : QgsModelComponentGraphicItem( parameter, model, parent )
768 QPainter painter( &mPicture );
769 svg.render( &painter );
773 setLabel( parameterDefinition->description() );
775 setLabel( QObject::tr(
"Error (%1)" ).arg( parameter->parameterName() ) );
778void QgsModelParameterGraphicItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
780 QMenu *popupmenu =
new QMenu( event->widget() );
781 QAction *removeAction = popupmenu->addAction( QObject::tr(
"Remove" ) );
782 connect( removeAction, &QAction::triggered,
this, &QgsModelParameterGraphicItem::deleteComponent );
783 QAction *editAction = popupmenu->addAction( QObject::tr(
"Edit…" ) );
784 connect( editAction, &QAction::triggered,
this, &QgsModelParameterGraphicItem::editComponent );
785 QAction *editCommentAction = popupmenu->addAction( component()->comment()->description().isEmpty() ? QObject::tr(
"Add Comment…" ) : QObject::tr(
"Edit Comment…" ) );
786 connect( editCommentAction, &QAction::triggered,
this, &QgsModelParameterGraphicItem::editComment );
788 popupmenu->exec( event->screenPos() );
791QColor QgsModelParameterGraphicItem::fillColor( QgsModelComponentGraphicItem::State state )
const
793 QColor
c( 238, 242, 131 );
809QColor QgsModelParameterGraphicItem::strokeColor( QgsModelComponentGraphicItem::State state )
const
814 return QColor( 116, 113, 68 );
817 return QColor( 234, 226, 118 );
822QColor QgsModelParameterGraphicItem::textColor( QgsModelComponentGraphicItem::State )
const
827QPicture QgsModelParameterGraphicItem::iconPicture()
const
832int QgsModelParameterGraphicItem::linkPointCount( Qt::Edge edge )
const
847QString QgsModelParameterGraphicItem::linkPointText( Qt::Edge,
int index )
const
854 if (
const QgsProcessingModelParameter *parameter =
dynamic_cast< const QgsProcessingModelParameter *
>( component() ) )
856 QString text = this->model()->parameterDefinition( parameter->parameterName() )->type();
861 const QVariant paramValue = paramDef->defaultValue();
863 if ( paramValue.isValid() )
865 text +=
": " + paramDef->userFriendlyString( paramValue );
868 return truncatedTextForItem( text );
874QColor QgsModelParameterGraphicItem::linkColor( Qt::Edge ,
int index )
const
878 return FALLBACK_COLOR;
881 if (
const QgsProcessingModelParameter *parameter =
dynamic_cast< const QgsProcessingModelParameter *
>( component() ) )
885 return parameterDefinition->modelColor();
889 return FALLBACK_COLOR;
892void QgsModelParameterGraphicItem::updateStoredComponentPosition(
const QPointF &pos,
const QSizeF &size )
894 if ( QgsProcessingModelParameter *param =
dynamic_cast<QgsProcessingModelParameter *
>( component() ) )
896 model()->parameterComponent( param->parameterName() ).setPosition( pos );
897 model()->parameterComponent( param->parameterName() ).setSize( size );
901bool QgsModelParameterGraphicItem::canDeleteComponent()
903 if (
const QgsProcessingModelParameter *param =
dynamic_cast<const QgsProcessingModelParameter *
>( component() ) )
905 if ( model()->childAlgorithmsDependOnParameter( param->parameterName() ) )
909 else if ( model()->otherParametersDependOnParameter( param->parameterName() ) )
921void QgsModelParameterGraphicItem::deleteComponent()
923 if (
const QgsProcessingModelParameter *param =
dynamic_cast<const QgsProcessingModelParameter *
>( component() ) )
925 if ( model()->childAlgorithmsDependOnParameter( param->parameterName() ) )
927 QMessageBox::warning(
929 QObject::tr(
"Could not remove input" ),
931 "Algorithms depend on the selected input.\n"
932 "Remove them before trying to remove it."
936 else if ( model()->otherParametersDependOnParameter( param->parameterName() ) )
938 QMessageBox::warning(
940 QObject::tr(
"Could not remove input" ),
942 "Other inputs depend on the selected input.\n"
943 "Remove them before trying to remove it."
949 emit aboutToChange( tr(
"Delete Input %1" ).arg( param->description() ) );
950 model()->removeModelParameter( param->parameterName() );
952 emit requestModelRepaint();
958QgsModelChildAlgorithmGraphicItem::QgsModelChildAlgorithmGraphicItem( QgsProcessingModelChildAlgorithm *child, QgsProcessingModelAlgorithm *model, QGraphicsItem *parent )
959 : QgsModelComponentGraphicItem( child, model, parent )
961 if ( child->algorithm() && !child->algorithm()->svgIconPath().isEmpty() )
963 QSvgRenderer svg( child->algorithm()->svgIconPath() );
964 const QSizeF size = svg.defaultSize();
965 QPainter painter( &mPicture );
966 painter.scale( 16.0 / size.width(), 16.0 / size.width() );
967 svg.render( &painter );
970 else if ( child->algorithm() )
972 mPixmap = child->algorithm()->icon().pixmap( 15, 15 );
975 setLabel( child->description() );
978 mIsValid = model->validateChildAlgorithm( child->childId(), issues );
981void QgsModelChildAlgorithmGraphicItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
983 QMenu *popupmenu =
new QMenu( event->widget() );
987 QAction *runSelectedStepsAction = popupmenu->addAction( QObject::tr(
"Run Selected Steps…" ) );
989 connect( runSelectedStepsAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::runSelected );
992 QAction *runFromHereAction = popupmenu->addAction( QObject::tr(
"Run from Here…" ) );
994 connect( runFromHereAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::runFromHere );
996 popupmenu->addSeparator();
998 QAction *removeAction = popupmenu->addAction( QObject::tr(
"Remove" ) );
999 connect( removeAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::deleteComponent );
1000 QAction *editAction = popupmenu->addAction( QObject::tr(
"Edit…" ) );
1001 connect( editAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::editComponent );
1002 QAction *editCommentAction = popupmenu->addAction( component()->comment()->description().isEmpty() ? QObject::tr(
"Add Comment…" ) : QObject::tr(
"Edit Comment…" ) );
1003 connect( editCommentAction, &QAction::triggered,
this, &QgsModelParameterGraphicItem::editComment );
1004 popupmenu->addSeparator();
1006 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1008 if ( !child->isActive() )
1010 QAction *activateAction = popupmenu->addAction( QObject::tr(
"Activate" ) );
1011 connect( activateAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::activateAlgorithm );
1015 QAction *deactivateAction = popupmenu->addAction( QObject::tr(
"Deactivate" ) );
1016 connect( deactivateAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::deactivateAlgorithm );
1022 const QList<const QgsProcessingParameterDefinition *> outputParams =
algorithm->destinationParameterDefinitions();
1023 if ( !outputParams.isEmpty() )
1025 popupmenu->addSeparator();
1026 QAction *viewOutputLayersAction = popupmenu->addAction( QObject::tr(
"View Output Layers" ) );
1028 connect( viewOutputLayersAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::showPreviousResults );
1030 switch ( mResults.executionStatus() )
1034 viewOutputLayersAction->setEnabled(
false );
1043 QAction *viewLogAction = popupmenu->addAction( QObject::tr(
"View Log…" ) );
1044 connect( viewLogAction, &QAction::triggered,
this, &QgsModelChildAlgorithmGraphicItem::showLog );
1046 switch ( mResults.executionStatus() )
1049 viewLogAction->setEnabled(
false );
1058 popupmenu->exec( event->screenPos() );
1061QColor QgsModelChildAlgorithmGraphicItem::fillColor( QgsModelComponentGraphicItem::State state )
const
1066 c = QColor( 255, 255, 255 );
1068 c = QColor( 208, 0, 0 );
1073 c =
c.darker( 110 );
1076 c =
c.darker( 105 );
1085QColor QgsModelChildAlgorithmGraphicItem::strokeColor( QgsModelComponentGraphicItem::State state )
const
1090 return mIsValid ? QColor( 50, 50, 50 ) : QColor( 80, 0, 0 );
1093 return mIsValid ? Qt::gray : QColor( 134, 0, 0 );
1098QColor QgsModelChildAlgorithmGraphicItem::textColor( QgsModelComponentGraphicItem::State )
const
1100 return mIsValid ? ( qgis::down_cast<const QgsProcessingModelChildAlgorithm *>( component() )->isActive() ? Qt::black : Qt::gray ) : QColor( 255, 255, 255 );
1103QPixmap QgsModelChildAlgorithmGraphicItem::iconPixmap()
const
1108QPicture QgsModelChildAlgorithmGraphicItem::iconPicture()
const
1113int QgsModelChildAlgorithmGraphicItem::linkPointCount( Qt::Edge edge )
const
1115 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1117 if ( !child->algorithm() )
1122 case Qt::BottomEdge:
1123 return child->algorithm()->outputDefinitions().size();
1128 std::remove_if( params.begin(), params.end(), [](
const QgsProcessingParameterDefinition *param ) { return param->flags() & Qgis::ProcessingParameterFlag::Hidden || param->isDestination(); } ),
1131 return params.size();
1142QColor QgsModelComponentGraphicItem::linkColor( Qt::Edge edge,
int index )
const
1144 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1146 if ( !child->algorithm() )
1148 return FALLBACK_COLOR;
1153 case Qt::BottomEdge:
1155 if ( index <= child->
algorithm()->outputDefinitions().size() - 1 )
1157 return child->algorithm()->outputDefinitions().at( index )->modelColor();
1159 return FALLBACK_COLOR;
1165 if ( index <= params.size() - 1 )
1167 return params.at( index )->modelColor();
1170 return FALLBACK_COLOR;
1179 return FALLBACK_COLOR;
1182QString QgsModelChildAlgorithmGraphicItem::linkPointText( Qt::Edge edge,
int index )
const
1187 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1189 if ( !child->algorithm() )
1194 case Qt::BottomEdge:
1196 if ( index >= child->algorithm()->outputDefinitions().length() )
1205 return truncatedTextForItem( title );
1212 std::remove_if( params.begin(), params.end(), [](
const QgsProcessingParameterDefinition *param ) { return param->flags() & Qgis::ProcessingParameterFlag::Hidden || param->isDestination(); } ),
1216 if ( index >= params.length() )
1224 QString name = param->
name();
1226 QgsProcessingModelChildParameterSources paramSources = child->parameterSources().value( name );
1227 QString parameterValueAsString;
1229 if ( !paramSources.empty() )
1231 QgsProcessingModelChildParameterSource firstParameterSource = paramSources[0];
1233 switch ( firstParameterSource.source() )
1236 parameterValueAsString = u
": %1"_s.arg( firstParameterSource.friendlyIdentifier(
const_cast<QgsProcessingModelAlgorithm *
>( model() ) ) );
1240 parameterValueAsString = u
": %1"_s.arg( firstParameterSource.expression() );
1244 parameterValueAsString = u
": %1"_s.arg( firstParameterSource.expressionText() );
1248 parameterValueAsString = u
": <%1>"_s.arg( firstParameterSource.friendlyIdentifier(
const_cast<QgsProcessingModelAlgorithm *
>( model() ) ) );
1253 const QString friendlyName = firstParameterSource.friendlyIdentifier(
const_cast<QgsProcessingModelAlgorithm *
>( model() ) );
1254 parameterValueAsString = friendlyName.isEmpty() ? u
":"_s : u
": <%1>"_s.arg( friendlyName );
1259 const QVariant paramValue = paramSources[0].staticValue();
1262 title += parameterValueAsString;
1265 return truncatedTextForItem( title );
1276void QgsModelChildAlgorithmGraphicItem::updateStoredComponentPosition(
const QPointF &pos,
const QSizeF &size )
1278 if ( QgsProcessingModelChildAlgorithm *child =
dynamic_cast<QgsProcessingModelChildAlgorithm *
>( component() ) )
1280 model()->childAlgorithm( child->childId() ).setPosition( pos );
1281 model()->childAlgorithm( child->childId() ).setSize( size );
1285bool QgsModelChildAlgorithmGraphicItem::canDeleteComponent()
1287 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1289 return model()->dependentChildAlgorithms( child->childId() ).empty();
1296 if ( mResults == results )
1301 emit updateArrowPaths();
1304void QgsModelChildAlgorithmGraphicItem::deleteComponent()
1306 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1308 emit aboutToChange( tr(
"Remove %1" ).arg( child->algorithm() ? child->algorithm()->displayName() : tr(
"Algorithm" ) ) );
1309 if ( !model()->removeChildAlgorithm( child->childId() ) )
1311 QMessageBox::warning(
1313 QObject::tr(
"Could not remove algorithm" ),
1315 "Other algorithms depend on the selected one.\n"
1316 "Remove them before trying to remove it."
1323 emit requestModelRepaint();
1328void QgsModelChildAlgorithmGraphicItem::deactivateAlgorithm()
1330 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1332 model()->deactivateChildAlgorithm( child->childId() );
1333 emit requestModelRepaint();
1337void QgsModelChildAlgorithmGraphicItem::activateAlgorithm()
1339 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( component() ) )
1341 if ( model()->activateChildAlgorithm( child->childId() ) )
1343 emit requestModelRepaint();
1347 QMessageBox::warning(
1349 QObject::tr(
"Could not activate algorithm" ),
1351 "The selected algorithm depends on other currently non-active algorithms.\n"
1352 "Activate them them before trying to activate it.."
1360QgsModelOutputGraphicItem::QgsModelOutputGraphicItem( QgsProcessingModelOutput *output, QgsProcessingModelAlgorithm *model, QGraphicsItem *parent )
1361 : QgsModelComponentGraphicItem( output, model, parent )
1364 QPainter painter( &mPicture );
1365 svg.render( &painter );
1367 setLabel( output->description() );
1370QColor QgsModelOutputGraphicItem::fillColor( QgsModelComponentGraphicItem::State state )
const
1372 QColor
c( 172, 196, 114 );
1376 c =
c.darker( 110 );
1379 c =
c.darker( 105 );
1388QColor QgsModelOutputGraphicItem::strokeColor( QgsModelComponentGraphicItem::State state )
const
1393 return QColor( 42, 65, 42 );
1396 return QColor( 90, 140, 90 );
1401QColor QgsModelOutputGraphicItem::textColor( QgsModelComponentGraphicItem::State )
const
1406QPicture QgsModelOutputGraphicItem::iconPicture()
const
1411void QgsModelOutputGraphicItem::updateStoredComponentPosition(
const QPointF &pos,
const QSizeF &size )
1413 if ( QgsProcessingModelOutput *output =
dynamic_cast<QgsProcessingModelOutput *
>( component() ) )
1415 model()->childAlgorithm( output->childId() ).modelOutput( output->name() ).setPosition( pos );
1416 model()->childAlgorithm( output->childId() ).modelOutput( output->name() ).setSize( size );
1420bool QgsModelOutputGraphicItem::canDeleteComponent()
1422 if (
dynamic_cast<const QgsProcessingModelOutput *
>( component() ) )
1429void QgsModelOutputGraphicItem::deleteComponent()
1431 if (
const QgsProcessingModelOutput *output =
dynamic_cast<const QgsProcessingModelOutput *
>( component() ) )
1433 emit aboutToChange( tr(
"Delete Output %1" ).arg( output->description() ) );
1434 model()->childAlgorithm( output->childId() ).removeModelOutput( output->name() );
1435 model()->updateDestinationParameters();
1437 emit requestModelRepaint();
1446QgsModelGroupBoxGraphicItem::QgsModelGroupBoxGraphicItem( QgsProcessingModelGroupBox *box, QgsProcessingModelAlgorithm *model, QGraphicsItem *parent )
1447 : QgsModelComponentGraphicItem( box, model, parent )
1449 setZValue( QgsModelGraphicsScene::ZValues::GroupBox );
1450 setLabel( box->description() );
1454 f.setPixelSize( 14 );
1458void QgsModelGroupBoxGraphicItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
1460 QMenu *popupmenu =
new QMenu( event->widget() );
1461 QAction *removeAction = popupmenu->addAction( QObject::tr(
"Remove" ) );
1462 connect( removeAction, &QAction::triggered,
this, &QgsModelGroupBoxGraphicItem::deleteComponent );
1463 QAction *editAction = popupmenu->addAction( QObject::tr(
"Edit…" ) );
1464 connect( editAction, &QAction::triggered,
this, &QgsModelGroupBoxGraphicItem::editComponent );
1465 popupmenu->exec( event->screenPos() );
1468QgsModelGroupBoxGraphicItem::~QgsModelGroupBoxGraphicItem() =
default;
1470QColor QgsModelGroupBoxGraphicItem::fillColor( QgsModelComponentGraphicItem::State state )
const
1472 QColor
c( 230, 230, 230 );
1476 c =
c.darker( 110 );
1479 c =
c.darker( 105 );
1488QColor QgsModelGroupBoxGraphicItem::strokeColor( QgsModelComponentGraphicItem::State state )
const
1493 return QColor( 50, 50, 50 );
1496 return QColor( 150, 150, 150 );
1501QColor QgsModelGroupBoxGraphicItem::textColor( QgsModelComponentGraphicItem::State )
const
1503 return QColor( 100, 100, 100 );
1506Qt::PenStyle QgsModelGroupBoxGraphicItem::strokeStyle( QgsModelComponentGraphicItem::State )
const
1511Qt::Alignment QgsModelGroupBoxGraphicItem::titleAlignment()
const
1513 return Qt::AlignHCenter;
1516void QgsModelGroupBoxGraphicItem::updateStoredComponentPosition(
const QPointF &pos,
const QSizeF &size )
1518 if ( QgsProcessingModelGroupBox *box =
dynamic_cast<QgsProcessingModelGroupBox *
>( component() ) )
1520 box->setPosition( pos );
1521 box->setSize( size );
1522 model()->addGroupBox( *box );
1526bool QgsModelGroupBoxGraphicItem::canDeleteComponent()
1528 if (
dynamic_cast<QgsProcessingModelGroupBox *
>( component() ) )
1535void QgsModelGroupBoxGraphicItem::applyEdit(
const QgsProcessingModelGroupBox &groupBox )
1537 const QString commandId = u
"groupbox:%1"_s.arg( groupBox.uuid() );
1538 emit aboutToChange( tr(
"Edit Group Box" ), commandId );
1539 model()->addGroupBox( groupBox );
1541 emit requestModelRepaint();
1544void QgsModelGroupBoxGraphicItem::deleteComponent()
1546 if (
const QgsProcessingModelGroupBox *box =
dynamic_cast<const QgsProcessingModelGroupBox *
>( component() ) )
1548 emit aboutToChange( tr(
"Delete Group Box" ) );
1549 model()->removeGroupBox( box->uuid() );
1551 emit requestModelRepaint();
1555void QgsModelGroupBoxGraphicItem::editComponent()
1557 if (
const QgsProcessingModelGroupBox *box =
dynamic_cast<const QgsProcessingModelGroupBox *
>( component() ) )
1563 applyEdit( dlg.groupBox() );
1572QgsModelCommentGraphicItem::QgsModelCommentGraphicItem( QgsProcessingModelComment *comment, QgsModelComponentGraphicItem *parentItem, QgsProcessingModelAlgorithm *model, QGraphicsItem *parent )
1573 : QgsModelComponentGraphicItem( comment, model, parent )
1574 , mParentComponent( parentItem->component()->clone() )
1575 , mParentItem( parentItem )
1577 setLabel( comment->description() );
1580 f.setPixelSize( 9 );
1584void QgsModelCommentGraphicItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
1586 QMenu *popupmenu =
new QMenu( event->widget() );
1587 QAction *removeAction = popupmenu->addAction( QObject::tr(
"Remove" ) );
1588 connect( removeAction, &QAction::triggered,
this, &QgsModelCommentGraphicItem::deleteComponent );
1589 QAction *editAction = popupmenu->addAction( QObject::tr(
"Edit…" ) );
1590 connect( editAction, &QAction::triggered,
this, &QgsModelCommentGraphicItem::editComponent );
1591 popupmenu->exec( event->screenPos() );
1594QgsModelCommentGraphicItem::~QgsModelCommentGraphicItem() =
default;
1596QColor QgsModelCommentGraphicItem::fillColor( QgsModelComponentGraphicItem::State state )
const
1598 QColor
c( 230, 230, 230 );
1602 c =
c.darker( 110 );
1605 c =
c.darker( 105 );
1614QColor QgsModelCommentGraphicItem::strokeColor( QgsModelComponentGraphicItem::State state )
const
1619 return QColor( 50, 50, 50 );
1622 return QColor( 150, 150, 150 );
1627QColor QgsModelCommentGraphicItem::textColor( QgsModelComponentGraphicItem::State )
const
1629 return QColor( 100, 100, 100 );
1632Qt::PenStyle QgsModelCommentGraphicItem::strokeStyle( QgsModelComponentGraphicItem::State )
const
1637void QgsModelCommentGraphicItem::updateStoredComponentPosition(
const QPointF &pos,
const QSizeF &size )
1639 if ( QgsProcessingModelComment *comment = modelComponent() )
1641 comment->setPosition( pos );
1642 comment->setSize( size );
1646bool QgsModelCommentGraphicItem::canDeleteComponent()
1648 if ( modelComponent() )
1655void QgsModelCommentGraphicItem::deleteComponent()
1657 if ( QgsProcessingModelComment *comment = modelComponent() )
1659 emit aboutToChange( tr(
"Delete Comment" ) );
1660 comment->setDescription( QString() );
1662 emit requestModelRepaint();
1666void QgsModelCommentGraphicItem::editComponent()
1670 mParentItem->editComment();
1674QgsProcessingModelComment *QgsModelCommentGraphicItem::modelComponent()
1676 if (
const QgsProcessingModelChildAlgorithm *child =
dynamic_cast<const QgsProcessingModelChildAlgorithm *
>( mParentComponent.get() ) )
1678 return model()->childAlgorithm( child->childId() ).comment();
1680 else if (
const QgsProcessingModelParameter *param =
dynamic_cast<const QgsProcessingModelParameter *
>( mParentComponent.get() ) )
1682 return model()->parameterComponent( param->parameterName() ).comment();
1684 else if (
const QgsProcessingModelOutput *output =
dynamic_cast<const QgsProcessingModelOutput *
>( mParentComponent.get() ) )
1686 return model()->childAlgorithm( output->childId() ).modelOutput( output->name() ).comment();
1691QgsModelComponentGraphicItem *QgsModelCommentGraphicItem::parentComponentItem()
const
@ Success
Child was successfully executed.
@ NotExecuted
Child has not been executed.
@ Failed
Child encountered an error while executing.
@ Warning
Warning message.
@ ExpressionText
Parameter value is taken from a text with expressions, evaluated just before the algorithm runs.
@ ModelOutput
Parameter value is linked to an output parameter for the model.
@ ChildOutput
Parameter value is taken from an output generated by a child algorithm.
@ ModelParameter
Parameter value is taken from a parent model parameter.
@ StaticValue
Parameter value is a static value.
@ Expression
Parameter value is taken from an expression, evaluated just before the algorithm runs.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
A dialog which allows users to specify the properties of a model group box.
A mouse event which is the result of a user interaction with a QgsModelGraphicsView.
QPointF modelPoint() const
Returns the event point location in model coordinates.
Abstract base class for processing algorithms.
Encapsulates the results of running a child algorithm within a model.
Base class for the definition of processing outputs.
QString description() const
Returns the description for the output.
Base class for the definition of processing parameters.
virtual QString userFriendlyString(const QVariant &value) const
Returns a user-friendly string representation of the provided parameter value.
QString description() const
Returns the description for the parameter.
QString name() const
Returns the name of the parameter.
A rectangle specified with double values.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions
List of processing parameters.