Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Split guts of QgsExtentGroupBox out to QgsExtentWidget
This allows the widget to be used in places where a group box
is not desirable (e.g. when the widget is already in a group box)
  • Loading branch information
nyalldawson committed Mar 25, 2020
1 parent e723800 commit dbc022d
Show file tree
Hide file tree
Showing 13 changed files with 1,132 additions and 319 deletions.
6 changes: 4 additions & 2 deletions python/gui/auto_generated/qgsextentgroupbox.sip.in
Expand Up @@ -11,7 +11,6 @@




class QgsExtentGroupBox : QgsCollapsibleGroupBox
{
%Docstring
Expand All @@ -20,7 +19,9 @@ Collapsible group box for configuration of extent, typically for a save operatio
Besides allowing the user to enter the extent manually, it comes with options to use
original extent or extent defined by the current view in map canvas.

When using the widget, make sure to call setOriginalExtent(), setCurrentExtent() and setOutputCrs() during initialization.
When using the group box, make sure to call setOriginalExtent(), setCurrentExtent() and setOutputCrs() during initialization.

.. seealso:: :py:class:`QgsExtentWidget`

.. versionadded:: 2.4
%End
Expand All @@ -30,6 +31,7 @@ When using the widget, make sure to call setOriginalExtent(), setCurrentExtent()
%End
public:


enum ExtentState
{
OriginalExtent,
Expand Down
210 changes: 210 additions & 0 deletions python/gui/auto_generated/qgsextentwidget.sip.in
@@ -0,0 +1,210 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsextentwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsExtentWidget : QWidget
{
%Docstring
A widget for configuration of a map extent.

Besides allowing the user to enter the extent manually, it comes with options to use
original extent or extent defined by the current view in map canvas.

When using the widget, make sure to call setOriginalExtent(), setCurrentExtent() and setOutputCrs() during initialization.

.. seealso:: :py:class:`QgsExtentGroupBox`

.. versionadded:: 3.14
%End

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

enum ExtentState
{
OriginalExtent,
CurrentExtent,
UserExtent,
ProjectLayerExtent,
DrawOnCanvas,
};

explicit QgsExtentWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsExtentWidget.
%End

void setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs );
%Docstring
Sets the original extent and coordinate reference system for the widget. This should be called as part of initialization.

.. seealso:: :py:func:`originalExtent`

.. seealso:: :py:func:`originalCrs`
%End

QgsRectangle originalExtent() const;
%Docstring
Returns the original extent set for the widget.

.. seealso:: :py:func:`setOriginalExtent`

.. seealso:: :py:func:`originalCrs`
%End

QgsCoordinateReferenceSystem originalCrs() const;
%Docstring
Returns the original coordinate reference system set for the widget.

.. seealso:: :py:func:`originalExtent`

.. seealso:: :py:func:`setOriginalExtent`
%End

void setCurrentExtent( const QgsRectangle &currentExtent, const QgsCoordinateReferenceSystem &currentCrs );
%Docstring
Sets the current extent to show in the widget - should be called as part of initialization (or whenever current extent changes).
The current extent is usually set to match the current map canvas extent.

.. seealso:: :py:func:`currentExtent`

.. seealso:: :py:func:`currentCrs`
%End

QgsRectangle currentExtent() const;
%Docstring
Returns the current extent set for the widget. The current extent is usually set to match the
current map canvas extent.

.. seealso:: :py:func:`setCurrentExtent`

.. seealso:: :py:func:`currentCrs`
%End

QgsCoordinateReferenceSystem currentCrs() const;
%Docstring
Returns the coordinate reference system for the current extent set for the widget. The current
extent and CRS usually reflects the map canvas extent and CRS.

.. seealso:: :py:func:`setCurrentExtent`

.. seealso:: :py:func:`currentExtent`
%End

void setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs );
%Docstring
Sets the output CRS - may need to be used for transformation from original/current extent.
Should be called as part of initialization and whenever the the output CRS is changed.
The current extent will be reprojected into the new output CRS.
%End

QgsRectangle outputExtent() const;
%Docstring
Returns the extent shown in the widget - in output CRS coordinates.

.. seealso:: :py:func:`outputCrs`
%End

QgsCoordinateReferenceSystem outputCrs() const;
%Docstring
Returns the current output CRS, used in the display.

.. seealso:: :py:func:`outputExtent`
%End

QgsExtentWidget::ExtentState extentState() const;
%Docstring
Returns the currently selected state for the widget's extent.
%End

void setMapCanvas( QgsMapCanvas *canvas );
%Docstring
Sets the map canvas to enable dragging of extent on a canvas.

:param canvas: the map canvas
%End

QSize ratio() const;
%Docstring
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
If the aspect ratio isn't fixed, the width and height will be set to zero.
%End

QString extentLayerName() const;
%Docstring
Returns the name of the extent layer.
%End

bool isValid() const;
%Docstring
Returns ``True`` if the widget is in a valid state, i.e. has an extent set.
%End

public slots:

void setOutputExtentFromOriginal();
%Docstring
Sets the output extent to be the same as original extent (may be transformed to output CRS).
%End

void setOutputExtentFromCurrent();
%Docstring
Sets the output extent to be the same as current extent (may be transformed to output CRS).
%End

void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
%Docstring
Sets the output extent to a custom extent (may be transformed to output CRS).
%End

void setOutputExtentFromLayer( const QgsMapLayer *layer );
%Docstring
Sets the output extent to match a ``layer``'s extent (may be transformed to output CRS).
%End

void setOutputExtentFromDrawOnCanvas();
%Docstring
Sets the output extent by dragging on the canvas.
%End

void setRatio( QSize ratio );
%Docstring
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
To unset a fixed aspect ratio, set the width and height to zero.

:param ratio: aspect ratio's width and height
%End

signals:

void extentChanged( const QgsRectangle &r );
%Docstring
Emitted when the widget's extent is changed.
%End

void validationChanged( bool valid );
%Docstring
Emitted when the widget's validation state changes.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsextentwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -75,6 +75,7 @@
%Include auto_generated/qgsexpressionlineedit.sip
%Include auto_generated/qgsexpressionselectiondialog.sip
%Include auto_generated/qgsextentgroupbox.sip
%Include auto_generated/qgsextentwidget.sip
%Include auto_generated/qgsexternalresourcewidget.sip
%Include auto_generated/qgsfeaturelistcombobox.sip
%Include auto_generated/qgsfeatureselectiondlg.sip
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -33,7 +33,7 @@
#include "qgsfeatureaction.h"
#include "qgisapp.h"
#include "qgsexpressioncontextutils.h"

#include "qgsrubberband.h"
#include <QSettings>

QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas *canvas, CaptureMode mode )
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -381,6 +381,7 @@ SET(QGIS_GUI_SRCS
qgsexpressionselectiondialog.cpp
qgsexpressionstoredialog.cpp
qgsextentgroupbox.cpp
qgsextentwidget.cpp
qgsexternalresourcewidget.cpp
qgsfeatureselectiondlg.cpp
qgsfieldcombobox.cpp
Expand Down Expand Up @@ -598,6 +599,7 @@ SET(QGIS_GUI_HDRS
qgsexpressionlineedit.h
qgsexpressionselectiondialog.h
qgsextentgroupbox.h
qgsextentwidget.h
qgsexternalresourcewidget.h
qgsfeaturelistcombobox.h
qgsfeatureselectiondlg.h
Expand Down

0 comments on commit dbc022d

Please sign in to comment.