Qt viewer : Improve exports
- Add a dialog to select the exporter - Export based on exporter id instead of extensions (fix issues like for Collada) - Message box if there is an errorpull/1661/head
parent
bc541e56af
commit
e5891e5a09
|
@ -265,6 +265,8 @@ QString filename, filter, format_id;
|
||||||
Exporter exporter;
|
Exporter exporter;
|
||||||
QTime time_begin;
|
QTime time_begin;
|
||||||
aiReturn rv;
|
aiReturn rv;
|
||||||
|
QStringList exporterList;
|
||||||
|
QMap<QString, const aiExportFormatDesc*> exportersMap;
|
||||||
|
|
||||||
if(mScene == nullptr)
|
if(mScene == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -273,34 +275,40 @@ aiReturn rv;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// build filter
|
for (int i = 0; i < exporter.GetExportFormatCount(); ++i)
|
||||||
{
|
{
|
||||||
aiString filter_temp;
|
const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(i);
|
||||||
|
exporterList.push_back(desc->id + QString(": ") + desc->description);
|
||||||
mImporter.GetExtensionList(filter_temp);
|
exportersMap.insert(desc->id, desc);
|
||||||
filter = filter_temp.C_Str();
|
|
||||||
filter.replace(';', ' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get an exporter
|
||||||
|
bool dialogSelectExporterOk;
|
||||||
|
QString selectedExporter = QInputDialog::getItem(this, "Export format", "Select the exporter : ", exporterList, 0, false, &dialogSelectExporterOk);
|
||||||
|
if (!dialogSelectExporterOk)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// build the filter
|
||||||
|
QString selectedId = selectedExporter.left(selectedExporter.indexOf(':'));
|
||||||
|
filter = QString("*.") + exportersMap[selectedId]->fileExtension;
|
||||||
|
|
||||||
// get file path
|
// get file path
|
||||||
filename = QFileDialog::getSaveFileName(this, "Set file name", "", filter);
|
filename = QFileDialog::getSaveFileName(this, "Set file name", "", filter);
|
||||||
// extract format ID
|
// if it's canceled
|
||||||
format_id = filename.right(filename.length() - filename.lastIndexOf('.') - 1);
|
if (filename == "")
|
||||||
if(format_id.isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, "Export error", "File name must has extension.");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// begin export
|
// begin export
|
||||||
time_begin = QTime::currentTime();
|
time_begin = QTime::currentTime();
|
||||||
rv = exporter.Export(mScene, format_id.toLocal8Bit(), filename.toLocal8Bit(), aiProcess_FlipUVs);
|
rv = exporter.Export(mScene, selectedId.toLocal8Bit(), filename.toLocal8Bit(), aiProcess_FlipUVs);
|
||||||
ui->lblExportTime->setText(QString("%1").arg(time_begin.secsTo(QTime::currentTime())));
|
ui->lblExportTime->setText(QString("%1").arg(time_begin.secsTo(QTime::currentTime())));
|
||||||
if(rv == aiReturn_SUCCESS)
|
if(rv == aiReturn_SUCCESS)
|
||||||
LogInfo("Export done: " + filename);
|
LogInfo("Export done: " + filename);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
LogError("Export failed: " + filename);
|
LogError("Export failed: " + filename);
|
||||||
|
QMessageBox::critical(this, "Error", "Export failed: " + filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_cbxLighting_clicked(bool pChecked)
|
void MainWindow::on_cbxLighting_clicked(bool pChecked)
|
||||||
|
|
Loading…
Reference in New Issue