diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index d672679c5..e12bceb12 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -190,14 +190,20 @@ static PyObject * importer(PyObject *self, PyObject *args) static PyObject * exporter(PyObject *self, PyObject *args) { - PyObject* object; - char* Name; - if (!PyArg_ParseTuple(args, "Oet",&object,"utf-8",&Name)) + PyObject *object; + char *Name; + + // If tolerance is specified via python interface, use that. + // If not, use the preference, if that exists, else default to 0.1mm. + auto hGrp(App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Mesh") ); + float fTolerance = hGrp->GetFloat( "MaxDeviationExport", 0.1f ); + + if (!PyArg_ParseTuple(args, "Oet|f", &object, "utf-8", &Name, &fTolerance)) return NULL; + std::string EncodedName = std::string(Name); PyMem_Free(Name); - float fTolerance = 0.1f; MeshObject global_mesh; PY_TRY { @@ -535,7 +541,8 @@ PyDoc_STRVAR(inst_doc, "insert(string|mesh,[string]) -- Load or insert a mesh into the given or active document."); PyDoc_STRVAR(export_doc, -"export(list,string) -- Export a list of objects into a single file."); +"export(list,string,[tolerance]) -- Export a list of objects into a single file. tolerance is in mm\n" +"and specifies the maximum acceptable deviation between the specified objects and the exported mesh."); PyDoc_STRVAR(calculateEigenTransform_doc, "calculateEigenTransform(seq(Base.Vector)) -- Calculates the eigen Transformation from a list of points.\n" diff --git a/src/Mod/Mesh/Gui/AppMeshGui.cpp b/src/Mod/Mesh/Gui/AppMeshGui.cpp index 37a0ec490..c8e90ca9e 100644 --- a/src/Mod/Mesh/Gui/AppMeshGui.cpp +++ b/src/Mod/Mesh/Gui/AppMeshGui.cpp @@ -39,6 +39,7 @@ #include "DlgEvaluateMeshImp.h" #include "PropertyEditorMesh.h" #include "DlgSettingsMeshView.h" +#include "DlgSettingsImportExportImp.h" #include "SoFCMeshObject.h" #include "SoFCIndexedFaceSet.h" #include "SoPolygon.h" @@ -96,6 +97,7 @@ void MeshGuiExport initMeshGui() // register preferences pages (void)new Gui::PrefPageProducer ("Display"); + (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject", "Import-Export") ); MeshGui::SoFCMeshObjectElement ::initClass(); MeshGui::SoSFMeshObject ::initClass(); diff --git a/src/Mod/Mesh/Gui/CMakeLists.txt b/src/Mod/Mesh/Gui/CMakeLists.txt index 0a9ac8386..37df2ad5d 100644 --- a/src/Mod/Mesh/Gui/CMakeLists.txt +++ b/src/Mod/Mesh/Gui/CMakeLists.txt @@ -19,6 +19,8 @@ set(Mesh_MOC_HDRS DlgEvaluateMeshImp.h DlgRegularSolidImp.h DlgSettingsMeshView.h + DlgSettingsImportExportImp.h + DlgSmoothing.h MeshEditor.h PropertyEditorMesh.h @@ -32,6 +34,7 @@ set(Dialogs_UIC_SRCS DlgEvaluateMesh.ui DlgRegularSolid.ui DlgSettingsMeshView.ui + DlgSettingsImportExport.ui DlgSmoothing.ui RemoveComponents.ui Segmentation.ui @@ -49,6 +52,8 @@ SET(Dialogs_SRCS DlgSettingsMeshView.ui DlgSettingsMeshView.cpp DlgSettingsMeshView.h + DlgSettingsImportExportImp.cpp + DlgSettingsImportExportImp.h DlgSmoothing.ui DlgSmoothing.cpp DlgSmoothing.h diff --git a/src/Mod/Mesh/Gui/DlgSettingsImportExport.ui b/src/Mod/Mesh/Gui/DlgSettingsImportExport.ui new file mode 100644 index 000000000..fe2883911 --- /dev/null +++ b/src/Mod/Mesh/Gui/DlgSettingsImportExport.ui @@ -0,0 +1,96 @@ + + + MeshGui::DlgSettingsImportExport + + + + 0 + 0 + 539 + 339 + + + + Mesh Formats + + + + + + Qt::Vertical + + + + 20 + 61 + + + + + + + + Export + + + + + + + + Defines the deviation of tessellation to the actual surface + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:7.8pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Tessellation</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;"></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;"><span style=" font-weight:400;">Defines the maximum deviation of the tessellated mesh to the surface. The smaller the value is the slower the render speed and the nicer the appearance are.</span></p></body></html> + + + Maximum mesh deviation + + + + + + + mm + + + 4 + + + 0.000000000000000 + + + 100000000.000000000000000 + + + 0.010000000000000 + + + 0.100000000000000 + + + MaxDeviationExport + + + Mod/Mesh + + + + + + + + + + + + + + Gui::PrefDoubleSpinBox + QDoubleSpinBox +
Gui/PrefWidgets.h
+
+
+ + +
diff --git a/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp b/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp new file mode 100644 index 000000000..b19956a02 --- /dev/null +++ b/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (c) 2016 Ian Rees * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#include "PreCompiled.h" + +#include "DlgSettingsImportExportImp.h" +#include "ui_DlgSettingsImportExport.h" + +using namespace MeshGui; + +DlgSettingsImportExport::DlgSettingsImportExport(QWidget* parent) + : PreferencePage(parent), ui(new Ui_DlgSettingsImportExport) +{ + ui->setupUi(this); +} + +void DlgSettingsImportExport::saveSettings() +{ + ui->maxDeviationExport->onSave(); +} + +void DlgSettingsImportExport::loadSettings() +{ + ui->maxDeviationExport->onRestore(); +} + +/** + * Sets the strings of the subwidgets using the current language. + */ +void DlgSettingsImportExport::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + +#include "moc_DlgSettingsImportExportImp.cpp" + diff --git a/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.h b/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.h new file mode 100644 index 000000000..db2af98b9 --- /dev/null +++ b/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (c) 2016 Ian Rees * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef MESHGUI_DLGSETTINGSIMPORTEXPORTIMP_H +#define MESHGUI_DLGSETTINGSIMPORTEXPORTIMP_H + +#include + +namespace MeshGui { + +class Ui_DlgSettingsImportExport; +/** + * The DlgSettingsImportExportImp class implements a preference page to change settings + * for Importing and Exporting mesh objects. + */ +class DlgSettingsImportExport : public Gui::Dialog::PreferencePage +{ + Q_OBJECT + +public: + DlgSettingsImportExport(QWidget *parent=nullptr); + ~DlgSettingsImportExport() = default; + +protected: + void saveSettings(); + void loadSettings(); + void changeEvent(QEvent *e); + +private: + std::auto_ptr ui; +}; // end class DlgSettingsImportExport + +} // namespace MeshGui + +#endif // MESHGUI_DLGSETTINGSIMPORTEXPORTIMP_H +