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 };
ccCloudLayersHelper::hasChanges
bool hasChanges() const
Definition: ccCloudLayersHelper.h:81
ccAsprsModel::AsprsItem
Definition: ccAsprsModel.h:59
ccAsprsModel.h
ecvColorTypes.h
ccCloudLayersHelper::mouseMove
void mouseMove(const CCVector2 &center, float squareDist, std::map< ScalarType, int > &affected)
Definition: ccCloudLayersHelper.cpp:239
ccCloudLayersHelper
Definition: ccCloudLayersHelper.h:46
ccCloudLayersHelper::~ccCloudLayersHelper
~ccCloudLayersHelper()
Definition: ccCloudLayersHelper.cpp:58
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ecvPointCloud.h:146
ccCloudLayersHelper::ccCloudLayersHelper
ccCloudLayersHelper(ecvMainAppInterface *app, ccPointCloud *cloud)
Definition: ccCloudLayersHelper.cpp:23
color
math::float4 color
Definition: LineSetBuffers.cpp:46
ccGLCameraParameters
OpenGL camera parameters.
Definition: ecvGenericDisplayTools.h:554
ccCloudLayersHelper::setScalarFieldIndex
void setScalarFieldIndex(int index)
Definition: ccCloudLayersHelper.cpp:90
Vector2Tpl< PointCoordinateType >
ecvMainAppInterface
Main application interface (for plugins)
Definition: ecvMainAppInterface.h:24
ccCloudLayersHelper::Parameters::anyPoints
bool anyPoints
Definition: ccCloudLayersHelper.h:84
ccCloudLayersHelper::restoreState
void restoreState()
Definition: ccCloudLayersHelper.cpp:195
ccCloudLayersHelper::setVisible
void setVisible(bool value)
Definition: ccCloudLayersHelper.cpp:99
CVGeom.h
ccCloudLayersHelper::apply
void apply(QList< ccAsprsModel::AsprsItem > &items)
Definition: ccCloudLayersHelper.cpp:109
ccCloudLayersHelper::Parameters::output
ccAsprsModel::AsprsItem * output
Definition: ccCloudLayersHelper.h:87
ccCloudLayersHelper::changeCode
void changeCode(const ccAsprsModel::AsprsItem &item, ScalarType oldCode)
Definition: ccCloudLayersHelper.cpp:143
ccCloudLayersHelper::Parameters::input
ccAsprsModel::AsprsItem * input
Definition: ccCloudLayersHelper.h:86
a
a[190]
Definition: essential_matrix_poly.h:19
ccCloudLayersHelper::Parameters::visiblePoints
bool visiblePoints
Definition: ccCloudLayersHelper.h:85
ccCloudLayersHelper::keepCurrentSFVisible
void keepCurrentSFVisible()
Definition: ccCloudLayersHelper.cpp:94
CVTypes.h
ccCloudLayersHelper::moveItem
int moveItem(const ccAsprsModel::AsprsItem &from, const ccAsprsModel::AsprsItem *to, bool redrawDisplay=false)
Definition: ccCloudLayersHelper.cpp:157
ccCloudLayersHelper::Parameters
Definition: ccCloudLayersHelper.h:83
ecvColor::RgbTpl
RGB color structure.
Definition: ecvColorTypes.h:49
Parameters
Algorithm parameters.
Definition: ecvPoissonReconDlg.cpp:43
ccCloudLayersHelper::getParameters
Parameters & getParameters()
Definition: ccCloudLayersHelper.cpp:333
ccCloudLayersHelper::saveState
void saveState()
Definition: ccCloudLayersHelper.cpp:184
ccCloudLayersHelper::projectCloud
void projectCloud(const ccGLCameraParameters &camera)
Definition: ccCloudLayersHelper.cpp:295
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
ecvGenericDisplayTools.h
ccCloudLayersHelper::cloud
ccPointCloud * cloud()
Definition: ccCloudLayersHelper.h:92
ccCloudLayersHelper::getScalarFields
QStringList getScalarFields()
Definition: ccCloudLayersHelper.cpp:79
ColorsTableType
Array of RGB colors for each point.
Definition: ecvAdvancedTypes.h:82