31 #include <unordered_set>
35 Ui::FilterByLabelDialog(),
41 connect(splitPushButton, &QAbstractButton::clicked,
this,
43 connect(exportSelectedToolButton, &QAbstractButton::clicked,
this,
45 connect(exportUnselectedToolButton, &QAbstractButton::clicked,
this,
47 connect(selectAllRadioButton, &QAbstractButton::clicked,
this,
49 connect(unselectAllRadioButton, &QAbstractButton::clicked,
this,
51 connect(cancelToolButton, &QAbstractButton::clicked,
this,
53 connect(toggleSelectedToolButton, &QAbstractButton::clicked,
this,
68 labelGroupBox->setEnabled(
true);
73 std::unordered_set<size_t> labels_set;
74 for (
unsigned j = 0; j < pc->
size(); j++) {
76 size_t valueId =
static_cast<size_t>(value);
77 if (value - valueId != 0) {
79 "[ecvFilterByLabelDlg::start] only support int type scalar "
85 labels_set.insert(valueId);
87 m_labels.assign(labels_set.begin(), labels_set.end());
99 if (gridLayout && !gridLayout->isEmpty()) {
103 for (
size_t i = 0; i <
m_labels.size(); ++i) {
106 QCheckBox* labelCheckBox =
new QCheckBox(labelGroupBox);
107 labelCheckBox->setObjectName(QString::fromUtf8(labelName.c_str()));
108 labelCheckBox->setText(QString::fromUtf8(labelName.c_str()));
114 labelCheckBox->setChecked(isChecked);
117 col = *
m_toFilter.second->getScalarValueColor(
118 static_cast<ScalarType
>(label));
123 QString styleSheet = QString(
"background-color: rgb(%1, %2, %3, %4)")
128 labelCheckBox->setStyleSheet(styleSheet);
135 int rowIndex =
static_cast<int>(i / 2);
136 int colIndex =
static_cast<int>(i % 2);
138 gridLayout->addWidget(labelCheckBox, rowIndex, colIndex, 1, 1,
139 Qt::AlignLeft | Qt::AlignVCenter);
154 std::vector<ScalarType>& filteredClasses) {
155 if (!filteredClasses.empty()) {
156 filteredClasses.clear();
158 QList<QCheckBox*> list = labelGroupBox->findChildren<QCheckBox*>();
160 foreach (QCheckBox* ncheckBox, list) {
161 if (ncheckBox && ncheckBox->isChecked()) {
164 filteredClasses.push_back(
static_cast<ScalarType
>(index));
170 bool state = selectAllRadioButton->isChecked();
171 QList<QCheckBox*> list = labelGroupBox->findChildren<QCheckBox*>();
173 foreach (QCheckBox* ncheckBox, list) {
175 ncheckBox->setChecked(state);
203 CVLog::Warning(tr(
"Entity [%1] scalar field value range is bigger "
210 int pointNumber =
static_cast<int>(pc->
size());
211 if (pointNumber < 10) {
213 "Skip entity [%1] as the point number of it is "
214 "%2 lower than min limit 10!")
215 .arg(entity->
getName(), pointNumber));
232 std::vector<ScalarType> selectedLabels;
234 if (selectedLabels.empty()) {
236 "[ecvFilterByLabelDlg::apply] no filter labels selected, "
237 "please select some and try again!");
243 assert(outSfIdx >= 0);
298 results.push_back(resultInside);
307 results.push_back(resultOutside);
310 if (!results.empty()) {
312 tr(
"Previously selected entities (sources) have been hidden!"));
324 if (gridLayout && !gridLayout->isEmpty()) {
326 while ((item = layout->takeAt(0)) != 0) {
328 if (item->widget()) {
329 delete item->widget();
333 QLayout* childLayout = item->layout();
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
static MainWindow * TheInstance()
Returns the unique instance of this object.
ccDBRoot * db()
Returns real 'dbRoot' object.
void addToDB(const QStringList &filenames, QString fileFilter=QString(), bool displayDialog=true)
void selectEntities(std::unordered_set< int > entIDs)
Selects multiple entities at once (shortcut to the other version)
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual void invertVisibilityArray()
Inverts the visibility array.
virtual void unallocateVisibilityArray()
Erases the points visibility information.
static ccMesh * ToMesh(ccHObject *obj)
Converts current object to ccMesh (if possible)
static ccGenericPointCloud * ToGenericPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccGenericPointCloud.
static ccSubMesh * ToSubMesh(ccHObject *obj)
Converts current object to ccSubMesh (if possible)
Hierarchical CLOUDVIEWER Object.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
ccMesh * createNewMeshFromSelection(bool removeSelectedTriangles, std::vector< int > *newIndexesOfRemainingTriangles=nullptr, bool withChildEntities=false)
Creates a new mesh with the selected vertices only.
virtual QString getName() const
Returns object name.
bool isA(CV_CLASS_ENUM type) const
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
bool isKindOf(CV_CLASS_ENUM type) const
Generic overlay dialog interface.
virtual void stop(bool accepted)
Stops process/dialog.
virtual bool start()
Starts process.
virtual bool linkWith(QWidget *win)
Links the overlay dialog with a MDI window.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void hidePointsByScalarValue(ScalarType minVal, ScalarType maxVal)
Hides points whose scalar values falls into an interval.
int getCurrentDisplayedScalarFieldIndex() const
Returns the currently displayed scalar field index (or -1 if none)
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
ccPointCloud * filterPointsByScalarValue(ScalarType minVal, ScalarType maxVal, bool outside=false)
Filters out points whose scalar values falls into an interval.
A scalar field associated to display-related parameters.
const Range & displayRange() const
Access to the range of displayed values.
ccSubMesh * createNewSubMeshFromSelection(bool removeSelectedTriangles, const std::vector< int > &selectedTriangleIndexes, IndexMap *newRemainingTriangleIndexes=nullptr)
Creates a new sub mesh with the visible vertices only.
void setCurrentOutScalarField(int index)
Sets the OUTPUT scalar field.
unsigned size() const override
A simple scalar field (to be associated to a point cloud)
ScalarType & getValue(std::size_t index)
unsigned currentSize() const
bool setInputEntity(ccHObject *entity)
Adds an entity to the 'selected' entities set.
virtual bool start() override
Starts process.
EntityAndVerticesType m_toFilter
void clearLayoutWidgets(QLayout *layout)
std::pair< ccHObject *, ccPointCloud * > EntityAndVerticesType
virtual ~ecvFilterByLabelDlg()
ecvFilterByLabelDlg(QWidget *parent=nullptr)
Default constructor.
void toggleSelectedVisibility()
virtual void stop(bool state) override
Stops process/dialog.
virtual bool linkWith(QWidget *win) override
Links the overlay dialog with a MDI window.
void createCheckboxesWithLabels()
void onExportUnSelected()
void getSelectedFilterClasses(std::vector< ScalarType > &filteredClasses)
std::vector< size_t > m_labels
cloudViewer object type flags
static std::map< size_t, std::string > SemanticMap
static int FindindexByValue(const std::string &value)