Debian Codegraph @

plugins/core/Standard/qCloudLayers/include/ccCloudLayersHelper.h

raw
1 #pragma once
2
3 //##########################################################################
4 //# #
5 //# CLOUDCOMPARE PLUGIN: qCloudLayers #
6 //# #
7 //# This program is free software; you can redistribute it and/or modify #
8 //# it under the terms of the GNU General Public License as published by #
9 //# the Free Software Foundation; version 2 of the License. #
10 //# #
11 //# This program is distributed in the hope that it will be useful, #
12 //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 //# GNU General Public License for more details. #
15 //# #
16 //# COPYRIGHT: WigginsTech 2022 #
17 //# #
18 //##########################################################################
19
20 #include "ccAsprsModel.h"
21
22 //CC
23 #include <CCTypes.h>
24 #include <CCGeom.h>
25 #include <ccColorTypes.h>
26 #include <ccGenericGLDisplay.h>
27
28 //QT
29 #include <QColor>
30
31 //std
32 #include <vector>
33
34 class ccPointCloud;
35 class QStringList;
36 class ccMainAppInterface;
37 class RGBAColorsTableType;
38
39 class ccCloudLayersHelper
40 {
41 public:
42 ccCloudLayersHelper(ccMainAppInterface* app, ccPointCloud* cloud);
43 ~ccCloudLayersHelper();
44
45 QStringList getScalarFields();
46 void setScalarFieldIndex(int index);
47
48 // set colors alpha to MAX
49 void setVisible(bool value);
50
51 // apply visibility and colors
52 void apply(QList<ccAsprsModel::AsprsItem>& items);
53
54 // apply visibility and color return affected count
55 int apply(ccAsprsModel::AsprsItem& item, bool redrawDisplay = false);
56
57 // asprs item code changed
58 void changeCode(const ccAsprsModel::AsprsItem& item, ScalarType oldCode);
59
60 // set scalar code to zero return affected count
61 int moveItem(const ccAsprsModel::AsprsItem& from, const ccAsprsModel::AsprsItem* to, bool redrawDisplay = false);
62
63 // save color and codes
64 void saveState();
65
66 // restore initial colors and codes
67 void restoreState();
68
69 void mouseMove(const CCVector2& center, float squareDist, std::map<ScalarType, int>& affected);
70 void projectCloud(const ccGLCameraParameters& camera);
71 bool hasChanges() const { return m_modified; }
72
73 struct Parameters
74 {
75 bool anyPoints = false;
76 bool visiblePoints = false;
77 ccAsprsModel::AsprsItem* input = nullptr;
78 ccAsprsModel::AsprsItem* output = nullptr;
79 };
80
81 Parameters& getParameters();
82
83 inline ccPointCloud* cloud() { return m_cloud; }
84
85 void keepCurrentSFVisible();
86
87 private: // methods
88 void project(const ccGLCameraParameters& camera, unsigned start, unsigned end);
89 static PointCoordinateType ComputeSquaredEuclideanDistance(const CCVector2& a, const CCVector2& b);
90
91 private: // variables
92 ccMainAppInterface* m_app;
93 ccPointCloud* m_cloud;
94 RGBAColorsTableType* m_formerCloudColors;
95 bool m_formerCloudColorsWereShown;
96 bool m_formerCloudSFWasShown;
97 Parameters m_parameters;
98
99 unsigned m_scalarFieldIndex;
100 bool m_modified;
101
102 ccGLCameraParameters m_cameraParameters;
103 std::vector<CCVector2> m_projectedPoints;
104 std::vector<bool> m_pointInFrustum;
105
106 struct CloudState
107 {
108 void update(ScalarType code, ccColor::Rgb color)
109 {
110 this->code = code;
111 this->color = color;
112 }
113
114 ScalarType code = 0;
115 ccColor::Rgb color = ccColor::blackRGB;
116 };
117
118 std::vector<CloudState> m_cloudState;
119
120 };
121