QGIS API Documentation 3.43.0-Master (a6cade80589)
qgsmodelgraphicsscene.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelgraphicsscene.cpp
3 ----------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgsmodelgraphicsscene.cpp"
21#include "qgsmodelarrowitem.h"
23#include "qgsmessagebar.h"
24#include "qgsmessagebaritem.h"
25#include "qgsmessageviewer.h"
26#include "qgsmessagelog.h"
27#include <QGraphicsSceneMouseEvent>
28#include <QPushButton>
29
31
32QgsModelGraphicsScene::QgsModelGraphicsScene( QObject *parent )
33 : QGraphicsScene( parent )
34{
35 setItemIndexMethod( QGraphicsScene::NoIndex );
36}
37
38QgsProcessingModelAlgorithm *QgsModelGraphicsScene::model()
39{
40 return mModel;
41}
42
43void QgsModelGraphicsScene::setModel( QgsProcessingModelAlgorithm *model )
44{
45 mModel = model;
46}
47
48void QgsModelGraphicsScene::setFlag( QgsModelGraphicsScene::Flag flag, bool on )
49{
50 if ( on )
51 mFlags |= flag;
52 else
53 mFlags &= ~flag;
54}
55
56void QgsModelGraphicsScene::mousePressEvent( QGraphicsSceneMouseEvent *event )
57{
58 if ( event->button() != Qt::LeftButton )
59 return;
60 QGraphicsScene::mousePressEvent( event );
61}
62
63QgsModelComponentGraphicItem *QgsModelGraphicsScene::createParameterGraphicItem( QgsProcessingModelAlgorithm *model, QgsProcessingModelParameter *param ) const
64{
65 return new QgsModelParameterGraphicItem( param, model, nullptr );
66}
67
68QgsModelChildAlgorithmGraphicItem *QgsModelGraphicsScene::createChildAlgGraphicItem( QgsProcessingModelAlgorithm *model, QgsProcessingModelChildAlgorithm *child ) const
69{
70 return new QgsModelChildAlgorithmGraphicItem( child, model, nullptr );
71}
72
73QgsModelComponentGraphicItem *QgsModelGraphicsScene::createOutputGraphicItem( QgsProcessingModelAlgorithm *model, QgsProcessingModelOutput *output ) const
74{
75 return new QgsModelOutputGraphicItem( output, model, nullptr );
76}
77
78QgsModelComponentGraphicItem *QgsModelGraphicsScene::createCommentGraphicItem( QgsProcessingModelAlgorithm *model, QgsProcessingModelComment *comment, QgsModelComponentGraphicItem *parentItem ) const
79{
80 return new QgsModelCommentGraphicItem( comment, parentItem, model, nullptr );
81}
82
83QgsModelComponentGraphicItem *QgsModelGraphicsScene::createGroupBoxGraphicItem( QgsProcessingModelAlgorithm *model, QgsProcessingModelGroupBox *box ) const
84{
85 return new QgsModelGroupBoxGraphicItem( box, model, nullptr );
86}
87
88void QgsModelGraphicsScene::createItems( QgsProcessingModelAlgorithm *model, QgsProcessingContext &context )
89{
90 // model group boxes
91 const QList<QgsProcessingModelGroupBox> boxes = model->groupBoxes();
92 mGroupBoxItems.clear();
93 for ( const QgsProcessingModelGroupBox &box : boxes )
94 {
95 QgsModelComponentGraphicItem *item = createGroupBoxGraphicItem( model, box.clone() );
96 addItem( item );
97 item->setPos( box.position().x(), box.position().y() );
98 mGroupBoxItems.insert( box.uuid(), item );
99 connect( item, &QgsModelComponentGraphicItem::requestModelRepaint, this, &QgsModelGraphicsScene::rebuildRequired );
100 connect( item, &QgsModelComponentGraphicItem::changed, this, &QgsModelGraphicsScene::componentChanged );
101 connect( item, &QgsModelComponentGraphicItem::aboutToChange, this, &QgsModelGraphicsScene::componentAboutToChange );
102 }
103
104 // model input parameters
105 const QMap<QString, QgsProcessingModelParameter> params = model->parameterComponents();
106 for ( auto it = params.constBegin(); it != params.constEnd(); ++it )
107 {
108 QgsModelComponentGraphicItem *item = createParameterGraphicItem( model, it.value().clone() );
109 addItem( item );
110 item->setPos( it.value().position().x(), it.value().position().y() );
111 mParameterItems.insert( it.value().parameterName(), item );
112 connect( item, &QgsModelComponentGraphicItem::requestModelRepaint, this, &QgsModelGraphicsScene::rebuildRequired );
113 connect( item, &QgsModelComponentGraphicItem::changed, this, &QgsModelGraphicsScene::componentChanged );
114 connect( item, &QgsModelComponentGraphicItem::aboutToChange, this, &QgsModelGraphicsScene::componentAboutToChange );
115
116 addCommentItemForComponent( model, it.value(), item );
117 }
118
119 // input dependency arrows
120 for ( auto it = params.constBegin(); it != params.constEnd(); ++it )
121 {
122 const QgsProcessingParameterDefinition *parameterDef = model->parameterDefinition( it.key() );
123 const QStringList parameterLinks = parameterDef->dependsOnOtherParameters();
124 for ( const QString &otherName : parameterLinks )
125 {
126 if ( mParameterItems.contains( it.key() ) && mParameterItems.contains( otherName ) )
127 {
128 auto arrow = std::make_unique<QgsModelArrowItem>( mParameterItems.value( otherName ), QgsModelArrowItem::Marker::Circle, mParameterItems.value( it.key() ), QgsModelArrowItem::Marker::ArrowHead );
129 arrow->setPenStyle( Qt::DotLine );
130 addItem( arrow.release() );
131 }
132 }
133 }
134
135 // child algorithms
136 const QMap<QString, QgsProcessingModelChildAlgorithm> childAlgs = model->childAlgorithms();
137 for ( auto it = childAlgs.constBegin(); it != childAlgs.constEnd(); ++it )
138 {
139 QgsModelChildAlgorithmGraphicItem *item = createChildAlgGraphicItem( model, it.value().clone() );
140 addItem( item );
141 item->setPos( it.value().position().x(), it.value().position().y() );
142
143 const QString childId = it.value().childId();
144 item->setResults( mLastResult.childResults().value( childId ) );
145 mChildAlgorithmItems.insert( childId, item );
146 connect( item, &QgsModelComponentGraphicItem::requestModelRepaint, this, &QgsModelGraphicsScene::rebuildRequired );
147 connect( item, &QgsModelComponentGraphicItem::changed, this, &QgsModelGraphicsScene::componentChanged );
148 connect( item, &QgsModelComponentGraphicItem::aboutToChange, this, &QgsModelGraphicsScene::componentAboutToChange );
149 connect( item, &QgsModelChildAlgorithmGraphicItem::runFromHere, this, [this, childId] {
150 emit runFromChild( childId );
151 } );
152 connect( item, &QgsModelChildAlgorithmGraphicItem::runSelected, this, &QgsModelGraphicsScene::runSelected );
153 connect( item, &QgsModelChildAlgorithmGraphicItem::showPreviousResults, this, [this, childId] {
154 emit showChildAlgorithmOutputs( childId );
155 } );
156 connect( item, &QgsModelChildAlgorithmGraphicItem::showLog, this, [this, childId] {
157 emit showChildAlgorithmLog( childId );
158 } );
159
160 addCommentItemForComponent( model, it.value(), item );
161 }
162
163 // arrows linking child algorithms
164 for ( auto it = childAlgs.constBegin(); it != childAlgs.constEnd(); ++it )
165 {
166 int topIdx = 0;
167 int bottomIdx = 0;
168 if ( !it.value().algorithm() )
169 continue;
170
171 const QgsProcessingParameterDefinitions parameters = it.value().algorithm()->parameterDefinitions();
172 for ( const QgsProcessingParameterDefinition *parameter : parameters )
173 {
174 if ( !( parameter->flags() & Qgis::ProcessingParameterFlag::Hidden ) )
175 {
176 QList<QgsProcessingModelChildParameterSource> sources;
177 if ( it.value().parameterSources().contains( parameter->name() ) )
178 sources = it.value().parameterSources()[parameter->name()];
179 for ( const QgsProcessingModelChildParameterSource &source : std::as_const( sources ) )
180 {
181 const QList<LinkSource> sourceItems = linkSourcesForParameterValue( model, QVariant::fromValue( source ), it.value().childId(), context );
182 for ( const LinkSource &link : sourceItems )
183 {
184 if ( !link.item )
185 continue;
186 QgsModelArrowItem *arrow = nullptr;
187 if ( link.linkIndex == -1 )
188 {
189 arrow = new QgsModelArrowItem( link.item, QgsModelArrowItem::Marker::NoMarker, mChildAlgorithmItems.value( it.value().childId() ), parameter->isDestination() ? Qt::BottomEdge : Qt::TopEdge, parameter->isDestination() ? bottomIdx : topIdx, QgsModelArrowItem::Marker::Circle );
190 }
191 else
192 {
193 arrow = new QgsModelArrowItem( link.item, link.edge, link.linkIndex, true, QgsModelArrowItem::Marker::NoMarker, mChildAlgorithmItems.value( it.value().childId() ), parameter->isDestination() ? Qt::BottomEdge : Qt::TopEdge, parameter->isDestination() ? bottomIdx : topIdx, true, QgsModelArrowItem::Marker::NoMarker );
194 }
195 addItem( arrow );
196 }
197 }
198 if ( parameter->isDestination() )
199 bottomIdx++;
200 else
201 topIdx++;
202 }
203 }
204 const QList<QgsProcessingModelChildDependency> dependencies = it.value().dependencies();
205 for ( const QgsProcessingModelChildDependency &depend : dependencies )
206 {
207 if ( depend.conditionalBranch.isEmpty() || !model->childAlgorithm( depend.childId ).algorithm() )
208 {
209 addItem( new QgsModelArrowItem( mChildAlgorithmItems.value( depend.childId ), QgsModelArrowItem::Marker::Circle, mChildAlgorithmItems.value( it.value().childId() ), QgsModelArrowItem::Marker::ArrowHead ) );
210 }
211 else
212 {
213 // find branch link point
214 const QgsProcessingOutputDefinitions outputs = model->childAlgorithm( depend.childId ).algorithm()->outputDefinitions();
215 int i = 0;
216 bool found = false;
217 for ( const QgsProcessingOutputDefinition *output : outputs )
218 {
219 if ( output->name() == depend.conditionalBranch )
220 {
221 found = true;
222 break;
223 }
224 i++;
225 }
226 if ( found )
227 addItem( new QgsModelArrowItem( mChildAlgorithmItems.value( depend.childId ), Qt::BottomEdge, i, QgsModelArrowItem::Marker::Circle, mChildAlgorithmItems.value( it.value().childId() ), QgsModelArrowItem::Marker::ArrowHead ) );
228 }
229 }
230 }
231
232 // and finally the model outputs
233 for ( auto it = childAlgs.constBegin(); it != childAlgs.constEnd(); ++it )
234 {
235 const QMap<QString, QgsProcessingModelOutput> outputs = it.value().modelOutputs();
236 QMap<QString, QgsModelComponentGraphicItem *> outputItems;
237
238 // offsets from algorithm item needed to correctly place output items
239 // which does not have valid position assigned (https://github.com/qgis/QGIS/issues/48132)
240 QgsProcessingModelComponent *algItem = mChildAlgorithmItems[it.value().childId()]->component();
241 const double outputOffsetX = algItem->size().width();
242 double outputOffsetY = 1.5 * algItem->size().height();
243
244 for ( auto outputIt = outputs.constBegin(); outputIt != outputs.constEnd(); ++outputIt )
245 {
246 QgsModelComponentGraphicItem *item = createOutputGraphicItem( model, outputIt.value().clone() );
247 addItem( item );
248 connect( item, &QgsModelComponentGraphicItem::requestModelRepaint, this, &QgsModelGraphicsScene::rebuildRequired );
249 connect( item, &QgsModelComponentGraphicItem::changed, this, &QgsModelGraphicsScene::componentChanged );
250 connect( item, &QgsModelComponentGraphicItem::aboutToChange, this, &QgsModelGraphicsScene::componentAboutToChange );
251
252 // if output added not at the same time as algorithm then it does not have
253 // valid position and will be placed at (0,0). We need to calculate better position.
254 // See https://github.com/qgis/QGIS/issues/48132.
255 QPointF pos = outputIt.value().position();
256 if ( pos.isNull() )
257 {
258 pos = algItem->position() + QPointF( outputOffsetX, outputOffsetY );
259 outputOffsetY += 1.5 * outputIt.value().size().height();
260 }
261 int idx = -1;
262 int i = 0;
263 // find the actual index of the linked output from the child algorithm it comes from
264 if ( it.value().algorithm() )
265 {
266 const QgsProcessingOutputDefinitions sourceChildAlgOutputs = it.value().algorithm()->outputDefinitions();
267 for ( const QgsProcessingOutputDefinition *childAlgOutput : sourceChildAlgOutputs )
268 {
269 if ( childAlgOutput->name() == outputIt.value().childOutputName() )
270 {
271 idx = i;
272 break;
273 }
274 i++;
275 }
276 }
277
278 item->setPos( pos );
279 item->component()->setPosition( pos );
280 outputItems.insert( outputIt.key(), item );
281 addItem( new QgsModelArrowItem( mChildAlgorithmItems[it.value().childId()], Qt::BottomEdge, idx, QgsModelArrowItem::Marker::Circle, item, QgsModelArrowItem::Marker::Circle ) );
282
283 addCommentItemForComponent( model, outputIt.value(), item );
284 }
285 mOutputItems.insert( it.value().childId(), outputItems );
286 }
287}
288
289QList<QgsModelComponentGraphicItem *> QgsModelGraphicsScene::selectedComponentItems()
290{
291 QList<QgsModelComponentGraphicItem *> componentItemList;
292
293 const QList<QGraphicsItem *> graphicsItemList = selectedItems();
294 for ( QGraphicsItem *item : graphicsItemList )
295 {
296 if ( QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( item ) )
297 {
298 componentItemList.push_back( componentItem );
299 }
300 }
301
302 return componentItemList;
303}
304
305QgsModelComponentGraphicItem *QgsModelGraphicsScene::componentItemAt( QPointF position ) const
306{
307 //get a list of items which intersect the specified position, in descending z order
308 const QList<QGraphicsItem *> itemList = items( position, Qt::IntersectsItemShape, Qt::DescendingOrder );
309
310 for ( QGraphicsItem *graphicsItem : itemList )
311 {
312 if ( QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( graphicsItem ) )
313 {
314 return componentItem;
315 }
316 }
317 return nullptr;
318}
319
320QgsModelComponentGraphicItem *QgsModelGraphicsScene::groupBoxItem( const QString &uuid )
321{
322 return mGroupBoxItems.value( uuid );
323}
324
325QgsModelChildAlgorithmGraphicItem *QgsModelGraphicsScene::childAlgorithmItem( const QString &childId )
326{
327 return mChildAlgorithmItems.value( childId );
328}
329
330QgsModelComponentGraphicItem *QgsModelGraphicsScene::parameterItem( const QString &name )
331{
332 return mParameterItems.value( name );
333}
334
335void QgsModelGraphicsScene::selectAll()
336{
337 //select all items in scene
338 QgsModelComponentGraphicItem *focusedItem = nullptr;
339 const QList<QGraphicsItem *> itemList = items();
340 for ( QGraphicsItem *graphicsItem : itemList )
341 {
342 if ( QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( graphicsItem ) )
343 {
344 componentItem->setSelected( true );
345 if ( !focusedItem )
346 focusedItem = componentItem;
347 }
348 }
349 emit selectedItemChanged( focusedItem );
350}
351
352void QgsModelGraphicsScene::deselectAll()
353{
354 //we can't use QGraphicsScene::clearSelection, as that emits no signals
355 //and we don't know which items are being deselected
356 //instead, do the clear selection manually...
357 const QList<QGraphicsItem *> selectedItemList = selectedItems();
358 for ( QGraphicsItem *item : selectedItemList )
359 {
360 if ( QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( item ) )
361 {
362 componentItem->setSelected( false );
363 }
364 }
365 emit selectedItemChanged( nullptr );
366}
367
368void QgsModelGraphicsScene::setSelectedItem( QgsModelComponentGraphicItem *item )
369{
370 whileBlocking( this )->deselectAll();
371 if ( item )
372 {
373 item->setSelected( true );
374 }
375 emit selectedItemChanged( item );
376}
377
378void QgsModelGraphicsScene::setLastRunResult( const QgsProcessingModelResult &result )
379{
380 mLastResult = result;
381
382 const auto childResults = mLastResult.childResults();
383 for ( auto it = childResults.constBegin(); it != childResults.constEnd(); ++it )
384 {
385 if ( QgsModelChildAlgorithmGraphicItem *item = mChildAlgorithmItems.value( it.key() ) )
386 {
387 item->setResults( it.value() );
388 }
389 }
390}
391
392QList<QgsModelGraphicsScene::LinkSource> QgsModelGraphicsScene::linkSourcesForParameterValue( QgsProcessingModelAlgorithm *model, const QVariant &value, const QString &childId, QgsProcessingContext &context ) const
393{
394 QList<QgsModelGraphicsScene::LinkSource> res;
395 if ( value.userType() == QMetaType::Type::QVariantList )
396 {
397 const QVariantList list = value.toList();
398 for ( const QVariant &v : list )
399 res.append( linkSourcesForParameterValue( model, v, childId, context ) );
400 }
401 else if ( value.userType() == QMetaType::Type::QStringList )
402 {
403 const QStringList list = value.toStringList();
404 for ( const QString &v : list )
405 res.append( linkSourcesForParameterValue( model, v, childId, context ) );
406 }
407 else if ( value.userType() == qMetaTypeId<QgsProcessingModelChildParameterSource>() )
408 {
409 const QgsProcessingModelChildParameterSource source = value.value<QgsProcessingModelChildParameterSource>();
410 switch ( source.source() )
411 {
413 {
414 LinkSource l;
415 l.item = mParameterItems.value( source.parameterName() );
416 l.edge = Qt::BottomEdge;
417 l.linkIndex = 0;
418
419 res.append( l );
420 break;
421 }
423 {
424 if ( !model->childAlgorithm( source.outputChildId() ).algorithm() )
425 break;
426
427 const QgsProcessingOutputDefinitions outputs = model->childAlgorithm( source.outputChildId() ).algorithm()->outputDefinitions();
428 int i = 0;
429 for ( const QgsProcessingOutputDefinition *output : outputs )
430 {
431 if ( output->name() == source.outputName() )
432 break;
433 i++;
434 }
435 if ( mChildAlgorithmItems.contains( source.outputChildId() ) )
436 {
437 LinkSource l;
438 l.item = mChildAlgorithmItems.value( source.outputChildId() );
439 l.edge = Qt::BottomEdge;
440
441 // do sanity check of linked index
442 if ( i >= model->childAlgorithm( source.outputChildId() ).algorithm()->outputDefinitions().length() )
443 {
444 QString short_message = tr( "Check output links for alg: %1" ).arg( model->childAlgorithm( source.outputChildId() ).algorithm()->name() );
445 QString long_message = tr( "Cannot link output for alg: %1" ).arg( model->childAlgorithm( source.outputChildId() ).algorithm()->name() );
446 QString title( tr( "Algorithm link error" ) );
447 if ( messageBar() )
448 showWarning( const_cast<QString &>( short_message ), const_cast<QString &>( title ), const_cast<QString &>( long_message ) );
449 else
450 QgsMessageLog::logMessage( long_message, "QgsModelGraphicsScene", Qgis::MessageLevel::Warning, true );
451 break;
452 }
453
454 l.linkIndex = i;
455 res.append( l );
456 }
457
458 break;
459 }
460
462 {
463 const QMap<QString, QgsProcessingModelAlgorithm::VariableDefinition> variables = model->variablesForChildAlgorithm( childId, &context );
464 const QgsExpression exp( source.expression() );
465 const QSet<QString> vars = exp.referencedVariables();
466 for ( const QString &v : vars )
467 {
468 if ( variables.contains( v ) )
469 {
470 res.append( linkSourcesForParameterValue( model, QVariant::fromValue( variables.value( v ).source ), childId, context ) );
471 }
472 }
473 break;
474 }
475
479 break;
480 }
481 }
482 return res;
483}
484
485void QgsModelGraphicsScene::addCommentItemForComponent( QgsProcessingModelAlgorithm *model, const QgsProcessingModelComponent &component, QgsModelComponentGraphicItem *parentItem )
486{
487 if ( mFlags & FlagHideComments || !component.comment() || component.comment()->description().isEmpty() )
488 return;
489
490 QgsModelComponentGraphicItem *commentItem = createCommentGraphicItem( model, component.comment()->clone(), parentItem );
491 commentItem->setPos( component.comment()->position().x(), component.comment()->position().y() );
492 addItem( commentItem );
493 connect( commentItem, &QgsModelComponentGraphicItem::requestModelRepaint, this, &QgsModelGraphicsScene::rebuildRequired );
494 connect( commentItem, &QgsModelComponentGraphicItem::changed, this, &QgsModelGraphicsScene::componentChanged );
495 connect( commentItem, &QgsModelComponentGraphicItem::aboutToChange, this, &QgsModelGraphicsScene::componentAboutToChange );
496
497 auto arrow = std::make_unique<QgsModelArrowItem>( parentItem, QgsModelArrowItem::Circle, commentItem, QgsModelArrowItem::Circle );
498 arrow->setPenStyle( Qt::DotLine );
499 addItem( arrow.release() );
500}
501
502QgsMessageBar *QgsModelGraphicsScene::messageBar() const
503{
504 return mMessageBar;
505}
506
507void QgsModelGraphicsScene::setMessageBar( QgsMessageBar *messageBar )
508{
509 mMessageBar = messageBar;
510}
511
512void QgsModelGraphicsScene::showWarning( const QString &shortMessage, const QString &title, const QString &longMessage, Qgis::MessageLevel level ) const
513{
514 QgsMessageBarItem *messageWidget = QgsMessageBar::createMessage( QString(), shortMessage );
515 QPushButton *detailsButton = new QPushButton( tr( "Details" ) );
516 connect( detailsButton, &QPushButton::clicked, detailsButton, [=] {
517 QgsMessageViewer *dialog = new QgsMessageViewer( detailsButton );
518 dialog->setTitle( title );
519 dialog->setMessage( longMessage, QgsMessageOutput::MessageHtml );
520 dialog->showMessage();
521 } );
522 messageWidget->layout()->addWidget( detailsButton );
523 mMessageBar->clearWidgets();
524 mMessageBar->pushWidget( messageWidget, level, 0 );
525}
526
527void QgsModelGraphicsScene::requestRebuildRequired()
528{
529 emit rebuildRequired();
530}
531
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:154
@ Warning
Warning message.
Definition qgis.h:156
@ 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.
@ Hidden
Parameter is hidden and should not be shown to users.
Handles parsing and evaluation of expressions (formerly called "search strings").
Represents an item shown within a QgsMessageBar widget.
A bar for displaying non-blocking messages to the user.
static QgsMessageBarItem * createMessage(const QString &text, QWidget *parent=nullptr)
Creates message bar item widget containing a message text to be displayed on the bar.
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())
Adds a message to the log instance (and creates it if necessary).
A generic message view for displaying QGIS messages.
void setTitle(const QString &title) override
Sets title for the messages.
void setMessage(const QString &message, MessageType msgType) override
Sets message, it won't be displayed until.
void showMessage(bool blocking=true) override
display the message to the user and deletes itself
QgsProcessingOutputDefinitions outputDefinitions() const
Returns an ordered list of output definitions utilized by the algorithm.
Contains information about the context in which a processing algorithm is executed.
Encapsulates the results of running a Processing model.
QMap< QString, QgsProcessingModelChildAlgorithmResult > childResults() const
Returns the map of child algorithm results.
Base class for the definition of processing outputs.
Base class for the definition of processing parameters.
virtual QStringList dependsOnOtherParameters() const
Returns a list of other parameter names on which this parameter is dependent (e.g.
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
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:6206
QList< const QgsProcessingOutputDefinition * > QgsProcessingOutputDefinitions
List of processing parameters.
QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions
List of processing parameters.