-#include <HYDROData_Image.h>
-#include <HYDROData_Iterator.h>
-#include <HYDROOperations_Factory.h>
+#include "HYDROData_Image.h"
+
+#include "HYDROData_Iterator.h"
+#include "HYDROOperations_Factory.h"
+#include "HYDROData_Tool.h"
#include <TDataStd_RealArray.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDF_ListIteratorOfLabelList.hxx>
#include <ImageComposer_Operator.h>
+#include <ImageComposer_MetaTypes.h>
#include <QStringList>
static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
+static const Standard_GUID GUID_SELF_SPLITTED("997995aa-5c19-40bf-9a60-ab4b70ad04d8");
#define PYTHON_IMAGE_ID "1"
aResList << anOpArgs;
aResList << QString( "" );
- aResList << QString( "%1.SetArgs( \"%2\" );" )
+ aResList << QString( "%1.SetArgs( %2 );" )
.arg( anImageName ).arg( anOpArgsArrayName );
}
}
for ( int i = 0; i < aNbReferences; ++i )
{
- Handle(HYDROData_Image) aRefImg = Reference( i );
+ Handle(HYDROData_Image) aRefImg = Handle(HYDROData_Image)::DownCast( Reference( i ) );
if ( aRefImg.IsNull() )
continue;
.arg( anImageName ).arg( aRefImgName );
}
}
+
+ // Necessary to update image in case of composed operator
+ aResList << QString( "" );
+ aResList << QString( "%1.Update();" ).arg( anImageName );
}
// Dump transformation matrix for image
return aResList;
}
+void HYDROData_Image::Update()
+{
+ HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
+
+ // Update image only if there is an operation
+ ImageComposer_Operator* anOp = aFactory->Operator( this );
+ if ( anOp )
+ {
+ // Fill by arguments and process the operation
+ QVariant anObj1, anObj2;
+ int aNbReferences = NbReferences();
+
+ if ( aNbReferences > 0 )
+ {
+ // First referenced object
+ Handle(HYDROData_Object) aRefObj = Reference( 0 );
+ if ( !aRefObj.IsNull() )
+ {
+ anObj1 = aRefObj->GetDataVariant();
+ if ( !anObj1.isNull() && anObj1.canConvert<ImageComposer_Image>() )
+ {
+ ImageComposer_Image anImage = anObj1.value<ImageComposer_Image>();
+ QTransform aTransform = anImage.transform();
+ SetTrsf( aTransform );
+ }
+ }
+ }
+
+ if ( aNbReferences > 1 )
+ {
+ // Second referenced object
+ Handle(HYDROData_Object) aRefObj = Reference( 1 );
+ if ( !aRefObj.IsNull() )
+ anObj2 = aRefObj->GetDataVariant();
+ }
+
+ ImageComposer_Image aResImg = anOp->process( anObj1, anObj2 );
+ SetImage( aResImg );
+ }
+
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+ if ( !aDocument.IsNull() )
+ {
+ // Change the states of this and all depended images
+ MustBeUpdated( true );
+ HYDROData_Tool::SetMustBeUpdatedImages( aDocument );
+ MustBeUpdated( false );
+ }
+}
+
+QVariant HYDROData_Image::GetDataVariant()
+{
+ QTransform aTransform = Trsf();
+
+ ImageComposer_Image anImage = Image();
+ anImage.setTransform( aTransform );
+
+ QVariant aVarData;
+ aVarData.setValue<ImageComposer_Image>( anImage );
+
+ return aVarData;
+}
+
void HYDROData_Image::SetImage(const QImage& theImage)
{
if (theImage.isNull()) {
}
}
-void HYDROData_Image::AppendReference(Handle(HYDROData_Image) theReferenced)
+bool HYDROData_Image::HasTrsfPoints() const
+{
+ Handle(TDataStd_RealArray) anArray;
+ return myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray);
+}
+
+void HYDROData_Image::AppendReference(Handle(HYDROData_Object) theReferenced)
{
Handle(TDataStd_ReferenceList) aRefs;
if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
return aRefs->Extent();
}
-Handle(HYDROData_Image) 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_Image)();
+ return Handle(HYDROData_Object)();
if (theIndex < 0 || theIndex >= aRefs->Extent())
- return Handle(HYDROData_Image)();
+ 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_Image)::DownCast(HYDROData_Iterator::Object(aRefLab));
+ return Handle(HYDROData_Object)::DownCast(HYDROData_Iterator::Object(aRefLab));
}
void HYDROData_Image::ChangeReference(
- const int theIndex, Handle(HYDROData_Image) theReferenced)
+ const int theIndex, Handle(HYDROData_Object) theReferenced)
{
Handle(TDataStd_ReferenceList) aRefs;
if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
}
}
-bool HYDROData_Image::MustBeUpdated()
+bool HYDROData_Image::MustBeUpdated() const
{
return myLab.IsAttribute(GUID_MUST_BE_UPDATED);
}
+
+void HYDROData_Image::SetIsSelfSplitted(bool theFlag)
+{
+ if (theFlag) {
+ TDataStd_UAttribute::Set(myLab, GUID_SELF_SPLITTED);
+ } else {
+ myLab.ForgetAttribute(GUID_SELF_SPLITTED);
+ }
+}
+
+bool HYDROData_Image::IsSelfSplitted() const
+{
+ return myLab.IsAttribute(GUID_SELF_SPLITTED);
+}