ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccCloudLayersHelper.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // ##########################################################################
11 // # #
12 // # CloudViewer PLUGIN: qCloudLayers #
13 // # #
14 // # This program is free software; you can redistribute it and/or modify #
15 // # it under the terms of the GNU General Public License as published by #
16 // # the Free Software Foundation; version 2 of the License. #
17 // # #
18 // # This program is distributed in the hope that it will be useful, #
19 // # but WITHOUT ANY WARRANTY; without even the implied warranty of #
20 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21 // # GNU General Public License for more details. #
22 // # #
23 // # COPYRIGHT: WigginsTech 2022 #
24 // # #
25 // ##########################################################################
26 
27 #include "ccAsprsModel.h"
28 
29 // CC
30 #include <CVGeom.h>
31 #include <CVTypes.h>
32 #include <ecvColorTypes.h>
33 #include <ecvGenericDisplayTools.h>
34 
35 // QT
36 #include <QColor>
37 #include <QStringList>
38 
39 // std
40 #include <vector>
41 
42 class ccPointCloud;
44 class ColorsTableType;
45 
47 public:
50 
51  QStringList getScalarFields();
52  void setScalarFieldIndex(int index);
53 
54  // set colors alpha to MAX
55  void setVisible(bool value);
56 
57  // apply visibility and colors
58  void apply(QList<ccAsprsModel::AsprsItem>& items);
59 
60  // apply visibility and color return affected count
61  int apply(ccAsprsModel::AsprsItem& item, bool redrawDisplay = false);
62 
63  // asprs item code changed
64  void changeCode(const ccAsprsModel::AsprsItem& item, ScalarType oldCode);
65 
66  // set scalar code to zero return affected count
67  int moveItem(const ccAsprsModel::AsprsItem& from,
68  const ccAsprsModel::AsprsItem* to,
69  bool redrawDisplay = false);
70 
71  // save color and codes
72  void saveState();
73 
74  // restore initial colors and codes
75  void restoreState();
76 
77  void mouseMove(const CCVector2& center,
78  float squareDist,
79  std::map<ScalarType, int>& affected);
80  void projectCloud(const ccGLCameraParameters& camera);
81  bool hasChanges() const { return m_modified; }
82 
83  struct Parameters {
84  bool anyPoints = false;
85  bool visiblePoints = false;
88  };
89 
91 
92  inline ccPointCloud* cloud() { return m_cloud; }
93 
94  void keepCurrentSFVisible();
95 
96 private: // methods
97  void project(ccGLCameraParameters camera, unsigned start, unsigned end);
98  static PointCoordinateType ComputeSquaredEuclideanDistance(
99  const CCVector2& a, const CCVector2& b);
100 
101 private: // variables
102  ecvMainAppInterface* m_app;
103  ccPointCloud* m_cloud;
104  ColorsTableType* m_formerCloudColors;
105  bool m_formerCloudColorsWereShown;
106  bool m_formerCloudSFWasShown;
107  Parameters m_parameters;
108 
109  unsigned m_scalarFieldIndex;
110  bool m_modified;
111 
112  ccGLCameraParameters m_cameraParameters;
113  std::vector<CCVector2> m_projectedPoints;
114  std::vector<bool> m_pointInFrustum;
115 
116  struct CloudState {
117  public:
118  CloudState() {}
119 
120  void update(ScalarType code, ecvColor::Rgb color) {
121  this->code = code;
122  this->color = color;
123  }
124 
125  ScalarType code;
127  };
128 
129  std::vector<CloudState> m_cloudState;
130 };
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
math::float4 color
Array of RGB colors for each point.
void projectCloud(const ccGLCameraParameters &camera)
void apply(QList< ccAsprsModel::AsprsItem > &items)
int moveItem(const ccAsprsModel::AsprsItem &from, const ccAsprsModel::AsprsItem *to, bool redrawDisplay=false)
void mouseMove(const CCVector2 &center, float squareDist, std::map< ScalarType, int > &affected)
void changeCode(const ccAsprsModel::AsprsItem &item, ScalarType oldCode)
void setScalarFieldIndex(int index)
ccCloudLayersHelper(ecvMainAppInterface *app, ccPointCloud *cloud)
void setVisible(bool value)
ccPointCloud * cloud()
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
RGB color structure.
Definition: ecvColorTypes.h:49
Main application interface (for plugins)
Algorithm parameters.
ccAsprsModel::AsprsItem * output
ccAsprsModel::AsprsItem * input
OpenGL camera parameters.