-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());
+bool HYDROData_Image::GetGlobalPoints( TransformationMode& theMode,
+ QPointF& thePointA,
+ QPointF& thePointB,
+ QPointF& thePointC ) const
+{
+ if ( !HasGlobalPoints() )
+ return false;
+
+ theMode = GetTrsfMode();
+
+ Handle(TDataStd_RealArray) anArray;
+ myLab.FindChild( DataTag_TrsfPoints ).FindAttribute( TDataStd_RealArray::GetID(), anArray );
+
+ thePointA = QPointF( anArray->Value( 7 ), anArray->Value( 8 ) );
+ thePointB = QPointF( anArray->Value( 9 ), anArray->Value( 10 ) );
+ thePointC = QPointF( anArray->Value( 11 ), anArray->Value( 12 ) );
+
+ return true;
+}
+
+bool HYDROData_Image::HasGlobalPoints() const
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_TrsfPoints, false );
+ if ( aLabel.IsNull() || !aLabel.IsAttribute( GUID_HAS_GLOBAL_POINTS ) )
+ return false;
+
+ Handle(TDataStd_RealArray) anArray;
+ return aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray );
+}
+
+void HYDROData_Image::SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
+ const QPointF& thePointA,
+ const QPointF& thePointB,
+ const QPointF& thePointC,
+ const bool theIsUpdate )
+{
+ SetTrsfReferenceImage( theRefImage );
+ SetGlobalPoints( ReferenceImage, thePointA, thePointB, thePointC, theIsUpdate );
+}
+
+bool HYDROData_Image::GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
+ QPointF& thePointA,
+ QPointF& thePointB,
+ QPointF& thePointC ) const
+{
+ if ( !HasReferencePoints() )
+ return false;
+
+ theRefImage = GetTrsfReferenceImage();
+
+ TransformationMode aMode;
+ GetGlobalPoints( aMode, thePointA, thePointB, thePointC );
+
+ return true;
+}
+
+bool HYDROData_Image::HasReferencePoints() const
+{
+ if ( !HasGlobalPoints() )
+ return false;
+
+ Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
+ if ( aRefImage.IsNull() )
+ return false;
+
+ TransformationMode aTrsfMode = GetTrsfMode();
+ if ( aTrsfMode != ReferenceImage )
+ return false;
+
+ return true;
+}
+
+void HYDROData_Image::SetTrsfMode( const TransformationMode& theMode )
+{
+ TDataStd_Integer::Set( myLab.FindChild( DataTag_TrsfMode ), (int)theMode );
+ SetToUpdate( true );
+}
+
+HYDROData_Image::TransformationMode HYDROData_Image::GetTrsfMode() const
+{
+ TransformationMode aResMode = ManualGeodesic;
+
+ TDF_Label aLabel = myLab.FindChild( DataTag_TrsfPoints, false );
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Integer) aMode;
+ if ( myLab.FindChild( DataTag_TrsfMode ).FindAttribute( TDataStd_Integer::GetID(), aMode ) )
+ aResMode = (TransformationMode)aMode->Get();