| 1 |
//########################################################################## |
| 2 |
//# # |
| 3 |
//# CLOUDCOMPARE # |
| 4 |
//# # |
| 5 |
//# This program is free software; you can redistribute it and/or modify # |
| 6 |
//# it under the terms of the GNU General Public License as published by # |
| 7 |
//# the Free Software Foundation; version 2 or later of the License. # |
| 8 |
//# # |
| 9 |
//# This program is distributed in the hope that it will be useful, # |
| 10 |
//# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
| 11 |
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
| 12 |
//# GNU General Public License for more details. # |
| 13 |
//# # |
| 14 |
//# COPYRIGHT: CloudCompare project # |
| 15 |
//# # |
| 16 |
//########################################################################## |
| 17 |
|
| 18 |
#include <SaveDracoFileDlg.h> |
| 19 |
|
| 20 |
//Qt |
| 21 |
#include <QDialogButtonBox> |
| 22 |
#include <QPushButton> |
| 23 |
#include <QSettings> |
| 24 |
|
| 25 |
static const int DefaultCoordsQuant = 11; |
| 26 |
static const int DefaultNormQuant = 8; |
| 27 |
static const int DefaultSFQuant = 8; |
| 28 |
|
| 29 |
SaveDracoFileDlg::SaveDracoFileDlg(QWidget* parent/*=nullptr*/) |
| 30 |
: QDialog(parent) |
| 31 |
{ |
| 32 |
setupUi(this); |
| 33 |
|
| 34 |
initFromPersistentSettings(); |
| 35 |
|
| 36 |
connect(buttonBox, &QDialogButtonBox::accepted, this, &SaveDracoFileDlg::saveToPersistentSettings); |
| 37 |
connect(buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &SaveDracoFileDlg::reset); |
| 38 |
} |
| 39 |
|
| 40 |
void SaveDracoFileDlg::initFromPersistentSettings() |
| 41 |
{ |
| 42 |
QSettings settings; |
| 43 |
settings.beginGroup("DracoSaveDialog"); |
| 44 |
|
| 45 |
//read parameters |
| 46 |
int coordQuantization = settings.value("coordQuantization", DefaultCoordsQuant).toInt(); |
| 47 |
int normQuantization = settings.value("normalQuantization", DefaultNormQuant).toInt(); |
| 48 |
int sfQuantization = settings.value("sfQuantization", DefaultSFQuant).toInt(); |
| 49 |
|
| 50 |
//apply parameters |
| 51 |
coordsQuantSpinBox->setValue(coordQuantization); |
| 52 |
normQuantSpinBox->setValue(normQuantization); |
| 53 |
sfQuantSpinBox->setValue(sfQuantization); |
| 54 |
|
| 55 |
settings.endGroup(); |
| 56 |
} |
| 57 |
|
| 58 |
void SaveDracoFileDlg::saveToPersistentSettings() |
| 59 |
{ |
| 60 |
QSettings settings; |
| 61 |
settings.beginGroup("DracoSaveDialog"); |
| 62 |
|
| 63 |
//write parameters |
| 64 |
settings.setValue("coordQuantization", coordsQuantSpinBox->value()); |
| 65 |
settings.setValue("normalQuantization", normQuantSpinBox->value()); |
| 66 |
settings.setValue("sfQuantization", sfQuantSpinBox->value()); |
| 67 |
|
| 68 |
settings.endGroup(); |
| 69 |
|
| 70 |
accept(); |
| 71 |
} |
| 72 |
|
| 73 |
void SaveDracoFileDlg::reset() |
| 74 |
{ |
| 75 |
coordsQuantSpinBox->setValue(DefaultCoordsQuant); |
| 76 |
normQuantSpinBox->setValue(DefaultNormQuant); |
| 77 |
sfQuantSpinBox->setValue(DefaultSFQuant); |
| 78 |
} |