Skip to content
Permalink
Browse files

Move QgsRasterLayerProperties class to the gui API

Motivation :
Move the QgsRasterLayerProperties class to the GUI API.
So, this class could be used using the QGIS API, notably for standalone applications.

The instance of this class was dependent, since QGIS 3.8, from the QgisApp instance, when calling the askUserForDatumTransform(). As this method, defines a title and only call QgsDatumTransformDialog::run() method from the gui API, this PR purpose to :
  • Loading branch information
vcloarec authored and nyalldawson committed Jan 2, 2020
1 parent ef9b8c2 commit 30569bce1f5e69bb1e2fb0e26ece78b69c8808ae
@@ -0,0 +1,48 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/raster/qgsrasterlayerproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsRasterLayerProperties : QgsOptionsDialogBase
{
%Docstring
Property sheet for a raster map layer

.. versionadded:: 3.12
%End

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


QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent = 0, Qt::WindowFlags = QgsGuiUtils::ModalDialogFlags );
%Docstring
Constructor

:param lyr: Map layer for which properties will be displayed
:param canvas: the QgsMapCanvas instance
:param parent: the parent of this widget
:param fl: windows flag
%End

protected slots:

};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/raster/qgsrasterlayerproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -318,6 +318,7 @@
%Include auto_generated/raster/qgsrendererrasterpropertieswidget.sip
%Include auto_generated/raster/qgssinglebandgrayrendererwidget.sip
%Include auto_generated/raster/qgssinglebandpseudocolorrendererwidget.sip
%Include auto_generated/raster/qgsrasterlayerproperties.sip
%Include auto_generated/symbology/characterwidget.sip
%Include auto_generated/symbology/qgs25drendererwidget.sip
%Include auto_generated/symbology/qgsarrowsymbollayerwidget.sip
@@ -66,7 +66,6 @@ SET(QGIS_APP_SRCS
qgsmasksourceselectionwidget.cpp
qgsmapcanvasdockwidget.cpp
qgsmaplayerstylecategoriesmodel.cpp
qgsmaplayerstyleguiutils.cpp
qgsmapsavedialog.cpp
qgsprojectlistitemdelegate.cpp
qgspuzzlewidget.cpp
@@ -145,7 +144,6 @@ SET(QGIS_APP_SRCS
qgsprojectlayergroupdialog.cpp
qgsprojectproperties.cpp
qgsrastercalcdialog.cpp
qgsrasterlayerproperties.cpp
qgsrelationmanagerdialog.cpp
qgsrelationadddlg.cpp
qgsselectbyformdialog.cpp
@@ -4,6 +4,7 @@ SET(QGIS_GUI_SRCS
raster/qgspalettedrendererwidget.cpp
raster/qgsrasterbandcombobox.cpp
raster/qgsrasterhistogramwidget.cpp
raster/qgsrasterlayerproperties.cpp
raster/qgsrasterminmaxwidget.cpp
raster/qgsrasterrendererwidget.cpp
raster/qgssinglebandgrayrendererwidget.cpp
@@ -337,6 +338,7 @@ SET(QGIS_GUI_SRCS
qgsmaplayeractionregistry.cpp
qgsmaplayercombobox.cpp
qgsmaplayerconfigwidgetfactory.cpp
qgsmaplayerstyleguiutils.cpp
qgsmaplayerstylemanagerwidget.cpp
qgsmapmouseevent.cpp
qgsmapoverviewcanvas.cpp
@@ -541,6 +543,7 @@ SET(QGIS_GUI_HDRS
qgsmaplayercombobox.h
qgsmaplayerconfigwidget.h
qgsmaplayerconfigwidgetfactory.h
qgsmaplayerstyleguiutils.h
qgsmaplayerstylemanagerwidget.h
qgsmapmouseevent.h
qgsmapoverviewcanvas.h
@@ -831,6 +834,7 @@ SET(QGIS_GUI_HDRS
raster/qgsrendererrasterpropertieswidget.h
raster/qgssinglebandgrayrendererwidget.h
raster/qgssinglebandpseudocolorrendererwidget.h
raster/qgsrasterlayerproperties.h

symbology/characterwidget.h
symbology/qgs25drendererwidget.h
@@ -935,6 +939,7 @@ SET(QGIS_GUI_UI_HDRS
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsowssourceselectbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsarcgisservicesourceselectbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsprojectionselectorbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsrasterlayerpropertiesbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsquerybuilderbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgssqlcomposerdialogbase.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgssublayersdialogbase.h
@@ -963,6 +968,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/gui/processing
${CMAKE_SOURCE_DIR}/src/gui/providers/gdal
${CMAKE_SOURCE_DIR}/src/gui/providers/ogr
${CMAKE_SOURCE_DIR}/src/gui/raster
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core/annotations
${CMAKE_SOURCE_DIR}/src/core/auth
File renamed without changes.
@@ -17,27 +17,46 @@
#define QGSMAPLAYERSTYLEGUIUTILS_H

#include <QObject>
#include "qgis_gui.h"

#define SIP_NO_FILE

class QgsMapLayer;

class QAction;
class QMenu;

//! Various GUI utility functions for dealing with map layer's style manager
class QgsMapLayerStyleGuiUtils : public QObject

/**
* \ingroup gui
* \class QgsMapLayerStyleGuiUtils
* Various GUI utility functions for dealing with map layer's style manager
* \note not available in Python bindings
* \since QGIS 3.12 (in the GUI API)
*/

class GUI_EXPORT QgsMapLayerStyleGuiUtils : public QObject
{
Q_OBJECT

public:

/**
* \brief returns a singleton instance of this class
*/
static QgsMapLayerStyleGuiUtils *instance();

/**
* \brief adds actions to the menu in accordance to the layer
*/
void addStyleManagerActions( QMenu *m, QgsMapLayer *layer );

private :
QAction *actionAddStyle( QgsMapLayer *layer, QObject *parent = nullptr );
QAction *actionRemoveStyle( QgsMapLayer *layer, QObject *parent = nullptr );
QAction *actionRenameStyle( QgsMapLayer *layer, QObject *parent = nullptr );
QList<QAction *> actionsUseStyle( QgsMapLayer *layer, QObject *parent = nullptr );

//! Add actions for the given map layer to the menu
void addStyleManagerActions( QMenu *m, QgsMapLayer *layer );

private slots:
void addStyle();
void useStyle();
@@ -18,7 +18,6 @@
#include <limits>
#include <typeinfo>

#include "qgisapp.h"
#include "qgsgui.h"
#include "qgsapplication.h"
#include "qgsbilinearrasterresampler.h"
@@ -55,6 +54,7 @@
#include "qgshuesaturationfilter.h"
#include "qgshillshaderendererwidget.h"
#include "qgssettings.h"
#include "qgsdatumtransformdialog.h"
#include "qgsmaplayerlegend.h"
#include "qgsfileutils.h"
#include "qgswebview.h"
@@ -75,6 +75,7 @@
#include <QMouseEvent>
#include <QVector>
#include <QUrl>
#include <QMenu>

QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent, Qt::WindowFlags fl )
: QgsOptionsDialogBase( QStringLiteral( "RasterLayerProperties" ), parent, fl )
@@ -1272,7 +1273,7 @@ void QgsRasterLayerProperties::pbnAddValuesManually_clicked()

void QgsRasterLayerProperties::mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs )
{
QgisApp::instance()->askUserForDatumTransform( crs, QgsProject::instance()->crs(), mRasterLayer );
QgsDatumTransformDialog::run( crs, QgsProject::instance()->crs(), this, mMapCanvas, tr( "Select Transformation" ) );
mRasterLayer->setCrs( crs );
mMetadataWidget->crsChanged();
}
@@ -1752,7 +1753,7 @@ void QgsRasterLayerProperties::toggleColorizeControls( bool colorizeEnabled )
QLinearGradient QgsRasterLayerProperties::redGradient()
{
//define a gradient
///@TODO change this to actual polygon dims
// TODO change this to actual polygon dims
QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
myGradient.setColorAt( 0.0, QColor( 242, 14, 25, 190 ) );
myGradient.setColorAt( 0.5, QColor( 175, 29, 37, 190 ) );
@@ -1762,7 +1763,7 @@ QLinearGradient QgsRasterLayerProperties::redGradient()
QLinearGradient QgsRasterLayerProperties::greenGradient()
{
//define a gradient
///@TODO change this to actual polygon dims
// TODO change this to actual polygon dims
QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
myGradient.setColorAt( 0.0, QColor( 48, 168, 5, 190 ) );
myGradient.setColorAt( 0.8, QColor( 36, 122, 4, 190 ) );
@@ -1772,7 +1773,7 @@ QLinearGradient QgsRasterLayerProperties::greenGradient()
QLinearGradient QgsRasterLayerProperties::blueGradient()
{
//define a gradient
///@TODO change this to actual polygon dims
// TODO change this to actual polygon dims
QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
myGradient.setColorAt( 0.0, QColor( 30, 0, 106, 190 ) );
myGradient.setColorAt( 0.2, QColor( 30, 72, 128, 190 ) );
@@ -1782,7 +1783,7 @@ QLinearGradient QgsRasterLayerProperties::blueGradient()
QLinearGradient QgsRasterLayerProperties::grayGradient()
{
//define a gradient
///@TODO change this to actual polygon dims
// TODO change this to actual polygon dims
QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
myGradient.setColorAt( 0.0, QColor( 5, 5, 5, 190 ) );
myGradient.setColorAt( 0.8, QColor( 122, 122, 122, 190 ) );
@@ -1792,7 +1793,7 @@ QLinearGradient QgsRasterLayerProperties::grayGradient()
QLinearGradient QgsRasterLayerProperties::highlightGradient()
{
//define another gradient for the highlight
///@TODO change this to actual polygon dims
// TODO change this to actual polygon dims
QLinearGradient myGradient = QLinearGradient( mGradientWidth, 0, mGradientWidth, mGradientHeight );
myGradient.setColorAt( 1.0, QColor( 255, 255, 255, 50 ) );
myGradient.setColorAt( 0.5, QColor( 255, 255, 255, 100 ) );
@@ -27,7 +27,7 @@
#include "qgshelp.h"
#include "qgsmaplayerstylemanager.h"
#include "qgsmaptoolemitpoint.h"
#include "qgis_app.h"
#include "qgis_gui.h"

class QgsPointXY;
class QgsMapLayer;
@@ -39,36 +39,50 @@ class QgsRasterRendererWidget;
class QgsRasterHistogramWidget;
class QgsWebView;


/**
* \ingroup gui
* \class QgsRasterLayerProperties
* Property sheet for a raster map layer
*/
class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private Ui::QgsRasterLayerPropertiesBase
* \since QGIS 3.12 (in the GUI API)
*/

class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private Ui::QgsRasterLayerPropertiesBase
{
Q_OBJECT

public:

/**
* enumeration for the different types of style
*/
#ifndef SIP_RUN
enum StyleType
{
QML,
SLD
};
Q_ENUM( StyleType )
#endif

/**
* \brief Constructor
* \param ml Map layer for which properties will be displayed
* Constructor
* \param lyr Map layer for which properties will be displayed
* \param canvas the QgsMapCanvas instance
* \param parent the parent of this widget
* \param fl windows flag
*/
QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent = nullptr, Qt::WindowFlags = QgsGuiUtils::ModalDialogFlags );

//! Synchronize state with associated raster layer
void sync();
protected slots:
//! \brief auto slot executed when the active page in the main widget stack is changed
void optionsStackedWidget_CurrentChanged( int index ) override SIP_SKIP ;

private slots:

public slots:
//TODO: Verify that these all need to be public
//! \brief Applies the settings made in the dialog without closing the box
void apply();
//! Called when cancel button is pressed
//! \brief Called when cancel button is pressed
void onCancel();
//! \brief Slot to update layer display name as original is edited.
void mLayerOrigNameLineEd_textEdited( const QString &text );
@@ -84,8 +98,6 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
void pbnDefaultValues_clicked();
//! \brief slot executed when user wishes to export transparency values
void pbnExportTransparentPixelValues_clicked();
//! \brief auto slot executed when the active page in the main widget stack is changed
void optionsStackedWidget_CurrentChanged( int index ) override;
//! \brief slow executed when user wishes to import transparency values
void pbnImportTransparentPixelValues_clicked();
//! \brief slot executed when user presses "Remove Selected Row" button on the transparency page
@@ -99,7 +111,8 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private

void pixelSelected( const QgsPointXY &, const Qt::MouseButton & );

private slots:


void mRenderTypeComboBox_currentIndexChanged( int index );
//! Load the default style when appropriate button is pressed.
void loadDefaultStyle_clicked();
@@ -233,6 +246,9 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private

bool mMetadataFilled;

//! Synchronize state with associated raster layer
void sync();

friend class QgsAppScreenShots;
};
#endif
@@ -70,6 +70,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/gui
${CMAKE_SOURCE_DIR}/src/gui/editorwidgets
${CMAKE_SOURCE_DIR}/src/gui/layertree
${CMAKE_SOURCE_DIR}/src/gui/raster
${CMAKE_SOURCE_DIR}/src/plugins
${CMAKE_SOURCE_DIR}/external
${CMAKE_SOURCE_DIR}/external/nlohmann
@@ -49,7 +49,7 @@

#include "qgsproject.h"
#include "qgsrasterlayer.h"
#include "../../app/qgsrasterlayerproperties.h"
#include "../../gui/raster/qgsrasterlayerproperties.h"
#include "qgsproviderregistry.h"

#include "qgsgeorefdatapoint.h"
@@ -2174,7 +2174,7 @@ p, li { white-space: pre-wrap; }
<customwidget>
<class>QgsRasterBandComboBox</class>
<extends>QComboBox</extends>
<header>raster/qgsrasterbandcombobox.h</header>
<header>qgsrasterbandcombobox.h</header>
</customwidget>
<customwidget>
<class>QgsWebView</class>
@@ -371,11 +371,6 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsRasterBandComboBox</class>
<extends>QComboBox</extends>
<header>raster/qgsrasterbandcombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>

0 comments on commit 30569bc

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