From: asl Date: Thu, 19 Dec 2013 12:30:48 +0000 (+0000) Subject: bug #263: boundary polyline for bathymetry X-Git-Tag: BR_hydro_v_0_6~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c7019bbe1470fd78e243033d71e8b9fcdaee18a7;p=modules%2Fhydro.git bug #263: boundary polyline for bathymetry --- diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 60e2d9bf..cb9ee5c6 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -2,6 +2,7 @@ #include "HYDROData_Bathymetry.h" #include "HYDROData_Document.h" #include "HYDROData_Tool.h" +#include "HYDROData_PolylineXY.h" #include #include @@ -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 || xXmax ) + Xmax = x; + if( isFirst || yYmax ) + 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; +} diff --git a/src/HYDROData/HYDROData_Bathymetry.h b/src/HYDROData/HYDROData_Bathymetry.h index d4866779..e8682fd4 100644 --- a/src/HYDROData/HYDROData_Bathymetry.h +++ b/src/HYDROData/HYDROData_Bathymetry.h @@ -112,6 +112,7 @@ public: */ HYDRODATA_EXPORT virtual bool ImportFromFile( const QString& theFileName ); + HYDRODATA_EXPORT bool CreateBoundaryPolyline() const; private: diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 9fa01059..64cbc1d8 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -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 index 00000000..35540e01 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx @@ -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 +#include +#include + +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 index 00000000..00b92d56 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h @@ -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 +#include + +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 diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 909dbdb5..8297a5ec 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -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 ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 277eee95..829ca2ad 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -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 @@ -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 ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 5528cbac..21771ffd 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -58,6 +58,7 @@ enum OperationId ImportBathymetryId, EditImportedBathymetryId, + BathymetryBoundsId, CreateImmersibleZoneId, EditImmersibleZoneId, diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index e2cadb8e..e6c3d02e 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -656,6 +656,10 @@ file cannot be correctly imported for a Bathymetry definition. DSK_EDIT_IMPORTED_BATHYMETRY Edit imported bathymetry + + DSK_BATHYMETRY_BOUNDS + Create boundary polyline + DSK_IMPORT_IMAGE Import image @@ -880,6 +884,10 @@ file cannot be correctly imported for a Bathymetry definition. MEN_EDIT_IMPORTED_BATHYMETRY Edit imported bathymetry + + MEN_BATHYMETRY_BOUNDS + Create boundary polyline + MEN_IMPORT_IMAGE Import image @@ -1080,6 +1088,10 @@ file cannot be correctly imported for a Bathymetry definition. STB_EDIT_IMPORTED_BATHYMETRY Edit imported bathymetry + + STB_BATHYMETRY_BOUNDS + Create boundary polyline + STB_IMPORT_IMAGE Import image