From: adv Date: Fri, 13 Sep 2013 11:10:15 +0000 (+0000) Subject: Changes for dumping image object to python script. X-Git-Tag: BR_hydro_v_0_1~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5f8ad21d6ab7bf0a438ff106c073a582d7198bd8;p=modules%2Fhydro.git Changes for dumping image object to python script. --- diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index 49b9f1fb..5fe12bb0 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -57,6 +57,50 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject aResList << QString( "" ); aResList << QString( "%1.LoadImage( \"%2\" );" ) .arg( anImageName ).arg( aFilePath ); + + // Dump transformation matrix for image + aResList << QString( "" ); + + QTransform aTrsf = Trsf(); + + aResList << QString( "trsf = QTransform( %1, %2, %3," ) + .arg( aTrsf.m11() ).arg( aTrsf.m12() ).arg( aTrsf.m13() ); + aResList << QString( " %1, %2, %3," ) + .arg( aTrsf.m21() ).arg( aTrsf.m22() ).arg( aTrsf.m23() ); + aResList << QString( " %1, %2, %3 );" ) + .arg( aTrsf.m31() ).arg( aTrsf.m32() ).arg( aTrsf.m33() ); + + aResList << QString( "%1.SetTrsf( trsf );" ).arg( anImageName ); + + // Dump transformation points for image + aResList << QString( "" ); + + QPoint aPointAIn, aPointBIn, aPointCIn; + QPointF aPointAOut, aPointBOut, aPointCOut; + TrsfPoints( aPointAIn, aPointBIn, aPointCIn, + aPointAOut, aPointBOut, aPointCOut ); + + aResList << QString( "a_in = QPoint( %1, %2 );" ) + .arg( aPointAIn.x() ).arg( aPointAIn.y() ); + + aResList << QString( "b_in = QPoint( %1, %2 );" ) + .arg( aPointBIn.x() ).arg( aPointBIn.y() ); + + aResList << QString( "c_in = QPoint( %1, %2 );" ) + .arg( aPointCIn.x() ).arg( aPointCIn.y() ); + + aResList << QString( "a_out = QPointF( %1, %2 );" ) + .arg( aPointAOut.x() ).arg( aPointAOut.y() ); + + aResList << QString( "b_out = QPointF( %1, %2 );" ) + .arg( aPointBOut.x() ).arg( aPointBOut.y() ); + + aResList << QString( "c_out = QPointF( %1, %2 );" ) + .arg( aPointCOut.x() ).arg( aPointCOut.y() ); + + QString aGap = QString().fill( ' ', anImageName.size() + 16 ); + aResList << QString( "%1.SetTrsfPoints( a_in, b_in, c_in," ).arg( anImageName ); + aResList << QString( aGap + "a_out, b_out, c_out );" ); } else { @@ -125,62 +169,18 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject // Necessary to update image in case of composed operator aResList << QString( "" ); - aResList << QString( "%1.Update();" ).arg( anImageName ); + aResList << QString( "%1.Update( False );" ).arg( anImageName ); } - // Dump transformation matrix for image - aResList << QString( "" ); - - QTransform aTrsf = Trsf(); - - aResList << QString( "trsf = QTransform( %2, %3, %4," ) - .arg( aTrsf.m11() ).arg( aTrsf.m12() ).arg( aTrsf.m13() ); - aResList << QString( " %1, %2, %3," ) - .arg( aTrsf.m21() ).arg( aTrsf.m22() ).arg( aTrsf.m23() ); - aResList << QString( " %1, %2, %3 );" ) - .arg( aTrsf.m31() ).arg( aTrsf.m32() ).arg( aTrsf.m33() ); - - aResList << QString( "%1.SetTrsf( trsf );" ).arg( anImageName ); - - // Dump transformation points for image - aResList << QString( "" ); - - QPoint aPointAIn, aPointBIn, aPointCIn; - QPointF aPointAOut, aPointBOut, aPointCOut; - TrsfPoints( aPointAIn, aPointBIn, aPointCIn, - aPointAOut, aPointBOut, aPointCOut ); - - aResList << QString( "a_in = QPoint( %1, %2 );" ) - .arg( aPointAIn.x() ).arg( aPointAIn.y() ); - - aResList << QString( "b_in = QPoint( %1, %2 );" ) - .arg( aPointBIn.x() ).arg( aPointBIn.y() ); - - aResList << QString( "c_in = QPoint( %1, %2 );" ) - .arg( aPointCIn.x() ).arg( aPointCIn.y() ); - - aResList << QString( "a_out = QPointF( %1, %2 );" ) - .arg( aPointAOut.x() ).arg( aPointAOut.y() ); - - aResList << QString( "b_out = QPointF( %1, %2 );" ) - .arg( aPointBOut.x() ).arg( aPointBOut.y() ); - - aResList << QString( "c_out = QPointF( %1, %2 );" ) - .arg( aPointCOut.x() ).arg( aPointCOut.y() ); - - QString aGap = QString().fill( ' ', anImageName.size() + 16 ); - aResList << QString( "%1.SetTrsfPoints( a_in, b_in, c_in," ).arg( anImageName ); - aResList << QString( aGap + "a_out, b_out, c_out );" ); - return aResList; } -void HYDROData_Image::Update() +void HYDROData_Image::Update( const bool theIsForce ) { HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory(); // Update image only if there is an operation - ImageComposer_Operator* anOp = aFactory->Operator( this ); + ImageComposer_Operator* anOp = aFactory->Operator( OperatorName() ); if ( anOp ) { // Fill by arguments and process the operation @@ -215,13 +215,16 @@ void HYDROData_Image::Update() SetImage( aResImg ); } - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); - if ( !aDocument.IsNull() ) + if ( theIsForce ) { - // Change the states of this and all depended images - MustBeUpdated( true ); - HYDROData_Tool::SetMustBeUpdatedImages( aDocument ); - MustBeUpdated( false ); + 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 ); + } } } diff --git a/src/HYDROData/HYDROData_Image.h b/src/HYDROData/HYDROData_Image.h index 0b92af77..134a5b2e 100644 --- a/src/HYDROData/HYDROData_Image.h +++ b/src/HYDROData/HYDROData_Image.h @@ -46,8 +46,9 @@ public: * Reimplemented to update an Image object in the data structure. * Call this method whenever you made changes for operator or reference objects. * If it is changed, sets "MustBeUpdated" flag to other depended images. + * \param theIsForce force reupdating of data object */ - HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true ); /** * Returns data of object wrapped to QVariant. diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 9b84cef2..46d5b3a5 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -42,7 +42,7 @@ QStringList HYDROData_Object::DumpToPython( MapOfTreatedObjects& theTreatedObjec return anEmptyList; } -void HYDROData_Object::Update() +void HYDROData_Object::Update( const bool theIsForce ) { } diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 680b8581..595c6f9a 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -73,8 +73,9 @@ public: /** * Updates object state. * Base implementation dose nothing. + * \param theIsForce force reupdating of data object */ - HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true ); /** * Returns data of object wrapped to QVariant. diff --git a/src/HYDROPy/HYDROData_Object.sip b/src/HYDROPy/HYDROData_Object.sip index ea716567..852e58f5 100644 --- a/src/HYDROPy/HYDROData_Object.sip +++ b/src/HYDROPy/HYDROData_Object.sip @@ -84,8 +84,9 @@ public: /** * Updates object state. + * \param theIsForce force reupdating of data object */ - void Update(); + void Update(const bool theIsForce); /** * Checks is object exists in the data structure.