Commit 673612b5 authored by Martin Schultz's avatar Martin Schultz

added confirmation dialog when files with multiple materials are loaded

parent 78e57c54
......@@ -44,7 +44,6 @@
#include "AssimpPlugin.hh"
#include <ACG/QtWidgets/QtFlapBox.hh>
// Defines for the type handling drop down box
#define TYPEAUTODETECT 0
......@@ -91,6 +90,8 @@ void AssimpPlugin::initializePlugin() {
" <br> ";
emit addAboutInfo(info,"File-Assimp Plugin");
connect(this, SIGNAL(showConfirmationDialog(const QString&, const QString&)), this, SLOT(slotShowConfirmationDialog(const QString&, const QString&)), Qt::BlockingQueuedConnection);
}
int AssimpPlugin::convertAiSceneToOpenMesh(const aiScene *_scene, QString _objectName) {
......@@ -99,6 +100,15 @@ int AssimpPlugin::convertAiSceneToOpenMesh(const aiScene *_scene, QString _objec
if (_scene->mNumMeshes == 0)
emit log(LOGWARN, tr("aiScene contains no meshes"));
if(_scene->mNumMaterials > 1)
{
if(!emit showConfirmationDialog(tr("Multiple MAterials in file"),
tr("The File you are trying to load contains %1 materials. "
"Assimp creates a separate Mesh for each material, which may cause performance issues.\n\n "
"Do you want to continue loading the file?").arg(_scene->mNumMaterials)))
return returnId;
}
for (unsigned int i = 0; i < _scene->mNumMeshes; ++i) {
int objectId = -1;
......@@ -479,10 +489,13 @@ QWidget *AssimpPlugin::loadOptionsWidget(QString) {
triMeshHandling_->addItem( tr("Open as PolyMesh") );
triMeshHandling_->addItem( tr("Open as TriangleMesh") );
loadFaceColor_ = new QCheckBox("Load Face Colors");
loadNormals_ = new QCheckBox("Load Normals");
loadTexCoords_ = new QCheckBox("Load Texture Coordinates");
loadTextures_ = new QCheckBox("Load Textures");
loadFaceColor_ = new QCheckBox("Load Vertex Colors");
loadNormals_ = new QCheckBox("Load Vertex Normals");
loadTexCoords_ = new QCheckBox("Load Vertex Texture Coordinates");
loadTextures_ = new QCheckBox("Load Textures");
//loading textures is not yet supported
loadTextures_->setDisabled(true);
QList<QWidget*> generalOptions = {triMeshHandling_, loadFaceColor_, loadNormals_, loadTexCoords_, loadTextures_};
......@@ -766,11 +779,26 @@ unsigned int AssimpPlugin::processSteps( const std::unordered_map<QCheckBox*, un
unsigned int result = 0;
for(auto entry : _options)
{
result |= entry.first->isChecked()? entry.second : 0;
if(entry.first != nullptr)
result |= entry.first->isChecked()? entry.second : 0;
}
return result;
}
bool AssimpPlugin::slotShowConfirmationDialog(const QString& _title, const QString& _message)
{
QMessageBox msgBox;
QPushButton *cancelButton = msgBox.addButton(tr("Cancel"), QMessageBox::ActionRole);
/*QPushButton *confirmButton =*/ msgBox.addButton(tr("Continue"), QMessageBox::ActionRole);
msgBox.setWindowTitle( _title );
msgBox.setText( _message );
msgBox.setDefaultButton( cancelButton );
msgBox.exec();
if (msgBox.clickedButton() == cancelButton)
return false;
return true;
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( assimpplugin , AssimpPlugin )
#endif
......@@ -137,6 +137,14 @@ private slots:
void slotLoadDefault();
void slotSaveDefault();
/// displays a message dialog with the given message,
/// and returns whether confirm or cancel was clicked
/// returns true if confirm was clicked
bool slotShowConfirmationDialog(const QString& _title, const QString & _message);
signals:
bool showConfirmationDialog(const QString& _title, const QString & _message);
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment