#include "HYDROData_Image.h"
-#include "HYDROData_Iterator.h"
-#include "HYDROOperations_Factory.h"
+#include "HYDROData_Document.h"
#include "HYDROData_Tool.h"
+#include "HYDROOperations_Factory.h"
#include <TDataStd_RealArray.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TDataStd_AsciiString.hxx>
-#include <TDF_ListIteratorOfLabelList.hxx>
#include <ImageComposer_Operator.h>
#include <ImageComposer_MetaTypes.h>
return myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray);
}
-void HYDROData_Image::AppendReference(Handle(HYDROData_Object) theReferenced)
+void HYDROData_Image::AppendReference( const Handle(HYDROData_Object)& theReferenced )
{
- Handle(TDataStd_ReferenceList) aRefs;
- if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
- aRefs = TDataStd_ReferenceList::Set(myLab);
- aRefs->Append(theReferenced->Label());
+ AddReferenceObject( theReferenced, 0 );
}
int HYDROData_Image::NbReferences() const
{
- Handle(TDataStd_ReferenceList) aRefs;
- if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
- return 0;
- return aRefs->Extent();
+ return NbReferenceObjects( 0 );
}
-Handle(HYDROData_Object) HYDROData_Image::Reference(const int theIndex) const
+Handle(HYDROData_Object) HYDROData_Image::Reference( const int theIndex ) const
{
- Handle(TDataStd_ReferenceList) aRefs;
- if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
- return Handle(HYDROData_Object)();
- if (theIndex < 0 || theIndex >= aRefs->Extent())
- return Handle(HYDROData_Object)();
-
- TDF_ListIteratorOfLabelList anIter(aRefs->List());
- for(int anIndex = 0; anIndex != theIndex; anIter.Next(), anIndex++);
- const TDF_Label& aRefLab = anIter.Value();
- return Handle(HYDROData_Object)::DownCast(HYDROData_Iterator::Object(aRefLab));
+ return GetReferenceObject( 0, theIndex );
}
void HYDROData_Image::ChangeReference(
const int theIndex, Handle(HYDROData_Object) theReferenced)
{
- Handle(TDataStd_ReferenceList) aRefs;
- if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
- aRefs = TDataStd_ReferenceList::Set(myLab);
- if (theIndex >= aRefs->Extent()) { // for too big index append it just to the end
- AppendReference(theReferenced);
- } else { // remove and insert new
- TDF_ListIteratorOfLabelList anIter(aRefs->List());
- int anIndex = 0;
- for(; anIndex != theIndex; anIter.Next(), anIndex++);
- const TDF_Label& aRemovedLab = anIter.Value();
- anIter.Next();
- aRefs->Remove(aRemovedLab);
- if (anIter.More())
- aRefs->InsertBefore(theReferenced->Label(), anIter.Value());
- else
- aRefs->Append(theReferenced->Label());
- }
+ SetReferenceObject( theReferenced, 0, theIndex );
}
void HYDROData_Image::RemoveReference(const int theIndex)
{
- Handle(TDataStd_ReferenceList) aRefs;
- if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
- return; // no references, nothing to remove
- if (aRefs->Extent() == 1 && theIndex == 0) { // remove all if only one
- ClearReferences();
- return;
- }
- TDF_ListIteratorOfLabelList anIter(aRefs->List());
- int anIndex = 0;
- for(; anIndex != theIndex && anIter.More(); anIter.Next(), anIndex++);
- if (anIter.More())
- aRefs->Remove(anIter.Value());
+ RemoveReferenceObject( 0, theIndex );
}
void HYDROData_Image::ClearReferences()
{
- myLab.ForgetAttribute(TDataStd_ReferenceList::GetID());
+ ClearReferenceObjects( 0 );
}
void HYDROData_Image::SetOperatorName(const QString theOpName)