Skip to content
Permalink
Browse files

Port model arrow item to c++

  • Loading branch information
nyalldawson committed Mar 3, 2020
1 parent b624d3d commit d34c01350fa0cae533eb18c8f97be20d118419fc
@@ -0,0 +1,90 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelarrowitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsModelArrowItem : QObject, QGraphicsPathItem
{
%Docstring
A link arrow item for use in the model designer.

.. warning::

Not stable API

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgsmodelarrowitem.h"
%End
public:

QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Qt::Edge startEdge, int startIndex,
QgsModelComponentGraphicItem *endItem, Qt::Edge endEdge, int endIndex );
%Docstring
Constructor for QgsModelArrowItem, with the specified ``parent`` item.

The arrow will link ``startItem`` to ``endItem``, joining the specified ``startEdge`` and ``startIndex``
to ``endEdge`` and ``endIndex``.
%End

QgsModelArrowItem( QgsModelComponentGraphicItem *startItem, Qt::Edge startEdge, int startIndex,
QgsModelComponentGraphicItem *endItem );
%Docstring
Constructor for QgsModelArrowItem, with the specified ``parent`` item.

The arrow will link ``startItem`` to ``endItem``, joining the specified ``startEdge`` and ``startIndex``
to an automatic point on ``endItem``.
%End

QgsModelArrowItem( QgsModelComponentGraphicItem *startItem,
QgsModelComponentGraphicItem *endItem, Qt::Edge endEdge, int endIndex );
%Docstring
Constructor for QgsModelArrowItem, with the specified ``parent`` item.

The arrow will link ``startItem`` to ``endItem``, joining an automatic point on ``startItem`` to the specified
``endEdge`` and ``endIndex``.
%End

QgsModelArrowItem( QgsModelComponentGraphicItem *startItem,
QgsModelComponentGraphicItem *endItem );
%Docstring
Constructor for QgsModelArrowItem, with the specified ``parent`` item.

The arrow will link ``startItem`` to ``endItem``, joining an automatic points on both items.
%End

virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );


void setPenStyle( Qt::PenStyle style );
%Docstring
Sets the pen ``style`` to use for rendering the arrow line.
%End

public slots:

void updatePath();
%Docstring
Updates the cached path linking the two items.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelarrowitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -309,6 +309,7 @@
%Include auto_generated/processing/qgsprocessingtoolboxmodel.sip
%Include auto_generated/processing/qgsprocessingtoolboxtreeview.sip
%Include auto_generated/processing/qgsprocessingwidgetwrapper.sip
%Include auto_generated/processing/models/qgsmodelarrowitem.sip
%Include auto_generated/processing/models/qgsmodelcomponentgraphicitem.sip
%Include auto_generated/processing/models/qgsmodelgraphicitem.sip
%Include auto_generated/processing/models/qgsmodelgraphicsscene.sip

This file was deleted.

@@ -23,7 +23,7 @@

import os

from qgis.PyQt.QtCore import Qt, QPointF, QRectF
from qgis.PyQt.QtCore import Qt, QPointF
from qgis.PyQt.QtGui import QFontMetricsF, QPen, QBrush, QColor, QPicture, QPainter, QPalette
from qgis.PyQt.QtWidgets import QApplication, QMessageBox, QMenu
from qgis.PyQt.QtSvg import QSvgRenderer
@@ -27,15 +27,14 @@
QgsProcessingModelChildParameterSource,
QgsExpression)
from qgis.gui import (
QgsModelGraphicsScene
QgsModelGraphicsScene,
QgsModelArrowItem
)
from processing.modeler.ModelerGraphicItem import (
ModelerGraphicItem,
ModelerInputGraphicItem,
ModelerOutputGraphicItem,
ModelerChildAlgorithmGraphicItem
)
from processing.modeler.ModelerArrowItem import ModelerArrowItem
from processing.tools.dataobjects import createContext


