From b97489a03c25bc13a55db045e41af90ebabe1d08 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 19 May 2015 15:19:34 +0300 Subject: [PATCH] refs #526: objects excluded from the final geometry --- src/HYDROData/HYDROData_CalculationCase.cxx | 2 +- src/HYDROData/HYDROData_Object.cxx | 18 +++++++ src/HYDROData/HYDROData_Object.h | 4 ++ src/HYDROData/HYDROData_Region.cxx | 16 +++++- src/HYDROData/HYDROData_Region.h | 2 + src/HYDROData/HYDROData_Zone.cxx | 14 ++++- src/HYDROData/HYDROData_Zone.h | 2 + src/HYDROGUI/CMakeLists.txt | 2 + src/HYDROGUI/HYDROGUI_Module.cxx | 12 +++++ src/HYDROGUI/HYDROGUI_Operations.cxx | 6 +++ src/HYDROGUI/HYDROGUI_Operations.h | 4 +- src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx | 54 ++++++++++++++++++++ src/HYDROGUI/HYDROGUI_SubmersibleOp.h | 42 +++++++++++++++ src/HYDROGUI/resources/HYDROGUI_images.ts | 4 ++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 13 +++++ src/HYDROGUI/resources/icon_submersible.png | Bin 0 -> 1481 bytes 16 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_SubmersibleOp.h create mode 100644 src/HYDROGUI/resources/icon_submersible.png diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index d19e77e7..ec18b345 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -961,7 +961,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, { Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast( aRegionIter.Value() ); - if( aRegion.IsNull() ) + if( aRegion.IsNull() || !aRegion->IsSubmersible() ) continue; TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs ); diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index a2aeb479..25b9e262 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -28,6 +28,7 @@ #include #include +#include #include @@ -376,3 +377,20 @@ void HYDROData_Object::removeShape3D() aLabel.ForgetAllAttributes(); } +bool HYDROData_Object::IsSubmersible() const +{ + Handle(TDataStd_Integer) aSubMersibleAttr; + + bool isSubmersible = true; //default + if( myLab.FindAttribute(TDataStd_Integer::GetID(), aSubMersibleAttr ) ) + { + int aValue = aSubMersibleAttr->Get(); + isSubmersible = ( aValue != 0 ); + } + return isSubmersible; +} + +void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const +{ + TDataStd_Integer::Set( myLab, isSubmersible ? 1 : 0 ); +} diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 96cdaa39..badf45ea 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -66,6 +66,7 @@ protected: DataTag_Object3D, ///< child 3D object DataTag_EdgesGroup, ///< child group objects DataTag_ChildAltitudeObject, ///< child altitude object + DataTag_IsSubmersible, ///< the attribute "is submersible" }; public: @@ -174,6 +175,9 @@ public: */ HYDRODATA_EXPORT virtual QColor GetBorderColor() const; + HYDRODATA_EXPORT bool IsSubmersible() const; + HYDRODATA_EXPORT void SetIsSubmersible( bool ) const; + protected: /** diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index bf633f3f..0cbb266d 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -438,4 +438,18 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec } return aResList; -} \ No newline at end of file +} + +bool HYDROData_Region::IsSubmersible() const +{ + HYDROData_SequenceOfObjects aZones = GetZones(); + HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones ); + for ( ; aZonesIter.More(); aZonesIter.Next() ) + { + Handle(HYDROData_Zone) aZone = + Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() ); + if ( !aZone->IsSubmersible() ) + return false; //if one of zones is not submersible the region is considered as not submersible + } + return true; +} diff --git a/src/HYDROData/HYDROData_Region.h b/src/HYDROData/HYDROData_Region.h index d1bc7ab8..b8da0556 100644 --- a/src/HYDROData/HYDROData_Region.h +++ b/src/HYDROData/HYDROData_Region.h @@ -114,6 +114,8 @@ public: */ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups = 0 ) const; + HYDRODATA_EXPORT bool IsSubmersible() const; + protected: /** diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index b1c3a879..53d40e52 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -193,5 +193,17 @@ void HYDROData_Zone::RemoveGeometryObjects() ClearReferenceObjects( DataTag_GeometryObject ); } - +bool HYDROData_Zone::IsSubmersible() const +{ + HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); + HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects ); + for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() ) + { + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() ); + if( !aRefGeomObj->IsSubmersible() ) + return false; //if one of geometry objects is not submersible the zone is considered as not submersible + } + return true; +} diff --git a/src/HYDROData/HYDROData_Zone.h b/src/HYDROData/HYDROData_Zone.h index 3fa4dfdf..b8a8c0d2 100644 --- a/src/HYDROData/HYDROData_Zone.h +++ b/src/HYDROData/HYDROData_Zone.h @@ -166,6 +166,8 @@ public: */ HYDRODATA_EXPORT virtual void RemoveGeometryObjects(); + HYDRODATA_EXPORT bool IsSubmersible() const; + protected: friend class HYDROData_Region; diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index d1586649..fb6568b8 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -68,6 +68,7 @@ set(PROJECT_HEADERS HYDROGUI_ShowHideOp.h HYDROGUI_StreamDlg.h HYDROGUI_StreamOp.h + HYDROGUI_SubmersibleOp.h HYDROGUI_Tool.h HYDROGUI_TwoImagesDlg.h HYDROGUI_TwoImagesOp.h @@ -178,6 +179,7 @@ set(PROJECT_SOURCES HYDROGUI_ShowHideOp.cxx HYDROGUI_StreamDlg.cxx HYDROGUI_StreamOp.cxx + HYDROGUI_SubmersibleOp.cxx HYDROGUI_Tool.cxx HYDROGUI_TwoImagesDlg.cxx HYDROGUI_TwoImagesOp.cxx diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index b697cec0..caad11e4 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -700,6 +700,18 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, if( isRoot ) theMenu->addAction( action( EditLocalCSId ) ); + + if( anIsObjectBrowser && anOwners.size()==1 ) + { + Handle( HYDROData_Object ) anObject = Handle( HYDROData_Object )::DownCast( aSeq.First() ); + if( !anObject.IsNull() ) + { + theMenu->addSeparator(); + theMenu->addAction( action( SubmersibleId ) ); + action( SubmersibleId )->setCheckable( true ); + action( SubmersibleId )->setChecked( anObject->IsSubmersible() ); + } + } } void HYDROGUI_Module::update( const int flags ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 0db568ab..ce02c32f 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -55,6 +55,7 @@ #include "HYDROGUI_LocalCSOp.h" #include "HYDROGUI_RiverBottomOp.h" #include "HYDROGUI_ProfileInterpolateOp.h" +#include "HYDROGUI_SubmersibleOp.h" #include #include @@ -182,6 +183,8 @@ void HYDROGUI_Module::createActions() createAction( RiverBottomId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" ); createAction( RiverBottomContextId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" ); createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" ); + + createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" ); } void HYDROGUI_Module::createMenus() @@ -522,6 +525,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case HideAllId: anOp = new HYDROGUI_ShowHideOp( aModule, theId ); break; + case SubmersibleId: + anOp = new HYDROGUI_SubmersibleOp( aModule ); + break; } if( !anOp ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 5640e009..5362e538 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -105,7 +105,9 @@ enum OperationId RiverBottomId, RiverBottomContextId, - ProfileInterpolateId + ProfileInterpolateId, + + SubmersibleId, }; #endif diff --git a/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx b/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx new file mode 100644 index 00000000..630bf678 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx @@ -0,0 +1,54 @@ +// 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 +// + +#include +#include +#include + +HYDROGUI_SubmersibleOp::HYDROGUI_SubmersibleOp( HYDROGUI_Module* theModule ) + : HYDROGUI_Operation( theModule ) +{ +} + +HYDROGUI_SubmersibleOp::~HYDROGUI_SubmersibleOp() +{ +} + +void HYDROGUI_SubmersibleOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + myObject = Handle(HYDROData_Object)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( myObject.IsNull() ) + onCancel(); + else + onApply(); +} + +bool HYDROGUI_SubmersibleOp::processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + bool isOK = !myObject.IsNull(); + theUpdateFlags = 0; + if( isOK ) + { + myObject->SetIsSubmersible( !myObject->IsSubmersible() ); + theUpdateFlags = 0; + } + return isOK; +} + diff --git a/src/HYDROGUI/HYDROGUI_SubmersibleOp.h b/src/HYDROGUI/HYDROGUI_SubmersibleOp.h new file mode 100644 index 00000000..e4f26a56 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_SubmersibleOp.h @@ -0,0 +1,42 @@ +// 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 +// + +#ifndef HYDROGUI_SUBMERSIBLEOP_H +#define HYDROGUI_SUBMERSIBLEOP_H + +#include +#include + +class HYDROGUI_SubmersibleOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_SubmersibleOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_SubmersibleOp(); + +protected: + virtual void startOperation(); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); + +private: + Handle(HYDROData_Object) myObject; +}; + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index dbbf4380..cf09a9d9 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -42,6 +42,10 @@ ARROW_BOTTOM_ICO icon_arrow_bottom.png + + SUBMERSIBLE_ICO + icon_submersible.png + diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 58c93cde..996a948d 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -866,6 +866,10 @@ Would you like to remove all references from the image? DSK_EDIT_LOCAL_CS Change local CS + + DSK_SUBMERSIBLE + Submersible + MEN_CREATE_CALCULATION Create calculation case @@ -1122,6 +1126,10 @@ Would you like to remove all references from the image? MEN_EDIT_LOCAL_CS Change local CS + + MEN_SUBMERSIBLE + Submersible + STB_CREATE_CALCULATION Create calculation case @@ -1359,6 +1367,11 @@ Would you like to remove all references from the image? STB_CREATE_STREAM_BOTTOM Creates the stream bottom polyline on selected stream object + + STB_SUBMERSIBLE + If the object is submersible + + MEN_PROFILE_INTERPOLATE diff --git a/src/HYDROGUI/resources/icon_submersible.png b/src/HYDROGUI/resources/icon_submersible.png new file mode 100644 index 0000000000000000000000000000000000000000..a134745dc8be61fb980a0b4883adb9c85efdeb54 GIT binary patch literal 1481 zcmV;)1vdJLP)Px#1ZP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