From: asl Date: Thu, 1 Oct 2015 14:16:23 +0000 (+0300) Subject: refs #636: flags for geometry 2d/3d change X-Git-Tag: v1.5~109^2~3^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=981b9eb91e769d90dd63a0288cc3af6841bcb15e;p=modules%2Fhydro.git refs #636: flags for geometry 2d/3d change --- diff --git a/src/HYDROData/HYDROData_ArtificialObject.cxx b/src/HYDROData/HYDROData_ArtificialObject.cxx index 170477a8..80a47654 100644 --- a/src/HYDROData/HYDROData_ArtificialObject.cxx +++ b/src/HYDROData/HYDROData_ArtificialObject.cxx @@ -21,8 +21,8 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_ArtificialObject,HYDROData_Object) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ArtificialObject,HYDROData_Object) -HYDROData_ArtificialObject::HYDROData_ArtificialObject() -: HYDROData_Object() +HYDROData_ArtificialObject::HYDROData_ArtificialObject( Geometry theGeometry ) +: HYDROData_Object( theGeometry ) { } diff --git a/src/HYDROData/HYDROData_ArtificialObject.h b/src/HYDROData/HYDROData_ArtificialObject.h index e12d6a3f..dc91253b 100644 --- a/src/HYDROData/HYDROData_ArtificialObject.h +++ b/src/HYDROData/HYDROData_ArtificialObject.h @@ -48,7 +48,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDRODATA_EXPORT HYDROData_ArtificialObject(); + HYDRODATA_EXPORT HYDROData_ArtificialObject( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index e48d04ff..73e763ef 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -96,7 +96,7 @@ void HYDROData_Bathymetry::SetAltitudePoints( const AltitudePoints& thePoints ) aCoordsArray->SetValue( i * 3 + 2, aPoint.Z() ); } - SetToUpdate( true ); + Changed( Geom_Z ); } HYDROData_Bathymetry::AltitudePoints HYDROData_Bathymetry::GetAltitudePoints(bool IsConvertToGlobal) const @@ -136,7 +136,7 @@ void HYDROData_Bathymetry::RemoveAltitudePoints() if ( !aLabel.IsNull() ) { aLabel.ForgetAllAttributes(); - SetToUpdate( true ); + Changed( Geom_Z ); } } @@ -358,7 +358,7 @@ void HYDROData_Bathymetry::SetAltitudesInverted( const bool theIsInverted, TDataStd_Integer::Set( myLab.FindChild( DataTag_AltitudesInverted ), (Standard_Integer)theIsInverted ); - SetToUpdate( true ); + Changed( Geom_Z ); if ( !theIsUpdate ) return; diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 55bb858b..2761ce1b 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -80,7 +80,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity) HYDROData_CalculationCase::HYDROData_CalculationCase() -: HYDROData_Entity() +: HYDROData_Entity( Geom_2d_and_groups ) { } @@ -500,7 +500,7 @@ bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object AddReferenceObject( theObject, DataTag_GeometryObject ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); return true; } @@ -518,7 +518,7 @@ void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Obj RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_CalculationCase::RemoveGeometryObjects() @@ -526,7 +526,7 @@ void HYDROData_CalculationCase::RemoveGeometryObjects() ClearReferenceObjects( DataTag_GeometryObject ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup ) @@ -540,7 +540,7 @@ bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesG AddReferenceObject( theGroup, DataTag_GeometryGroup ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_Groups ); return true; } @@ -558,7 +558,7 @@ void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_Shap RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_Groups ); } void HYDROData_CalculationCase::RemoveGeometryGroups() @@ -566,7 +566,7 @@ void HYDROData_CalculationCase::RemoveGeometryGroups() ClearReferenceObjects( DataTag_GeometryGroup ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_Groups ); } void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ) @@ -576,7 +576,8 @@ void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_Poly SetReferenceObject( thePolyline, DataTag_Polyline ); // Indicate model of the need to update zones splitting - SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() ); + if( !IsEqual( aPrevPolyline, thePolyline ) ) + Changed( Geom_2d ); } Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const @@ -592,7 +593,7 @@ void HYDROData_CalculationCase::RemoveBoundaryPolyline() ClearReferenceObjects( DataTag_Polyline ); // Indicate model of the need to update zones splitting - SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() ); + Changed( Geom_2d ); } void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable ) @@ -602,7 +603,8 @@ void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_Strick SetReferenceObject( theStricklerTable, DataTag_StricklerTable ); // Indicate model of the need to update land covers partition - SetToUpdate( !IsEqual( aPrevStricklerTable, theStricklerTable ) || IsMustBeUpdated() ); + if( !IsEqual( aPrevStricklerTable, theStricklerTable ) ) + Changed( Geom_No ); } Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const @@ -618,7 +620,7 @@ void HYDROData_CalculationCase::RemoveStricklerTable() ClearReferenceObjects( DataTag_StricklerTable ); // Indicate model of the need to update land covers partition - SetToUpdate( !aPrevStricklerTable.IsNull() || IsMustBeUpdated() ); + Changed( Geom_No ); } bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& theLandCover ) @@ -629,7 +631,7 @@ bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& AddReferenceObject( theLandCover, DataTag_LandCover ); // Indicate model of the need to update land covers partition - SetToUpdate( true ); + Changed( Geom_No ); return true; } @@ -647,7 +649,7 @@ void HYDROData_CalculationCase::RemoveLandCover( const Handle(HYDROData_LandCove RemoveReferenceObject( theLandCover->Label(), DataTag_LandCover ); // Indicate model of the need to update land cover partition - SetToUpdate( true ); + Changed( Geom_No ); } void HYDROData_CalculationCase::RemoveLandCovers() @@ -655,7 +657,7 @@ void HYDROData_CalculationCase::RemoveLandCovers() ClearReferenceObjects( DataTag_LandCover ); // Indicate model of the need to update land cover partition - SetToUpdate( true ); + Changed( Geom_No ); } Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone, @@ -1293,7 +1295,7 @@ void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag t // Indicate model of the need to update splitting if ( theIsSetToUpdate ) { - SetToUpdate( true ); + Changed( Geom_2d ); } } @@ -1307,7 +1309,7 @@ void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theO HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } QString HYDROData_CalculationCase::DumpRules() const @@ -1328,7 +1330,7 @@ void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode ) TDataStd_Integer::Set( aModeLab, ( int ) theMode ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const @@ -1431,7 +1433,7 @@ void HYDROData_CalculationCase::SetAssignmentLandCoverMode( AssignmentMode theMo TDataStd_Integer::Set( aModeLab, ( int ) theMode ); // Indicate model of the need to update land covers partition - SetToUpdate( true ); + Changed( Geom_No ); } HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentLandCoverMode() const diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index c78c5e41..6099dba6 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -393,7 +393,7 @@ bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGui SetReferenceObject( theGuideLine, DataTag_GuideLine ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + SetToUpdate( true, true ); return true; } @@ -413,7 +413,7 @@ void HYDROData_Channel::RemoveGuideLine() ClearReferenceObjects( DataTag_GuideLine ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + SetToUpdate( true, true ); } bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile ) @@ -432,7 +432,7 @@ bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile SetReferenceObject( theProfile, DataTag_Profile ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + SetToUpdate( true, true ); return true; } @@ -452,7 +452,7 @@ void HYDROData_Channel::RemoveProfile() ClearReferenceObjects( DataTag_Profile ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + SetToUpdate( true, true ); } ObjectKind HYDROData_Channel::getAltitudeObjectType() const diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 95d7426c..65edad85 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -38,8 +38,6 @@ #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) @@ -82,7 +80,7 @@ QStringList HYDROData_Entity::DumpToPython( MapOfTreatedObjects& theTreatedObjec void HYDROData_Entity::Update() { - SetToUpdate( false ); + ClearChanged(); } void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy ) @@ -112,31 +110,58 @@ QVariant HYDROData_Entity::GetDataVariant() return QVariant(); } -void HYDROData_Entity::SetToUpdate( bool theFlag ) +void HYDROData_Entity::ClearChanged() { - if ( IsMustBeUpdated() == theFlag ) + TDataStd_Integer::Set( myLab.FindChild( DataTag_GeomChange ), 0 ); +} + +int HYDROData_Entity::GetGeomChangeFlag() const +{ + int aGeomChangeFlag = 0; + Handle(TDataStd_Integer) aGeomChangeAttr; + TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange ); + aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr ); + if ( !aGeomChangeAttr.IsNull() ) + aGeomChangeFlag = aGeomChangeAttr->Get(); + return aGeomChangeFlag; +} + +void HYDROData_Entity::Changed( Geometry theChangedGeometry ) +{ + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if( aDocument.IsNull() ) return; - if ( theFlag ) - { - TDataStd_UAttribute::Set( myLab, GUID_MUST_BE_UPDATED ); + int aGeomChangeFlag = 0; + Handle(TDataStd_Integer) aGeomChangeAttr; + TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange ); + aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr ); + if ( !aGeomChangeAttr.IsNull() ) + aGeomChangeFlag = aGeomChangeAttr->Get(); - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( !aDocument.IsNull() ) + if( ( myGeom & theChangedGeometry ) == 0 ) + return; + + aGeomChangeFlag = ( aGeomChangeFlag | theChangedGeometry ); + TDataStd_Integer::Set( aGeomChangeLab, aGeomChangeFlag ); + + HYDROData_Iterator anIter( aDocument ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) anObject = anIter.Current(); + HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects(); + for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i ) { - // Change the states of this and all depended objects - HYDROData_Tool::SetMustBeUpdatedObjects( aDocument ); + Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i ); + if( aRefObject->Label()==myLab ) + Changed( theChangedGeometry ); } } - else - { - myLab.ForgetAttribute( GUID_MUST_BE_UPDATED ); - } } -bool HYDROData_Entity::IsMustBeUpdated() const +bool HYDROData_Entity::IsMustBeUpdated( Geometry theGeom ) const { - return myLab.IsAttribute( GUID_MUST_BE_UPDATED ); + return ( ( GetGeomChangeFlag() & theGeom ) != 0 ); } bool HYDROData_Entity::CanBeUpdated() const @@ -159,7 +184,8 @@ bool HYDROData_Entity::CanRemove() return true; } -HYDROData_Entity::HYDROData_Entity() +HYDROData_Entity::HYDROData_Entity( Geometry theGeom ) + : myGeom( theGeom ) { } diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index f02cb5eb..b05fb5d5 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -85,9 +85,7 @@ HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Hand */ class HYDROData_Entity : public MMgt_TShared { - protected: - /** * Enumeration of tags corresponding to the persistent object parameters. */ @@ -95,6 +93,19 @@ protected: { DataTag_First = 0, ///< first tag, to reserve DataTag_ZLevel, ///< z-level of object presentation + DataTag_GeomChange, + }; + +public: + enum Geometry + { + Geom_No = 1, + Geom_2d = 2, + Geom_Z = 4, + Geom_Groups = 8, + + Geom_3d = Geom_2d | Geom_Z, + Geom_2d_and_groups = Geom_2d | Geom_Groups, }; public: @@ -113,7 +124,7 @@ public: /** * Updates the name of this object. */ - HYDRODATA_EXPORT virtual void SetName( const QString& theName ); + HYDRODATA_EXPORT void SetName( const QString& theName ); /** * Returns the name of this object valid for Python script. @@ -153,17 +164,11 @@ 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 virtual 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 virtual bool IsMustBeUpdated() const; + HYDRODATA_EXPORT virtual void ClearChanged(); + HYDRODATA_EXPORT virtual void Changed( Geometry ); + + HYDRODATA_EXPORT bool IsMustBeUpdated( Geometry ) const; /** * Returns flag indicating that object is updateble or not. @@ -263,7 +268,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDRODATA_EXPORT HYDROData_Entity(); + HYDRODATA_EXPORT HYDROData_Entity( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. @@ -410,16 +415,18 @@ protected: const QColor& theColor, const QColor& theDefaultColor, const QString& theMethod ) const; - protected: Handle(TDataStd_ReferenceList) getReferenceList( const int theTag, const bool theIsCreate ) const; + int GetGeomChangeFlag() const; + protected: /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty. TDF_Label myLab; ///< label of this object + Geometry myGeom; }; #endif diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 13a01102..fff074ad 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -35,8 +35,8 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity) -HYDROData_Object::HYDROData_Object() -: HYDROData_Entity() +HYDROData_Object::HYDROData_Object( Geometry theGeometry ) + : HYDROData_Entity( theGeometry ) { } @@ -75,9 +75,14 @@ void HYDROData_Object::SetName( const QString& theName ) void HYDROData_Object::Update() { - removeTopShape(); - removeShape3D(); - removeGroupObjects(); + if( IsMustBeUpdated2d() ) + { + removeTopShape(); + removeGroupObjects(); + } + if( IsMustBeUpdated3d() ) + removeShape3D(); + checkAndSetAltitudeObject(); HYDROData_Entity::Update(); } @@ -93,13 +98,13 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const return aResSeq; } -void HYDROData_Object::SetToUpdate( bool theFlag ) +void HYDROData_Object::Changed( Geometry theChangedGeometry ) { - HYDROData_Entity::SetToUpdate( theFlag ); + HYDROData_Entity::Changed( theChangedGeometry ); Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D(); if ( !anObject3D.IsNull() ) - anObject3D->SetToUpdate( theFlag ); + anObject3D->Changed( theChangedGeometry ); } void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape ) diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 520a70ab..a9c1ad82 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -76,7 +76,7 @@ public: * Sets the "MustBeUpdated" flag: if object is depended on updated features. * Reimplemented to update the state of child 3D object. */ - HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag ); + HYDRODATA_EXPORT virtual void Changed( Geometry ); /** @@ -179,7 +179,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDRODATA_EXPORT HYDROData_Object(); + HYDRODATA_EXPORT HYDROData_Object( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index c30bff5e..dee9901e 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -58,38 +58,6 @@ void HYDROData_Tool::WriteStringsToFile( QFile& theFile, anOutStream << aWriteStr << theSep << theSep; } -void HYDROData_Tool::SetMustBeUpdatedObjects( - const Handle(HYDROData_Document)& theDoc ) -{ - bool anIsChanged = true; - - // iterate until there is no changes because objects on all level of dependency must be updated - while ( anIsChanged ) - { - anIsChanged = false; - - HYDROData_Iterator anIter( theDoc ); - for ( ; anIter.More(); anIter.Next() ) - { - Handle(HYDROData_Entity) anObject = anIter.Current(); - if ( anObject.IsNull() || anObject->IsMustBeUpdated() ) - continue; - - HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects(); - for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i ) - { - Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i ); - if ( aRefObject.IsNull() || !aRefObject->IsMustBeUpdated() ) - continue; - - anObject->SetToUpdate( true ); - anIsChanged = true; - break; - } - } - } -} - QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& theDoc, const QString& thePrefix, const QStringList& theUsedNames, diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 4bb77866..0642d4fd 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -46,12 +46,6 @@ public: const QStringList& theStrings, const QString& theSep = "\n" ); - /** - * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects. - * \param theDoc document where this operation is performed - */ - static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc ); - /** * \brief Generate name for new object. * \param theDoc document