Skip to content

Commit

Permalink
Start moving base classes to c++
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 2, 2020
1 parent dfa5cb6 commit 16841ef
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 6 deletions.
@@ -0,0 +1,46 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelcomponentgraphicitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsModelComponentGraphicItem : QGraphicsObject
{
%Docstring
Base class for graphic items representing model components in the model designer.

.. warning::

Not stable API

.. versionadded:: 3.14
%End

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

QgsModelComponentGraphicItem( QgsProcessingModelComponent *component /Transfer/, QGraphicsItem *parent /TransferThis/ );
%Docstring
Constructor for QgsModelComponentGraphicItem for the specified ``component``, with the specified ``parent`` item.

Ownership of ``component`` is transferred to the item.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelcomponentgraphicitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Expand Up @@ -27,7 +27,7 @@ A flat button graphic item for use in the Processing model designer.
%End
public:

QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent, const QPicture &picture, const QPointF &position,
QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent /TransferThis/, const QPicture &picture, const QPointF &position,
const QSizeF &size = QSizeF( 16, 16 ) );
%Docstring
Constructor for QgsModelDesignerFlatButtonGraphicItem, with the specified ``parent`` item.
Expand Down Expand Up @@ -81,7 +81,7 @@ A button allowing folding or expanding component graphics in the Processing mode
%End
public:

QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent, bool folded, const QPointF &position,
QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent /TransferThis/, bool folded, const QPointF &position,
const QSizeF &size = QSizeF( 11, 11 ) );
%Docstring
Constructor for QgsModelDesignerFoldButtonGraphicItem, with the specified ``parent`` item.
Expand Down
@@ -0,0 +1,45 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelgraphicsscene.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsModelGraphicsScene : QGraphicsScene
{
%Docstring
QGraphicsScene subclass representing the model designer.

.. warning::

Not stable API

.. versionadded:: 3.14
%End

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

QgsModelGraphicsScene( QObject *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsModelGraphicsScene with the specified ``parent`` object.
%End


};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/processing/models/qgsmodelgraphicsscene.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2 changes: 2 additions & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -309,7 +309,9 @@
%Include auto_generated/processing/qgsprocessingtoolboxmodel.sip
%Include auto_generated/processing/qgsprocessingtoolboxtreeview.sip
%Include auto_generated/processing/qgsprocessingwidgetwrapper.sip
%Include auto_generated/processing/models/qgsmodelcomponentgraphicitem.sip
%Include auto_generated/processing/models/qgsmodelgraphicitem.sip
%Include auto_generated/processing/models/qgsmodelgraphicsscene.sip
%Include auto_generated/raster/qgscolorrampshaderwidget.sip
%Include auto_generated/raster/qgshillshaderendererwidget.sip
%Include auto_generated/raster/qgsmultibandcolorrendererwidget.sip
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/modeler/ModelerScene.py
Expand Up @@ -27,15 +27,16 @@
from qgis.core import (QgsProcessingParameterDefinition,
QgsProcessingModelChildParameterSource,
QgsExpression)
from qgis.gui import QgsModelGraphicsScene
from processing.modeler.ModelerGraphicItem import ModelerGraphicItem
from processing.modeler.ModelerArrowItem import ModelerArrowItem
from processing.tools.dataobjects import createContext


class ModelerScene(QGraphicsScene):
class ModelerScene(QgsModelGraphicsScene):

def __init__(self, parent=None, dialog=None):
super(ModelerScene, self).__init__(parent)
super().__init__(parent)
self.paramItems = {}
self.algItems = {}
self.outputItems = {}
Expand Down
5 changes: 5 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -252,7 +252,9 @@ SET(QGIS_GUI_SRCS
processing/qgsprocessingwidgetwrapper.cpp
processing/qgsprocessingwidgetwrapperimpl.cpp

processing/models/qgsmodelcomponentgraphicitem.cpp
processing/models/qgsmodelgraphicitem.cpp
processing/models/qgsmodelgraphicsscene.cpp

providers/gdal/qgsgdalsourceselect.cpp
providers/gdal/qgsgdalguiprovider.cpp
Expand Down Expand Up @@ -880,7 +882,9 @@ SET(QGIS_GUI_HDRS
processing/qgsprocessingwidgetwrapper.h
processing/qgsprocessingwidgetwrapperimpl.h

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

providers/gdal/qgsgdalguiprovider.h
providers/gdal/qgsgdalsourceselect.h
Expand Down Expand Up @@ -1072,6 +1076,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core/metadata
${CMAKE_SOURCE_DIR}/src/core/numericformats
${CMAKE_SOURCE_DIR}/src/core/processing
${CMAKE_SOURCE_DIR}/src/core/processing/models
${CMAKE_SOURCE_DIR}/src/core/mesh
${CMAKE_SOURCE_DIR}/src/core/pal
${CMAKE_SOURCE_DIR}/src/core/providers/memory
Expand Down
29 changes: 29 additions & 0 deletions src/gui/processing/models/qgsmodelcomponentgraphicitem.cpp
@@ -0,0 +1,29 @@
/***************************************************************************
qgsmodelcomponentgraphicitem.cpp
----------------------------------
Date : March 2020
Copyright : (C) 2020 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsmodelcomponentgraphicitem.h"

///@cond NOT_STABLE


///@endcond


QgsModelComponentGraphicItem::QgsModelComponentGraphicItem( QgsProcessingModelComponent *component, QGraphicsItem *parent )
: QGraphicsObject( parent )
, mComponent( component )
{

}
55 changes: 55 additions & 0 deletions src/gui/processing/models/qgsmodelcomponentgraphicitem.h
@@ -0,0 +1,55 @@
/***************************************************************************
qgsmodelcomponentgraphicitem.h
----------------------------------
Date : March 2020
Copyright : (C) 2020 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSMODELCOMPONENTGRAPHICITEM_H
#define QGSMODELCOMPONENTGRAPHICITEM_H

#include "qgis.h"
#include "qgis_gui.h"
#include "qgsprocessingmodelcomponent.h"
#include <QGraphicsObject>


///@cond NOT_STABLE

/**
* \ingroup gui
* \brief Base class for graphic items representing model components in the model designer.
* \warning Not stable API
* \since QGIS 3.14
*/
class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
{
Q_OBJECT

public:

/**
* Constructor for QgsModelComponentGraphicItem for the specified \a component, with the specified \a parent item.
*
* Ownership of \a component is transferred to the item.
*/
QgsModelComponentGraphicItem( QgsProcessingModelComponent *component SIP_TRANSFER, QGraphicsItem *parent SIP_TRANSFERTHIS );

private:

std::unique_ptr< QgsProcessingModelComponent > mComponent;


};

///@endcond

#endif // QGSMODELCOMPONENTGRAPHICITEM_H
4 changes: 2 additions & 2 deletions src/gui/processing/models/qgsmodelgraphicitem.h
Expand Up @@ -41,7 +41,7 @@ class GUI_EXPORT QgsModelDesignerFlatButtonGraphicItem : public QGraphicsObject
* The \a picture argument specifies a QPicture object containing the graphic to render
* for the button. The button will be rendered at the specified \a position and \a size.
*/
QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent, const QPicture &picture, const QPointF &position,
QgsModelDesignerFlatButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, const QPicture &picture, const QPointF &position,
const QSizeF &size = QSizeF( 16, 16 ) );

void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
Expand Down Expand Up @@ -92,7 +92,7 @@ class GUI_EXPORT QgsModelDesignerFoldButtonGraphicItem : public QgsModelDesigner
*
* The button will be rendered at the specified \a position and \a size.
*/
QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent, bool folded, const QPointF &position,
QgsModelDesignerFoldButtonGraphicItem( QGraphicsItem *parent SIP_TRANSFERTHIS, bool folded, const QPointF &position,
const QSizeF &size = QSizeF( 11, 11 ) );

void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
Expand Down
27 changes: 27 additions & 0 deletions src/gui/processing/models/qgsmodelgraphicsscene.cpp
@@ -0,0 +1,27 @@
/***************************************************************************
qgsmodelgraphicsscene.cpp
----------------------------------
Date : March 2020
Copyright : (C) 2020 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsmodelgraphicsscene.h"

///@cond NOT_STABLE

QgsModelGraphicsScene::QgsModelGraphicsScene( QObject *parent )
: QGraphicsScene( parent )
{

}

///@endcond

48 changes: 48 additions & 0 deletions src/gui/processing/models/qgsmodelgraphicsscene.h
@@ -0,0 +1,48 @@
/***************************************************************************
qgsmodelgraphicsscene.h
-----------------------
Date : March 2020
Copyright : (C) 2020 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSMODELGRAPHICSCENE_H
#define QGSMODELGRAPHICSCENE_H

#include "qgis.h"
#include "qgis_gui.h"
#include <QGraphicsScene>


///@cond NOT_STABLE

/**
* \ingroup gui
* \brief QGraphicsScene subclass representing the model designer.
* \warning Not stable API
* \since QGIS 3.14
*/
class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
{
Q_OBJECT

public:

/**
* Constructor for QgsModelGraphicsScene with the specified \a parent object.
*/
QgsModelGraphicsScene( QObject *parent SIP_TRANSFERTHIS = nullptr );


};

///@endcond

#endif // QGSMODELCOMPONENTGRAPHICITEM_H

0 comments on commit 16841ef

Please sign in to comment.