return aResList;
}
-bool HYDROData_Region::AddZone( Handle(HYDROData_Zone)& theZone )
+bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone )
{
if ( theZone.IsNull() )
return false;
Handle(HYDROData_Region)::DownCast( theZone->GetFatherObject() );
if ( !aFatherRegion.IsNull() && aFatherRegion->Label() != myLab )
{
- Handle(HYDROData_Zone) aNewZone = AddNewZone();
+ Handle(HYDROData_Zone) aNewZone = addNewZone();
theZone->CopyTo( aNewZone );
aFatherRegion->RemoveZone( theZone );
- theZone = aNewZone;
+ theZone->SetLabel( aNewZone->Label() );
}
AddReferenceObject( theZone, DataTag_Zone );
void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone )
{
- if ( theZone.IsNull() || !HasReference( theZone, DataTag_Zone ) )
+ if ( theZone.IsNull() )
return;
RemoveReferenceObject( theZone->Label(), DataTag_Zone );
// Remove zone from data model
- theZone->Remove();
+ Handle(HYDROData_Region) aFatherRegion =
+ Handle(HYDROData_Region)::DownCast( theZone->GetFatherObject() );
+ if ( !aFatherRegion.IsNull() && aFatherRegion->Label() == myLab )
+ theZone->Remove();
+
+ // If the last zone has been removed from region we remove this region
+ HYDROData_SequenceOfObjects aRefZones = GetZones();
+ if ( aRefZones.IsEmpty() )
+ Remove();
}
void HYDROData_Region::RemoveZones()
{
ClearReferenceObjects( DataTag_Zone );
- myLab.FindChild( ChildTag_Zone ).ForgetAllAttributes( true );
+ myLab.FindChild( DataTag_ChildZone ).ForgetAllAttributes( true );
}
-Handle(HYDROData_Zone) HYDROData_Region::AddNewZone()
+Handle(HYDROData_Zone) HYDROData_Region::addNewZone()
{
- TDF_Label aNewLab = myLab.FindChild( ChildTag_Zone ).NewChild();
+ TDF_Label aNewLab = myLab.FindChild( DataTag_ChildZone ).NewChild();
Handle(HYDROData_Zone) aNewZone =
Handle(HYDROData_Zone)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_ZONE ) );