11 #include <QFileDialog>
18 auto item =
new QListWidgetItem(
name);
19 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
20 item->setCheckState(Qt::Checked);
32 for (
int i = 0; i < list->count(); ++i)
34 if (list->item(i)->text() ==
name)
36 return list->item(i)->checkState() == Qt::Checked;
43 template <
typename T,
typename Pred>
46 auto firstFalse = std::partition(vec.begin(), vec.end(), predicate);
48 if (firstFalse != vec.end())
50 vec.erase(firstFalse, vec.end());
59 connect(applyButton, &QPushButton::clicked,
this, &QDialog::accept);
60 connect(applyAllButton, &QPushButton::clicked,
this, &QDialog::accept);
61 connect(cancelButton, &QPushButton::clicked,
this, &QDialog::reject);
62 connect(automaticTimeShiftCheckBox, &QCheckBox::toggled,
this, &LasOpenDialog::onAutomaticTimeShiftToggle);
63 connect(applyAllButton, &QPushButton::clicked,
this, &LasOpenDialog::onApplyAll);
64 connect(selectAllToolButton, &QPushButton::clicked, [&]
65 { doSelectAll(
true); });
66 connect(unselectAllToolButton, &QPushButton::clicked,
this, [&]
67 { doSelectAll(
false); });
68 connect(tilingBrowseToolButton, &QPushButton::clicked,
this, &LasOpenDialog::onBrowseTilingOutputDir);
69 connect(actionTab, &QTabWidget::currentChanged,
this, &LasOpenDialog::onCurrentTabChanged);
70 connect(selectAllESFToolButton, &QPushButton::clicked, [&]
71 { doSelectAllESF(
true); });
72 connect(unselectAllESFToolButton, &QPushButton::clicked,
this, [&]
73 { doSelectAllESF(
false); });
76 void LasOpenDialog::doSelectAll(
bool doSelect)
78 if (!availableScalarFields)
84 for (
int i = 0; i < availableScalarFields->count(); ++i)
86 availableScalarFields->item(i)->setCheckState(doSelect ? Qt::Checked : Qt::Unchecked);
90 void LasOpenDialog::doSelectAllESF(
bool doSelect)
92 if (!availableExtraScalarFields)
98 for (
int i = 0; i < availableExtraScalarFields->count(); ++i)
100 availableExtraScalarFields->item(i)->setCheckState(doSelect ? Qt::Checked : Qt::Unchecked);
106 versionLabelValue->setText(QString(
"1.%1").arg(QString::number(versionMinor)));
107 pointFormatLabelValue->setText(QString::number(pointFormatId));
108 numPointsLabelValue->setText(QLocale(QLocale::English).
toString(numPoints));
115 const std::vector<LasExtraScalarField>& extraScalarFields)
117 availableScalarFields->clear();
118 availableExtraScalarFields->clear();
120 if (!scalarFields.empty())
122 scalarFieldFrame->show();
125 availableScalarFields->addItem(
CreateItem(lasScalarField.name()));
130 scalarFieldFrame->hide();
133 if (!extraScalarFields.empty())
135 extraScalarFieldsFrame->show();
138 availableExtraScalarFields->addItem(
CreateItem(lasExtraScalarField.name));
140 int height = availableExtraScalarFields->frameWidth() + (availableExtraScalarFields->sizeHintForRow(0) + availableExtraScalarFields->frameWidth()) * availableExtraScalarFields->count();
141 availableExtraScalarFields->setMaximumHeight(
height);
145 extraScalarFieldsFrame->hide();
150 std::vector<LasExtraScalarField>& extraScalarFields)
152 const auto isFieldSelected = [
this](
const auto& field)
153 {
return isChecked(field); };
161 return ignoreFieldsWithDefaultValuesCheckBox->isChecked();
166 return force8bitColorsCheckBox->isChecked();
171 if (automaticTimeShiftCheckBox->isChecked())
173 return std::numeric_limits<double>::quiet_NaN();
176 return manualTimeShiftSpinBox->value();
181 return IsCheckedIn(lasExtraScalarField.
name, availableExtraScalarFields);
184 bool LasOpenDialog::isChecked(
const LasScalarField& lasScalarField)
const
189 void LasOpenDialog::onAutomaticTimeShiftToggle(
bool checked)
191 manualTimeShiftSpinBox->setEnabled(!checked);
196 return m_shouldSkipDialog;
201 m_shouldSkipDialog =
false;
204 void LasOpenDialog::onApplyAll()
206 m_shouldSkipDialog =
true;
224 int index = tilingDimensioncomboBox->currentIndex();
234 int numTiles0 =
std::max(tilingSpinBox0->value(), 1);
235 int numTiles1 =
std::max(tilingSpinBox0->value(), 1);
238 tilingOutputPathLineEdit->text(),
240 static_cast<unsigned>(numTiles0),
241 static_cast<unsigned>(numTiles1),
245 void LasOpenDialog::onBrowseTilingOutputDir()
247 const QString outputDir = QFileDialog::getExistingDirectory(
this,
"Select output directory for tiles");
248 tilingOutputPathLineEdit->setText(outputDir);
251 void LasOpenDialog::onCurrentTabChanged(
int index)
253 const static QString TILE_TEXT = QStringLiteral(
"Tile");
254 const static QString TILE_ALL_TEXT = QStringLiteral(
"Tile All");
256 const static QString APPLY_TEXT = QStringLiteral(
"Apply");
257 const static QString APPLY_ALL_TEXT = QStringLiteral(
"Apply All");
261 applyButton->setText(TILE_TEXT);
262 applyAllButton->setText(TILE_ALL_TEXT);
266 applyButton->setText(APPLY_TEXT);
267 applyAllButton->setText(APPLY_ALL_TEXT);
static QListWidgetItem * CreateItem(const char *name)
static bool IsCheckedIn(const QString &name, const QListWidget *list)
constexpr int TILLING_TAB_INDEX
static void RemoveFalse(std::vector< T > &vec, Pred predicate)
LasTilingOptions tilingOptions() const
bool shouldSkipDialog() const
void setAvailableScalarFields(const std::vector< LasScalarField > &scalarFields, const std::vector< LasExtraScalarField > &extraScalarFields)
double timeShiftValue() const
@ Tile
The user wants to tile the file into multiple smaller ones.
@ Load
The user wants to load the file in ACloudViewer.
bool shouldForce8bitColors() const
void setInfo(int versionMinor, int pointFormatId, qulonglong numPoints)
void filterOutNotChecked(std::vector< LasScalarField > &scalarFields, std::vector< LasExtraScalarField > &extraScalarFields)
bool shouldIgnoreFieldsWithDefaultValues() const
LasOpenDialog(QWidget *parent=nullptr)
Default constructor.
void resetShouldSkipDialog()
bool HasRGB(unsigned pointFormatId)
Returns whether the point format supports RGB.
bool HasGpsTime(unsigned pointFormatId)
Returns whether the point format supports Gps Time.
std::string toString(T x)
const char * name() const