From: asl Date: Tue, 19 May 2015 12:19:34 +0000 (+0300) Subject: refs #526: objects excluded from the final geometry X-Git-Tag: v1.4.1~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b97489a03c25bc13a55db045e41af90ebabe1d08;p=modules%2Fhydro.git refs #526: objects excluded from the final geometry --- 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 00000000..a134745d Binary files /dev/null and b/src/HYDROGUI/resources/icon_submersible.png differ