Skip to content

Commit

Permalink
Use nicer approach to populating and handling symbol choice combobox
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 4, 2020
1 parent 235a71e commit e840297
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 50 deletions.
16 changes: 11 additions & 5 deletions src/app/3d/qgspointcloud3dsymbolwidget.cpp
Expand Up @@ -18,6 +18,7 @@
#include "qgspointcloudlayer.h"
#include "qgspointcloud3dsymbol.h"
#include "qgspointcloudlayer3drenderer.h"
#include "qgsapplication.h"

QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *layer, QgsPointCloud3DSymbol *symbol, QWidget *parent )
: QWidget( parent )
Expand All @@ -29,6 +30,11 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la

mRenderingParameterComboBox->setLayer( layer );

mRenderingStyleComboBox->addItem( tr( "No Rendering" ), QgsPointCloud3DSymbol::NoRendering );
mRenderingStyleComboBox->addItem( tr( "Single Color" ), QgsPointCloud3DSymbol::SingleColor );
mRenderingStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "styleicons/singlebandpseudocolor.svg" ) ), tr( "Attribute by Ramp" ), QgsPointCloud3DSymbol::ColorRamp );
mRenderingStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "styleicons/multibandcolor.svg" ) ), tr( "RGB" ), QgsPointCloud3DSymbol::RgbRendering );

if ( symbol )
setSymbol( symbol );

Expand All @@ -40,7 +46,7 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la

void QgsPointCloud3DSymbolWidget::setSymbol( QgsPointCloud3DSymbol *symbol )
{
mRenderingStyleComboBox->setCurrentIndex( symbol ? symbol->renderingStyle() : 0 );
mRenderingStyleComboBox->setCurrentIndex( mRenderingStyleComboBox->findData( symbol->renderingStyle() ) );
if ( symbol )
{
switch ( symbol->renderingStyle() )
Expand Down Expand Up @@ -73,13 +79,13 @@ void QgsPointCloud3DSymbolWidget::setSymbol( QgsPointCloud3DSymbol *symbol )
}
}

onRenderingStyleChanged( mRenderingStyleComboBox->currentIndex() );
onRenderingStyleChanged();
}

QgsPointCloud3DSymbol *QgsPointCloud3DSymbolWidget::symbol() const
{
QgsPointCloud3DSymbol *retSymb = nullptr;
QgsPointCloud3DSymbol::RenderingStyle renderingStyle = static_cast< QgsPointCloud3DSymbol::RenderingStyle >( mRenderingStyleComboBox->currentIndex() );
QgsPointCloud3DSymbol::RenderingStyle renderingStyle = static_cast< QgsPointCloud3DSymbol::RenderingStyle >( mRenderingStyleComboBox->currentData().toInt() );

switch ( renderingStyle )
{
Expand Down Expand Up @@ -131,9 +137,9 @@ void QgsPointCloud3DSymbolWidget::reloadColorRampShaderMinMax()
mColorRampShaderWidget->classify();
}

void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged( int current )
void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged()
{
QgsPointCloud3DSymbol::RenderingStyle currentStyle = static_cast< QgsPointCloud3DSymbol::RenderingStyle >( current );
const QgsPointCloud3DSymbol::RenderingStyle currentStyle = static_cast< QgsPointCloud3DSymbol::RenderingStyle>( mRenderingStyleComboBox->currentData().toInt() );
switch ( currentStyle )
{
case QgsPointCloud3DSymbol::RenderingStyle::NoRendering:
Expand Down
3 changes: 2 additions & 1 deletion src/app/3d/qgspointcloud3dsymbolwidget.h
Expand Up @@ -17,6 +17,7 @@
#define QGSPOINTCLOUD3DSYMBOLWIDGET_H

#include "ui_qgspointcloud3dsymbolwidget.h"
#include "qgspointcloud3dsymbol.h"

class QgsPointCloudLayer;
class QgsPointCloud3DSymbol;
Expand All @@ -34,7 +35,7 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS

private slots:
void reloadColorRampShaderMinMax();
void onRenderingStyleChanged( int current );
void onRenderingStyleChanged();

signals:
void changed();
Expand Down
44 changes: 0 additions & 44 deletions src/ui/3d/qgspointcloud3dsymbolwidget.ui
Expand Up @@ -11,50 +11,6 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2" colspan="2">
<widget class="QComboBox" name="mRenderingStyleComboBox">
<item>
<property name="text">
<string>No Rendering</string>
</property>
</item>
<item>
<property name="text">
<string>Single color</string>
</property>
</item>
<item>
<property name="text">
<string>Color ramp</string>
</property>
</item>
<item>
<property name="text">
<string>RGB rendering</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0" colspan="4">
<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>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Rendering style</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
Expand Down

0 comments on commit e840297

Please sign in to comment.