Salome HOME
dumping to py, sip, translations BR_1813
authorisn <isn@opencascade.com>
Tue, 18 Sep 2018 13:28:08 +0000 (16:28 +0300)
committerisn <isn@opencascade.com>
Tue, 18 Sep 2018 17:28:34 +0000 (20:28 +0300)
Signed-off-by: isn <isn@opencascade.com>
src/HYDROData/HYDROData_BCPolygon.cxx
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROPy/CMakeLists.txt
src/HYDROPy/HYDROData.sip
src/HYDROPy/HYDROData_BCPolygon.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_CalculationCase.sip
src/HYDROPy/HYDROData_Document.sip
src/HYDROPy/HYDROData_Entity.sip
src/HYDROPy/HYDROData_Object.sip

index 9276a119feb8dd8b373a8b9bb2df85d0dfa18c50..60717e3485b90dd2268ea1165dc2457889e8771e 100644 (file)
@@ -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 );
index 12aca20da9df2a77b0a89344036dcfe8acc52472..1c5a4d274d276f131853d0d98a9209f694ae35cf 100644 (file)
@@ -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" );
 
index 95c1a1bcb13321d095c8427b6a12a211401c4d0a..bc83c0f2abe7506a9200f7a357e2a839c835c4f3 100644 (file)
@@ -166,17 +166,22 @@ NCollection_Sequence<Handle(HYDROData_Entity)> 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);
index ebe6fe75d5219d9fb0c75a9c6296a7f2fa540f42..63f70684a5d39834aebbac551e8be6b5ce5a7e5b 100644 (file)
@@ -2536,6 +2536,33 @@ file cannot be correctly imported for an Obstacle definition.</translation>
       <source>NO_ONE_POLYLINE_IMPORTED</source>
       <translation>Polyline cannot be read from seleted file</translation>
     </message>
+
+    <message>
+      <source>POLYLINE_IMPORT_FAILED_AS_POLYGON</source>
+      <translation>Cannot import content of this file as polygon</translation>
+    </message>
+    <message>
+      <source>POLYLINE_IMPORT_FAILED_AS_POLYLINE</source>
+      <translation>Cannot import content of this file as polyline</translation>
+    </message>
+    <message>
+      <source>POLYGON_IMPORTED_AS_POLYLINE</source>
+      <translation>Contour of the polygon(s) have been imported as polyline(s)</translation>
+    </message>
+    <message>
+      <source>CANT_OPEN_SHP</source>
+      <translation>Cannot open SHP file</translation>
+    </message>
+    <message>
+      <source>CANT_OPEN_SHX</source>
+      <translation>Cannot open SHX file</translation>
+    </message>
+     <message>
+      <source>SHAPE_TYPE_IS</source>
+      <translation>The shape type of file is </translation>
+    </message>
+
+
     <message>
       <source>BAD_IMPORTED_POLYLINE_FILES</source>
       <translation>The data from following files cannot be completely imported:
index bf8f72c42474aae0dca8294ef69620415aa9d44b..b6f3fadef1a99d5b771066e858b654f9f038fce3 100644 (file)
@@ -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
index 9038f64095acb454bc00ee73d2708b1d601435f9..0c6c993d0f52e6c48e50e8ce1fcba21dca1c605b 100644 (file)
@@ -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 (file)
index 0000000..f5197a1
--- /dev/null
@@ -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 <HYDROData_BCPolygon.h>
+%End
+
+class HYDROData_BCPolygon : public HYDROData_Object
+{
+
+%TypeHeaderCode
+#include <HYDROData_BCPolygon.h>
+%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<HYDROData_PolylineXY>&)];
+  %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<HYDROData_PolylineXY> ()];
+  %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();
+};
+
+
index 52c09e4f954aa47742ceb3502fa2b00ab380fc3f..dac4e0d40f026c2e4ad101f581c3cebfb3b1dc6d 100644 (file)
@@ -176,6 +176,47 @@ public:
    */
   void RemoveGeometryGroups();
 
+     
+  /**
+   * Add new boundary polygon to calculation case.
+   */
+  bool AddBoundaryPolygon( HYDROData_BCPolygon theObject ) [bool ( const opencascade::handle<HYDROData_BCPolygon>& )];
+  %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<HYDROData_BCPolygon>& )];
+  %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.
index 882fe167ab7cd1444c472ad7bcc15896a8810877..49febca4cea5406453b4d26c3dcb627c87170708 100644 (file)
@@ -84,6 +84,11 @@ class HYDROData_Document
         aRes = new HYDROData_ImmersibleZone( *dynamic_cast<HYDROData_ImmersibleZone*>( theObject ) );
         break;
       }
+      case KIND_BC_POLYGON:
+      {
+        aRes = new HYDROData_BCPolygon( *dynamic_cast<HYDROData_BCPolygon*>( theObject ) );
+        break;
+      }
       case KIND_RIVER:
       {
         aRes = new HYDROData_River( *dynamic_cast<HYDROData_River*>( theObject ) );
index c9b676672b057c24642281f4c541696d28fd7492..d32d61b750af275aa9363c469d55a91ce853cd28 100644 (file)
@@ -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;
index 9b0fd58ee70b4dfebec055796f244e6c41c929b7..6507f676b52dfe8845992ca741acc84376985f57 100644 (file)
@@ -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;