Added ability to save out overlay textures using the TextureSaveDialog.

This is part of the work specified by github Issue 586, allowing the
ability to save out the overlay in the TextureViewer.  If no overlays
are on then there is no option to save the overlay. Currently there is
no option to remap the overlay to a grayscale or absolute value range
before saving. This can be a future task.

NOTE: the overlay texture resource that's saved out is not the blended
texture that the user will see in the TextureViewer, it is just the
overlay itself. The ability to save out the blended texture would be a
future task.
This commit is contained in:
Richard Khoury
2017-12-14 14:01:07 +11:00
committed by Baldur Karlsson
parent a68e55e814
commit d8bc07f945
5 changed files with 48 additions and 8 deletions
@@ -28,8 +28,8 @@
#include "Code/QRDUtils.h"
#include "ui_TextureSaveDialog.h"
TextureSaveDialog::TextureSaveDialog(const TextureDescription &t, const TextureSave &s,
QWidget *parent)
TextureSaveDialog::TextureSaveDialog(const TextureDescription &t, bool enableOverlaySelection,
const TextureSave &s, QWidget *parent)
: QDialog(parent), ui(new Ui::TextureSaveDialog)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@@ -46,6 +46,9 @@ TextureSaveDialog::TextureSaveDialog(const TextureDescription &t, const TextureS
ui->blackPoint->setFont(Formatter::PreferredFont());
ui->whitePoint->setFont(Formatter::PreferredFont());
if(!enableOverlaySelection)
ui->texSelectionGroup->hide();
QObject::connect(&typingTimer, &QTimer::timeout, [this] { SetFiletypeFromFilename(); });
ui->fileFormat->clear();
@@ -126,15 +129,20 @@ TextureSaveDialog::TextureSaveDialog(const TextureDescription &t, const TextureS
ui->gridWidth->setMaximum(tex.depth * tex.arraysize * tex.msSamp);
ui->mipGroup->setVisible(tex.mips > 1);
SetOptionsVisible(true);
}
ui->sampleGroup->setVisible(tex.msSamp > 1);
void TextureSaveDialog::SetOptionsVisible(bool visible)
{
ui->mipGroup->setVisible(visible && tex.mips > 1);
ui->sliceGroup->setVisible(tex.depth > 1 || tex.arraysize > 1 || tex.msSamp > 1);
ui->sampleGroup->setVisible(visible && tex.msSamp > 1);
ui->sliceGroup->setVisible(visible && (tex.depth > 1 || tex.arraysize > 1 || tex.msSamp > 1));
if(saveData.destType != FileType::DDS)
{
ui->cubeCruciform->setEnabled(tex.cubemap && tex.arraysize == 6);
ui->cubeCruciform->setEnabled(visible && tex.cubemap && tex.arraysize == 6);
if(!ui->oneSlice->isChecked() && !ui->cubeCruciform->isEnabled())
ui->mapSlicesToGrid->setChecked(true);
@@ -188,6 +196,18 @@ void TextureSaveDialog::SetFilenameFromFiletype()
}
}
void TextureSaveDialog::on_mainTex_clicked()
{
SetOptionsVisible(true);
m_saveOverlayInsteadOfSelectedTexture = false;
}
void TextureSaveDialog::on_overlayTex_clicked()
{
SetOptionsVisible(false);
m_saveOverlayInsteadOfSelectedTexture = true;
}
void TextureSaveDialog::on_fileFormat_currentIndexChanged(int index)
{
saveData.destType = (FileType)qMax(0, ui->fileFormat->currentIndex());