Skip to content

Commit

Permalink
use one spinbox instead of a slider
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Feb 10, 2021
1 parent 5de28dd commit dca57c9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 76 deletions.
1 change: 0 additions & 1 deletion src/3d/chunks/qgschunkedentity_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ void QgsChunkedEntity::update( QgsChunkNode *root, const SceneState &state )
if ( renderedCount > mPrimitivesBudget )
break;


// ensure we have child nodes (at least skeletons) available, if any
if ( node->childCount() == -1 )
{
Expand Down
39 changes: 6 additions & 33 deletions src/app/3d/qgspointcloud3dsymbolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,9 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
mRenderingStyleComboBox->setCurrentIndex( 0 );
mStackedWidget->setCurrentIndex( 0 );

mPointBudgetPercentageSlider->setMinimum( 0.0 );
mPointBudgetPercentageSlider->setMaximum( 100.0 );

mPointBudgetPercentage = std::min( 100.0, 100.0 * 1000000.0 / mLayer->pointCount() );
whileBlocking( mPointBudgetPercentageSlider ) ->setValue( mPointBudgetPercentage );
whileBlocking( mPointBudgetPercentageSpinBox ) ->setValue( mPointBudgetPercentage );

whileBlocking( mRenderedPointsSpinBox )->setMinimum( 0 );
whileBlocking( mRenderedPointsSpinBox )->setMaximum( mLayer->pointCount() + 1 );
whileBlocking( mRenderedPointsSpinBox )->setValue( 1000000 );
whileBlocking( mPointBudgetSpinBox )->setMinimum( 0 );
whileBlocking( mPointBudgetSpinBox )->setMaximum( mLayer->pointCount() + 1 );
whileBlocking( mPointBudgetSpinBox )->setValue( 1000000 );

if ( symbol )
setSymbol( symbol );
Expand All @@ -112,9 +105,8 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
connect( mColorRampShaderMaxEdit, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::minMaxChanged );

connect( mMaxScreenErrorSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, [&]() { emitChangedSignal(); } );
connect( mPointBudgetPercentageSlider, &QSlider::valueChanged, this, &QgsPointCloud3DSymbolWidget::pointBudgetSliderChanged );
connect( mPointBudgetPercentageSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::pointBudgetSpinBoxChanged );
connect( mShowBoundingBoxesCheckBox, &QCheckBox::stateChanged, [&]() { emitChangedSignal(); } );
connect( mPointBudgetSpinBox, qgis::overload<int>::of( &QSpinBox::valueChanged ), [&]() { emitChangedSignal(); } );

if ( !symbol ) // if we have a symbol, this was already handled in setSymbol above
rampAttributeChanged();
Expand Down Expand Up @@ -622,15 +614,12 @@ void QgsPointCloud3DSymbolWidget::setShowBoundingBoxes( bool showBoundingBoxes )

void QgsPointCloud3DSymbolWidget::setPointBudget( int budget )
{
mPointBudgetPercentage = 100.0 * budget / mLayer->pointCount();
whileBlocking( mPointBudgetPercentageSlider )->setValue( mPointBudgetPercentage );
whileBlocking( mPointBudgetPercentageSpinBox )->setValue( mPointBudgetPercentage );
whileBlocking( mRenderedPointsSpinBox )->setValue( budget );
whileBlocking( mPointBudgetSpinBox )->setValue( budget );
}

int QgsPointCloud3DSymbolWidget::pointBudget() const
{
return mPointBudgetPercentage * mLayer->pointCount() / 100.0f;
return mPointBudgetSpinBox->value();
}

double QgsPointCloud3DSymbolWidget::showBoundingBoxes() const
Expand All @@ -643,19 +632,3 @@ void QgsPointCloud3DSymbolWidget::connectChildPanels( QgsPanelWidget *parent )
parent->connectChildPanel( mClassifiedRendererWidget );
}

void QgsPointCloud3DSymbolWidget::pointBudgetSliderChanged( int value )
{
whileBlocking( mPointBudgetPercentageSpinBox )->setValue( value );
mPointBudgetPercentage = value;
mRenderedPointsSpinBox->setValue( mPointBudgetPercentage * mLayer->pointCount() / 100.0f );
emitChangedSignal();
}

void QgsPointCloud3DSymbolWidget::pointBudgetSpinBoxChanged( double percentage )
{
mPointBudgetPercentageSlider->setValue( percentage );
mPointBudgetPercentage = percentage;
mRenderedPointsSpinBox->setValue( mPointBudgetPercentage * mLayer->pointCount() / 100.0f );
emitChangedSignal();
}

4 changes: 1 addition & 3 deletions src/app/3d/qgspointcloud3dsymbolwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
void greenAttributeChanged();
void blueAttributeChanged();

void pointBudgetSliderChanged( int value );
void pointBudgetSpinBoxChanged( double budget );

signals:
void changed();
Expand All @@ -91,7 +89,7 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
void minMaxModified();
void setMinMaxValue( const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit );

double mPointBudgetPercentage;
int mPointBudget = 1000000;
};

#endif // QGSPOINTCLOUD3DSYMBOLWIDGET_H
60 changes: 21 additions & 39 deletions src/ui/3d/qgspointcloud3dsymbolwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,10 @@
</property>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<item row="2" column="1">
<widget class="QSlider" name="mPointBudgetPercentageSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Maximum number of rendered points:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelPointBudget">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QLabel" name="label">
<property name="text">
<string>Point budget percentage</string>
<string>Point budget</string>
</property>
</widget>
</item>
Expand All @@ -86,10 +66,26 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QSpinBox" name="mRenderedPointsSpinBox">
<item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="mPointBudgetSpinBox">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="maximum">
<number>99999999</number>
</property>
<property name="singleStep">
<number>10000</number>
</property>
<property name="value">
<number>1000000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Maximum screen space error</string>
</property>
</widget>
</item>
Expand All @@ -106,20 +102,6 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="mPointBudgetPercentageSpinBox">
<property name="maximum">
<double>100.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Maximum screen space error</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QgsDoubleSpinBox" name="mMaxScreenErrorSpinBox">
<property name="maximum">
Expand Down

0 comments on commit dca57c9

Please sign in to comment.