Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Promote QgsRasterPipe enums to enum classes in Qgis namespace
and add forward declares where possible
  • Loading branch information
nyalldawson committed Jun 23, 2021
1 parent e2b7f07 commit f62ddb3
Show file tree
Hide file tree
Showing 19 changed files with 275 additions and 171 deletions.
40 changes: 40 additions & 0 deletions python/core/auto_additions/qgis.py
Expand Up @@ -338,3 +338,43 @@
Qgis.SublayerQueryFlag.__doc__ = 'Flags which control how data providers will scan for sublayers in a dataset.\n\n.. versionadded:: 3.22\n\n' + '* ``FastScan``: ' + Qgis.SublayerQueryFlag.FastScan.__doc__ + '\n' + '* ``ResolveGeometryType``: ' + Qgis.SublayerQueryFlag.ResolveGeometryType.__doc__ + '\n' + '* ``CountFeatures``: ' + Qgis.SublayerQueryFlag.CountFeatures.__doc__
# --
Qgis.SublayerQueryFlag.baseClass = Qgis
QgsRasterPipe.Role = Qgis.RasterPipeInterfaceRole
# monkey patching scoped based enum
QgsRasterPipe.UnknownRole = Qgis.RasterPipeInterfaceRole.Unknown
QgsRasterPipe.UnknownRole.is_monkey_patched = True
QgsRasterPipe.UnknownRole.__doc__ = "Unknown role"
QgsRasterPipe.ProviderRole = Qgis.RasterPipeInterfaceRole.Provider
QgsRasterPipe.ProviderRole.is_monkey_patched = True
QgsRasterPipe.ProviderRole.__doc__ = "Data provider role"
QgsRasterPipe.RendererRole = Qgis.RasterPipeInterfaceRole.Renderer
QgsRasterPipe.RendererRole.is_monkey_patched = True
QgsRasterPipe.RendererRole.__doc__ = "Raster renderer role"
QgsRasterPipe.BrightnessRole = Qgis.RasterPipeInterfaceRole.Brightness
QgsRasterPipe.BrightnessRole.is_monkey_patched = True
QgsRasterPipe.BrightnessRole.__doc__ = "Brightness filter role"
QgsRasterPipe.ResamplerRole = Qgis.RasterPipeInterfaceRole.Resampler
QgsRasterPipe.ResamplerRole.is_monkey_patched = True
QgsRasterPipe.ResamplerRole.__doc__ = "Resampler role"
QgsRasterPipe.ProjectorRole = Qgis.RasterPipeInterfaceRole.Projector
QgsRasterPipe.ProjectorRole.is_monkey_patched = True
QgsRasterPipe.ProjectorRole.__doc__ = "Projector role"
QgsRasterPipe.NullerRole = Qgis.RasterPipeInterfaceRole.Nuller
QgsRasterPipe.NullerRole.is_monkey_patched = True
QgsRasterPipe.NullerRole.__doc__ = "Raster nuller role"
QgsRasterPipe.HueSaturationRole = Qgis.RasterPipeInterfaceRole.HueSaturation
QgsRasterPipe.HueSaturationRole.is_monkey_patched = True
QgsRasterPipe.HueSaturationRole.__doc__ = "Hue/saturation filter role"
Qgis.RasterPipeInterfaceRole.__doc__ = 'Raster pipe interface roles.\n\n.. versionadded:: 3.22\n\n' + '* ``UnknownRole``: ' + Qgis.RasterPipeInterfaceRole.Unknown.__doc__ + '\n' + '* ``ProviderRole``: ' + Qgis.RasterPipeInterfaceRole.Provider.__doc__ + '\n' + '* ``RendererRole``: ' + Qgis.RasterPipeInterfaceRole.Renderer.__doc__ + '\n' + '* ``BrightnessRole``: ' + Qgis.RasterPipeInterfaceRole.Brightness.__doc__ + '\n' + '* ``ResamplerRole``: ' + Qgis.RasterPipeInterfaceRole.Resampler.__doc__ + '\n' + '* ``ProjectorRole``: ' + Qgis.RasterPipeInterfaceRole.Projector.__doc__ + '\n' + '* ``NullerRole``: ' + Qgis.RasterPipeInterfaceRole.Nuller.__doc__ + '\n' + '* ``HueSaturationRole``: ' + Qgis.RasterPipeInterfaceRole.HueSaturation.__doc__
# --
Qgis.RasterPipeInterfaceRole.baseClass = Qgis
QgsRasterPipe.ResamplingStage = Qgis.RasterResamplingStage
# monkey patching scoped based enum
QgsRasterPipe.ResampleFilter = Qgis.RasterResamplingStage.ResampleFilter
QgsRasterPipe.ResampleFilter.is_monkey_patched = True
QgsRasterPipe.ResampleFilter.__doc__ = ""
QgsRasterPipe.Provider = Qgis.RasterResamplingStage.Provider
QgsRasterPipe.Provider.is_monkey_patched = True
QgsRasterPipe.Provider.__doc__ = ""
Qgis.RasterResamplingStage.__doc__ = 'Stage at which raster resampling occurs.\n\n.. versionadded:: 3.22\n\n' + '* ``ResampleFilter``: ' + Qgis.RasterResamplingStage.ResampleFilter.__doc__ + '\n' + '* ``Provider``: ' + Qgis.RasterResamplingStage.Provider.__doc__
# --
Qgis.RasterResamplingStage.baseClass = Qgis
6 changes: 0 additions & 6 deletions python/core/auto_additions/qgsrasterpipe.py

