21 m_scalarFieldsUserInputs[0] = {firstScalarFieldComboBox, firstScalarFieldScaleSpinBox, firstScalarFieldOffsetSpinBox};
22 m_scalarFieldsUserInputs[1] = {secondScalarFieldComboBox, secondScalarFieldScaleSpinBox, secondScalarFieldOffsetSpinBox};
23 m_scalarFieldsUserInputs[2] = {thirdScalarFieldComboBox, thirdScalarFieldScaleSpinBox, thirdScalarFieldOffsetSpinBox};
26 &QRadioButton::clicked,
28 &LasExtraScalarFieldCard::onRadioButton1Selected);
31 &QRadioButton::clicked,
33 &LasExtraScalarFieldCard::onRadioButton2Selected);
36 &QRadioButton::clicked,
38 &LasExtraScalarFieldCard::onRadioButton3Selected);
40 connect(firstScalarFieldComboBox,
41 &QComboBox::currentTextChanged,
43 [
this](
const QString& text)
45 if (radioButton1->isChecked())
47 nameEdit->setText(text);
51 advancedOptionFrame->hide();
52 scaledCheckBox->setChecked(
false);
53 scalingOptionGroup->setEnabled(
false);
55 connect(advancedOptionsButton, &QPushButton::clicked,
this, &LasExtraScalarFieldCard::onToggleAdvancedOptionsClicked);
56 connect(scaledCheckBox, &QCheckBox::stateChanged, scalingOptionGroup, &QGroupBox::setEnabled);
63 radioButton1->setChecked(
true);
64 emit radioButton1->clicked(
true);
67 if (advancedOptionsButton->isChecked())
69 advancedOptionsButton->setChecked(
false);
70 emit advancedOptionsButton->clicked();
73 #ifdef CC_CORE_LIB_USES_DOUBLE
74 const char* defaultType =
"float64";
76 const char* defaultType =
"float32";
78 typeComboBox->setCurrentText(defaultType);
80 firstScalarFieldComboBox->setCurrentIndex(0);
81 secondScalarFieldComboBox->setCurrentIndex(0);
82 thirdScalarFieldComboBox->setCurrentIndex(0);
87 assert(field.
ccName[0] == 0);
89 nameEdit->setText(field.
name);
93 radioButton1->setChecked(
true);
94 emit radioButton1->clicked(
true);
99 radioButton2->setChecked(
true);
100 emit radioButton2->clicked(
true);
107 radioButton3->setChecked(
true);
108 emit radioButton3->clicked(
true);
123 scaledCheckBox->setChecked(
false);
124 emit scaledCheckBox->stateChanged(
false);
128 scaledCheckBox->setChecked(
true);
129 emit scaledCheckBox->stateChanged(
true);
133 m_scalarFieldsUserInputs[i].scaleSpinBox->setValue(field.
scales[i]);
139 emit scaledCheckBox->stateChanged(
true);
143 m_scalarFieldsUserInputs[i].offsetSpinBox->setValue(field.
offsets[i]);
150 typeComboBox->setCurrentText(
"uint8");
153 typeComboBox->setCurrentText(
"uint16");
156 typeComboBox->setCurrentText(
"uint32");
159 typeComboBox->setCurrentText(
"uint64");
162 typeComboBox->setCurrentText(
"int8");
165 typeComboBox->setCurrentText(
"int16");
167 case LasExtraScalarField::DataType::i32:
168 typeComboBox->setCurrentText(
"int32");
171 typeComboBox->setCurrentText(
"int64");
173 case LasExtraScalarField::DataType::f32:
174 typeComboBox->setCurrentText(
"float32");
176 case LasExtraScalarField::DataType::f64:
177 typeComboBox->setCurrentText(
"float64");
180 typeComboBox->setCurrentText(
"float32");
187 if (nameEdit->text().isEmpty())
192 const std::string stdName = nameEdit->text().toStdString();
195 const std::string stdDescription = descriptionEdit->text().toStdString();
204 CVLog::Warning(
"[LAS] Extra Scalar field name '%s' is too long and will be truncated",
209 CVLog::Warning(
"[LAS] Extra scalar field description '%s' is too long and will be truncated",
210 stdDescription.c_str());
214 if (radioButton1->isChecked())
218 else if (radioButton2->isChecked())
222 else if (radioButton3->isChecked())
227 if (scaledCheckBox->isChecked())
234 field.
scales[i] = m_scalarFieldsUserInputs[i].scaleSpinBox->value();
235 field.
offsets[i] = m_scalarFieldsUserInputs[i].offsetSpinBox->value();
246 const std::string sfName =
247 m_scalarFieldsUserInputs[i].scalarFieldComboBox->currentText().toStdString();
252 CVLog::Warning(
"Failed to get scalar field named '%s'", sfName.c_str());
263 const QString selectedElementType = typeComboBox->currentText();
265 if (selectedElementType ==
"uint8")
270 if (selectedElementType ==
"uint16")
275 if (selectedElementType ==
"uint32")
280 if (selectedElementType ==
"uint64")
285 if (selectedElementType ==
"int8")
290 if (selectedElementType ==
"int16")
295 if (selectedElementType ==
"int32")
297 return LasExtraScalarField::DataType::i32;
300 if (selectedElementType ==
"int64")
305 if (selectedElementType ==
"float32")
307 return LasExtraScalarField::DataType::f32;
310 if (selectedElementType ==
"float64")
312 return LasExtraScalarField::DataType::f64;
316 return LasExtraScalarField::DataType::Invalid;
319 void LasExtraScalarFieldCard::onNumberOfElementsSelected(
unsigned numberOfElements)
321 if (numberOfElements == 0 || numberOfElements > 3)
323 Q_ASSERT_X(
false,
"onNumberOfElementsSelected",
"Invalid number of elements");
329 ScalarFieldUserInputs& userInput = m_scalarFieldsUserInputs[i];
331 const bool isPartOfSelected = i <= (numberOfElements - 1);
333 userInput.scalarFieldComboBox->setVisible(isPartOfSelected);
334 userInput.scaleSpinBox->setEnabled(isPartOfSelected);
335 userInput.offsetSpinBox->setEnabled(isPartOfSelected);
339 void LasExtraScalarFieldCard::onRadioButton1Selected(
bool)
341 onNumberOfElementsSelected(1);
344 void LasExtraScalarFieldCard::onRadioButton2Selected(
bool)
346 onNumberOfElementsSelected(2);
349 void LasExtraScalarFieldCard::onRadioButton3Selected(
bool)
351 onNumberOfElementsSelected(3);
354 void LasExtraScalarFieldCard::onToggleAdvancedOptionsClicked()
356 if (advancedOptionFrame->isHidden())
358 advancedOptionFrame->show();
362 advancedOptionFrame->hide();
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
A scalar field associated to display-related parameters.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
const char * getName() const
Returns scalar field name.