Merge pull request #78 from ianrrees/20160119-mesh-export-tolerance-preference
Added ability to change mesh export tolerance.
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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<MeshGui::DlgSettingsMeshView> ("Display");
|
||||
(void)new Gui::PrefPageProducer<MeshGui::DlgSettingsImportExport> ( QT_TRANSLATE_NOOP("QObject", "Import-Export") );
|
||||
|
||||
MeshGui::SoFCMeshObjectElement ::initClass();
|
||||
MeshGui::SoSFMeshObject ::initClass();
|
||||
|
||||
@@ -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
|
||||
|
||||
96
src/Mod/Mesh/Gui/DlgSettingsImportExport.ui
Normal file
96
src/Mod/Mesh/Gui/DlgSettingsImportExport.ui
Normal file
File diff suppressed because one or more lines are too long
60
src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp
Normal file
60
src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2016 Ian Rees <ian.rees@gmail.com> *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
56
src/Mod/Mesh/Gui/DlgSettingsImportExportImp.h
Normal file
56
src/Mod/Mesh/Gui/DlgSettingsImportExportImp.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2016 Ian Rees <ian.rees@gmail.com> *
|
||||
* *
|
||||
* 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 <Gui/PropertyPage.h>
|
||||
|
||||
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_DlgSettingsImportExport> ui;
|
||||
}; // end class DlgSettingsImportExport
|
||||
|
||||
} // namespace MeshGui
|
||||
|
||||
#endif // MESHGUI_DLGSETTINGSIMPORTEXPORTIMP_H
|
||||
|
||||
Reference in New Issue
Block a user