Skip to content
Permalink
Browse files

More point cloud renderer widget framework

  • Loading branch information
nyalldawson committed Nov 16, 2020
1 parent 090afdd commit 055716064f90d2904f0983f8cfe0f53af95454f2
@@ -0,0 +1,45 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/pointcloud/qgspointcloudrendererpropertieswidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsPointCloudRendererPropertiesWidget : QgsPanelWidget
{
%Docstring
A generic widget for setting the 2D renderer for a point cloud layer.

.. versionadded:: 3.18
%End

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

QgsPointCloudRendererPropertiesWidget( QgsPointCloudLayer *layer, QgsStyle *style, QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsPointCloudRendererPropertiesWidget, associated with the specified ``layer`` and ``style`` database.
%End

void setContext( const QgsSymbolWidgetContext &context );
%Docstring
Sets the ``context`` in which the widget is shown, e.g., the associated map canvas and expression contexts.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/pointcloud/qgspointcloudrendererpropertieswidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,94 @@
/***************************************************************************
qgspointcloudrendererpropertieswidget.cpp
---------------------
begin : November 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 "qgspointcloudrendererpropertieswidget.h"

#include "qgspointcloudrendererregistry.h"
#include "qgsapplication.h"
#include "qgssymbolwidgetcontext.h"
#include "qgspointcloudrendererwidget.h"

static bool _initRenderer( const QString &name, QgsPointCloudRendererWidgetFunc f, const QString &iconName = QString() )
{
QgsPointCloudRendererRegistry *reg = QgsApplication::pointCloudRendererRegistry();
QgsPointCloudRendererAbstractMetadata *am = reg->rendererMetadata( name );
if ( !am )
return false;
QgsPointCloudRendererMetadata *m = dynamic_cast<QgsPointCloudRendererMetadata *>( am );
if ( !m )
return false;

m->setWidgetFunction( f );

if ( !iconName.isEmpty() )
{
m->setIcon( QgsApplication::getThemeIcon( iconName ) );
}

QgsDebugMsgLevel( "Set for " + name, 2 );
return true;
}

static void _initRendererWidgetFunctions()
{
static bool sInitialized = false;
if ( sInitialized )
return;

//_initRenderer( QStringLiteral( "rgb" ), QgsSingleSymbolRendererWidget::create, QStringLiteral( "rendererSingleSymbol.svg" ) );

sInitialized = true;
}

QgsPointCloudRendererPropertiesWidget::QgsPointCloudRendererPropertiesWidget( QgsPointCloudLayer *layer, QgsStyle *style, QWidget *parent )
: QgsPanelWidget( parent )
, mLayer( layer )
, mStyle( style )

{
setupUi( this );
mLayerRenderingGroupBox->setSettingGroup( QStringLiteral( "layerRenderingGroupBox" ) );

layout()->setContentsMargins( 0, 0, 0, 0 );

// initialize registry's widget functions
_initRendererWidgetFunctions();

QgsPointCloudRendererRegistry *reg = QgsApplication::pointCloudRendererRegistry();
const QStringList renderers = reg->renderersList();
for ( const QString &name : renderers )
{
if ( QgsPointCloudRendererAbstractMetadata *m = reg->rendererMetadata( name ) )
cboRenderers->addItem( m->icon(), m->visibleName(), name );
}

cboRenderers->setCurrentIndex( -1 ); // set no current renderer

// connect layer opacity slider and spin box
//connect( cboRenderers, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsPointCloudRendererPropertiesWidget::rendererChanged );

//syncToLayer();
}


void QgsPointCloudRendererPropertiesWidget::setContext( const QgsSymbolWidgetContext &context )
{
mMapCanvas = context.mapCanvas();
mMessageBar = context.messageBar();
if ( mActiveWidget )
{
mActiveWidget->setContext( context );
}
}

@@ -0,0 +1,66 @@
/***************************************************************************
qgspointcloudrendererpropertieswidget.h
---------------------
begin : November 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 QGSPOINTCLOUDRENDERERPROPERTIESWIDGET_H
#define QGSPOINTCLOUDRENDERERPROPERTIESWIDGET_H

#include "qgis_sip.h"
#include "qgis_gui.h"

#include "ui_qgspointcloudrendererpropsdialogbase.h"

class QgsPointCloudLayer;
class QgsStyle;
class QgsPointCloudRendererWidget;
class QgsMapCanvas;
class QgsSymbolWidgetContext;
class QgsMessageBar;

/**
* \ingroup gui
* A generic widget for setting the 2D renderer for a point cloud layer.
*
* \since QGIS 3.18
*/
class GUI_EXPORT QgsPointCloudRendererPropertiesWidget : public QgsPanelWidget, private Ui::QgsPointCloudRendererPropsDialogBase
{
Q_OBJECT

public:

/**
* Constructor for QgsPointCloudRendererPropertiesWidget, associated with the specified \a layer and \a style database.
*/
QgsPointCloudRendererPropertiesWidget( QgsPointCloudLayer *layer, QgsStyle *style, QWidget *parent SIP_TRANSFERTHIS = nullptr );

/**
* Sets the \a context in which the widget is shown, e.g., the associated map canvas and expression contexts.
*/
void setContext( const QgsSymbolWidgetContext &context );

private:

QgsPointCloudLayer *mLayer = nullptr;
QgsStyle *mStyle = nullptr;

QgsPointCloudRendererWidget *mActiveWidget = nullptr;

QgsMapCanvas *mMapCanvas = nullptr;
QgsMessageBar *mMessageBar = nullptr;

};


#endif // QGSPOINTCLOUDRENDERERPROPERTIESWIDGET_H
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsPointCloudRendererPropsDialogBase</class>
<widget class="QgsPanelWidget" name="QgsPointCloudRendererPropsDialogBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>371</width>
<height>501</height>
</rect>
</property>
<property name="windowTitle">
<string>Renderer Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<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="QStackedWidget" name="mainStack">
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="cboRenderers"/>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="pageNoWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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="QLabel" name="label">
<property name="text">
<string>This renderer doesn't implement a graphical interface.</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mLayerRenderingGroupBox">
<property name="title">
<string>Layer Rendering</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="collapsed" stdset="0">
<bool>true</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblTransparency">
<property name="text">
<string>Opacity</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QgsOpacityWidget" name="mOpacityWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblBlend">
<property name="text">
<string>Blending mode</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsOpacityWidget</class>
<extends>QWidget</extends>
<header>qgsopacitywidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsPanelWidget</class>
<extends>QWidget</extends>
<header>qgspanelwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cboRenderers</tabstop>
<tabstop>mOpacityWidget</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

0 comments on commit 0557160

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