]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
bug #263: boundary polyline for bathymetry
authorasl <asl@opencascade.com>
Thu, 19 Dec 2013 12:30:48 +0000 (12:30 +0000)
committerasl <asl@opencascade.com>
Thu, 19 Dec 2013 12:30:48 +0000 (12:30 +0000)
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 60e2d9bf300fd069819fa1c8188df4803b4f14ac..cb9ee5c6008023a63dfba06402b110236cb6560c 100644 (file)
@@ -2,6 +2,7 @@
 #include "HYDROData_Bathymetry.h"
 #include "HYDROData_Document.h"
 #include "HYDROData_Tool.h"
+#include "HYDROData_PolylineXY.h"
 
 #include <gp_XY.hxx>
 #include <gp_XYZ.hxx>
@@ -479,5 +480,40 @@ bool HYDROData_Bathymetry::importFromXYZFile( QFile&          theFile,
 }
 
 
+bool HYDROData_Bathymetry::CreateBoundaryPolyline() const
+{
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+  Handle_HYDROData_PolylineXY aResult = 
+    Handle_HYDROData_PolylineXY::DownCast( aDocument->CreateObject( KIND_POLYLINEXY ) );
+
+  if( aResult.IsNull() )
+    return false;
+
+  aResult->SetName( GetName() + "_boundary" );
 
+  double Xmin = 0.0, Xmax = 0.0, Ymin = 0.0, Ymax = 0.0;
+  bool isFirst = true;
+  AltitudePoints aPoints = GetAltitudePoints();
+  foreach( AltitudePoint aPnt, aPoints )
+  {
+    double x = aPnt.X(), y = aPnt.Y();
+    if( isFirst || x<Xmin )
+      Xmin = x;
+    if( isFirst || x>Xmax )
+      Xmax = x;
+    if( isFirst || y<Ymin )
+      Ymin = y;
+    if( isFirst || y>Ymax )
+      Ymax = y;
+    isFirst = false;
+  }
+
+  aResult->AddSection( "bound", HYDROData_IPolyline::SECTION_POLYLINE, true );
+  aResult->AddPoint( 0, HYDROData_IPolyline::Point( Xmin, Ymin ) );
+  aResult->AddPoint( 0, HYDROData_IPolyline::Point( Xmin, Ymax ) );
+  aResult->AddPoint( 0, HYDROData_IPolyline::Point( Xmax, Ymax ) );
+  aResult->AddPoint( 0, HYDROData_IPolyline::Point( Xmax, Ymin ) );
+  aResult->Update();
 
+  return true;
+}
index d4866779fc7c06e317efb8783abe7b7ec8bb2fd6..e8682fd461db8beaa38415f8104c4907c0bc61ad 100644 (file)
@@ -112,6 +112,7 @@ public:
    */
   HYDRODATA_EXPORT virtual bool             ImportFromFile( const QString& theFileName );
 
+  HYDRODATA_EXPORT bool CreateBoundaryPolyline() const;
 
 private:
 
index 9fa01059f1e6c3685e043d9c13b1122d2c482ecc..64cbc1d831d5bb931f7223d167ed86ea56f9ec91 100644 (file)
@@ -80,6 +80,7 @@ set(PROJECT_HEADERS
     HYDROGUI_GeoreferencementDlg.h
     HYDROGUI_GeoreferencementOp.h
     HYDROGUI_Actor.h
+    HYDROGUI_BathymetryBoundsOp.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -161,6 +162,7 @@ set(PROJECT_SOURCES
     HYDROGUI_GeoreferencementDlg.cxx
     HYDROGUI_GeoreferencementOp.cxx
     HYDROGUI_Actor.cxx
+    HYDROGUI_BathymetryBoundsOp.cxx
 )
 
 add_definitions(
diff --git a/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx
new file mode 100644 (file)
index 0000000..35540e0
--- /dev/null
@@ -0,0 +1,61 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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 <HYDROGUI_BathymetryBoundsOp.h>
+#include <HYDROGUI_Tool.h>
+#include <HYDROGUI_UpdateFlags.h>
+
+HYDROGUI_BathymetryBoundsOp::HYDROGUI_BathymetryBoundsOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+}
+
+HYDROGUI_BathymetryBoundsOp::~HYDROGUI_BathymetryBoundsOp()
+{
+}
+
+HYDROGUI_InputPanel* HYDROGUI_BathymetryBoundsOp::createInputPanel() const
+{
+  return 0;
+}
+
+void HYDROGUI_BathymetryBoundsOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  myBath = Handle(HYDROData_Bathymetry)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+  if( myBath.IsNull() )
+    onCancel();
+  else
+    onApply();
+}
+
+bool HYDROGUI_BathymetryBoundsOp::processApply( int& theUpdateFlags, QString& theErrorMsg )
+{
+  bool isOK = myBath->CreateBoundaryPolyline();
+  theUpdateFlags = 0;
+  if( isOK )
+    theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  else
+    theErrorMsg = tr( "CANNOT_CREATE_BOUNDARY_POLYLINE" );
+  return isOK;
+}
diff --git a/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h
new file mode 100644 (file)
index 0000000..00b92d5
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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 HYDROGUI_BATHYMETRY_BOUND_H
+#define HYDROGUI_BATHYMETRY_BOUND_H
+
+#include <HYDROGUI_Operation.h>
+#include <HYDROData_Bathymetry.h>
+
+class HYDROGUI_BathymetryBoundsOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_BathymetryBoundsOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_BathymetryBoundsOp();
+
+protected:
+  virtual void startOperation();
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
+  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+private:
+  Handle(HYDROData_Bathymetry) myBath;
+};
+
+#endif
index 909dbdb5dac4b028bcc626474f9ded4141fc9bd3..8297a5ec06f570ce83554bf8549296f888167188 100644 (file)
@@ -514,6 +514,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       else if( anIsBathymetry )
       {
         theMenu->addAction( action( EditImportedBathymetryId ) );
+        theMenu->addAction( action( BathymetryBoundsId ) );
         theMenu->addSeparator();
       }
       else if( anIsPolyline )
