X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Zone.cxx;h=3e45fb89074b0b16282d6aa17b23dbc463623c03;hb=3ad1721baafb8864b968fe6ef6ab68ecf49a669e;hp=15246161d2b3710adeebe6801dff6cd379787a02;hpb=b20ed0044cebfdd161511eae3dd31f3d0ccc8810;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 15246161..3e45fb89 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -1,76 +1,200 @@ +// 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 "HYDROData_Zone.h" -#include "HYDROData_Bathymetry.h" +#include "HYDROData_ArtificialObject.h" +#include "HYDROData_IAltitudeObject.h" #include "HYDROData_Document.h" -#include "HYDROData_Polyline.h" -#include "HYDROData_Iterator.h" - -#include - -#include +#include "HYDROData_NaturalObject.h" #include +#include +#include + +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" -#define PYTHON_ZONE_ID "KIND_ZONE" +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) -IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Domain) -IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Domain) HYDROData_Zone::HYDROData_Zone() +: HYDROData_Entity( Geom_2d ) { + myInterpolator = NULL; } HYDROData_Zone::~HYDROData_Zone() { } -QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +bool HYDROData_Zone::CanBeUpdated() const +{ + return false; +} + +bool HYDROData_Zone::IsHas2dPrs() const { - QStringList aResList = HYDROData_Domain::DumpToPython( theTreatedObjects ); - if ( aResList.isEmpty() ) - return aResList; + return true; +} + +bool HYDROData_Zone::CanRemove() +{ + return false; +} - aResList << QString( "" ); +HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const +{ + HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects(); - Handle(HYDROData_Polyline) aRefPolyline = GetPolyline(); - setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" ); + HYDROData_SequenceOfObjects aSeqOfObjects = GetObjects(); + aResSeq.Append( aSeqOfObjects ); - return aResList; + return aResSeq; } -void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ) +void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape ) { - SetReferenceObject( thePolyline, DataTag_Polyline ); + HYDROData_Entity::SetShape( DataTag_Shape, theShape ); } -Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const +TopoDS_Shape HYDROData_Zone::GetShape() const { - return Handle(HYDROData_Polyline)::DownCast( - GetReferenceObject( DataTag_Polyline ) ); + return HYDROData_Entity::GetShape( DataTag_Shape ); } -void HYDROData_Zone::RemovePolyline() +bool HYDROData_Zone::IsMergingNeed() const { - ClearReferenceObjects( DataTag_Polyline ); + // Zones based on geometry objects (compare altitudes) + Handle(HYDROData_IAltitudeObject) aRefAltitude; + + HYDROData_SequenceOfObjects anObjects = GetObjects(); + HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects ); + for ( ; anObjsIter.More(); anObjsIter.Next() ) + { + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( anObjsIter.Value() ); + if ( aRefGeomObj.IsNull() ) + continue; + + Handle(HYDROData_IAltitudeObject) anObjAltitude = aRefGeomObj->GetAltitudeObject(); + if ( anObjAltitude.IsNull() ) + continue; + + if ( aRefAltitude.IsNull() ) + { + aRefAltitude = anObjAltitude; + continue; + } + + if ( !IsEqual( aRefAltitude, anObjAltitude ) ) + return true; + } + + return false; } -QPainterPath HYDROData_Zone::GetPainterPath() const +void HYDROData_Zone::SetInterpolator( HYDROData_IInterpolator* theInter ) { - QPainterPath aPath; + myInterpolator = theInter; +} - Handle(HYDROData_Polyline) aPolyline = GetPolyline(); - if ( !aPolyline.IsNull() ) +HYDROData_IInterpolator* HYDROData_Zone::GetInterpolator() const +{ + return myInterpolator; +} + +void HYDROData_Zone::SetMergeType( const MergeType& theType ) +{ + TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType ); +} + +HYDROData_Zone::MergeType HYDROData_Zone::GetMergeType() const +{ + MergeType aMergeType = Merge_UNKNOWN; + + TDF_Label aLabel = myLab.FindChild( DataTag_MergeType, false ); + if ( !aLabel.IsNull() ) { - aPath = aPolyline->painterPath(); + Handle(TDataStd_Integer) anInt; + if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anInt ) ) + aMergeType = (MergeType)anInt->Get(); } - return aPath; + return aMergeType; } -QString HYDROData_Zone::getPythonKindId() const +void HYDROData_Zone::SetMergeObject( const Handle(HYDROData_Entity)& theObject ) { - return QString( PYTHON_ZONE_ID ); + //DEBTRACE("HYDROData_Zone::SetMergeObject"); + SetReferenceObject( theObject, DataTag_MergeObject ); } +Handle(HYDROData_Entity) HYDROData_Zone::GetMergeObject() const +{ + return GetReferenceObject( DataTag_MergeObject ); +} + +void HYDROData_Zone::RemoveMergeObject() +{ + ClearReferenceObjects( DataTag_MergeObject ); +} + +bool HYDROData_Zone::AddObject( const Handle(HYDROData_Entity)& theObject ) +{ + if ( theObject.IsNull() ) + return false; + + if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) && + !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) ) + return false; // Wrong type of object + + if ( HasReference( theObject, DataTag_Object ) ) + return false; // Object is already in reference list + + AddReferenceObject( theObject, DataTag_Object ); + + return true; +} +HYDROData_SequenceOfObjects HYDROData_Zone::GetObjects() const +{ + return GetReferenceObjects( DataTag_Object ); +} + +void HYDROData_Zone::RemoveObjects() +{ + ClearReferenceObjects( DataTag_Object ); +} + +bool HYDROData_Zone::IsSubmersible() const +{ + HYDROData_SequenceOfObjects anObjects = GetObjects(); + HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects ); + for ( ; anObjsIter.More(); anObjsIter.Next() ) + { + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( anObjsIter.Value() ); + if ( aRefGeomObj.IsNull() ) + continue; + + if( !aRefGeomObj->IsSubmersible() ) + return false; //if one of geometry objects is not submersible the zone is considered as not submersible + } + return true; +}