1 /***************************************************************************
2   qgspointcloud3dsymbolwidget.h
3   ------------------------------
4   Date                 : November 2020
5   Copyright            : (C) 2020 by Nedjima Belgacem
6   Email                : belgacem dot nedjima at gmail dot com
7  ***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 
16 #ifndef QGSPOINTCLOUD3DSYMBOLWIDGET_H
17 #define QGSPOINTCLOUD3DSYMBOLWIDGET_H
18 
19 #include "ui_qgspointcloud3dsymbolwidget.h"
20 #include "qgspointcloud3dsymbol.h"
21 
22 class QgsPointCloudLayer;
23 class QgsPointCloud3DSymbol;
24 class QgsPointCloudClassifiedRendererWidget;
25 
26 class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DSymbolWidget
27 {
28     Q_OBJECT
29 
30   public:
31     explicit QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *layer, QgsPointCloud3DSymbol *symbol, QWidget *parent = nullptr );
32 
33     void setSymbol( QgsPointCloud3DSymbol *symbol );
34 
35     void setDockMode( bool dockMode );
36 
37     QgsPointCloud3DSymbol *symbol() const;
38 
39     void setMaximumScreenError( double maxScreenError );
40     double maximumScreenError() const;
41 
42     void setShowBoundingBoxes( bool showBoundingBoxes );
43     bool showBoundingBoxes() const;
44 
45     void setPointBudget( double budget );
46     double pointBudget() const;
47 
48     void setPointCloudSize( int size );
49 
50     void connectChildPanels( QgsPanelWidget *parent );
51 
52   private slots:
53     void reloadColorRampShaderMinMax();
54     void onRenderingStyleChanged();
55     void emitChangedSignal();
56     void rampAttributeChanged();
57     void setMinMaxFromLayer();
58     void minMaxChanged();
59 
60     void mRedMinLineEdit_textChanged( const QString & );
61     void mRedMaxLineEdit_textChanged( const QString & );
62     void mGreenMinLineEdit_textChanged( const QString & );
63     void mGreenMaxLineEdit_textChanged( const QString & );
64     void mBlueMinLineEdit_textChanged( const QString & );
65     void mBlueMaxLineEdit_textChanged( const QString & );
66     void redAttributeChanged();
67     void greenAttributeChanged();
68     void blueAttributeChanged();
69 
70 
71   signals:
72     void changed();
73 
74   private:
75     void setColorRampMinMax( double min, double max );
76 
77   private:
78     int mBlockChangedSignals = 0;
79     int mDisableMinMaxWidgetRefresh = 0;
80     QgsPointCloudClassifiedRendererWidget *mClassifiedRendererWidget = nullptr;
81     QgsPointCloudLayer *mLayer = nullptr;
82 
83     bool mBlockMinMaxChanged = false;
84     bool mBlockSetMinMaxFromLayer = false;
85 
86     double mProviderMin = std::numeric_limits< double >::quiet_NaN();
87     double mProviderMax = std::numeric_limits< double >::quiet_NaN();
88 
89     void createValidators();
90     void setCustomMinMaxValues( QgsRgbPointCloud3DSymbol *r ) const;
91     void minMaxModified();
92     void setMinMaxValue( const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit );
93 
94     double mPointBudget = 1000000;
95 };
96 
97 #endif // QGSPOINTCLOUD3DSYMBOLWIDGET_H
98