index 277eee95d06e1fc403a649666490875d94696bb6..829ca2adb65fcd22b2620bceab60780ac26db7a7 100644 (file)
@@ -51,6 +51,7 @@
 #include "HYDROGUI_ImportProfilesOp.h"
 #include "HYDROGUI_GeoreferencementOp.h"
 #include "HYDROGUI_SetColorOp.h"
+#include "HYDROGUI_BathymetryBoundsOp.h"
 #include "HYDROGUI_Tool.h"
 
 #include <HYDROData_Document.h>
@@ -126,6 +127,7 @@ void HYDROGUI_Module::createActions()
   
   createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "IMPORT_BATHYMETRY_ICO", Qt::CTRL + Qt::Key_B );
   createAction( EditImportedBathymetryId, "EDIT_IMPORTED_BATHYMETRY", "EDIT_IMPORTED_BATHYMETRY_ICO" );
+  createAction( BathymetryBoundsId, "BATHYMETRY_BOUNDS", "BATHYMETRY_BOUNDS_ICO" );
 
   createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE", "CREATE_IMMERSIBLE_ZONE_ICO" );
   createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE", "EDIT_IMMERSIBLE_ZONE_ICO" );
@@ -418,6 +420,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditImportedBathymetryId:
     anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId  );
     break;
+  case BathymetryBoundsId:
+    anOp = new HYDROGUI_BathymetryBoundsOp( aModule );
+    break;
   case CreateImmersibleZoneId:
   case EditImmersibleZoneId:
     anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
index 5528cbacac8261ecc0bcae086b116494ffc7d3ec..21771ffd0df9666949b09bc04bb64f4cbe88c742 100644 (file)
@@ -58,6 +58,7 @@ enum OperationId
 
   ImportBathymetryId,
   EditImportedBathymetryId,
+  BathymetryBoundsId,
 
   CreateImmersibleZoneId,
   EditImmersibleZoneId,
index e2cadb8e5aa5ce16bdfb1d915214ef7a0b938f14..e6c3d02e75efe057544eb4bf77bb85f67a5e881b 100644 (file)
@@ -656,6 +656,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>DSK_EDIT_IMPORTED_BATHYMETRY</source>
       <translation>Edit imported bathymetry</translation>
     </message>
+    <message>
+      <source>DSK_BATHYMETRY_BOUNDS</source>
+      <translation>Create boundary polyline</translation>
+    </message>
     <message>
       <source>DSK_IMPORT_IMAGE</source>
       <translation>Import image</translation>
@@ -880,6 +884,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_EDIT_IMPORTED_BATHYMETRY</source>
       <translation>Edit imported bathymetry</translation>
     </message>
+    <message>
+      <source>MEN_BATHYMETRY_BOUNDS</source>
+      <translation>Create boundary polyline</translation>
+    </message>
     <message>
       <source>MEN_IMPORT_IMAGE</source>
       <translation>Import image</translation>
@@ -1080,6 +1088,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>STB_EDIT_IMPORTED_BATHYMETRY</source>
       <translation>Edit imported bathymetry</translation>
     </message>
+    <message>
+      <source>STB_BATHYMETRY_BOUNDS</source>
+      <translation>Create boundary polyline</translation>
+    </message>
     <message>
       <source>STB_IMPORT_IMAGE</source>
       <translation>Import image</translation>