FilterSketchfab uses new applyFilter call

This commit is contained in:
alemuntoni 2021-03-05 14:56:23 +01:00
parent 7e69d37def
commit 1a79d4d0e4
4 changed files with 26 additions and 15 deletions

View File

@ -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

View File

@ -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 \

View File

@ -125,22 +125,31 @@ void FilterSketchFabPlugin::initParameterList(const QAction* action, MeshModel&,
}
}
bool FilterSketchFabPlugin::applyFilter(const QAction * action, MeshDocument& md, std::map<std::string, QVariant>&, unsigned int& /*postConditionMask*/, const RichParameterList& par, vcg::CallBackPos* cb)
std::map<std::string, QVariant> FilterSketchFabPlugin::applyFilter(
const QAction * action,
const RichParameterList& par,
MeshDocument& md,
unsigned int& /*postConditionMask*/,
vcg::CallBackPos* cb)
{
std::map<std::string, QVariant> 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 the<a href=\"https://sketchfab.com/settings/password\">Sketchfab Password Settings.");
return false;
throw MLException("Please set in the MeshLab preferences your private API Token string that you can find on the<a href=\"https://sketchfab.com/settings/password\">Sketchfab 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("<a href=\"%s\">%s</a>\n",qUtf8Printable(QString::fromStdString(urlModel)),qUtf8Printable(QString::fromStdString(urlModel)));
return true;
return urlModel;
}
bool FilterSketchFabPlugin::upload(

View File

@ -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<std::string, QVariant>& outputValues, unsigned int& postConditionMask, const RichParameterList & /*parent*/, vcg::CallBackPos * cb) ;
std::map<std::string, QVariant> 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&,