From c374597f70481110faa82dc189353d689d66bc0c Mon Sep 17 00:00:00 2001 From: adv Date: Tue, 5 Nov 2013 10:57:12 +0000 Subject: [PATCH] The "MustBeUpdated" flag is moved to base data object class and implemented for calculation case. --- src/HYDROData/HYDROData_CalculationCase.cxx | 13 +++++++++++++ src/HYDROData/HYDROData_Entity.cxx | 19 +++++++++++++++++++ src/HYDROData/HYDROData_Entity.h | 12 ++++++++++++ src/HYDROData/HYDROData_Image.cxx | 21 +++------------------ src/HYDROData/HYDROData_Image.h | 11 ----------- src/HYDROData/HYDROData_Tool.cxx | 20 ++++++++++---------- src/HYDROGUI/HYDROGUI_DataObject.cxx | 4 ++-- src/HYDROGUI/HYDROGUI_Module.cxx | 2 +- src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx | 2 +- 9 files changed, 61 insertions(+), 43 deletions(-) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index adc5843e..764d3cd1 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -123,6 +123,9 @@ void HYDROData_CalculationCase::SplitGeometryObjects() aRegionZone->AddGeometryObject( aRefObject ); } } + + // The splitted data is up to date + SetToUpdate( false ); } bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) @@ -138,6 +141,10 @@ bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object return false; // Object is already in reference list AddReferenceObject( theObject, DataTag_GeometryObject ); + + // Indicate model of the need to update zones splitting + SetToUpdate( true ); + return true; } @@ -152,11 +159,17 @@ void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Obj return; RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject ); + + // Indicate model of the need to update zones splitting + SetToUpdate( true ); } void HYDROData_CalculationCase::RemoveGeometryObjects() { ClearReferenceObjects( DataTag_GeometryObject ); + + // Indicate model of the need to update zones splitting + SetToUpdate( true ); } Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone ) diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 0aab7b14..eb7d6599 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -19,6 +19,8 @@ #include #include +static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000"); + IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Entity,MMgt_TShared) @@ -60,6 +62,23 @@ QVariant HYDROData_Entity::GetDataVariant() return QVariant(); } +void HYDROData_Entity::SetToUpdate(bool theFlag) +{ + if ( theFlag ) + { + TDataStd_UAttribute::Set( myLab, GUID_MUST_BE_UPDATED ); + } + else + { + myLab.ForgetAttribute( GUID_MUST_BE_UPDATED ); + } +} + +bool HYDROData_Entity::IsMustBeUpdated() const +{ + return myLab.IsAttribute( GUID_MUST_BE_UPDATED ); +} + bool HYDROData_Entity::IsRemoved() const { return !myLab.HasAttribute(); diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index 8f60960d..3fb5d239 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -106,6 +106,18 @@ public: */ HYDRODATA_EXPORT virtual QVariant GetDataVariant(); + /** + * Sets the "MustBeUpdated" flag: if object is depended on updated features. + * \param theFlag is true for objects that must be updated, false for up-to-date + */ + HYDRODATA_EXPORT void SetToUpdate(bool theFlag); + + /** + * Returns the "MustBeUpdated" flag: is object data must be updated or not + * \returns false if object is up to date + */ + HYDRODATA_EXPORT bool IsMustBeUpdated() const; + /** * Checks is object exists in the data structure. * \returns true is object is not exists in the data model diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index 3ca786fc..3556d543 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -20,7 +20,6 @@ #include -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"); static const Standard_GUID GUID_HAS_LOCAL_POINTS("FD8841AA-FC44-42fa-B6A7-0F682CCC6F27"); static const Standard_GUID GUID_HAS_GLOBAL_POINTS("330D0E81-742D-4ea3-92D4-484877CFA7C1"); @@ -199,9 +198,9 @@ void HYDROData_Image::Update() if ( !aDocument.IsNull() ) { // Change the states of this and all depended images - MustBeUpdated( true ); + SetToUpdate( true ); HYDROData_Tool::SetMustBeUpdatedImages( aDocument ); - MustBeUpdated( false ); + SetToUpdate( false ); } } @@ -434,7 +433,7 @@ void HYDROData_Image::RemoveAllReferences() SetIsSelfSplitted( false ); } - MustBeUpdated( false ); + SetToUpdate( false ); bool anIsByTwoPoints = IsByTwoPoints(); @@ -730,20 +729,6 @@ QByteArray HYDROData_Image::Args() const return QByteArray(aData, aLen); } -void HYDROData_Image::MustBeUpdated(bool theFlag) -{ - if (theFlag) { - TDataStd_UAttribute::Set(myLab, GUID_MUST_BE_UPDATED); - } else { - myLab.ForgetAttribute(GUID_MUST_BE_UPDATED); - } -} - -bool HYDROData_Image::MustBeUpdated() const -{ - return myLab.IsAttribute(GUID_MUST_BE_UPDATED); -} - void HYDROData_Image::SetIsSelfSplitted(bool theFlag) { if (theFlag) { diff --git a/src/HYDROData/HYDROData_Image.h b/src/HYDROData/HYDROData_Image.h index 7fe84c93..7cf8a05f 100644 --- a/src/HYDROData/HYDROData_Image.h +++ b/src/HYDROData/HYDROData_Image.h @@ -316,17 +316,6 @@ public: */ HYDRODATA_EXPORT QByteArray Args() const; - /** - * Sets the "MustBeUpdated" flag: if image is depended on updated features. - * \param theFlag is true for images that must be updated, false for up-to-date - */ - HYDRODATA_EXPORT void MustBeUpdated(bool theFlag); - - /** - * Returns the "MustBeUpdated" flag: is image must be recomputed or not - * \returns false if image is up to date - */ - HYDRODATA_EXPORT bool MustBeUpdated() const; /** * Marks the image as self-splitted. diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index cd609037..8c05efa2 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -26,26 +26,26 @@ void HYDROData_Tool::WriteStringsToFile( QFile& theFile, void HYDROData_Tool::SetMustBeUpdatedImages( const Handle(HYDROData_Document)& theDoc ) { - bool aChanged = true; + bool anIsChanged = true; // iterate until there is no changes because images on all level of dependency must be updated - while ( aChanged ) + while ( anIsChanged ) { - aChanged = false; + anIsChanged = false; HYDROData_Iterator anIter( theDoc, KIND_IMAGE ); for ( ; anIter.More(); anIter.Next() ) { Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anIter.Current() ); - if ( anImage.IsNull() || anImage->MustBeUpdated() ) + if ( anImage.IsNull() || anImage->IsMustBeUpdated() ) continue; Handle(HYDROData_Image) aTrsfRefImage = anImage->GetTrsfReferenceImage(); - if ( !aTrsfRefImage.IsNull() && aTrsfRefImage->MustBeUpdated() ) + if ( !aTrsfRefImage.IsNull() && aTrsfRefImage->IsMustBeUpdated() ) { - anImage->MustBeUpdated( true ); - aChanged = true; + anImage->SetToUpdate( true ); + anIsChanged = true; continue; } @@ -53,11 +53,11 @@ void HYDROData_Tool::SetMustBeUpdatedImages( { Handle(HYDROData_Image) aRefImage = Handle(HYDROData_Image)::DownCast( anImage->Reference( i ) ); - if ( !aRefImage.IsNull() && aRefImage->MustBeUpdated() ) + if ( !aRefImage.IsNull() && aRefImage->IsMustBeUpdated() ) { // image references to updated => also must be updated - anImage->MustBeUpdated(true); - aChanged = true; + anImage->SetToUpdate( true ); + anIsChanged = true; } } } diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index 532ae5f2..bab5e039 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -63,8 +63,8 @@ QFont HYDROGUI_DataObject::font( const int theId ) const QFont aFont = LightApp_DataObject::font( theId ); if( theId == NameId ) { - Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( modelObject() ); - if( !anImage.IsNull() && anImage->MustBeUpdated() ) + Handle(HYDROData_Entity) aDataObject = modelObject(); + if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated() ) aFont.setItalic( true ); } return aFont; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index ff04b7d0..e5b3ded0 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -243,7 +243,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsSplittedImage = true; } } - anIsMustBeUpdatedImage = anImage->MustBeUpdated(); + anIsMustBeUpdatedImage = anImage->IsMustBeUpdated(); } } else if( anObject->GetKind() == KIND_POLYLINE ) diff --git a/src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx b/src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx index 4ab7f7f4..34256182 100644 --- a/src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx @@ -50,7 +50,7 @@ void HYDROGUI_UpdateImageOp::startOperation() { Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( aSeq.Value( anIndex ) ); - if( !anImage.IsNull() && anImage->MustBeUpdated() ) + if( !anImage.IsNull() && anImage->IsMustBeUpdated() ) anImage->Update(); } -- 2.39.2