mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Clean up QgsExtentGroupBox API
Make protected members private, improve documentation
This commit is contained in:
parent
4e4f232ad4
commit
f216db102c
@ -27,7 +27,6 @@ class QgsExtentGroupBox : QgsCollapsibleGroupBox
|
|||||||
#include "qgsextentgroupbox.h"
|
#include "qgsextentgroupbox.h"
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
explicit QgsExtentGroupBox( QWidget *parent /TransferThis/ = 0 );
|
|
||||||
|
|
||||||
enum ExtentState
|
enum ExtentState
|
||||||
{
|
{
|
||||||
@ -37,101 +36,120 @@ class QgsExtentGroupBox : QgsCollapsibleGroupBox
|
|||||||
ProjectLayerExtent,
|
ProjectLayerExtent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
explicit QgsExtentGroupBox( QWidget *parent /TransferThis/ = 0 );
|
||||||
|
%Docstring
|
||||||
|
Constructor for QgsExtentGroupBox.
|
||||||
|
%End
|
||||||
|
|
||||||
void setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs );
|
void setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs );
|
||||||
%Docstring
|
%Docstring
|
||||||
Setup original extent - should be called as part of initialization
|
Sets the original extent and coordinate reference system for the widget. This should be called as part of initialization.
|
||||||
|
.. seealso:: originalExtent()
|
||||||
|
.. seealso:: originalCrs()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QgsRectangle originalExtent() const;
|
QgsRectangle originalExtent() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns the original extent set for the widget.
|
||||||
|
.. seealso:: setOriginalExtent()
|
||||||
|
.. seealso:: originalCrs()
|
||||||
:rtype: QgsRectangle
|
:rtype: QgsRectangle
|
||||||
%End
|
%End
|
||||||
const QgsCoordinateReferenceSystem &originalCrs() const;
|
|
||||||
|
QgsCoordinateReferenceSystem originalCrs() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns the original coordinate reference system set for the widget.
|
||||||
|
.. seealso:: originalExtent()
|
||||||
|
.. seealso:: setOriginalExtent()
|
||||||
:rtype: QgsCoordinateReferenceSystem
|
:rtype: QgsCoordinateReferenceSystem
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setCurrentExtent( const QgsRectangle ¤tExtent, const QgsCoordinateReferenceSystem ¤tCrs );
|
void setCurrentExtent( const QgsRectangle ¤tExtent, const QgsCoordinateReferenceSystem ¤tCrs );
|
||||||
%Docstring
|
%Docstring
|
||||||
Setup current extent - should be called as part of initialization (or whenever current extent changes)
|
Sets the current extent to show in the widget - should be called as part of initialization (or whenever current extent changes).
|
||||||
|
.. seealso:: currentExtent()
|
||||||
|
.. seealso:: currentCrs()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QgsRectangle currentExtent() const;
|
QgsRectangle currentExtent() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns the current extent set for the widget.
|
||||||
|
.. seealso:: setCurrentExtent()
|
||||||
|
.. seealso:: currentCrs()
|
||||||
:rtype: QgsRectangle
|
:rtype: QgsRectangle
|
||||||
%End
|
%End
|
||||||
const QgsCoordinateReferenceSystem ¤tCrs() const;
|
|
||||||
|
QgsCoordinateReferenceSystem currentCrs() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns the coordinate reference system for the current extent set for the widget.
|
||||||
|
.. seealso:: setCurrentExtent()
|
||||||
|
.. seealso:: currentExtent()
|
||||||
:rtype: QgsCoordinateReferenceSystem
|
:rtype: QgsCoordinateReferenceSystem
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs );
|
void setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs );
|
||||||
%Docstring
|
%Docstring
|
||||||
Should be called as part of initialization and whenever the the output CRS is changed
|
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.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QgsRectangle outputExtent() const;
|
QgsRectangle outputExtent() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Get the resulting extent - in output CRS coordinates
|
Returns the extent shown in the widget - in output CRS coordinates.
|
||||||
:rtype: QgsRectangle
|
:rtype: QgsRectangle
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QgsExtentGroupBox::ExtentState extentState() const;
|
QgsExtentGroupBox::ExtentState extentState() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns the currently selected state for the widget's extent.
|
||||||
:rtype: QgsExtentGroupBox.ExtentState
|
:rtype: QgsExtentGroupBox.ExtentState
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setTitleBase( const QString &title );
|
void setTitleBase( const QString &title );
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Sets the base part of ``title`` of the group box (will be appended with extent state)
|
||||||
.. versionadded:: 2.12
|
.. versionadded:: 2.12
|
||||||
|
.. seealso:: titleBase()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QString titleBase() const;
|
QString titleBase() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Returns the base part of title of the group box (will be appended with extent state).
|
||||||
.. versionadded:: 2.12
|
.. versionadded:: 2.12
|
||||||
|
.. seealso:: setTitleBase()
|
||||||
:rtype: str
|
:rtype: str
|
||||||
%End
|
%End
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setOutputExtentFromOriginal();
|
void setOutputExtentFromOriginal();
|
||||||
%Docstring
|
%Docstring
|
||||||
set output extent to be the same as original extent (may be transformed to output CRS)
|
Sets the output extent to be the same as original extent (may be transformed to output CRS).
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setOutputExtentFromCurrent();
|
void setOutputExtentFromCurrent();
|
||||||
%Docstring
|
%Docstring
|
||||||
set output extent to be the same as current extent (may be transformed to output CRS)
|
Sets the output extent to be the same as current extent (may be transformed to output CRS).
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
|
void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
|
||||||
%Docstring
|
%Docstring
|
||||||
set output extent to custom extent (may be transformed to output CRS)
|
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).
|
||||||
|
.. versionadded:: 3.0
|
||||||
%End
|
%End
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void extentChanged( const QgsRectangle &r );
|
void extentChanged( const QgsRectangle &r );
|
||||||
%Docstring
|
%Docstring
|
||||||
emitted when extent is changed
|
Emitted when the widget's extent is changed.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
protected slots:
|
|
||||||
|
|
||||||
void on_mXMinLineEdit_textEdited( const QString & );
|
|
||||||
void on_mXMaxLineEdit_textEdited( const QString & );
|
|
||||||
void on_mYMinLineEdit_textEdited( const QString & );
|
|
||||||
void on_mYMaxLineEdit_textEdited( const QString & );
|
|
||||||
|
|
||||||
void groupBoxClicked();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, QgsExtentGroupBox::ExtentState state );
|
|
||||||
void setOutputExtentFromLineEdit();
|
|
||||||
void updateTitle();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -171,10 +171,7 @@ void QgsExtentGroupBox::setExtentToLayerExtent( const QString &layerId )
|
|||||||
if ( !layer )
|
if ( !layer )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mExtentLayerId = layerId;
|
setOutputExtentFromLayer( layer );
|
||||||
mExtentLayerName = layer->name();
|
|
||||||
|
|
||||||
setOutputExtent( layer->extent(), layer->crs(), ProjectLayerExtent );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsExtentGroupBox::setOutputExtentFromCurrent()
|
void QgsExtentGroupBox::setOutputExtentFromCurrent()
|
||||||
@ -193,6 +190,17 @@ void QgsExtentGroupBox::setOutputExtentFromUser( const QgsRectangle &extent, con
|
|||||||
setOutputExtent( extent, crs, UserExtent );
|
setOutputExtent( extent, crs, UserExtent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsExtentGroupBox::setOutputExtentFromLayer( const QgsMapLayer *layer )
|
||||||
|
{
|
||||||
|
if ( !layer )
|
||||||
|
return;
|
||||||
|
|
||||||
|
mExtentLayerId = layer->id();
|
||||||
|
mExtentLayerName = layer->name();
|
||||||
|
|
||||||
|
setOutputExtent( layer->extent(), layer->crs(), ProjectLayerExtent );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsExtentGroupBox::groupBoxClicked()
|
void QgsExtentGroupBox::groupBoxClicked()
|
||||||
{
|
{
|
||||||
if ( !isCheckable() )
|
if ( !isCheckable() )
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
class QgsCoordinateReferenceSystem;
|
class QgsCoordinateReferenceSystem;
|
||||||
class QgsMapLayerModel;
|
class QgsMapLayerModel;
|
||||||
|
class QgsMapLayer;
|
||||||
|
|
||||||
/** \ingroup gui
|
/** \ingroup gui
|
||||||
* Collapsible group box for configuration of extent, typically for a save operation.
|
* Collapsible group box for configuration of extent, typically for a save operation.
|
||||||
@ -43,8 +44,8 @@ class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::
|
|||||||
Q_PROPERTY( QString titleBase READ titleBase WRITE setTitleBase )
|
Q_PROPERTY( QString titleBase READ titleBase WRITE setTitleBase )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QgsExtentGroupBox( QWidget *parent SIP_TRANSFERTHIS = 0 );
|
|
||||||
|
|
||||||
|
//! Available states for the current extent selection in the widget
|
||||||
enum ExtentState
|
enum ExtentState
|
||||||
{
|
{
|
||||||
OriginalExtent, //!< Layer's extent
|
OriginalExtent, //!< Layer's extent
|
||||||
@ -53,49 +54,114 @@ class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::
|
|||||||
ProjectLayerExtent, //!< Extent taken from a layer within the project
|
ProjectLayerExtent, //!< Extent taken from a layer within the project
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Setup original extent - should be called as part of initialization
|
/**
|
||||||
|
* Constructor for QgsExtentGroupBox.
|
||||||
|
*/
|
||||||
|
explicit QgsExtentGroupBox( QWidget *parent SIP_TRANSFERTHIS = 0 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the original extent and coordinate reference system for the widget. This should be called as part of initialization.
|
||||||
|
* \see originalExtent()
|
||||||
|
* \see originalCrs()
|
||||||
|
*/
|
||||||
void setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs );
|
void setOriginalExtent( const QgsRectangle &originalExtent, const QgsCoordinateReferenceSystem &originalCrs );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the original extent set for the widget.
|
||||||
|
* \see setOriginalExtent()
|
||||||
|
* \see originalCrs()
|
||||||
|
*/
|
||||||
QgsRectangle originalExtent() const { return mOriginalExtent; }
|
QgsRectangle originalExtent() const { return mOriginalExtent; }
|
||||||
const QgsCoordinateReferenceSystem &originalCrs() const { return mOriginalCrs; }
|
|
||||||
|
|
||||||
//! Setup current extent - should be called as part of initialization (or whenever current extent changes)
|
/**
|
||||||
|
* Returns the original coordinate reference system set for the widget.
|
||||||
|
* \see originalExtent()
|
||||||
|
* \see setOriginalExtent()
|
||||||
|
*/
|
||||||
|
QgsCoordinateReferenceSystem originalCrs() const { return mOriginalCrs; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current extent to show in the widget - should be called as part of initialization (or whenever current extent changes).
|
||||||
|
* \see currentExtent()
|
||||||
|
* \see currentCrs()
|
||||||
|
*/
|
||||||
void setCurrentExtent( const QgsRectangle ¤tExtent, const QgsCoordinateReferenceSystem ¤tCrs );
|
void setCurrentExtent( const QgsRectangle ¤tExtent, const QgsCoordinateReferenceSystem ¤tCrs );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current extent set for the widget.
|
||||||
|
* \see setCurrentExtent()
|
||||||
|
* \see currentCrs()
|
||||||
|
*/
|
||||||
QgsRectangle currentExtent() const { return mCurrentExtent; }
|
QgsRectangle currentExtent() const { return mCurrentExtent; }
|
||||||
const QgsCoordinateReferenceSystem ¤tCrs() const { return mCurrentCrs; }
|
|
||||||
|
|
||||||
//! Set 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
|
* Returns the coordinate reference system for the current extent set for the widget.
|
||||||
|
* \see setCurrentExtent()
|
||||||
|
* \see currentExtent()
|
||||||
|
*/
|
||||||
|
QgsCoordinateReferenceSystem currentCrs() const { return mCurrentCrs; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
void setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs );
|
void setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs );
|
||||||
|
|
||||||
//! Get the resulting extent - in output CRS coordinates
|
/**
|
||||||
|
* Returns the extent shown in the widget - in output CRS coordinates.
|
||||||
|
*/
|
||||||
QgsRectangle outputExtent() const;
|
QgsRectangle outputExtent() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the currently selected state for the widget's extent.
|
||||||
|
*/
|
||||||
QgsExtentGroupBox::ExtentState extentState() const { return mExtentState; }
|
QgsExtentGroupBox::ExtentState extentState() const { return mExtentState; }
|
||||||
|
|
||||||
//! Set base part of title of the group box (will be appended with extent state)
|
/**
|
||||||
//! \since QGIS 2.12
|
* Sets the base part of \a title of the group box (will be appended with extent state)
|
||||||
|
* \since QGIS 2.12
|
||||||
|
* \see titleBase()
|
||||||
|
*/
|
||||||
void setTitleBase( const QString &title );
|
void setTitleBase( const QString &title );
|
||||||
//! Set base part of title of the group box (will be appended with extent state)
|
|
||||||
//! \since QGIS 2.12
|
/**
|
||||||
|
* Returns the base part of title of the group box (will be appended with extent state).
|
||||||
|
* \since QGIS 2.12
|
||||||
|
* \see setTitleBase()
|
||||||
|
*/
|
||||||
QString titleBase() const;
|
QString titleBase() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! set output extent to be the same as original extent (may be transformed to output CRS)
|
|
||||||
|
/**
|
||||||
|
* Sets the output extent to be the same as original extent (may be transformed to output CRS).
|
||||||
|
*/
|
||||||
void setOutputExtentFromOriginal();
|
void setOutputExtentFromOriginal();
|
||||||
|
|
||||||
//! set output extent to be the same as current extent (may be transformed to output CRS)
|
/**
|
||||||
|
* Sets the output extent to be the same as current extent (may be transformed to output CRS).
|
||||||
|
*/
|
||||||
void setOutputExtentFromCurrent();
|
void setOutputExtentFromCurrent();
|
||||||
|
|
||||||
//! set output extent to custom extent (may be transformed to output CRS)
|
/**
|
||||||
|
* Sets the output extent to a custom extent (may be transformed to output CRS).
|
||||||
|
*/
|
||||||
void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
|
void setOutputExtentFromUser( const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the output extent to match a \a layer's extent (may be transformed to output CRS).
|
||||||
|
* \since QGIS 3.0
|
||||||
|
*/
|
||||||
|
void setOutputExtentFromLayer( const QgsMapLayer *layer );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! emitted when extent is changed
|
|
||||||
|
/**
|
||||||
|
* Emitted when the widget's extent is changed.
|
||||||
|
*/
|
||||||
void extentChanged( const QgsRectangle &r );
|
void extentChanged( const QgsRectangle &r );
|
||||||
|
|
||||||
protected slots:
|
private slots:
|
||||||
|
|
||||||
void on_mXMinLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
|
void on_mXMinLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
|
||||||
void on_mXMaxLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
|
void on_mXMaxLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
|
||||||
@ -103,8 +169,9 @@ class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::
|
|||||||
void on_mYMaxLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
|
void on_mYMaxLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
|
||||||
|
|
||||||
void groupBoxClicked();
|
void groupBoxClicked();
|
||||||
|
void layerMenuAboutToShow();
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, QgsExtentGroupBox::ExtentState state );
|
void setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, QgsExtentGroupBox::ExtentState state );
|
||||||
void setOutputExtentFromLineEdit();
|
void setOutputExtentFromLineEdit();
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
@ -122,12 +189,6 @@ class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::
|
|||||||
QgsRectangle mOriginalExtent;
|
QgsRectangle mOriginalExtent;
|
||||||
QgsCoordinateReferenceSystem mOriginalCrs;
|
QgsCoordinateReferenceSystem mOriginalCrs;
|
||||||
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
void layerMenuAboutToShow();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
QMenu *mLayerMenu = nullptr;
|
QMenu *mLayerMenu = nullptr;
|
||||||
QgsMapLayerModel *mMapLayerModel = nullptr;
|
QgsMapLayerModel *mMapLayerModel = nullptr;
|
||||||
QList< QAction * > mMenuActions;
|
QList< QAction * > mMenuActions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user