This file was deleted.

20 changes: 20 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -251,6 +251,26 @@ The development version
typedef QFlags<Qgis::SublayerQueryFlag> SublayerQueryFlags;


enum class RasterPipeInterfaceRole
{
Unknown,
Provider,
Renderer,
Brightness,
Resampler,
Projector,
Nuller,
HueSaturation,
};

enum class RasterResamplingStage
{
//! Resampling occurs in ResamplingFilter
ResampleFilter,
//! Resampling occurs in Provider
Provider
};

static const double DEFAULT_SEARCH_RADIUS_MM;

static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
Expand Down
Expand Up @@ -9,6 +9,7 @@




class QgsRasterFileWriterTask : QgsTask
{
%Docstring(signature="appended")
Expand Down Expand Up @@ -57,6 +58,8 @@ Ownership of the ``pipe`` is transferred to the writer task, and will
be deleted when the task completes.
%End

~QgsRasterFileWriterTask();

virtual void cancel();


Expand Down
4 changes: 2 additions & 2 deletions python/core/auto_generated/raster/qgsrasterlayer.sip.in
Expand Up @@ -204,7 +204,7 @@ Returns the raster's hue/saturation filter.
.. seealso:: :py:func:`brightnessFilter`
%End

void setResamplingStage( QgsRasterPipe::ResamplingStage stage );
void setResamplingStage( Qgis::RasterResamplingStage stage );
%Docstring
Select which stage of the pipe should apply resampling.

Expand All @@ -213,7 +213,7 @@ Select which stage of the pipe should apply resampling.
.. versionadded:: 3.16
%End

QgsRasterPipe::ResamplingStage resamplingStage() const;
Qgis::RasterResamplingStage resamplingStage() const;
%Docstring
Returns which stage of the pipe should apply resampling.

Expand Down
24 changes: 2 additions & 22 deletions python/core/auto_generated/raster/qgsrasterpipe.sip.in
Expand Up @@ -22,18 +22,6 @@ Contains a pipeline of raster interfaces for sequential raster processing.
%End
public:

enum Role
{
UnknownRole,
ProviderRole,
RendererRole,
BrightnessRole,
ResamplerRole,
ProjectorRole,
NullerRole,
HueSaturationRole,
};

QgsRasterPipe();
%Docstring
Constructor for an empty QgsRasterPipe.
Expand Down Expand Up @@ -175,15 +163,7 @@ Returns the projector interface, or ``None`` if no projector is present in the p
Returns the raster nuller interface, or ``None`` if no raster nuller is present in the pipe.
%End

enum class ResamplingStage
{
//! Resampling occurs in ResamplingFilter
ResampleFilter,
//! Resampling occurs in Provider
Provider
};

void setResamplingStage( ResamplingStage stage );
void setResamplingStage( Qgis::RasterResamplingStage stage );
%Docstring
Sets which stage of the pipe should apply resampling.

Expand All @@ -195,7 +175,7 @@ ProviderHintCanPerformProviderResampling in :py:func:`~QgsRasterPipe.providerCap
.. versionadded:: 3.16
%End

ResamplingStage resamplingStage() const;
Qgis::RasterResamplingStage resamplingStage() const;
%Docstring
Returns which stage of the pipe should apply resampling

Expand Down
1 change: 1 addition & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -259,6 +259,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgslayertreeviewnocrsindicator.h"
#include "qgslayertreeviewtemporalindicator.h"
#include "qgslayertreeviewofflineindicator.h"
#include "qgsrasterpipe.h"
#include "qgslayout.h"
#include "qgslayoutatlas.h"
#include "qgslayoutcustomdrophandler.h"
Expand Down
31 changes: 31 additions & 0 deletions src/core/qgis.h
Expand Up @@ -371,6 +371,37 @@ class CORE_EXPORT Qgis
Q_DECLARE_FLAGS( SublayerQueryFlags, SublayerQueryFlag )
Q_ENUM( SublayerQueryFlag )

/**
* Raster pipe interface roles.
*
* \since QGIS 3.22
*/
enum class RasterPipeInterfaceRole SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRasterPipe, Role ) : int
{
Unknown SIP_MONKEYPATCH_COMPAT_NAME( UnknownRole ) = 0, //!< Unknown role
Provider SIP_MONKEYPATCH_COMPAT_NAME( ProviderRole ) = 1, //!< Data provider role
Renderer SIP_MONKEYPATCH_COMPAT_NAME( RendererRole ) = 2, //!< Raster renderer role
Brightness SIP_MONKEYPATCH_COMPAT_NAME( BrightnessRole ) = 3, //!< Brightness filter role
Resampler SIP_MONKEYPATCH_COMPAT_NAME( ResamplerRole ) = 4, //!< Resampler role
Projector SIP_MONKEYPATCH_COMPAT_NAME( ProjectorRole ) = 5, //!< Projector role
Nuller SIP_MONKEYPATCH_COMPAT_NAME( NullerRole ) = 6, //!< Raster nuller role
HueSaturation SIP_MONKEYPATCH_COMPAT_NAME( HueSaturationRole ) = 7, //!< Hue/saturation filter role
};
Q_ENUM( RasterPipeInterfaceRole )

/**
* Stage at which raster resampling occurs.
* \since QGIS 3.22
*/
enum class RasterResamplingStage SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsRasterPipe, ResamplingStage ) : int
{
//! Resampling occurs in ResamplingFilter
ResampleFilter,
//! Resampling occurs in Provider
Provider
};
Q_ENUM( RasterResamplingStage )

/**
* Identify search radius in mm
* \since QGIS 2.3
Expand Down
1 change: 1 addition & 0 deletions src/core/raster/qgsrasterfilewriter.cpp
Expand Up @@ -25,6 +25,7 @@
#include "qgsrasterdataprovider.h"
#include "qgsrasternuller.h"
#include "qgsreadwritelocker.h"
#include "qgsrasterpipe.h"

#include <QCoreApplication>
#include <QProgressDialog>
Expand Down
3 changes: 3 additions & 0 deletions src/core/raster/qgsrasterfilewritertask.cpp
Expand Up @@ -18,6 +18,7 @@
#include "qgsrasterfilewritertask.h"
#include "qgsrasterinterface.h"
#include "qgsrasterdataprovider.h"
#include "qgsrasterpipe.h"

// Deprecated!
QgsRasterFileWriterTask::QgsRasterFileWriterTask( const QgsRasterFileWriter &writer, QgsRasterPipe *pipe, int columns, int rows,
Expand All @@ -43,6 +44,8 @@ QgsRasterFileWriterTask::QgsRasterFileWriterTask( const QgsRasterFileWriter &wri
{
}

QgsRasterFileWriterTask::~QgsRasterFileWriterTask() = default;

void QgsRasterFileWriterTask::cancel()
{
mFeedback->cancel();
Expand Down
5 changes: 4 additions & 1 deletion src/core/raster/qgsrasterfilewritertask.h
Expand Up @@ -23,7 +23,8 @@
#include "qgsrasterfilewriter.h"
#include "qgscoordinatetransformcontext.h"
#include "qgsrasterinterface.h"
#include "qgsrasterpipe.h"

class QgsRasterPipe;

/**
* \class QgsRasterFileWriterTask
Expand Down Expand Up @@ -68,6 +69,8 @@ class CORE_EXPORT QgsRasterFileWriterTask : public QgsTask
const QgsCoordinateTransformContext &transformContext
);

~QgsRasterFileWriterTask() override;

void cancel() override;

signals:
Expand Down

0 comments on commit f62ddb3

Please sign in to comment.