From 1a79d4d0e445f4a44b4efd49e2befb7b2cae6166 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 5 Mar 2021 14:56:23 +0100 Subject: [PATCH] FilterSketchfab uses new applyFilter call --- src/CMakeLists.txt | 2 +- src/meshlab.pro | 2 +- .../filter_sketchfab/filter_sketchfab.cpp | 27 ++++++++++++------- .../filter_sketchfab/filter_sketchfab.h | 10 ++++--- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e0a77e16..9e2ac1246 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,7 +158,7 @@ else() meshlabplugins/filter_screened_poisson meshlabplugins/filter_sdfgpu meshlabplugins/filter_select -# meshlabplugins/filter_sketchfab + meshlabplugins/filter_sketchfab # meshlabplugins/filter_ssynth # meshlabplugins/filter_texture # meshlabplugins/filter_trioptimize diff --git a/src/meshlab.pro b/src/meshlab.pro index 6113c0e9b..d58c0975e 100644 --- a/src/meshlab.pro +++ b/src/meshlab.pro @@ -79,7 +79,7 @@ SUBDIRS += \ #sub projects names filter_screened_poisson \ filter_sdfgpu \ filter_select \ - #filter_sketchfab \ + filter_sketchfab \ #filter_ssynth \ #filter_texture \ #filter_trioptimize \ diff --git a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp index bea07c123..7ac7ea402 100644 --- a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp +++ b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp @@ -125,22 +125,31 @@ void FilterSketchFabPlugin::initParameterList(const QAction* action, MeshModel&, } } -bool FilterSketchFabPlugin::applyFilter(const QAction * action, MeshDocument& md, std::map&, unsigned int& /*postConditionMask*/, const RichParameterList& par, vcg::CallBackPos* cb) +std::map FilterSketchFabPlugin::applyFilter( + const QAction * action, + const RichParameterList& par, + MeshDocument& md, + unsigned int& /*postConditionMask*/, + vcg::CallBackPos* cb) { + std::map outValues; + std::string url; switch (ID(action)) { case FP_SKETCHFAB: - return sketchfab(md, cb, + url = sketchfab(md, cb, par.getString("sketchFabKeyCode"), par.getString("title"), par.getString("description"), par.getString("tags"), par.getBool("isPrivate"), par.getBool("isPublished"), par.getBool("autoRotate"), par.getBool("saveApiSetting")); + outValues["url_model"] = QVariant::fromValue(QString::fromStdString(url)); + break; default: - assert(0); - return false; + wrongActionCalled(action); } + return outValues; } -bool FilterSketchFabPlugin::sketchfab( +std::string FilterSketchFabPlugin::sketchfab( MeshDocument& md, vcg::CallBackPos* cb, const QString& apiToken, @@ -160,8 +169,7 @@ bool FilterSketchFabPlugin::sketchfab( Matrix44m rotI; rot.SetRotateDeg(90,Point3m(1,0,0)); if(apiToken.isEmpty() || apiToken == DEFAULT_API) { - this->errorMessage = QString("Please set in the MeshLab preferences your private API Token string that you can find on theSketchfab Password Settings."); - return false; + throw MLException("Please set in the MeshLab preferences your private API Token string that you can find on theSketchfab Password Settings."); } QSettings settings; @@ -190,13 +198,12 @@ bool FilterSketchFabPlugin::sketchfab( std::string urlModel; bool ret = upload(tmpZipFileName, apiToken, name, description, tags, QString::number(isPrivate), QString::number(isPublished), urlModel); if(!ret){ - qDebug("Upload FAILED"); - return false; + throw MLException("Upload FAILED"); } this->log("Upload Completed; you can access the uploaded model at the following URL:\n"); this->log("%s\n",qUtf8Printable(QString::fromStdString(urlModel)),qUtf8Printable(QString::fromStdString(urlModel))); - return true; + return urlModel; } bool FilterSketchFabPlugin::upload( diff --git a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h index 29622fd88..9d57e6ad2 100644 --- a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h +++ b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h @@ -47,14 +47,18 @@ public: int getPreConditions(const QAction*) const; int postCondition(const QAction* ) const; void initParameterList(const QAction*, MeshModel &/*m*/, RichParameterList & /*parent*/); - bool applyFilter(const QAction* filter, MeshDocument &md, std::map& outputValues, unsigned int& postConditionMask, const RichParameterList & /*parent*/, vcg::CallBackPos * cb) ; - + std::map applyFilter( + const QAction* action, + const RichParameterList & parameters, + MeshDocument &md, + unsigned int& postConditionMask, + vcg::CallBackPos * cb); public slots: void finished(); void uploadProgress(qint64 bytesSent, qint64 bytesTotal); private: - bool sketchfab(MeshDocument &md, + std::string sketchfab(MeshDocument &md, vcg::CallBackPos* cb, const QString& apiToken, const QString&,