diff --git a/src/meshlabplugins/io_3ds/meshio.cpp b/src/meshlabplugins/io_3ds/meshio.cpp index 9e9ea049f..d556ad25c 100644 --- a/src/meshlabplugins/io_3ds/meshio.cpp +++ b/src/meshlabplugins/io_3ds/meshio.cpp @@ -47,10 +47,44 @@ using namespace std; using namespace vcg; +QString ExtraMeshIOPlugin::pluginName() const +{ + return "IO3DS"; +} +std::list ExtraMeshIOPlugin::importFormats() const +{ + return {FileFormat("3D-Studio File Format" ,tr("3DS"))}; +} +std::list ExtraMeshIOPlugin::exportFormats() const +{ + return {FileFormat("3D-Studio File Format" ,tr("3DS"))}; +} -bool ExtraMeshIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList &, CallBackPos *cb, QWidget *parent) +void ExtraMeshIOPlugin::exportMaskCapability(const QString &format, int &capability, int &defaultBits) const +{ + if(format.toUpper() == tr("3DS")){capability=defaultBits= vcg::tri::io::Exporter3DS::GetExportMaskCapability();} + return; +} + +void ExtraMeshIOPlugin::initPreOpenParameter( + const QString& format, + const QString&, + RichParameterList& parameters) +{ + if (format.toUpper() == tr("3DS")){ + //parameters.addParam(RichBool(paramNames[SEPARATE_LAYERS], false, "Separate layers", "Import each mesh contained in the file as a separate layer")); + } +} + +bool ExtraMeshIOPlugin::open( + const QString &formatName, + const QString &fileName, + MeshModel &m, int& mask, + const RichParameterList& params, + CallBackPos *cb, + QWidget *parent) { // initializing mask mask = 0; @@ -210,19 +244,24 @@ bool ExtraMeshIOPlugin::open(const QString &formatName, const QString &fileName, return false; } -bool ExtraMeshIOPlugin::save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask, const RichParameterList &, vcg::CallBackPos *cb, QWidget *parent) +bool ExtraMeshIOPlugin::save( + const QString &formatName, + const QString &fileName, + MeshModel &m, + const int mask, + const RichParameterList &, + vcg::CallBackPos *cb, + QWidget *) { QString errorMsgFormat = "Error encountered while exporting file %1:\n%2"; string filename = QFile::encodeName(fileName).constData (); //string filename = fileName.toUtf8().data(); string ex = formatName.toUtf8().data(); - if(formatName.toUpper() == tr("3DS")) - { + if(formatName.toUpper() == tr("3DS")) { int result = vcg::tri::io::Exporter3DS::Save(m.cm,filename.c_str(),mask,cb); - if(result!=0) - { - QMessageBox::warning(parent, tr("Saving Error"), errorMsgFormat.arg(fileName, vcg::tri::io::Exporter3DS::ErrorMsg(result))); + if(result!=0) { + errorMessage = "Saving Error: " + errorMsgFormat.arg(fileName, vcg::tri::io::Exporter3DS::ErrorMsg(result)); return false; } return true; @@ -232,35 +271,4 @@ bool ExtraMeshIOPlugin::save(const QString &formatName, const QString &fileName, return false; } -/* - returns the list of the file's type which can be imported -*/ -std::list ExtraMeshIOPlugin::importFormats() const -{ - return {FileFormat("3D-Studio File Format" ,tr("3DS"))}; -} - -/* - returns the list of the file's type which can be exported -*/ -std::list ExtraMeshIOPlugin::exportFormats() const -{ - return {FileFormat("3D-Studio File Format" ,tr("3DS"))}; -} - -QString ExtraMeshIOPlugin::pluginName() const -{ - return "IO3DS"; -} - -/* - returns the mask on the basis of the file's type. - otherwise it returns 0 if the file format is unknown -*/ -void ExtraMeshIOPlugin::exportMaskCapability(const QString &format, int &capability, int &defaultBits) const -{ - if(format.toUpper() == tr("3DS")){capability=defaultBits= vcg::tri::io::Exporter3DS::GetExportMaskCapability();} - return; -} - MESHLAB_PLUGIN_NAME_EXPORTER(ExtraMeshIOPlugin) diff --git a/src/meshlabplugins/io_3ds/meshio.h b/src/meshlabplugins/io_3ds/meshio.h index 067a37874..2846a72d9 100644 --- a/src/meshlabplugins/io_3ds/meshio.h +++ b/src/meshlabplugins/io_3ds/meshio.h @@ -36,13 +36,43 @@ class ExtraMeshIOPlugin : public QObject, public IOMeshPlugin Q_INTERFACES(IOMeshPlugin) public: + QString pluginName() const; + std::list importFormats() const; std::list exportFormats() const; - QString pluginName() const; + void exportMaskCapability(const QString& format, int &capability, int &defaultBits) const; - bool open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList &, vcg::CallBackPos *cb=0, QWidget *parent=0); - bool save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask, const RichParameterList &, vcg::CallBackPos *cb=0, QWidget *parent= 0); + + void initPreOpenParameter( + const QString& format, + const QString& fileName, + RichParameterList& parameters); + + bool open(const QString &formatName, + const QString &fileName, + MeshModel &m, + int& mask, + const RichParameterList ¶ms, + vcg::CallBackPos *cb=0, + QWidget *parent=0); + + bool save( + const QString &formatName, + const QString &fileName, + MeshModel &m, + const int mask, + const RichParameterList &, + vcg::CallBackPos *cb=0, + QWidget *parent= 0); + +private: + const std::array paramNames = { + "separate_layers" + }; + enum paramEnum { + SEPARATE_LAYERS = 0 + }; }; #endif