Skip to content

Commit

Permalink
add possibility to use layer name when save snapshot, fix #1358
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Nov 22, 2023
1 parent 32d84cd commit 5bb42ba
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 8 deletions.
22 changes: 22 additions & 0 deletions src/meshlab/dialogs/save_snapshot_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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);
}

4 changes: 4 additions & 0 deletions src/meshlab/dialogs/save_snapshot_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 31 additions & 3 deletions src/meshlab/dialogs/save_snapshot_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,38 @@
</spacer>
</item>
<item>
<widget class="QCheckBox" name="alllayersCheckBox">
<property name="text">
<string>Snap All Layers</string>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="alllayersCheckBox">
<property name="text">
<string>Snap All Layers</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useLayerNameCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use Layer Name</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
Expand Down
11 changes: 7 additions & 4 deletions src/meshlab/glarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion src/meshlab/snapshotsetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -44,9 +45,10 @@ class SnapshotSetting
resolution=1;
background=0;
snapAllLayers=false;
useLayerName=false;
tiledSave=false;
addToRasters=false;
};
};

#endif
#endif

0 comments on commit 5bb42ba

Please sign in to comment.