X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Zone.cxx;h=6f247eddc32f07a68190252993d20c8f155effff;hb=d398a8be8e0b0259b476b358d53d234ce4c82379;hp=f87234534466247acc4ab6ad9db284cb10685dc4;hpb=5bdd5a07050d0879edb5efdc7e009850a46c64f8;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index f8723453..6f247edd 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -1,126 +1,202 @@ +// 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_POLYLINE_ID "KIND_ZONE" +IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) -IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Object) -IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Object) 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 +{ + return true; +} + +bool HYDROData_Zone::CanRemove() +{ + return false; +} + +HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const { - QStringList aResList; + HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects(); - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); - if ( aDocument.IsNull() ) - return aResList; + HYDROData_SequenceOfObjects aSeqOfObjects = GetObjects(); + aResSeq.Append( aSeqOfObjects ); - return aResList; + return aResSeq; } -void HYDROData_Zone::SetColor( const QColor& theColor ) +void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape ) { - Handle(TDataStd_IntegerArray) aColorArray; - if ( !myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) ) - aColorArray = TDataStd_IntegerArray::Set( myLab.FindChild( DataTag_Color ), 1, 4 ); + HYDROData_Entity::SetShape( DataTag_Shape, theShape ); +} - aColorArray->SetValue( 1, theColor.red() ); - aColorArray->SetValue( 2, theColor.green() ); - aColorArray->SetValue( 3, theColor.blue() ); - aColorArray->SetValue( 4, theColor.alpha() ); +TopoDS_Shape HYDROData_Zone::GetShape() const +{ + return HYDROData_Entity::GetShape( DataTag_Shape ); } -QColor HYDROData_Zone::GetColor() const +bool HYDROData_Zone::IsMergingNeed() const { - QColor aResColor( Qt::green ); + // Zones based on geometry objects (compare altitudes) + Handle(HYDROData_IAltitudeObject) aRefAltitude; - Handle(TDataStd_IntegerArray) aColorArray; - if ( myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) ) + HYDROData_SequenceOfObjects anObjects = GetObjects(); + HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects ); + for ( ; anObjsIter.More(); anObjsIter.Next() ) { - aResColor.setRed( aColorArray->Value( 1 ) ); - aResColor.setGreen( aColorArray->Value( 2 ) ); - aResColor.setBlue( aColorArray->Value( 3 ) ); - aResColor.setAlpha( aColorArray->Value( 4 ) ); + 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 aResColor; + return false; } -void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ) +void HYDROData_Zone::SetInterpolator( HYDROData_IInterpolator* theInter ) { - SetReferenceObject( thePolyline, DataTag_Polyline ); + myInterpolator = theInter; } -Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const +HYDROData_IInterpolator* HYDROData_Zone::GetInterpolator() const { - return Handle(HYDROData_Polyline)::DownCast( - GetReferenceObject( DataTag_Polyline ) ); + return myInterpolator; } -void HYDROData_Zone::RemovePolyline() +void HYDROData_Zone::SetMergeType( const MergeType& theType ) { - ClearReferenceObjects( DataTag_Polyline ); + TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType ); } -int HYDROData_Zone::NbBathymetries() const +HYDROData_Zone::MergeType HYDROData_Zone::GetMergeType() const { - return NbReferenceObjects( DataTag_Bathymetry ); + MergeType aMergeType = Merge_UNKNOWN; + + TDF_Label aLabel = myLab.FindChild( DataTag_MergeType, false ); + if ( !aLabel.IsNull() ) + { + Handle(TDataStd_Integer) anInt; + if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anInt ) ) + aMergeType = (MergeType)anInt->Get(); + } + + return aMergeType; } -void HYDROData_Zone::AddBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ) +void HYDROData_Zone::SetMergeObject( const Handle(HYDROData_Entity)& theObject ) { - AddReferenceObject( theBathymetry, DataTag_Bathymetry ); + //DEBTRACE("HYDROData_Zone::SetMergeObject"); + SetReferenceObject( theObject, DataTag_MergeObject ); } -void HYDROData_Zone::SetBathymetry( const int theIndex, - const Handle(HYDROData_Bathymetry)& theBathymetry ) +Handle(HYDROData_Entity) HYDROData_Zone::GetMergeObject() const { - SetReferenceObject( theBathymetry, DataTag_Bathymetry, theIndex ); + return Handle(HYDROData_Entity)::DownCast( + GetReferenceObject( DataTag_MergeObject ) ); } -Handle(HYDROData_Bathymetry) HYDROData_Zone::GetBathymetry( const int theIndex ) const +void HYDROData_Zone::RemoveMergeObject() { - return Handle(HYDROData_Bathymetry)::DownCast( - GetReferenceObject( DataTag_Bathymetry, theIndex ) ); + ClearReferenceObjects( DataTag_MergeObject ); } -HYDROData_SequenceOfObjects HYDROData_Zone::GetBathymetries() const +bool HYDROData_Zone::AddObject( const Handle(HYDROData_Entity)& theObject ) { - return GetReferenceObjects( DataTag_Bathymetry ); + 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; } -void HYDROData_Zone::RemoveBathymetries() +HYDROData_SequenceOfObjects HYDROData_Zone::GetObjects() const { - ClearReferenceObjects( DataTag_Bathymetry ); + return GetReferenceObjects( DataTag_Object ); } -QPainterPath HYDROData_Zone::GetPainterPath() const +void HYDROData_Zone::RemoveObjects() { - QPainterPath aPath; + ClearReferenceObjects( DataTag_Object ); +} - Handle(HYDROData_Polyline) aPolyline = GetPolyline(); - if ( !aPolyline.IsNull() ) +bool HYDROData_Zone::IsSubmersible() const +{ + HYDROData_SequenceOfObjects anObjects = GetObjects(); + HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects ); + for ( ; anObjsIter.More(); anObjsIter.Next() ) { - aPath = aPolyline->painterPath(); - } + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( anObjsIter.Value() ); + if ( aRefGeomObj.IsNull() ) + continue; - return aPath; + if( !aRefGeomObj->IsSubmersible() ) + return false; //if one of geometry objects is not submersible the zone is considered as not submersible + } + return true; }