Commit 0a3402c6 authored by Martin Schultz's avatar Martin Schultz

added cancel functionality to Assimp loader Plugin.

User can now click the cancel button to abort loading at per Mesh level
parent 673612b5
......@@ -55,7 +55,8 @@ AssimpPlugin::AssimpPlugin()
:
loadOptions_(nullptr),
saveOptions_(nullptr),
type_(DATA_TRIANGLE_MESH)
type_(DATA_TRIANGLE_MESH),
cancel_(false)
{
}
......@@ -110,7 +111,7 @@ int AssimpPlugin::convertAiSceneToOpenMesh(const aiScene *_scene, QString _objec
return returnId;
}
for (unsigned int i = 0; i < _scene->mNumMeshes; ++i) {
for (unsigned int i = 0; i < _scene->mNumMeshes && !cancel_; ++i) {
int objectId = -1;
if(type_ == DATA_UNKNOWN)
{
......@@ -625,6 +626,7 @@ QWidget *AssimpPlugin::loadOptionsWidget(QString) {
int AssimpPlugin::loadObject(QString _filename) {
Assimp::Importer importer;
cancel_ = false;
const aiScene* scene = NULL;
scene = importer.ReadFile(_filename.toStdString(), processSteps(loadOptions));
......@@ -799,6 +801,12 @@ bool AssimpPlugin::slotShowConfirmationDialog(const QString& _title, const QStri
return true;
}
void AssimpPlugin::canceledJob(QString _jobId)
{
if(_jobId == "Loading File" || _jobId == "Loading Files")
cancel_ = true;
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( assimpplugin , AssimpPlugin )
#endif
......@@ -57,6 +57,7 @@
#include <OpenFlipper/BasePlugin/TypeInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/BasePlugin/AboutInfoInterface.hh>
#include <OpenFlipper/BasePlugin/ProcessInterface.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
......@@ -69,7 +70,7 @@
#include<unordered_map>
class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInterface,
LoggingInterface, ScriptInterface, RPCInterface, AboutInfoInterface
LoggingInterface, ScriptInterface, RPCInterface, AboutInfoInterface, ProcessInterface
{
Q_OBJECT
Q_INTERFACES(FileInterface)
......@@ -79,6 +80,7 @@ class AssimpPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(RPCInterface)
Q_INTERFACES(AboutInfoInterface)
Q_INTERFACES(ProcessInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Assimp")
......@@ -143,6 +145,9 @@ private slots:
/// returns true if confirm was clicked
bool slotShowConfirmationDialog(const QString& _title, const QString & _message);
/// slot gets called when a user clicks on the cancel button.
void canceledJob(QString _jobId);
signals:
bool showConfirmationDialog(const QString& _title, const QString & _message);
......@@ -260,6 +265,8 @@ private:
/// maps indices of vertices in an aiMesh to OpenMesh VertexHandles
std::map<unsigned int, OpenMesh::VertexHandle> vertexHandles_;
bool cancel_;
};
#endif // ASSIMPPLUGIN_HH
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