mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0027932: Improvement of standard attributes usability.
OCAF attributes TDataStd_AsciiString, TDataStd_Integer, TDataStd_Name, TDataStd_Real are extended by possibility to use custom GUID. Now multiple attributes of any of these types can be placed at the same label using different user-defined GUIDs. For this new "Set" methods were added into each attribute, which takes this custom GUID as an argument. Other aspects of management of attributes on labels remain the same. Version number of persistent OCAF documents is incremented. However, the attributes are stored in the same way unless non-standard GUID is used for particular attribute. Previously saved documents are fully supported, but the new documents with this extension used will be non-readable by the previous version of OCAF libraries.
This commit is contained in:
@@ -48,12 +48,30 @@ Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L,
|
||||
Handle(TDataStd_Integer) A;
|
||||
if (!L.FindAttribute (TDataStd_Integer::GetID(), A)) {
|
||||
A = new TDataStd_Integer ();
|
||||
A->SetID(GetID());
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose : Set user defined attribute
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const Standard_Integer V)
|
||||
{
|
||||
Handle(TDataStd_Integer) A;
|
||||
if (!L.FindAttribute(theGuid, A)) {
|
||||
A = new TDataStd_Integer ();
|
||||
A->SetID(theGuid);
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : TDataStd_Integer
|
||||
//purpose : Empty Constructor
|
||||
@@ -103,9 +121,20 @@ Standard_Boolean TDataStd_Integer::IsCaptured() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& TDataStd_Integer::ID () const { return GetID(); }
|
||||
const Standard_GUID& TDataStd_Integer::ID () const { return myID; }
|
||||
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_Integer::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
@@ -113,7 +142,9 @@ const Standard_GUID& TDataStd_Integer::ID () const { return GetID(); }
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_Integer ();
|
||||
Handle(TDataStd_Integer) Att = new TDataStd_Integer();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -123,7 +154,9 @@ Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const
|
||||
|
||||
void TDataStd_Integer::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myValue = Handle(TDataStd_Integer)::DownCast (With)->Get();
|
||||
Handle(TDataStd_Integer) anInt = Handle(TDataStd_Integer)::DownCast (With);
|
||||
myValue = anInt->Get();
|
||||
myID = anInt->ID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -134,7 +167,9 @@ void TDataStd_Integer::Restore(const Handle(TDF_Attribute)& With)
|
||||
void TDataStd_Integer::Paste (const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
Handle(TDataStd_Integer)::DownCast(Into)->Set(myValue);
|
||||
Handle(TDataStd_Integer) anInt = Handle(TDataStd_Integer)::DownCast (Into);
|
||||
anInt->Set(myValue);
|
||||
anInt->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -146,6 +181,9 @@ Standard_OStream& TDataStd_Integer::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
anOS << "Integer:: "<< this <<" : ";
|
||||
anOS << myValue;
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid;
|
||||
//
|
||||
anOS <<"\nAttribute fields: ";
|
||||
TDF_Attribute::Dump(anOS);
|
||||
|
Reference in New Issue
Block a user