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 )
{
}
* 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.
aCoordsArray->SetValue( i * 3 + 2, aPoint.Z() );
}
- SetToUpdate( true );
+ Changed( Geom_Z );
}
HYDROData_Bathymetry::AltitudePoints HYDROData_Bathymetry::GetAltitudePoints(bool IsConvertToGlobal) const
if ( !aLabel.IsNull() )
{
aLabel.ForgetAllAttributes();
- SetToUpdate( true );
+ Changed( Geom_Z );
}
}
TDataStd_Integer::Set( myLab.FindChild( DataTag_AltitudesInverted ), (Standard_Integer)theIsInverted );
- SetToUpdate( true );
+ Changed( Geom_Z );
if ( !theIsUpdate )
return;
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
HYDROData_CalculationCase::HYDROData_CalculationCase()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_2d_and_groups )
{
}
AddReferenceObject( theObject, DataTag_GeometryObject );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_2d );
return true;
}
RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_2d );
}
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 )
AddReferenceObject( theGroup, DataTag_GeometryGroup );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_Groups );
return true;
}
RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup );
// Indicate model of the need to update splitting
- SetToUpdate( true );
+ Changed( Geom_Groups );
}
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 )
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
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 )
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
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 )
AddReferenceObject( theLandCover, DataTag_LandCover );
// Indicate model of the need to update land covers partition
- SetToUpdate( true );
+ Changed( Geom_No );
return true;
}
RemoveReferenceObject( theLandCover->Label(), DataTag_LandCover );
// Indicate model of the need to update land cover partition
- SetToUpdate( true );
+ Changed( Geom_No );
}
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,
// Indicate model of the need to update splitting
if ( theIsSetToUpdate ) {
- SetToUpdate( true );
+ Changed( Geom_2d );
}
}
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
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
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
SetReferenceObject( theGuideLine, DataTag_GuideLine );
// Indicate model of the need to update the chanel presentation
- SetToUpdate( true );
+ SetToUpdate( true, true );
return true;
}
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 )
SetReferenceObject( theProfile, DataTag_Profile );
// Indicate model of the need to update the chanel presentation
- SetToUpdate( true );
+ SetToUpdate( true, true );
return true;
}
ClearReferenceObjects( DataTag_Profile );
// Indicate model of the need to update the chanel presentation
- SetToUpdate( true );
+ SetToUpdate( true, true );
}
ObjectKind HYDROData_Channel::getAltitudeObjectType() const
#include <QStringList>
#include <QVariant>
-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)
void HYDROData_Entity::Update()
{
- SetToUpdate( false );
+ ClearChanged();
}
void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy )
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
return true;
}
-HYDROData_Entity::HYDROData_Entity()
+HYDROData_Entity::HYDROData_Entity( Geometry theGeom )
+ : myGeom( theGeom )
{
}
*/
class HYDROData_Entity : public MMgt_TShared
{
-
protected:
-
/**
* Enumeration of tags corresponding to the persistent object parameters.
*/
{
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:
/**
* 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.
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.
* 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.
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
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 )
{
}
void HYDROData_Object::Update()
{
- removeTopShape();
- removeShape3D();
- removeGroupObjects();
+ if( IsMustBeUpdated2d() )
+ {
+ removeTopShape();
+ removeGroupObjects();
+ }
+ if( IsMustBeUpdated3d() )
+ removeShape3D();
+
checkAndSetAltitudeObject();
HYDROData_Entity::Update();
}
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 )
* 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 );
/**
* 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.
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,
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