From 80a0257573fd57f2301477bc15185ddc168a67f6 Mon Sep 17 00:00:00 2001 From: skv Date: Mon, 7 Dec 2015 15:38:50 +0300 Subject: [PATCH] 0023125: EDF 11112 GEOM: Choose the unity of length when exporting to STEP --- idl/STEPPlugin.idl | 21 +++- src/GEOM_I_Superv/GEOM_Superv_i.cc | 5 +- src/GEOM_SWIG/STEPPluginBuilder.py | 7 +- src/STEPPlugin/CMakeLists.txt | 3 + src/STEPPlugin/STEPPlugin_ExportDlg.cxx | 109 +++++++++++++++++++++ src/STEPPlugin/STEPPlugin_ExportDlg.h | 52 ++++++++++ src/STEPPlugin/STEPPlugin_ExportDriver.cxx | 40 +++++++- src/STEPPlugin/STEPPlugin_GUI.cxx | 10 +- src/STEPPlugin/STEPPlugin_IECallBack.cxx | 4 +- src/STEPPlugin/STEPPlugin_IExport.hxx | 6 ++ src/STEPPlugin/STEPPlugin_IOperations.cxx | 59 ++++++++++- src/STEPPlugin/STEPPlugin_IOperations.hxx | 23 ++++- src/STEPPlugin/STEPPlugin_IOperations_i.cc | 45 ++++++++- src/STEPPlugin/STEPPlugin_IOperations_i.hh | 3 +- src/STEPPlugin/STEPPlugin_msg_en.ts | 47 +++++++++ 15 files changed, 414 insertions(+), 20 deletions(-) create mode 100644 src/STEPPlugin/STEPPlugin_ExportDlg.cxx create mode 100644 src/STEPPlugin/STEPPlugin_ExportDlg.h mode change 100755 => 100644 src/STEPPlugin/STEPPlugin_IECallBack.cxx diff --git a/idl/STEPPlugin.idl b/idl/STEPPlugin.idl index 083016fab..ba1a74ec8 100644 --- a/idl/STEPPlugin.idl +++ b/idl/STEPPlugin.idl @@ -24,6 +24,23 @@ module GEOM { + /*! + * \brief Units of length + */ + enum length_unit + { + LU_INCH, + LU_MILLIMETER, + LU_FOOT, + LU_MILE, + LU_METER, + LU_KILOMETER, + LU_MILLIINCH, + LU_MICROMETER, + LU_CENTIMETER, + LU_MICROINCH + }; + /*! * \brief Interface for STEPPlugin modeling functions. */ @@ -34,9 +51,11 @@ module GEOM * * \param theObject Shape to be stored in the file. * \param theFileName Name of the file to store the given shape in. + * \param theUnit the length unit. */ void ExportSTEP( in GEOM::GEOM_Object theObject, - in string theFileName ); + in string theFileName, + in GEOM::length_unit theUnit); /*! * \brief Import a shape from the STEP file. diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 449a3c6b8..662b2c768 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -3563,7 +3563,10 @@ void GEOM_Superv_i::ExportSTEP( GEOM::GEOM_Object_ptr theObject, beginService( " GEOM_Superv_i::ExportSTEP" ); MESSAGE("GEOM_Superv_i::ExportSTEP"); getSTEPPluginOp(); - mySTEPOp->ExportSTEP( theObject, theFileName ); + + const GEOM::length_unit aUnit = GEOM::LU_METER; + + mySTEPOp->ExportSTEP( theObject, theFileName, aUnit ); endService( " GEOM_Superv_i::ExportSTEP" ); } diff --git a/src/GEOM_SWIG/STEPPluginBuilder.py b/src/GEOM_SWIG/STEPPluginBuilder.py index 5501013f6..1ee4fc6c7 100644 --- a/src/GEOM_SWIG/STEPPluginBuilder.py +++ b/src/GEOM_SWIG/STEPPluginBuilder.py @@ -19,6 +19,7 @@ # from GEOM import ISTEPOperations +import GEOM # Engine Library Name __libraryName__ = "STEPPluginEngine" @@ -30,17 +31,19 @@ def GetSTEPPluginOperations(self): ## Export the given shape into a file with given name in STEP format. # @param theObject Shape to be stored in the file. # @param theFileName Name of the file to store the given shape in. +# @param theUnit the length unit (see GEOM::length_unit). In meters by default. # @ingroup l2_import_export -def ExportSTEP(self, theObject, theFileName): +def ExportSTEP(self, theObject, theFileName, theUnit=GEOM.LU_METER): """ Export the given shape into a file with given name in STEP format. Parameters: theObject Shape to be stored in the file. theFileName Name of the file to store the given shape in. + theUnit the length unit (see GEOM::length_unit). In meters by default. """ anOp = GetSTEPPluginOperations(self) - anOp.ExportSTEP(theObject, theFileName) + anOp.ExportSTEP(theObject, theFileName, theUnit) if anOp.IsDone() == 0: raise RuntimeError, "Export : " + anOp.GetErrorCode() pass diff --git a/src/STEPPlugin/CMakeLists.txt b/src/STEPPlugin/CMakeLists.txt index 513f54a74..52d210920 100644 --- a/src/STEPPlugin/CMakeLists.txt +++ b/src/STEPPlugin/CMakeLists.txt @@ -95,6 +95,7 @@ SET(STEPPluginEngine_HEADERS STEPPlugin_IExport.hxx STEPPlugin_IImport.hxx STEPPlugin_ImportDriver.hxx + STEPPlugin_ExportDlg.h STEPPlugin_ExportDriver.hxx STEPPlugin_IECallBack.hxx ) @@ -103,6 +104,7 @@ IF(SALOME_BUILD_GUI) # header files / to be processed by moc SET(_moc_HEADERS STEPPlugin_GUI.h + STEPPlugin_ExportDlg.h ) ENDIF() @@ -114,6 +116,7 @@ IF(SALOME_BUILD_GUI) SET(STEPPluginGUI_SOURCES STEPPlugin_GUI.cxx + STEPPlugin_ExportDlg.cxx ${_moc_SOURCES} ) ENDIF() diff --git a/src/STEPPlugin/STEPPlugin_ExportDlg.cxx b/src/STEPPlugin/STEPPlugin_ExportDlg.cxx new file mode 100644 index 000000000..2f8124b29 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ExportDlg.cxx @@ -0,0 +1,109 @@ +// Copyright (C) 2014-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "STEPPlugin_ExportDlg.h" + +#include +#include +#include +#include + +//============================================================================= +// Constructor +//============================================================================= +STEPPlugin_ExportDlg::STEPPlugin_ExportDlg(QWidget *parent) + : SUIT_FileDlg (parent, false, true, true), + myUnitCB (0) +{ + QLabel* aUnitLabel = new QLabel(tr("STEP_LENGTH_UNITS"), this); + + myUnitCB = new QComboBox(this); + myUnitCB->addItem(tr("STEP_UNITS_KILOMETER"), GEOM::LU_KILOMETER); + myUnitCB->addItem(tr("STEP_UNITS_METER"), GEOM::LU_METER); + myUnitCB->addItem(tr("STEP_UNITS_CENTIMETER"), GEOM::LU_CENTIMETER); + myUnitCB->addItem(tr("STEP_UNITS_MILLIMETER"), GEOM::LU_MILLIMETER); + myUnitCB->addItem(tr("STEP_UNITS_MICROMETER"), GEOM::LU_MICROMETER); + myUnitCB->addItem(tr("STEP_UNITS_MILE"), GEOM::LU_MILE); + myUnitCB->addItem(tr("STEP_UNITS_FOOT"), GEOM::LU_FOOT); + myUnitCB->addItem(tr("STEP_UNITS_INCH"), GEOM::LU_INCH); + myUnitCB->addItem(tr("STEP_UNITS_MILLIINCH"), GEOM::LU_MILLIINCH); + myUnitCB->addItem(tr("STEP_UNITS_MICROINCH"), GEOM::LU_MICROINCH); + + // Meters by default. + myUnitCB->setCurrentIndex(1); + + layout()->addWidget(aUnitLabel); + layout()->addWidget(myUnitCB); +} + +//============================================================================= +// Destructor +//============================================================================= +STEPPlugin_ExportDlg::~STEPPlugin_ExportDlg() +{ +} + +//============================================================================= +// getUnits +//============================================================================= +GEOM::length_unit STEPPlugin_ExportDlg::getUnits() const +{ + const GEOM::length_unit anUnit = + (GEOM::length_unit) myUnitCB->itemData(myUnitCB->currentIndex()).toInt(); + + return anUnit; +} + +//============================================================================= +// getFileName +//============================================================================= +QString STEPPlugin_ExportDlg::getFileName(const QString &theInitial, + const QString &theFilters, + const QString &theCaption, + QWidget *theParent, + GEOM::length_unit &theUnits) +{ + QStringList aFls = theFilters.split(";;", QString::SkipEmptyParts); + QString aTmpFileName = theInitial; + + aTmpFileName = aTmpFileName.simplified(); + aTmpFileName = + aTmpFileName.replace(QRegExp("\\*"), "").replace(QRegExp("\\?"), ""); + + STEPPlugin_ExportDlg aDlg(theParent); + + aDlg.setFileMode(AnyFile); + aDlg.setFilters(aFls); + aDlg.setWindowTitle(theCaption); + + if (!aTmpFileName.isEmpty()) { + aDlg.processPath(aTmpFileName); + } + + QString aFileName; + + if (aDlg.exec() == QDialog::Accepted) { + aFileName = aDlg.selectedFile(); + theUnits = aDlg.getUnits(); + } + + QApplication::processEvents(); + + return aFileName; +} diff --git a/src/STEPPlugin/STEPPlugin_ExportDlg.h b/src/STEPPlugin/STEPPlugin_ExportDlg.h new file mode 100644 index 000000000..d310484d3 --- /dev/null +++ b/src/STEPPlugin/STEPPlugin_ExportDlg.h @@ -0,0 +1,52 @@ +// Copyright (C) 2014-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef STEPPlugin_ExportDlg_H +#define STEPPlugin_ExportDlg_H + +#include +#include +#include CORBA_CLIENT_HEADER(STEPPlugin) + +class QComboBox; + +class STEPPlugin_ExportDlg: public SUIT_FileDlg +{ + Q_OBJECT + +public: + + STEPPlugin_ExportDlg(QWidget *parent); + ~STEPPlugin_ExportDlg(); + + GEOM::length_unit getUnits() const; + + static QString getFileName(const QString &theInitial, + const QString &theFilters, + const QString &theCaption, + QWidget *theParent, + GEOM::length_unit &theUnits); + +private: + + QComboBox *myUnitCB; + +}; + +#endif // STEPPlugin_ExportDlg_H diff --git a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx index 8f5f0db18..0adef6012 100644 --- a/src/STEPPlugin/STEPPlugin_ExportDriver.cxx +++ b/src/STEPPlugin/STEPPlugin_ExportDriver.cxx @@ -20,6 +20,7 @@ // internal includes #include "STEPPlugin_ExportDriver.hxx" #include "STEPPlugin_IExport.hxx" +#include "STEPPlugin_IOperations.hxx" // KERNEL includes #include @@ -74,6 +75,43 @@ Standard_Integer STEPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) cons aFunction->SetValue( aShape ); TCollection_AsciiString aFileName = aData.GetFileName(); + Standard_Integer anUnit = aData.GetUnit(); + TCollection_AsciiString aWriteUnit; + + switch (anUnit) { + case STEPPlugin_IOperations::LengthUnit_Inch: + aWriteUnit = "INCH"; + break; + case STEPPlugin_IOperations::LengthUnit_Millimeter: + aWriteUnit = "MM"; + break; + case STEPPlugin_IOperations::LengthUnit_Foot: + aWriteUnit = "FT"; + break; + case STEPPlugin_IOperations::LengthUnit_Mile: + aWriteUnit = "MI"; + break; + case STEPPlugin_IOperations::LengthUnit_Meter: + aWriteUnit = "M"; + break; + case STEPPlugin_IOperations::LengthUnit_Kilometer: + aWriteUnit = "KM"; + break; + case STEPPlugin_IOperations::LengthUnit_Milliinch: + aWriteUnit = "MIL"; + break; + case STEPPlugin_IOperations::LengthUnit_Micrometer: + aWriteUnit = "UM"; + break; + case STEPPlugin_IOperations::LengthUnit_Centimeter: + aWriteUnit = "CM"; + break; + case STEPPlugin_IOperations::LengthUnit_Microinch: + aWriteUnit = "UIN"; + break; + default: + return 0; + } MESSAGE("Export STEP into file " << aFileName.ToCString()); @@ -86,7 +124,7 @@ Standard_Integer STEPPlugin_ExportDriver::Execute( TFunction_Logbook& log ) cons //VRV: OCC 4.0 migration STEPControl_Writer aWriter; Interface_Static::SetCVal("xstep.cascade.unit","M"); - Interface_Static::SetCVal("write.step.unit", "M"); + Interface_Static::SetCVal("write.step.unit", aWriteUnit.ToCString()); Interface_Static::SetIVal("write.step.nonmanifold", 1); status = aWriter.Transfer( aShape, STEPControl_AsIs ); //VRV: OCC 4.0 migration diff --git a/src/STEPPlugin/STEPPlugin_GUI.cxx b/src/STEPPlugin/STEPPlugin_GUI.cxx index c8f0300e3..5543266d7 100644 --- a/src/STEPPlugin/STEPPlugin_GUI.cxx +++ b/src/STEPPlugin/STEPPlugin_GUI.cxx @@ -37,6 +37,7 @@ #include "GEOMBase.h" #include "GEOM_Displayer.h" #include "GEOM_GenericObjPtr.h" +#include "STEPPlugin_ExportDlg.h" #include #include CORBA_SERVER_HEADER(STEPPlugin) @@ -250,11 +251,12 @@ bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent ) if ( CORBA::is_nil( obj ) ) continue; - QString fileName = app->getFileName( false, - QString( io->getName() ), + GEOM::length_unit anUnit; + QString fileName = STEPPlugin_ExportDlg::getFileName + (QString( io->getName() ), tr( "STEP_FILES" ), tr( "EXPORT_TITLE" ), - parent ); + parent, anUnit); if ( fileName.isEmpty() ) return false; @@ -268,7 +270,7 @@ bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent ) app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); transaction.start(); - stepOp->ExportSTEP( obj, fileName.toUtf8().constData() ); + stepOp->ExportSTEP( obj, fileName.toUtf8().constData(), anUnit); if ( stepOp->IsDone() ) { diff --git a/src/STEPPlugin/STEPPlugin_IECallBack.cxx b/src/STEPPlugin/STEPPlugin_IECallBack.cxx old mode 100755 new mode 100644 index bc5c0ff81..ac0869716 --- a/src/STEPPlugin/STEPPlugin_IECallBack.cxx +++ b/src/STEPPlugin/STEPPlugin_IECallBack.cxx @@ -52,7 +52,9 @@ STEPPlugin_IECallBack::Export( int theDocId, const TCollection_AsciiString& theFormatName ) { STEPPlugin_IOperations* aPluginOperations = STEPPlugin_OperationsCreator::get( GetEngine(), theDocId ); - aPluginOperations->ExportSTEP( theOriginal, theFileName ); + const STEPPlugin_IOperations::LengthUnit aUnit = STEPPlugin_IOperations::LengthUnit_Meter; + + aPluginOperations->ExportSTEP( theOriginal, theFileName, aUnit ); return true; } diff --git a/src/STEPPlugin/STEPPlugin_IExport.hxx b/src/STEPPlugin/STEPPlugin_IExport.hxx index 020b573ad..77f01392b 100644 --- a/src/STEPPlugin/STEPPlugin_IExport.hxx +++ b/src/STEPPlugin/STEPPlugin_IExport.hxx @@ -24,6 +24,7 @@ #define EXPORTSTEP_ARG_ORIGINAL 1 #define EXPORTSTEP_ARG_FILENAME 2 +#define EXPORTSTEP_ARG_UNIT 3 class STEPPlugin_IExport { @@ -40,6 +41,11 @@ public: { _func->SetString( EXPORTSTEP_ARG_FILENAME, theFileName ); } TCollection_AsciiString GetFileName() { return _func->GetString( EXPORTSTEP_ARG_FILENAME ); } + + void SetUnit(const Standard_Integer theUnit) + { _func->SetInteger(EXPORTSTEP_ARG_UNIT, theUnit); } + Standard_Integer GetUnit() + { return _func->GetInteger(EXPORTSTEP_ARG_UNIT); } private: Handle(GEOM_Function) _func; diff --git a/src/STEPPlugin/STEPPlugin_IOperations.cxx b/src/STEPPlugin/STEPPlugin_IOperations.cxx index 86d1055e3..72064e8e3 100644 --- a/src/STEPPlugin/STEPPlugin_IOperations.cxx +++ b/src/STEPPlugin/STEPPlugin_IOperations.cxx @@ -54,18 +54,66 @@ STEPPlugin_IOperations::~STEPPlugin_IOperations() MESSAGE( "STEPPlugin_IOperations::~STEPPlugin_IOperations" ); } +//============================================================================= +/*! + * + */ +//============================================================================= +static GEOM::TPythonDump& operator<< + (GEOM::TPythonDump &theDump, + const STEPPlugin_IOperations::LengthUnit theState) +{ + switch (theState) { + case STEPPlugin_IOperations::LengthUnit_Inch: + theDump << "GEOM.LU_INCH"; + break; + case STEPPlugin_IOperations::LengthUnit_Millimeter: + theDump << "GEOM.LU_MILLIMETER"; + break; + case STEPPlugin_IOperations::LengthUnit_Foot: + theDump << "GEOM.LU_FOOT"; + break; + case STEPPlugin_IOperations::LengthUnit_Mile: + theDump << "GEOM.LU_MILE"; + break; + case STEPPlugin_IOperations::LengthUnit_Meter: + theDump << "GEOM.LU_METER"; + break; + case STEPPlugin_IOperations::LengthUnit_Kilometer: + theDump << "GEOM.LU_KILOMETER"; + break; + case STEPPlugin_IOperations::LengthUnit_Milliinch: + theDump << "GEOM.LU_MILLIINCH"; + break; + case STEPPlugin_IOperations::LengthUnit_Micrometer: + theDump << "GEOM.LU_MICROMETER"; + break; + case STEPPlugin_IOperations::LengthUnit_Centimeter: + theDump << "GEOM.LU_CENTIMETER"; + break; + case STEPPlugin_IOperations::LengthUnit_Microinch: + theDump << "GEOM.LU_MICROINCH"; + break; + default: + break; + } + + return theDump; +} + //============================================================================= /*! * ExportSTEP * Export a shape to STEP format * \param theOriginal The shape to export * \param theFileName The name of the file to exported - * \param theIsASCII The format of the exported file (ASCII or Binary) - * \param theDeflection The deflection of the shape to exported + * \param theUnit the length unit */ //============================================================================= -void STEPPlugin_IOperations::ExportSTEP( const Handle(GEOM_Object) theOriginal, - const TCollection_AsciiString& theFileName ) +void STEPPlugin_IOperations::ExportSTEP + (const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString &theFileName, + const LengthUnit theUnit) { SetErrorCode(KO); if( theOriginal.IsNull() ) return; @@ -87,6 +135,7 @@ void STEPPlugin_IOperations::ExportSTEP( const Handle(GEOM_Object) theOrigi STEPPlugin_IExport aCI( aFunction ); aCI.SetOriginal( aRefFunction ); aCI.SetFileName( theFileName ); + aCI.SetUnit( theUnit ); //Perform the Export try { @@ -104,7 +153,7 @@ void STEPPlugin_IOperations::ExportSTEP( const Handle(GEOM_Object) theOrigi //Make a Python command GEOM::TPythonDump(aFunction) << "geompy.ExportSTEP(" << theOriginal << ", \"" - << theFileName.ToCString() << "\" )"; + << theFileName.ToCString() << "\", " << theUnit << " )"; SetErrorCode(OK); } diff --git a/src/STEPPlugin/STEPPlugin_IOperations.hxx b/src/STEPPlugin/STEPPlugin_IOperations.hxx index ca81fac29..92b3f160e 100644 --- a/src/STEPPlugin/STEPPlugin_IOperations.hxx +++ b/src/STEPPlugin/STEPPlugin_IOperations.hxx @@ -29,12 +29,33 @@ class STEPPLUGINENGINE_EXPORT STEPPlugin_IOperations: public GEOMImpl_IBaseIEOperations { + +public: + + /*! + * \brief Units of length + */ + enum LengthUnit + { + LengthUnit_Inch, + LengthUnit_Millimeter, + LengthUnit_Foot, + LengthUnit_Mile, + LengthUnit_Meter, + LengthUnit_Kilometer, + LengthUnit_Milliinch, + LengthUnit_Micrometer, + LengthUnit_Centimeter, + LengthUnit_Microinch + }; + + public: STEPPlugin_IOperations( GEOM_Engine*, int ); ~STEPPlugin_IOperations(); void ExportSTEP( const Handle(GEOM_Object), - const TCollection_AsciiString& ); + const TCollection_AsciiString&, const LengthUnit ); Handle(TColStd_HSequenceOfTransient) ImportSTEP( const TCollection_AsciiString&, const bool ); diff --git a/src/STEPPlugin/STEPPlugin_IOperations_i.cc b/src/STEPPlugin/STEPPlugin_IOperations_i.cc index 7eeee1a94..fba3ce031 100644 --- a/src/STEPPlugin/STEPPlugin_IOperations_i.cc +++ b/src/STEPPlugin/STEPPlugin_IOperations_i.cc @@ -53,10 +53,12 @@ STEPPlugin_IOperations_i::~STEPPlugin_IOperations_i() * Export a shape to STEP format * \param theOriginal The shape to export * \param theFileName The name of the exported file + * \param theUnit the length unit. */ //============================================================================= -void STEPPlugin_IOperations_i::ExportSTEP( GEOM::GEOM_Object_ptr theOriginal, - const char* theFileName ) +void STEPPlugin_IOperations_i::ExportSTEP(GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName, + GEOM::length_unit theUnit) { // duplicate the original shape GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal ); @@ -68,8 +70,45 @@ void STEPPlugin_IOperations_i::ExportSTEP( GEOM::GEOM_Object_ptr theOriginal, Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal ); if (anOriginal.IsNull()) return; + STEPPlugin_IOperations::LengthUnit aUnit; + + switch (theUnit) { + case GEOM::LU_INCH: + aUnit = STEPPlugin_IOperations::LengthUnit_Inch; + break; + case GEOM::LU_MILLIMETER: + aUnit = STEPPlugin_IOperations::LengthUnit_Millimeter; + break; + case GEOM::LU_FOOT: + aUnit = STEPPlugin_IOperations::LengthUnit_Foot; + break; + case GEOM::LU_MILE: + aUnit = STEPPlugin_IOperations::LengthUnit_Mile; + break; + case GEOM::LU_METER: + aUnit = STEPPlugin_IOperations::LengthUnit_Meter; + break; + case GEOM::LU_KILOMETER: + aUnit = STEPPlugin_IOperations::LengthUnit_Kilometer; + break; + case GEOM::LU_MILLIINCH: + aUnit = STEPPlugin_IOperations::LengthUnit_Milliinch; + break; + case GEOM::LU_MICROMETER: + aUnit = STEPPlugin_IOperations::LengthUnit_Micrometer; + break; + case GEOM::LU_CENTIMETER: + aUnit = STEPPlugin_IOperations::LengthUnit_Centimeter; + break; + case GEOM::LU_MICROINCH: + aUnit = STEPPlugin_IOperations::LengthUnit_Microinch; + break; + default: + return; + } + //Export the shape to the file - GetOperations()->ExportSTEP( anOriginal, theFileName ); + GetOperations()->ExportSTEP( anOriginal, theFileName, aUnit ); } //============================================================================= diff --git a/src/STEPPlugin/STEPPlugin_IOperations_i.hh b/src/STEPPlugin/STEPPlugin_IOperations_i.hh index e2c51c79a..16e000909 100644 --- a/src/STEPPlugin/STEPPlugin_IOperations_i.hh +++ b/src/STEPPlugin/STEPPlugin_IOperations_i.hh @@ -43,7 +43,8 @@ public: STEPPlugin_IOperations* theImpl ); ~STEPPlugin_IOperations_i(); - void ExportSTEP( GEOM::GEOM_Object_ptr, const char* ); + void ExportSTEP( GEOM::GEOM_Object_ptr, const char*, + GEOM::length_unit ); GEOM::ListOfGO* ImportSTEP( const char*, const bool ); char* ReadValue( const char*, const char* ); diff --git a/src/STEPPlugin/STEPPlugin_msg_en.ts b/src/STEPPlugin/STEPPlugin_msg_en.ts index d24fc9014..47d15c8f8 100644 --- a/src/STEPPlugin/STEPPlugin_msg_en.ts +++ b/src/STEPPlugin/STEPPlugin_msg_en.ts @@ -48,4 +48,51 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specified in meters). + + STEPPlugin_ExportDlg + + STEP_LENGTH_UNITS + Length units + + + STEP_UNITS_INCH + inch + + + STEP_UNITS_MILLIMETER + millimeter + + + STEP_UNITS_FOOT + foot + + + STEP_UNITS_MILE + mile + + + STEP_UNITS_METER + meter + + + STEP_UNITS_KILOMETER + kilometer + + + STEP_UNITS_MILLIINCH + milliinch + + + STEP_UNITS_MICROMETER + micrometer + + + STEP_UNITS_CENTIMETER + centimeter + + + STEP_UNITS_MICROINCH + microinch + + -- 2.39.2