ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
GeneralFiltersDlg.cpp
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 #include "GeneralFiltersDlg.h"
9 
10 // CV_DB_LIB
11 #include <ecvMainAppInterface.h>
12 #include <ecvPointCloud.h>
13 #include <ecvPolyline.h>
14 
16  : QDialog(app ? app->getActiveWindow() : 0),
18  m_app(app) {
19  setupUi(this);
20  buttonGroup->setExclusive(true);
21  buttonGroup->setId(curvatureRadioButton, 0);
22  buttonGroup->setId(xRadioButton, 1);
23  buttonGroup->setId(yRadioButton, 2);
24  buttonGroup->setId(zRadioButton, 3);
25 
26  buttonGroup_2->setExclusive(true);
27  buttonGroup_2->setId(curvaturePassRadioButton, 0);
28  buttonGroup_2->setId(xPassRadioButton, 1);
29  buttonGroup_2->setId(yPassRadioButton, 2);
30  buttonGroup_2->setId(zPassRadioButton, 3);
31 }
32 
34  // return the cloud currently selected in the combox box
35  if (selectPolylineCheckBox->isChecked()) {
36  return getPolylineFromCombo(polylineComboBox, m_app->dbRootObject());
37  } else {
38  return nullptr;
39  }
40 }
41 
42 void GeneralFiltersDlg::getContour(std::vector<CCVector3>& contour) {
43  contour.clear();
44  contour.push_back(CCVector3(ltxDoubleSpinBox->value(),
45  ltyDoubleSpinBox->value(),
46  ltzDoubleSpinBox->value()));
47  contour.push_back(CCVector3(rtxDoubleSpinBox->value(),
48  rtyDoubleSpinBox->value(),
49  rtzDoubleSpinBox->value()));
50  contour.push_back(CCVector3(lbxDoubleSpinBox->value(),
51  lbyDoubleSpinBox->value(),
52  lbzDoubleSpinBox->value()));
53  contour.push_back(CCVector3(rbxDoubleSpinBox->value(),
54  rbyDoubleSpinBox->value(),
55  rbzDoubleSpinBox->value()));
56 }
57 
59  if (m_app) {
60  // add list of labels to the combo-boxes
61  ccHObject::Container labels;
62  if (m_app->dbRootObject())
63  m_app->dbRootObject()->filterChildren(labels, true,
65 
66  unsigned polylineCount = 0;
67  polylineComboBox->clear();
68  for (size_t i = 0; i < labels.size(); ++i) {
69  if (labels[i]->isA(CV_TYPES::POLY_LINE)) // as filterChildren only
70  // test 'isKindOf'
71  {
72  QString name = getEntityName(labels[i]);
73  QVariant uniqueID(labels[i]->getUniqueID());
74  polylineComboBox->addItem(name, uniqueID);
75  ++polylineCount;
76  }
77  }
78 
79  if (polylineCount >= 1 && m_app) {
80  // return the 2D Label currently selected in the combox box
81  selectPolylineCheckBox->setChecked(true);
82  polylineComboBox->setEnabled(true);
83  } else {
84  selectPolylineCheckBox->setChecked(false);
85  polylineComboBox->setEnabled(false);
86  }
87  }
88 }
89 
90 QString GeneralFiltersDlg::getEntityName(ccHObject* obj) {
91  if (!obj) {
92  assert(false);
93  return QString();
94  }
95 
96  QString name = obj->getName();
97  if (name.isEmpty()) name = tr("unnamed");
98  name += QString(" [ID %1]").arg(obj->getUniqueID());
99 
100  return name;
101 }
102 
103 ccPolyline* GeneralFiltersDlg::getPolylineFromCombo(QComboBox* comboBox,
104  ccHObject* dbRoot) {
105  assert(comboBox && dbRoot);
106  if (!comboBox || !dbRoot) {
107  return nullptr;
108  }
109 
110  // return the cloud currently selected in the combox box
111  int index = comboBox->currentIndex();
112  if (index < 0) {
113  return nullptr;
114  }
115  unsigned uniqueID = comboBox->itemData(index).toUInt();
116  ccHObject* item = dbRoot->find(uniqueID);
117  if (!item || !item->isA(CV_TYPES::POLY_LINE)) {
118  return nullptr;
119  }
120  return static_cast<ccPolyline*>(item);
121 }
122 
123 const QString GeneralFiltersDlg::getComparisonField(float& minValue,
124  float& maxValue) {
125  int index = tab->currentIndex();
126  if (index == 0) {
127  minValue = static_cast<float>(minLimitSpinBox->value());
128  maxValue = static_cast<float>(maxLimitSpinBox->value());
129  return buttonGroup_2->checkedButton()->text();
130  } else if (index == 1) {
131  minValue = static_cast<float>(minMagnitudeSpinBox->value());
132  maxValue = static_cast<float>(maxMagnitudeSpinBox->value());
133  return buttonGroup->checkedButton()->text();
134  } else {
135  assert(false);
136  return "";
137  }
138 }
139 
140 void GeneralFiltersDlg::getComparisonTypes(QStringList& types) {
141  types.clear();
142  if (equalCheckBox->isChecked()) {
143  if (greaterCheckBox->isChecked()) {
144  types << "GE";
145  }
146 
147  if (lessThanCheckBox->isChecked()) {
148  types << "LE";
149  }
150 
151  if (!greaterCheckBox->isChecked() && !lessThanCheckBox->isChecked()) {
152  types << "EQ";
153  }
154  } else {
155  if (greaterCheckBox->isChecked()) {
156  types << "GT";
157  }
158 
159  if (lessThanCheckBox->isChecked()) {
160  types << "LT";
161  }
162  }
163 }
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
std::string name
void getComparisonTypes(QStringList &types)
void getContour(std::vector< CCVector3 > &contour)
ccPolyline * getPolyline()
const QString getComparisonField(float &minValue, float &maxValue)
GeneralFiltersDlg(ecvMainAppInterface *app)
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
virtual unsigned getUniqueID() const
Returns object unique ID.
Definition: ecvObject.h:86
bool isA(CV_CLASS_ENUM type) const
Definition: ecvObject.h:131
Colored polyline.
Definition: ecvPolyline.h:24
Main application interface (for plugins)
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
@ POLY_LINE
Definition: CVTypes.h:112