Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make point cloud elevation properties a QgsMapLayerConfigWidget, so i…
…t shows in inline dock
- Loading branch information
1 parent
9fc11d9
commit e4c8ce8
Showing
7 changed files
with
269 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/app/pointcloud/qgspointcloudelevationpropertieswidget.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/*************************************************************************** | ||
qgspointcloudelevationpropertieswidget.cpp | ||
--------------------- | ||
begin : December 2020 | ||
copyright : (C) 2020 by 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 "qgspointcloudelevationpropertieswidget.h" | ||
#include "qgspointcloudrendererpropertieswidget.h" | ||
#include "qgsstyle.h" | ||
#include "qgsapplication.h" | ||
#include "qgsmaplayer.h" | ||
#include "qgspointcloudlayer.h" | ||
#include "qgspointcloudlayerelevationproperties.h" | ||
|
||
QgsPointCloudElevationPropertiesWidget::QgsPointCloudElevationPropertiesWidget( QgsPointCloudLayer *layer, QgsMapCanvas *canvas, QWidget *parent ) | ||
: QgsMapLayerConfigWidget( layer, canvas, parent ) | ||
{ | ||
setupUi( this ); | ||
|
||
mOffsetZSpinBox->setClearValue( 0 ); | ||
|
||
syncToLayer( layer ); | ||
|
||
connect( mOffsetZSpinBox, qgis::overload<double >::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloudElevationPropertiesWidget::onChanged ); | ||
} | ||
|
||
void QgsPointCloudElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) | ||
{ | ||
mLayer = qobject_cast< QgsPointCloudLayer * >( layer ); | ||
if ( !mLayer ) | ||
return; | ||
|
||
mBlockUpdates = true; | ||
mOffsetZSpinBox->setValue( static_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() )->zOffset() ); | ||
mBlockUpdates = false; | ||
} | ||
|
||
void QgsPointCloudElevationPropertiesWidget::apply() | ||
{ | ||
if ( !mLayer ) | ||
return; | ||
|
||
static_cast< QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() )->setZOffset( mOffsetZSpinBox->value() ); | ||
mLayer->trigger3DUpdate(); | ||
} | ||
|
||
void QgsPointCloudElevationPropertiesWidget::onChanged() | ||
{ | ||
if ( !mBlockUpdates ) | ||
emit widgetChanged(); | ||
} | ||
|
||
// | ||
// QgsPointCloudElevationPropertiesWidgetFactory | ||
// | ||
|
||
QgsPointCloudElevationPropertiesWidgetFactory::QgsPointCloudElevationPropertiesWidgetFactory( QObject *parent ) | ||
: QObject( parent ) | ||
{ | ||
setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mesh/Elevation.svg" ) ) ); | ||
setTitle( tr( "Elevation" ) ); | ||
} | ||
|
||
QgsMapLayerConfigWidget *QgsPointCloudElevationPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const | ||
{ | ||
return new QgsPointCloudElevationPropertiesWidget( qobject_cast< QgsPointCloudLayer * >( layer ), canvas, parent ); | ||
} | ||
|
||
bool QgsPointCloudElevationPropertiesWidgetFactory::supportLayerPropertiesDialog() const | ||
{ | ||
return true; | ||
} | ||
|
||
bool QgsPointCloudElevationPropertiesWidgetFactory::supportsStyleDock() const | ||
{ | ||
return true; | ||
} | ||
|
||
bool QgsPointCloudElevationPropertiesWidgetFactory::supportsLayer( QgsMapLayer *layer ) const | ||
{ | ||
return layer->type() == QgsMapLayerType::PointCloudLayer; | ||
} | ||
|
||
QString QgsPointCloudElevationPropertiesWidgetFactory::layerPropertiesPagePositionHint() const | ||
{ | ||
return QStringLiteral( "mOptsPage_Metadata" ); | ||
} | ||
|
65 changes: 65 additions & 0 deletions
65
src/app/pointcloud/qgspointcloudelevationpropertieswidget.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*************************************************************************** | ||
qgspointcloudelevationpropertieswidget.h | ||
--------------------- | ||
begin : December 2020 | ||
copyright : (C) 2020 by 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 QGSPOINTCLOUDELEVATIONPROPERTIESWIDGET_H | ||
#define QGSPOINTCLOUDELEVATIONPROPERTIESWIDGET_H | ||
|
||
#include "qgsmaplayerconfigwidget.h" | ||
#include "qgsmaplayerconfigwidgetfactory.h" | ||
|
||
#include "ui_qgspointcloudelevationpropertieswidgetbase.h" | ||
|
||
class QgsPointCloudLayer; | ||
|
||
class QgsPointCloudElevationPropertiesWidget : public QgsMapLayerConfigWidget, private Ui::QgsPointCloudElevationPropertiesWidgetBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
QgsPointCloudElevationPropertiesWidget( QgsPointCloudLayer *layer, QgsMapCanvas *canvas, QWidget *parent ); | ||
|
||
void syncToLayer( QgsMapLayer *layer ) override; | ||
|
||
public slots: | ||
void apply() override; | ||
|
||
private slots: | ||
|
||
void onChanged(); | ||
|
||
private: | ||
|
||
QgsPointCloudLayer *mLayer = nullptr; | ||
bool mBlockUpdates = false; | ||
|
||
}; | ||
|
||
|
||
class QgsPointCloudElevationPropertiesWidgetFactory : public QObject, public QgsMapLayerConfigWidgetFactory | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QgsPointCloudElevationPropertiesWidgetFactory( QObject *parent = nullptr ); | ||
|
||
QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const override; | ||
bool supportLayerPropertiesDialog() const override; | ||
bool supportsStyleDock() const override; | ||
bool supportsLayer( QgsMapLayer *layer ) const override; | ||
QString layerPropertiesPagePositionHint() const override; | ||
}; | ||
|
||
|
||
|
||
#endif // QGSPOINTCLOUDELEVATIONPROPERTIESWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/ui/pointcloud/qgspointcloudelevationpropertieswidgetbase.ui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>QgsPointCloudElevationPropertiesWidgetBase</class> | ||
<widget class="QWidget" name="QgsPointCloudElevationPropertiesWidgetBase"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<property name="leftMargin"> | ||
<number>0</number> | ||
</property> | ||
<property name="topMargin"> | ||
<number>0</number> | ||
</property> | ||
<property name="rightMargin"> | ||
<number>0</number> | ||
</property> | ||
<property name="bottomMargin"> | ||
<number>0</number> | ||
</property> | ||
<item> | ||
<widget class="QgsCollapsibleGroupBox" name="mCrsGroupBox_2"> | ||
<property name="focusPolicy"> | ||
<enum>Qt::StrongFocus</enum> | ||
</property> | ||
<property name="title"> | ||
<string>Elevation</string> | ||
</property> | ||
<property name="checkable"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="syncGroup" stdset="0"> | ||
<string notr="true">vectorgeneral</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout_2"> | ||
<item row="2" column="0"> | ||
<widget class="Line" name="line_3"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>Offset elevation</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QgsDoubleSpinBox" name="mOffsetZSpinBox"> | ||
<property name="decimals"> | ||
<number>6</number> | ||
</property> | ||
<property name="minimum"> | ||
<double>-99999999999.000000000000000</double> | ||
</property> | ||
<property name="maximum"> | ||
<double>99999999999.000000000000000</double> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>QgsCollapsibleGroupBox</class> | ||
<extends>QGroupBox</extends> | ||
<header>qgscollapsiblegroupbox.h</header> | ||
<container>1</container> | ||
</customwidget> | ||
<customwidget> | ||
<class>QgsDoubleSpinBox</class> | ||
<extends>QDoubleSpinBox</extends> | ||
<header>qgsdoublespinbox.h</header> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.