ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
AsciiSaveDlg.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 <ui_saveAsciiFileDlg.h>
9 
10 // local
11 #include "AsciiSaveDlg.h"
12 
13 // Qt
14 #include <QComboBox>
15 #include <QSettings>
16 #include <QSpinBox>
17 
18 // system
19 #include <assert.h>
20 
22  : QDialog(parent), m_ui(new Ui_AsciiSaveDialog), m_autoShow(true) {
23  m_ui->setupUi(this);
24 
25  connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this,
27 
29 }
30 
32  if (m_ui) delete m_ui;
33 }
34 
36  return m_ui->columnsHeaderCheckBox->isChecked();
37 }
38 
40  m_ui->columnsHeaderCheckBox->setChecked(state);
41 }
42 
44  return m_ui->pointCountHeaderCheckBox->isChecked();
45 }
46 
48  m_ui->pointCountHeaderCheckBox->setChecked(state);
49 }
50 
52  m_ui->saveFloatColorsCheckBox->setChecked(state);
53 }
54 
56  return m_ui->saveFloatColorsCheckBox->isChecked();
57 }
58 
60  m_ui->saveAlphaChannelCheckBox->setChecked(state);
61 }
62 
64  return m_ui->saveAlphaChannelCheckBox->isChecked();
65 }
66 
67 unsigned char AsciiSaveDlg::getSeparator() const {
68  switch (m_ui->separatorComboBox->currentIndex()) {
69  case 0:
70  return ' ';
71  case 1:
72  return ';';
73  case 2:
74  return ',';
75  case 3:
76  return '\t';
77  default:
78  assert(false);
79  }
80 
81  return 0;
82 }
83 
85  m_ui->separatorComboBox->setCurrentIndex(index);
86 }
87 
89  return m_ui->separatorComboBox->currentIndex();
90 }
91 
93  return m_ui->coordsPrecisionSpinBox->value();
94 }
95 
97  m_ui->coordsPrecisionSpinBox->setValue(prec);
98 }
99 
101  return m_ui->sfPrecisionSpinBox->value();
102 }
103 
105  m_ui->sfPrecisionSpinBox->setValue(prec);
106 }
107 
109  return m_ui->orderComboBox->currentIndex() == 1;
110 }
111 
113  m_ui->orderComboBox->setCurrentIndex(state ? 1 : 0);
114 }
115 
117  QSettings settings;
118  settings.beginGroup("AsciiSaveDialog");
119 
120  // read parameters
121  bool saveColHeader =
122  settings.value("saveHeader",
123  m_ui->columnsHeaderCheckBox->isChecked())
124  .toBool();
125  bool savePtsHeader =
126  settings.value("savePtsHeader",
127  m_ui->pointCountHeaderCheckBox->isChecked())
128  .toBool();
129  int coordsPrecision = settings.value("coordsPrecision",
130  m_ui->coordsPrecisionSpinBox->value())
131  .toInt();
132  int sfPrecision =
133  settings.value("sfPrecision", m_ui->sfPrecisionSpinBox->value())
134  .toInt();
135  int separatorIndex =
136  settings.value("separator", m_ui->separatorComboBox->currentIndex())
137  .toInt();
138  int orderIndex =
139  settings.value("saveOrder", m_ui->orderComboBox->currentIndex())
140  .toInt();
141  bool saveFloatColors =
142  settings.value("saveFloatColors",
143  m_ui->saveFloatColorsCheckBox->isChecked())
144  .toBool();
145  bool saveAlphaChannel =
146  settings.value("saveAlphaChannel",
147  m_ui->saveAlphaChannelCheckBox->isChecked())
148  .toBool();
149 
150  // apply parameters
151  m_ui->columnsHeaderCheckBox->setChecked(saveColHeader);
152  m_ui->pointCountHeaderCheckBox->setChecked(savePtsHeader);
153  m_ui->coordsPrecisionSpinBox->setValue(coordsPrecision);
154  m_ui->sfPrecisionSpinBox->setValue(sfPrecision);
155  m_ui->separatorComboBox->setCurrentIndex(separatorIndex);
156  m_ui->orderComboBox->setCurrentIndex(orderIndex);
157  m_ui->saveFloatColorsCheckBox->setChecked(saveFloatColors);
158  m_ui->saveAlphaChannelCheckBox->setChecked(saveAlphaChannel);
159 
160  settings.endGroup();
161 }
162 
164  QSettings settings;
165  settings.beginGroup("AsciiSaveDialog");
166 
167  // write parameters
168  settings.setValue("saveHeader", m_ui->columnsHeaderCheckBox->isChecked());
169  settings.setValue("savePtsHeader",
170  m_ui->pointCountHeaderCheckBox->isChecked());
171  settings.setValue("coordsPrecision", m_ui->coordsPrecisionSpinBox->value());
172  settings.setValue("sfPrecision", m_ui->sfPrecisionSpinBox->value());
173  settings.setValue("separator", m_ui->separatorComboBox->currentIndex());
174  settings.setValue("saveOrder", m_ui->orderComboBox->currentIndex());
175  settings.setValue("saveFloatColors",
176  m_ui->saveFloatColorsCheckBox->isChecked());
177  settings.setValue("saveAlphaChannel",
178  m_ui->saveAlphaChannelCheckBox->isChecked());
179  settings.endGroup();
180 }
void enableSaveColumnsNamesHeader(bool state)
Sets whether columns names should be be saved in header.
void acceptAndSaveSettings()
Saves dialog state to persistent settings.
virtual ~AsciiSaveDlg()
Destructor.
void setSaveAlphaChannel(bool state)
Sets whether to save the alpha (transparency) channel.
int sfPrecision() const
Returns SF precision.
bool saveAlphaChannel() const
Returns whether to save the alpha (transparency) channel.
unsigned char getSeparator() const
Returns separator.
void setSeparatorIndex(int index)
Set separator (index)
bool savePointCountHeader() const
Returns whether the number of points should be saved in header.
bool saveColumnsNamesHeader() const
Returns whether columns names should be be saved in header.
void initFromPersistentSettings()
Inits dialog state from persistent settings.
void setCoordsPrecision(int prec)
Sets coordinates precision.
void enableSavePointCountHeader(bool state)
Sets whether the number of points should be saved in header.
int getSeparatorIndex() const
Returns separator index.
int coordsPrecision() const
Returns coordinates precision.
Ui_AsciiSaveDialog * m_ui
Associated UI.
Definition: AsciiSaveDlg.h:90
void setSfPrecision(int prec)
Sets SF precision.
bool swapColorAndSF() const
Returns whether SF(s) and color should be swapped.
void setSaveFloatColors(bool state)
Sets whether to save colors as float values (instead of unsigned bytes)
void enableSwapColorAndSF(bool state)
Sets whether SF(s) and color should be swapped.
AsciiSaveDlg(QWidget *parent=nullptr)
Default constructor.
bool saveFloatColors() const