1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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:
szy
2016-10-27 17:55:43 +03:00
committed by abv
parent 9c86076b21
commit fa53efefc3
39 changed files with 1274 additions and 600 deletions

View File

@@ -23,6 +23,7 @@
#include <Standard_Type.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDF_Attribute.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_AsciiStringDriver,BinMDF_ADriver)
@@ -61,6 +62,19 @@ Standard_Boolean BinMDataStd_AsciiStringDriver::Paste
Standard_Boolean ok = Source >> aString;
if (ok)
aStrAtt->Set( aString );
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;
if (!ok) {
Source.SetPosition(aPos);
aStrAtt->SetID(TDataStd_AsciiString::GetID());
ok = Standard_True;
} else {
aStrAtt->SetID(aGuid);
}
} else
aStrAtt->SetID(TDataStd_AsciiString::GetID());
return ok;
}
@@ -76,4 +90,8 @@ void BinMDataStd_AsciiStringDriver::Paste
{
Handle(TDataStd_AsciiString) anAtt = Handle(TDataStd_AsciiString)::DownCast(Source);
Target << anAtt->Get();
// process user defined guid
if(anAtt->ID() != TDataStd_AsciiString::GetID())
Target << anAtt->ID();
}

View File

@@ -20,6 +20,7 @@
#include <Standard_Type.hxx>
#include <TDataStd_Integer.hxx>
#include <TDF_Attribute.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_IntegerDriver,BinMDF_ADriver)
@@ -58,6 +59,19 @@ Standard_Boolean BinMDataStd_IntegerDriver::Paste
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;
if (!ok) {
theSource.SetPosition(aPos);
anAtt->SetID(TDataStd_Integer::GetID());
ok = Standard_True;
} else {
anAtt->SetID(aGuid);
}
} else
anAtt->SetID(TDataStd_Integer::GetID());
return ok;
}
@@ -72,4 +86,7 @@ void BinMDataStd_IntegerDriver::Paste (const Handle(TDF_Attribute)& theSource,
{
Handle(TDataStd_Integer) anAtt = Handle(TDataStd_Integer)::DownCast(theSource);
theTarget << anAtt->Get();
// process user defined guid
if(anAtt->ID() != TDataStd_Integer::GetID())
theTarget << anAtt->ID();
}

View File

@@ -20,6 +20,7 @@
#include <Standard_Type.hxx>
#include <TDataStd_Name.hxx>
#include <TDF_Attribute.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_NameDriver,BinMDF_ADriver)
@@ -58,6 +59,19 @@ Standard_Boolean BinMDataStd_NameDriver::Paste
Standard_Boolean ok = Source >> aStr;
if (ok)
aName->Set( aStr );
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
const Standard_Integer& aPos = Source.Position();
Standard_GUID aGuid;
ok = Source >> aGuid;
if (!ok) {
Source.SetPosition(aPos);
aName->SetID(TDataStd_Name::GetID());
ok = Standard_True;
} else {
aName->SetID(aGuid);
}
} else
aName->SetID(TDataStd_Name::GetID());
return ok;
}
@@ -73,4 +87,7 @@ void BinMDataStd_NameDriver::Paste
{
Handle(TDataStd_Name) aName = Handle(TDataStd_Name)::DownCast(Source);
Target << aName->Get();
// process user defined guid
if(aName->ID() != TDataStd_Name::GetID())
Target << aName->ID();
}

View File

@@ -20,6 +20,7 @@
#include <Standard_Type.hxx>
#include <TDataStd_Real.hxx>
#include <TDF_Attribute.hxx>
#include <BinMDataStd.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_RealDriver,BinMDF_ADriver)
@@ -58,6 +59,19 @@ Standard_Boolean BinMDataStd_RealDriver::Paste
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);
if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
const Standard_Integer& aPos = theSource.Position();
Standard_GUID aGuid;
ok = theSource >> aGuid;
if (!ok) {
theSource.SetPosition(aPos);
anAtt->SetID(TDataStd_Real::GetID());
ok = Standard_True;
} else {
anAtt->SetID(aGuid);
}
} else
anAtt->SetID(TDataStd_Real::GetID());
return ok;
}
@@ -72,4 +86,7 @@ void BinMDataStd_RealDriver::Paste (const Handle(TDF_Attribute)& theSource,
{
Handle(TDataStd_Real) anAtt= Handle(TDataStd_Real)::DownCast(theSource);
theTarget << anAtt->Get();
// process user defined guid
if(anAtt->ID() != TDataStd_Real::GetID())
theTarget << anAtt->ID();
}