#include "HYDROData_Zone.h"
+#include "HYDROData_ArtificialObject.h"
+#include "HYDROData_Bathymetry.h"
#include "HYDROData_Document.h"
-#include "HYDROData_Object.h"
+#include "HYDROData_NaturalObject.h"
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <QStringList>
+#include <TDataStd_Integer.hxx>
+
#define PYTHON_ZONE_ID "KIND_ZONE"
IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
{
QStringList aResList;
- Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
if ( aDocument.IsNull() )
return aResList;
return aResList;
}
+bool HYDROData_Zone::CanRemove()
+{
+ return false;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const
+{
+ HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+
+ HYDROData_SequenceOfObjects aSeqOfGeomObjects = GetGeometryObjects();
+ aResSeq.Append( aSeqOfGeomObjects );
+
+ return aResSeq;
+}
+
void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape )
{
TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
return TopoDS_Shape();
}
-int HYDROData_Zone::NbGeometryObjects() const
+bool HYDROData_Zone::IsMergingNeed() const
{
- return NbReferenceObjects( DataTag_GeometryObject );
+ Handle(HYDROData_Bathymetry) aRefBathymetry;
+
+ 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.IsNull() )
+ continue;
+
+ Handle(HYDROData_Bathymetry) anObjBathymetry = aRefGeomObj->GetBathymetry();
+ if ( anObjBathymetry.IsNull() )
+ continue;
+
+ if ( aRefBathymetry.IsNull() )
+ {
+ aRefBathymetry = anObjBathymetry;
+ continue;
+ }
+
+ if ( !IsEqual( aRefBathymetry, anObjBathymetry ) )
+ return true;
+ }
+
+ return false;
}
-void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
+void HYDROData_Zone::SetMergeType( const MergeBathymetriesType& theType )
{
- AddReferenceObject( theObject, DataTag_GeometryObject );
+ Handle(TDataStd_Integer) anInt;
+ if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
+ {
+ anInt->Set( (int)theType );
+ }
+ else
+ {
+ anInt = TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType );
+ }
+}
+
+HYDROData_Zone::MergeBathymetriesType HYDROData_Zone::GetMergeType() const
+{
+ MergeBathymetriesType aMergeType = Merge_UNKNOWN;
+
+ Handle(TDataStd_Integer) anInt;
+ if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
+ aMergeType = (MergeBathymetriesType)anInt->Get();
+
+ return aMergeType;
}
-void HYDROData_Zone::SetGeometryObject( const int theIndex,
- const Handle(HYDROData_Object)& theObject )
+void HYDROData_Zone::SetMergeBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
{
- SetReferenceObject( theObject, DataTag_GeometryObject, theIndex );
+ SetReferenceObject( theBathymetry, DataTag_Bathymetry );
}
-void HYDROData_Zone::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects )
+Handle(HYDROData_Bathymetry) HYDROData_Zone::GetMergeBathymetry() const
{
- SetReferenceObjects( theObjects, DataTag_GeometryObject );
+ return Handle(HYDROData_Bathymetry)::DownCast(
+ GetReferenceObject( DataTag_Bathymetry ) );
}
-Handle(HYDROData_Object) HYDROData_Zone::GetGeometryObject( const int theIndex ) const
+void HYDROData_Zone::RemoveMergeBathymetry()
{
- return Handle(HYDROData_Object)::DownCast(
- GetReferenceObject( DataTag_GeometryObject, theIndex ) );
+ ClearReferenceObjects( DataTag_Bathymetry );
+}
+
+bool HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& 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_GeometryObject ) )
+ return false; // Object is already in reference list
+
+ AddReferenceObject( theObject, DataTag_GeometryObject );
+ return true;
}
HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const
-