From 8c651c251e4ceac4a505cf7f6d4795e68ff819b6 Mon Sep 17 00:00:00 2001 From: isn Date: Tue, 18 Sep 2018 16:28:08 +0300 Subject: [PATCH] dumping to py, sip, translations Signed-off-by: isn --- src/HYDROData/HYDROData_BCPolygon.cxx | 6 +- src/HYDROData/HYDROData_CalculationCase.cxx | 8 ++ src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx | 15 ++- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 27 +++++ src/HYDROPy/CMakeLists.txt | 1 + src/HYDROPy/HYDROData.sip | 2 +- src/HYDROPy/HYDROData_BCPolygon.sip | 109 ++++++++++++++++++++ src/HYDROPy/HYDROData_CalculationCase.sip | 41 ++++++++ src/HYDROPy/HYDROData_Document.sip | 5 + src/HYDROPy/HYDROData_Entity.sip | 5 + src/HYDROPy/HYDROData_Object.sip | 4 + 11 files changed, 214 insertions(+), 9 deletions(-) create mode 100644 src/HYDROPy/HYDROData_BCPolygon.sip diff --git a/src/HYDROData/HYDROData_BCPolygon.cxx b/src/HYDROData/HYDROData_BCPolygon.cxx index 9276a119..60717e34 100644 --- a/src/HYDROData/HYDROData_BCPolygon.cxx +++ b/src/HYDROData/HYDROData_BCPolygon.cxx @@ -53,12 +53,12 @@ QStringList HYDROData_BCPolygon::DumpToPython( const QString& thePyScriptPath, QString aBCName = GetObjPyName(); - //Handle(HYDROData_IAltitudeObject) aRefAltitude = GetAltitudeObject(); - //setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefAltitude, "SetAltitudeObject" ); - Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline(); setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolyline" ); + int nType = GetBoundaryType(); + aResList << QString( "%1.SetBoundaryType(%2)" ).arg(aBCName).arg(nType); + aResList << QString( "" ); aResList << QString( "%1.Update()" ).arg( aBCName ); diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 12aca20d..1c5a4d27 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -172,6 +172,14 @@ QStringList HYDROData_CalculationCase::DumpToPython( const QString& thePyS aResList << QString( "%1.AddGeometryGroup( %2 )" ).arg( aCalculName ).arg( aGroupName ); } + HYDROData_SequenceOfObjects aBPolygons = GetBoundaryPolygons(); + for (int i = 1; i <= aBPolygons.Size(); i++ ) + { + Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( aBPolygons(i) ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBCPoly, "AddBoundaryPolygon" ); + } + aResList << QString( "" ); + Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline(); setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" ); diff --git a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx index 95c1a1bc..bc83c0f2 100644 --- a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx @@ -166,17 +166,22 @@ NCollection_Sequence HYDROGUI_ImportPolylineOp::Import UpdateView(module, theEntities); if (theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All) //if other flag = > no need to show this messagebox SUIT_MessageBox::information(module->getApp()->desktop(), - tr( "IMPORT_POLYLINE" ), "Contour of the polygon(s) have been imported as polyline(s)"); + tr( "IMPORT_POLYLINE" ), tr ("POLYGON_IMPORTED_AS_POLYLINE")); } else { - QString aMess = "Cannot import content of this file as polyline;\n"; + QString aMess; + if (theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType::ImportShapeType_Polygon) + aMess += tr ("POLYLINE_IMPORT_FAILED_AS_POLYGON") + ";\n"; + else + aMess += tr ("POLYLINE_IMPORT_FAILED_AS_POLYLINE") + ";\n"; + if (aStat == -1) - aMess += "Cannot open SHP file"; + aMess += tr ("CANT_OPEN_SHP"); else if (aStat == -2) - aMess += "Cannot open SHX file"; + aMess += tr ("CANT_OPEN_SHX"); else - aMess += "The shape type of file is " + anImporter.GetShapeTypeName(aShapeTypeOfFile); + aMess += tr ("SHAPE_TYPE_IS") + anImporter.GetShapeTypeName(aShapeTypeOfFile); SUIT_MessageBox::warning( module->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), aMess); } importedEntities.Append(theEntities); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index ebe6fe75..63f70684 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2536,6 +2536,33 @@ file cannot be correctly imported for an Obstacle definition. NO_ONE_POLYLINE_IMPORTED Polyline cannot be read from seleted file + + + POLYLINE_IMPORT_FAILED_AS_POLYGON + Cannot import content of this file as polygon + + + POLYLINE_IMPORT_FAILED_AS_POLYLINE + Cannot import content of this file as polyline + + + POLYGON_IMPORTED_AS_POLYLINE + Contour of the polygon(s) have been imported as polyline(s) + + + CANT_OPEN_SHP + Cannot open SHP file + + + CANT_OPEN_SHX + Cannot open SHX file + + + SHAPE_TYPE_IS + The shape type of file is + + + BAD_IMPORTED_POLYLINE_FILES The data from following files cannot be completely imported: diff --git a/src/HYDROPy/CMakeLists.txt b/src/HYDROPy/CMakeLists.txt index bf8f72c4..b6f3fade 100644 --- a/src/HYDROPy/CMakeLists.txt +++ b/src/HYDROPy/CMakeLists.txt @@ -64,6 +64,7 @@ SET(_add_SOURCES sipHYDROPyHYDROData_Stream.cc sipHYDROPyHYDROData_StricklerTable.cc sipHYDROPyHYDROData_Zone.cc + sipHYDROPyHYDROData_BCPolygon.cc sipHYDROPyNCollection_Sequence0100gp_XY.cc sipHYDROPyNCollection_Sequence0100gp_XYZ.cc sipHYDROPyNCollection_Sequence0100HYDROData_IPolylineSectionType.cc diff --git a/src/HYDROPy/HYDROData.sip b/src/HYDROPy/HYDROData.sip index 9038f640..0c6c993d 100644 --- a/src/HYDROPy/HYDROData.sip +++ b/src/HYDROPy/HYDROData.sip @@ -83,4 +83,4 @@ %Include HYDROData_StreamAltitude.sip %Include HYDROData_StricklerTable.sip %Include HYDROData_Zone.sip - +%Include HYDROData_BCPolygon.sip diff --git a/src/HYDROPy/HYDROData_BCPolygon.sip b/src/HYDROPy/HYDROData_BCPolygon.sip new file mode 100644 index 00000000..f5197a14 --- /dev/null +++ b/src/HYDROPy/HYDROData_BCPolygon.sip @@ -0,0 +1,109 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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 +// + +%ExportedHeaderCode +#include +%End + +class HYDROData_BCPolygon : public HYDROData_Object +{ + +%TypeHeaderCode +#include +%End + +%ConvertToSubClassCode + switch ( sipCpp->GetKind() ) + { + case KIND_BC_POLYGON: + sipClass = sipClass_HYDROData_BCPolygon; + break; + + default: + // We don't recognise the type. + sipClass = NULL; + } +%End + +public: + + /** + * Sets reference polyline object for boundary polygon. + */ + void SetPolyline( HYDROData_PolylineXY thePolyline ) [void (const opencascade::handle&)]; + %MethodCode + + Handle(HYDROData_PolylineXY) aRefPolyline = + Handle(HYDROData_PolylineXY)::DownCast( createHandle( a0 ) ); + if ( !aRefPolyline.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_BCPolygon::SetPolyline( aRefPolyline ) : + sipCpp->SetPolyline( aRefPolyline ); + Py_END_ALLOW_THREADS + } + + %End + + /** + * Returns reference polyline object of boundary polygon. + */ + HYDROData_PolylineXY GetPolyline() const [opencascade::handle ()]; + %MethodCode + + Handle(HYDROData_PolylineXY) aRefPolyline; + + Py_BEGIN_ALLOW_THREADS + aRefPolyline = sipSelfWasArg ? sipCpp->HYDROData_BCPolygon::GetPolyline() : + sipCpp->GetPolyline(); + Py_END_ALLOW_THREADS + + sipRes = (HYDROData_PolylineXY*)createPointer( aRefPolyline ); + + %End + + /** + * Remove reference polyline object of boundary polygon. + */ + void RemovePolyline(); + + /** + * Set boundary type for boundary polygon. + */ + void SetBoundaryType( int ) const; + + /** + * Get boundary type for boundary polygon. + */ + int GetBoundaryType() const; + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_BCPolygon(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_BCPolygon(); +}; + + diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip index 52c09e4f..dac4e0d4 100644 --- a/src/HYDROPy/HYDROData_CalculationCase.sip +++ b/src/HYDROPy/HYDROData_CalculationCase.sip @@ -176,6 +176,47 @@ public: */ void RemoveGeometryGroups(); + + /** + * Add new boundary polygon to calculation case. + */ + bool AddBoundaryPolygon( HYDROData_BCPolygon theObject ) [bool ( const opencascade::handle& )]; + %MethodCode + Handle(HYDROData_BCPolygon) aRef = + Handle(HYDROData_BCPolygon)::DownCast( createHandle( a0 ) ); + if ( !aRef.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddBoundaryPolygon( aRef ): + sipCpp->AddBoundaryPolygon( aRef ); + Py_END_ALLOW_THREADS + } + %End + + /** + * Returns all boundary polygons of calculation case. + */ + HYDROData_SequenceOfObjects GetBoundaryPolygons() const; + + /** + * Removes boundary polygon from calculation case. + */ + void RemoveBoundaryPolygon( HYDROData_BCPolygon theObject ) + [void ( const opencascade::handle& )]; + %MethodCode + Handle(HYDROData_BCPolygon) aRef = + Handle(HYDROData_BCPolygon)::DownCast( createHandle( a0 ) ); + if ( !aRef.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + if ( sipSelfWasArg ) { + sipCpp->HYDROData_CalculationCase::RemoveBoundaryPolygon( aRef ); + } else { + sipCpp->RemoveBoundaryPolygon( aRef ); + } + Py_END_ALLOW_THREADS + } + %End /** * Sets reference boundary polyline object for calculation case. diff --git a/src/HYDROPy/HYDROData_Document.sip b/src/HYDROPy/HYDROData_Document.sip index 882fe167..49febca4 100644 --- a/src/HYDROPy/HYDROData_Document.sip +++ b/src/HYDROPy/HYDROData_Document.sip @@ -84,6 +84,11 @@ class HYDROData_Document aRes = new HYDROData_ImmersibleZone( *dynamic_cast( theObject ) ); break; } + case KIND_BC_POLYGON: + { + aRes = new HYDROData_BCPolygon( *dynamic_cast( theObject ) ); + break; + } case KIND_RIVER: { aRes = new HYDROData_River( *dynamic_cast( theObject ) ); diff --git a/src/HYDROPy/HYDROData_Entity.sip b/src/HYDROPy/HYDROData_Entity.sip index c9b67667..d32d61b7 100644 --- a/src/HYDROPy/HYDROData_Entity.sip +++ b/src/HYDROPy/HYDROData_Entity.sip @@ -45,6 +45,7 @@ const ObjectKind KIND_SPLIT_GROUP; const ObjectKind KIND_OBSTACLE_ALTITUDE; const ObjectKind KIND_STRICKLER_TABLE; const ObjectKind KIND_LAND_COVER_MAP; +const ObjectKind KIND_BC_POLYGON; class HYDROData_Entity { @@ -148,6 +149,10 @@ class HYDROData_Entity sipClass = sipClass_HYDROData_LandCoverMap; break; + case KIND_BC_POLYGON: + sipClass = sipClass_HYDROData_BCPolygon; + break; + case KIND_UNKNOWN: sipClass = sipClass_HYDROData_Entity; break; diff --git a/src/HYDROPy/HYDROData_Object.sip b/src/HYDROPy/HYDROData_Object.sip index 9b0fd58e..6507f676 100644 --- a/src/HYDROPy/HYDROData_Object.sip +++ b/src/HYDROPy/HYDROData_Object.sip @@ -62,6 +62,10 @@ class HYDROData_Object : public HYDROData_Entity /Abstract/ sipClass = sipClass_HYDROData_Stream; break; + case KIND_BC_POLYGON: + sipClass = sipClass_HYDROData_BCPolygon; + break; + case KIND_UNKNOWN: sipClass = sipClass_HYDROData_Entity; break; -- 2.39.2