diff --git a/src/common/python/function.cpp b/src/common/python/function.cpp index 0029bd1f1..5e3cb1813 100644 --- a/src/common/python/function.cpp +++ b/src/common/python/function.cpp @@ -57,6 +57,11 @@ QString pymeshlab::Function::description() const return funDescription; } +void pymeshlab::Function::setDescription(const QString& newDescription) +{ + funDescription = newDescription; +} + unsigned int pymeshlab::Function::parametersNumber() const { return parameters.size(); diff --git a/src/common/python/function.h b/src/common/python/function.h index 93b30466b..9ba7cb5af 100644 --- a/src/common/python/function.h +++ b/src/common/python/function.h @@ -45,6 +45,7 @@ public: QString pythonFunctionName() const; QString meshlabFunctionName() const; QString description() const; + void setDescription(const QString& newDescription); unsigned int parametersNumber() const; QStringList pythonFunctionParameters() const; bool contains(const QString& pythonParameter) const; diff --git a/src/common/python/function_set.cpp b/src/common/python/function_set.cpp index b6a7d76c2..66e3cf9d9 100644 --- a/src/common/python/function_set.cpp +++ b/src/common/python/function_set.cpp @@ -95,7 +95,24 @@ void pymeshlab::FunctionSet::loadIOPlugin(IOPlugin* iop) QString pythonFilterName = outputFormat.toLower(); Function f(pythonFilterName, originalFilterName, "Save " + outputFormat + " format."); RichParameterList rps = iop->initSaveParameter(outputFormat, *dummyMeshDocument.mm()); - + if (outputFormat.toUpper() == "PLY"){ + f.setDescription( + "Ply files also support saving custom attributes. You'll need to add an " + "additional boolean parameter for each one of that you want to save, and use " + "only non-capital letters for parameter names. These parameters have a prefix " + "for each type of custom attribute:
" + "- ``__ca_vs__``: Custom Attribute Vertex Scalar;
" + "- ``__ca_vp__``: Custom Attribute Vertex Point;
" + "- ``__ca_fs__``: Custom Attribute Face Scalar;
" + "- ``__ca_fp__``: Custom Attribute Face Point;
" + "For example, if your mesh has a custom per vertex scalar attribute called " + "'MyAttribute', you can save it in a ply file by calling:
" + "``ms.save_current_mesh(file_name='myfile.ply', __ca_vs__myattribute=True)`` " + "
" + "You can check the parameters available on a mesh by calling the MeshSet " + "method :py:meth:`pmeshlab.MeshSet.filter_parameter_values`, with first " + "parameter ``ply``."); + } //filename parameter QString sv = "file_name." + outputFormat; RichSaveFile of("file_name", sv, outputFormat, "File Name", "The name of the file to save"); diff --git a/src/meshlabplugins/io_base/baseio.cpp b/src/meshlabplugins/io_base/baseio.cpp index fbb87ae57..e37b645f9 100644 --- a/src/meshlabplugins/io_base/baseio.cpp +++ b/src/meshlabplugins/io_base/baseio.cpp @@ -414,25 +414,25 @@ void BaseMeshIOPlugin::save(const QString &formatName, const QString &fileName, // if pname starts with __CA_VS__, it is a PLY per-vertex scalar custom attribute if (pname.startsWith("__CA_VS__")) { if (par.getBool(pname)) { // if it is true, add to save list - pi.addPerVertexScalarAttribute(qUtf8Printable(pname.mid(4)), scalarPlyType); + pi.addPerVertexScalarAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType); } } // if pname starts with __CA_VP__, it is a PLY per-vertex point3m custom attribute else if (pname.startsWith("__CA_VP__")) { if (par.getBool(pname)) { // if it is true, add to save list - pi.addPerVertexPoint3mAttribute(qUtf8Printable(pname.mid(5)), scalarPlyType); + pi.addPerVertexPoint3mAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType); } } // if pname starts with __CA_FS__, it is a PLY per-face scalar custom attribute else if (pname.startsWith("__CA_FS__")) { if (par.getBool(pname)) { // if it is true, add to save list - pi.addPerFaceScalarAttribute(qUtf8Printable(pname.mid(4)), scalarPlyType); + pi.addPerFaceScalarAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType); } } // if pname starts with __CA_FP__, it is a PLY per-face point3m custom attribute else if (pname.startsWith("__CA_FP__")) { if (par.getBool(pname)) { - pi.addPerFacePoint3mAttribute(qUtf8Printable(pname.mid(5)), scalarPlyType); + pi.addPerFacePoint3mAttribute(qUtf8Printable(pname.mid(9)), scalarPlyType); } } }