From 5bb42ba64263f550b17b4b3d1ba3673b9bd89941 Mon Sep 17 00:00:00 2001 From: Alessandro Muntoni Date: Wed, 22 Nov 2023 11:31:54 +0100 Subject: [PATCH] add possibility to use layer name when save snapshot, fix #1358 --- src/meshlab/dialogs/save_snapshot_dialog.cpp | 22 +++++++++++++ src/meshlab/dialogs/save_snapshot_dialog.h | 4 +++ src/meshlab/dialogs/save_snapshot_dialog.ui | 34 ++++++++++++++++++-- src/meshlab/glarea.cpp | 11 ++++--- src/meshlab/snapshotsetting.h | 4 ++- 5 files changed, 67 insertions(+), 8 deletions(-) diff --git a/src/meshlab/dialogs/save_snapshot_dialog.cpp b/src/meshlab/dialogs/save_snapshot_dialog.cpp index 4968136c9f..58fdab5724 100644 --- a/src/meshlab/dialogs/save_snapshot_dialog.cpp +++ b/src/meshlab/dialogs/save_snapshot_dialog.cpp @@ -44,6 +44,7 @@ void SaveSnapshotDialog::setValues(const SnapshotSetting& ss) ui->counterSpinBox->setValue(settings.counter); ui->backgroundComboBox->setCurrentIndex(settings.background); ui->alllayersCheckBox->setChecked(settings.snapAllLayers); + ui->useLayerNameCheckBox->setChecked(settings.useLayerName); ui->tiledSaveCheckBox->setChecked(settings.tiledSave); ui->addToRastersCheckBox->setChecked(settings.addToRasters); } @@ -56,6 +57,7 @@ SnapshotSetting SaveSnapshotDialog::getValues() settings.resolution=ui->resolutionSpinBox->value(); settings.background = ui->backgroundComboBox->currentIndex(); settings.snapAllLayers=ui->alllayersCheckBox->isChecked(); + settings.useLayerName=ui->useLayerNameCheckBox->isChecked(); settings.tiledSave=ui->tiledSaveCheckBox->isChecked(); settings.addToRasters=ui->addToRastersCheckBox->isChecked(); return settings; @@ -80,3 +82,23 @@ void SaveSnapshotDialog::on_browseDir_clicked() ui->outDirLineEdit->setText(selection.at(0)); } } + +void SaveSnapshotDialog::on_alllayersCheckBox_stateChanged(int arg1) +{ + if (arg1 == Qt::Checked) + ui->useLayerNameCheckBox->setEnabled(true); + else { + ui->useLayerNameCheckBox->setEnabled(false); + ui->useLayerNameCheckBox->setChecked(false); + } +} + + +void SaveSnapshotDialog::on_useLayerNameCheckBox_stateChanged(int arg1) +{ + if (arg1 == Qt::Checked) + ui->baseNameLineEdit->setEnabled(false); + else + ui->baseNameLineEdit->setEnabled(true); +} + diff --git a/src/meshlab/dialogs/save_snapshot_dialog.h b/src/meshlab/dialogs/save_snapshot_dialog.h index 70cb374f1c..684cfac463 100644 --- a/src/meshlab/dialogs/save_snapshot_dialog.h +++ b/src/meshlab/dialogs/save_snapshot_dialog.h @@ -45,6 +45,10 @@ Q_OBJECT private slots: void on_browseDir_clicked(); + void on_alllayersCheckBox_stateChanged(int arg1); + + void on_useLayerNameCheckBox_stateChanged(int arg1); + private: Ui::SaveSnapShotDialog* ui; SnapshotSetting settings; diff --git a/src/meshlab/dialogs/save_snapshot_dialog.ui b/src/meshlab/dialogs/save_snapshot_dialog.ui index 8db45652ff..7195d68cf4 100644 --- a/src/meshlab/dialogs/save_snapshot_dialog.ui +++ b/src/meshlab/dialogs/save_snapshot_dialog.ui @@ -120,10 +120,38 @@ - - - Snap All Layers + + + + 10 + 0 + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + Snap All Layers + + + + + + + false + + + Use Layer Name + + + + diff --git a/src/meshlab/glarea.cpp b/src/meshlab/glarea.cpp index 41c8fbdde0..d10ce079c3 100644 --- a/src/meshlab/glarea.cpp +++ b/src/meshlab/glarea.cpp @@ -219,11 +219,14 @@ void GLArea::pasteTile() if (tileRow >= totalRows) { if (ss.snapAllLayers) { - outfile = QString("%1/%2%3_L%4.png") + QString lname = ss.basename; + if (ss.useLayerName) { + lname = md()->getMesh(snapshotCounter)->label(); + } + outfile = QString("%1/%2%3.png") .arg(ss.outdir) - .arg(ss.basename) - .arg(ss.counter, 2, 10, QChar('0')) - .arg(snapshotCounter, 2, 10, QChar('0')); + .arg(lname) + .arg(ss.counter, 2, 10, QChar('0')); } else { outfile = QString("%1/%2%3.png") diff --git a/src/meshlab/snapshotsetting.h b/src/meshlab/snapshotsetting.h index 9638ba8967..a9ad8eb4f9 100644 --- a/src/meshlab/snapshotsetting.h +++ b/src/meshlab/snapshotsetting.h @@ -33,6 +33,7 @@ class SnapshotSetting int resolution; int background; bool snapAllLayers; + bool useLayerName; bool tiledSave; // if true all the tiles are saved as separated files and not joined. bool addToRasters; @@ -44,9 +45,10 @@ class SnapshotSetting resolution=1; background=0; snapAllLayers=false; + useLayerName=false; tiledSave=false; addToRasters=false; }; }; -#endif \ No newline at end of file +#endif