@@ -128,15 +127,8 @@ def paintModel(self, model):
if input_name in self.paramItems and parent_name in self.paramItems:
input_item = self.paramItems[input_name]
parent_item = self.paramItems[parent_name]
arrow = ModelerArrowItem(parent_item, None, None, input_item, None, None)

input_item.repaintArrows.connect(arrow.update)
input_item.updateArrowPaths.connect(arrow.updatePath)
parent_item.repaintArrows.connect(arrow.update)
parent_item.updateArrowPaths.connect(arrow.updatePath)

arrow = QgsModelArrowItem(parent_item, input_item)
arrow.setPenStyle(Qt.DotLine)
arrow.updatePath()
self.addItem(arrow)

# We add the algs
@@ -162,27 +154,14 @@ def paintModel(self, model):
for source in sources:
sourceItems = self.getItemsFromParamValue(source, alg.childId(), context)
for sourceItem, sourceEdge, sourceIdx in sourceItems:
arrow = ModelerArrowItem(sourceItem, sourceEdge, sourceIdx, self.algItems[alg.childId()], Qt.TopEdge, idx)

sourceItem.repaintArrows.connect(arrow.update)
sourceItem.updateArrowPaths.connect(arrow.updatePath)

self.algItems[alg.childId()].repaintArrows.connect(arrow.update)
self.algItems[alg.childId()].updateArrowPaths.connect(arrow.updatePath)

arrow.updatePath()
if sourceEdge is None:
arrow = QgsModelArrowItem(sourceItem, self.algItems[alg.childId()], Qt.TopEdge, idx)
else:
arrow = QgsModelArrowItem(sourceItem, sourceEdge, sourceIdx, self.algItems[alg.childId()], Qt.TopEdge, idx)
self.addItem(arrow)
idx += 1
for depend in alg.dependencies():
arrow = ModelerArrowItem(self.algItems[depend], None, None,
self.algItems[alg.childId()], None, None)
self.algItems[depend].repaintArrows.connect(arrow.update)
self.algItems[depend].updateArrowPaths.connect(arrow.updatePath)

self.algItems[alg.childId()].repaintArrows.connect(arrow.update)
self.algItems[alg.childId()].updateArrowPaths.connect(arrow.updatePath)

arrow.updatePath()
arrow = QgsModelArrowItem(self.algItems[depend], self.algItems[alg.childId()])
self.addItem(arrow)

# And finally the outputs
@@ -212,15 +191,8 @@ def paintModel(self, model):
+ self.algItems[alg.childId()].linkPoint(Qt.BottomEdge, idx))
item.setPos(pos)
outputItems[key] = item
arrow = ModelerArrowItem(self.algItems[alg.childId()], Qt.BottomEdge, idx, item, None, None)

self.algItems[alg.childId()].repaintArrows.connect(arrow.update)
self.algItems[alg.childId()].updateArrowPaths.connect(arrow.updatePath)

item.repaintArrows.connect(arrow.update)
item.updateArrowPaths.connect(arrow.updatePath)

arrow.updatePath()
arrow = QgsModelArrowItem(self.algItems[alg.childId()], Qt.BottomEdge, idx, item)
self.addItem(arrow)
else:
outputItems[key] = None
@@ -252,6 +252,7 @@ SET(QGIS_GUI_SRCS
processing/qgsprocessingwidgetwrapper.cpp
processing/qgsprocessingwidgetwrapperimpl.cpp

processing/models/qgsmodelarrowitem.cpp
processing/models/qgsmodelcomponentgraphicitem.cpp
processing/models/qgsmodelgraphicitem.cpp
processing/models/qgsmodelgraphicsscene.cpp
@@ -882,6 +883,7 @@ SET(QGIS_GUI_HDRS
processing/qgsprocessingwidgetwrapper.h
processing/qgsprocessingwidgetwrapperimpl.h

processing/models/qgsmodelarrowitem.h
processing/models/qgsmodelcomponentgraphicitem.h
processing/models/qgsmodelgraphicitem.h
processing/models/qgsmodelgraphicsscene.h

0 comments on commit d34c013

Please sign in to comment.
You can’t perform that action at this time.