mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +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:
parent
9c86076b21
commit
fa53efefc3
@ -33,7 +33,7 @@
|
||||
//#include <BinMNaming.hxx>
|
||||
static Standard_GUID BinLStorageDriver ("13a56835-8269-11d5-aab2-0050044b1af1");
|
||||
static Standard_GUID BinLRetrievalDriver("13a56836-8269-11d5-aab2-0050044b1af1");
|
||||
#define CURRENT_DOCUMENT_VERSION 8
|
||||
#define CURRENT_DOCUMENT_VERSION 9
|
||||
|
||||
//=======================================================================
|
||||
//function : Factory
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -98,22 +98,32 @@
|
||||
#include <TDataStd_ReferenceList.hxx>
|
||||
#include <TDF_ListIteratorOfLabelList.hxx>
|
||||
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
|
||||
#define DEB_DDataStd
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetInteger
|
||||
//purpose : SetInteger (DF, entry, value)
|
||||
//purpose : SetInteger (DF, entry, value, [,guid])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetInteger (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 4) {
|
||||
if (nb >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
TDataStd_Integer::Set(L,Draw::Atoi(arg[3]));
|
||||
if(nb == 4)
|
||||
TDataStd_Integer::Set(L,Draw::Atoi(arg[3]));
|
||||
else {
|
||||
if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
|
||||
di<<"DDataStd_SetInteger: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
Standard_GUID guid(arg[4]);
|
||||
TDataStd_Integer::Set(L, guid, Draw::Atoi(arg[3]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_SetInteger : Error\n";
|
||||
@ -122,21 +132,30 @@ static Standard_Integer DDataStd_SetInteger (Draw_Interpretor& di,
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetReal
|
||||
//purpose : SetReal (DF, entry, value)
|
||||
//purpose : SetReal (DF, entry, value [,guid])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetReal (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 4) {
|
||||
if (nb >= 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
TDataStd_Real::Set(L,Draw::Atof(arg[3]));
|
||||
return 0;
|
||||
}
|
||||
if(nb == 4)
|
||||
TDataStd_Real::Set(L,Draw::Atof(arg[3]));
|
||||
else {
|
||||
if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
|
||||
di<<"DDataStd_SetReal: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
Standard_GUID guid(arg[4]);
|
||||
TDataStd_Real::Set(L, guid, Draw::Atof(arg[3]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_SetReal : Error\n";
|
||||
return 1;
|
||||
}
|
||||
@ -188,23 +207,43 @@ static Standard_Integer DDataStd_SetComment (Draw_Interpretor& di,
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetInteger
|
||||
//purpose : GetReal (DF, entry, [drawname])
|
||||
//purpose : GetReal (DF, entry, [drawname][, guid])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetInteger (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3 || nb == 4) {
|
||||
if (nb == 3 || nb == 4 || nb == 5) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
Handle(TDataStd_Integer) A;
|
||||
if (!DDF::Find(DF,arg[2],TDataStd_Integer::GetID(),A)) return 1;
|
||||
if (nb == 4) Draw::Set(arg[3],A->Get());
|
||||
Standard_GUID aGuid;
|
||||
Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000");
|
||||
Standard_Boolean isdrawname(Standard_False);
|
||||
if(nb < 5 ) {
|
||||
if(nb == 4) { //DF, entry, guid
|
||||
if (Standard_GUID::CheckGUIDFormat(arg[3]))
|
||||
aGuid = Standard_GUID(arg[3]);
|
||||
}
|
||||
if(Standard_GUID::IsEqual(aGuid, aNullGuid)) {
|
||||
isdrawname = Standard_True;
|
||||
aGuid = TDataStd_Integer::GetID();
|
||||
}
|
||||
} else if(nb == 5) {
|
||||
isdrawname = Standard_True;
|
||||
if (Standard_GUID::CheckGUIDFormat(arg[4]))
|
||||
aGuid = Standard_GUID(arg[4]);
|
||||
else {
|
||||
di<<"DDataStd_GetInteger: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!DDF::Find(DF,arg[2],aGuid,A)) return 1;
|
||||
if (nb == 4 && isdrawname) Draw::Set(arg[3],A->Get());
|
||||
else Draw::Set(arg[2],A->Get());
|
||||
di << A->Get();
|
||||
return 0;
|
||||
@ -215,19 +254,41 @@ static Standard_Integer DDataStd_GetInteger (Draw_Interpretor& di,
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetReal
|
||||
//purpose : GetReal (DF, entry, [drawname])
|
||||
//purpose : GetReal (DF, entry, [drawname][, guid])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetReal (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3 || nb == 4) {
|
||||
if (nb == 3 || nb == 4 || nb == 5) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
Handle(TDataStd_Real) A;
|
||||
if (!DDF::Find(DF,arg[2],TDataStd_Real::GetID(),A)) return 1;
|
||||
if (nb == 4) Draw::Set(arg[3],A->Get());
|
||||
Standard_GUID aGuid;
|
||||
Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000");
|
||||
Standard_Boolean isdrawname(Standard_False);
|
||||
if(nb < 5 ) {
|
||||
if(nb == 4) {
|
||||
if (Standard_GUID::CheckGUIDFormat(arg[3]))
|
||||
aGuid = Standard_GUID(arg[3]);
|
||||
}
|
||||
if(Standard_GUID::IsEqual(aGuid, aNullGuid)) {
|
||||
isdrawname = Standard_True;
|
||||
aGuid = TDataStd_Real::GetID();
|
||||
}
|
||||
}
|
||||
else if(nb == 5) {
|
||||
isdrawname = Standard_True;
|
||||
if (Standard_GUID::CheckGUIDFormat(arg[4]))
|
||||
aGuid = Standard_GUID(arg[4]);
|
||||
else {
|
||||
di<<"DDataStd_GetReal: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (!DDF::Find(DF,arg[2],aGuid,A)) return 1;
|
||||
if (nb == 4 && isdrawname) Draw::Set(arg[3],A->Get());
|
||||
else Draw::Set(arg[2],A->Get());
|
||||
di << A->Get();
|
||||
return 0;
|
||||
@ -2841,7 +2902,7 @@ static Standard_Integer DDataStd_SetNDataIntAr2 (Draw_Interpretor& di,
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAsciiString(DF, entry , String)
|
||||
//function : SetAsciiString(DF, entry, String[, guid])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetAsciiString (Draw_Interpretor& di,
|
||||
@ -2849,20 +2910,27 @@ static Standard_Integer DDataStd_SetAsciiString (Draw_Interpretor& di,
|
||||
const char** arg)
|
||||
{
|
||||
|
||||
if (nb ==4) {
|
||||
if (nb == 4 || nb == 5) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label aLabel;
|
||||
DDF::AddLabel(DF, arg[2], aLabel);
|
||||
TCollection_AsciiString aString(arg[3]);
|
||||
Handle(TDataStd_AsciiString) anAtt;
|
||||
if(!aLabel.FindAttribute(TDataStd_AsciiString::GetID(), anAtt))
|
||||
anAtt = TDataStd_AsciiString::Set(aLabel, aString);
|
||||
Standard_GUID aGuid (TDataStd_AsciiString::GetID());
|
||||
if(nb == 5) {
|
||||
if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
|
||||
di<<"DDataStd_SetAsciiString: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
aGuid = Standard_GUID (arg[4]);
|
||||
}
|
||||
|
||||
Handle(TDataStd_AsciiString) anAtt = TDataStd_AsciiString::Set(aLabel, aGuid, aString);
|
||||
if(anAtt.IsNull()) {
|
||||
di << "AsciiString attribute is not found or not set" << "\n";
|
||||
return 1;}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// anAtt->Set(aString);
|
||||
cout << "String = " << anAtt->Get().ToCString() << " is kept in DF" << endl;
|
||||
return 0;
|
||||
}
|
||||
@ -2871,25 +2939,37 @@ static Standard_Integer DDataStd_SetAsciiString (Draw_Interpretor& di,
|
||||
}
|
||||
//
|
||||
//=======================================================================
|
||||
//function : GetAsciiString(DF, entry )
|
||||
//function : GetAsciiString(DF, entry[, guid] )
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetAsciiString (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
|
||||
if (nb ==3) {
|
||||
if (nb == 3 || nb == 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label aLabel;
|
||||
DDF::AddLabel(DF, arg[2], aLabel);
|
||||
Handle(TDataStd_AsciiString) anAtt;
|
||||
if(!aLabel.FindAttribute(TDataStd_AsciiString::GetID(), anAtt)) {
|
||||
TDF_Label aLabel;
|
||||
DDF::FindLabel(DF, arg[2], aLabel);
|
||||
if(aLabel.IsNull()) di << "Label is not found" << "\n";
|
||||
Standard_GUID aGuid (TDataStd_AsciiString::GetID());
|
||||
if(nb == 4) {
|
||||
if (!Standard_GUID::CheckGUIDFormat(arg[3])) {
|
||||
di<<"DDataStd_GetAsciiString: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
aGuid = Standard_GUID(arg[3]);
|
||||
}
|
||||
Handle(TDataStd_AsciiString) anAtt;
|
||||
if( !aLabel.FindAttribute(aGuid, anAtt) ) {
|
||||
cout << "AsciiString attribute is not found or not set" << endl;
|
||||
return 1;
|
||||
}
|
||||
cout << "String = " <<anAtt->Get().ToCString() << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef DEB_DDataStd
|
||||
cout << "String = " << anAtt->Get().ToCString() << endl;
|
||||
#endif
|
||||
di << anAtt->Get().ToCString();
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_GetAsciiString : Error\n";
|
||||
@ -3751,7 +3831,7 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
||||
// SET
|
||||
|
||||
theCommands.Add ("SetInteger",
|
||||
"SetInteger (DF, entry, value)",
|
||||
"SetInteger (DF, entry, value [,guid])",
|
||||
__FILE__, DDataStd_SetInteger, g);
|
||||
|
||||
theCommands.Add ("SetIntArray",
|
||||
@ -3763,7 +3843,7 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
||||
__FILE__, DDataStd_SetIntArrayValue, g);
|
||||
|
||||
theCommands.Add ("SetReal",
|
||||
"SetReal (DF, entry, value)",
|
||||
"SetReal (DF, entry, value [,guid])",
|
||||
__FILE__, DDataStd_SetReal, g);
|
||||
|
||||
theCommands.Add ("SetRealArray",
|
||||
@ -3917,7 +3997,7 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
||||
__FILE__, DDataStd_GetAsciiString, g);
|
||||
|
||||
theCommands.Add ("GetInteger",
|
||||
"GetInteger (DF, entry, [drawname])",
|
||||
"GetInteger (DF, entry, [drawname][, guid])",
|
||||
__FILE__, DDataStd_GetInteger, g);
|
||||
|
||||
theCommands.Add ("GetIntArray",
|
||||
@ -3965,7 +4045,7 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
||||
__FILE__, DDataStd_GetIntPackedMap, g);
|
||||
|
||||
theCommands.Add ("GetReal",
|
||||
"GetReal (DF, entry, [drawname])",
|
||||
"GetReal (DF, entry, [drawname][, guid])",
|
||||
__FILE__, DDataStd_GetReal, g);
|
||||
|
||||
theCommands.Add ("GetReference",
|
||||
|
@ -42,57 +42,69 @@
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetName
|
||||
//purpose : SetName (DF, entry, name)
|
||||
//purpose : SetName (DF, entry, name [,guid])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_SetName (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
// if (nb == 3) {
|
||||
// Handle(TDF_Data) DF;
|
||||
// if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
// TDF_Label L;
|
||||
// DDF::FindLabel(DF, arg[2], L);
|
||||
// if(L.IsNull()) cout << "Label is not found" << endl;
|
||||
// Handle(TDataStd_Name) N = TDataStd_Name::Set(L);
|
||||
// return 0;
|
||||
// }
|
||||
// else if (nb == 4) {
|
||||
if (nb == 4) {
|
||||
|
||||
if (nb == 4 || nb == 5) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::FindLabel(DF, arg[2], L);
|
||||
DDF::AddLabel(DF, arg[2], L);
|
||||
if(L.IsNull()) di << "Label is not found" << "\n";
|
||||
Handle(TDataStd_Name) N;
|
||||
//if( !L.FindAttribute(TDataStd_Name::GetID(), N) ) N = TDataStd_Name::Set(L);
|
||||
//N->Set(arg[3]);
|
||||
N = TDataStd_Name::Set(L,arg[3]);
|
||||
if(nb == 4)
|
||||
TDataStd_Name::Set(L,TCollection_ExtendedString(arg[3],Standard_True));
|
||||
else {
|
||||
if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
|
||||
di<<"DDataStd_SetReal: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
Standard_GUID guid(arg[4]);
|
||||
TDataStd_Name::Set(L, guid, TCollection_ExtendedString(arg[3],Standard_True));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
di << "DDataStd_SetName : Error\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//#define DEB_DDataStd
|
||||
//=======================================================================
|
||||
//function : DDataStd_GetName
|
||||
//purpose : GetName (DF, entry)
|
||||
//purpose : GetName (DF, entry [,guid])
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer DDataStd_GetName (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char** arg)
|
||||
{
|
||||
if (nb == 3) {
|
||||
if (nb == 3 || nb == 4) {
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::FindLabel(DF, arg[2], L);
|
||||
if(L.IsNull()) di << "Label is not found" << "\n";
|
||||
Handle(TDataStd_Name) N;
|
||||
if( !L.FindAttribute(TDataStd_Name::GetID(), N) ) return 1;
|
||||
Standard_GUID aGuid (TDataStd_Name::GetID());
|
||||
if(nb == 4) {
|
||||
if (!Standard_GUID::CheckGUIDFormat(arg[3])) {
|
||||
di<<"DDataStd_GetAsciiString: The format of GUID is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
aGuid = Standard_GUID(arg[3]);
|
||||
}
|
||||
Handle(TDataStd_Name) N;
|
||||
if( !L.FindAttribute(aGuid, N) ) {
|
||||
cout << "Name attribute is not found or not set" << endl;
|
||||
return 1;
|
||||
}
|
||||
#ifdef DEB_DDataStd
|
||||
if(!N.IsNull())
|
||||
cout << "String = " << TCollection_AsciiString(N->Get(), '?').ToCString() << endl;
|
||||
#endif
|
||||
TCollection_AsciiString s(N->Get(),'?');
|
||||
di << s.ToCString();
|
||||
return 0;
|
||||
@ -103,82 +115,7 @@ static Standard_Integer DDataStd_GetName (Draw_Interpretor& di,
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LabelName (DF, [entry], path)
|
||||
//=======================================================================
|
||||
// static Standard_Integer DDataStd_LabelName (Draw_Interpretor& di,
|
||||
// Standard_Integer nb,
|
||||
// const char** arg)
|
||||
// {
|
||||
// Handle(TDF_Data) DF;
|
||||
// TDF_Label label;
|
||||
// Handle(TDataStd_Name) result;
|
||||
// TDataStd_ListOfExtendedString myList;
|
||||
// Standard_Integer i = 2;
|
||||
// Standard_Boolean Found = Standard_False;
|
||||
|
||||
// if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
// if( nb == 4 ) {
|
||||
// if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
// cout << "No label for entry" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
// i = 3;
|
||||
// }
|
||||
|
||||
// if( !TDataStd_Name::MakePath(arg[i], myList) ) return 1;
|
||||
|
||||
// if( nb == 4 ) {
|
||||
// Handle(TDataStd_Name) current;
|
||||
// if (TDataStd_Name::Find(label,current)) {
|
||||
// if (current->Find(myList ,result)) Found = Standard_True;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if(TDataStd_Name::Find(DF, myList ,result)) Found = Standard_True;
|
||||
// }
|
||||
|
||||
// if(Found) {
|
||||
// DDF::ReturnLabel(di, result->Label());
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// cout << "Label wasn't found" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
|
||||
// //=======================================================================
|
||||
// //function : FullPath (DF, entry)
|
||||
// //=======================================================================
|
||||
// static Standard_Integer DDataStd_FullPath (Draw_Interpretor& di,
|
||||
// Standard_Integer nb,
|
||||
// const char** arg)
|
||||
// {
|
||||
// Handle(TDF_Data) DF;
|
||||
// if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
// TDF_Label label;
|
||||
// if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
// cout << "No label for entry" << endl;
|
||||
// return 1;
|
||||
// }
|
||||
// Handle(TDataStd_Name) current;
|
||||
// if (TDataStd_Name::Find(label,current)) {
|
||||
// TDF_AttributeList myList;
|
||||
// if (!current->FullPath(myList)) return 1;
|
||||
// TDF_ListIteratorOfAttributeList itr(myList);
|
||||
// TCollection_AsciiString str;
|
||||
// for(;itr.More(); itr.Next() ) {
|
||||
// str+=Handle(TDataStd_Name)::DownCast(itr.Value())->Get();
|
||||
// str+=":";
|
||||
// }
|
||||
// str.Remove(str.Length()); //remove last ":"
|
||||
// di << str.ToCString();
|
||||
// }
|
||||
// #ifndef OCCT_DEBUG
|
||||
// return 0 ;
|
||||
// #endif
|
||||
// }
|
||||
//=======================================================================
|
||||
//function : SetCommands
|
||||
//purpose :
|
||||
@ -194,20 +131,13 @@ void DDataStd::NameCommands (Draw_Interpretor& theCommands)
|
||||
const char* g = "DDataStd : Name attribute commands";
|
||||
|
||||
theCommands.Add ("SetName",
|
||||
"SetName (DF, entry, name)",
|
||||
"SetName (DF, entry, name [,guid])",
|
||||
__FILE__, DDataStd_SetName, g);
|
||||
|
||||
theCommands.Add ("GetName",
|
||||
"GetNmae (DF, entry)",
|
||||
"GetNmae (DF, entry [,guid])",
|
||||
__FILE__, DDataStd_GetName, g);
|
||||
|
||||
// theCommands.Add ("LabelName",
|
||||
// "GetLabel (DF, [entry], path(name1:name2:...nameN)",
|
||||
// __FILE__, DDataStd_LabelName, g);
|
||||
|
||||
// theCommands.Add ("FullPath",
|
||||
// "FullPath (DF, entry)",
|
||||
// __FILE__, DDataStd_FullPath, g);
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,6 @@
|
||||
#include <Standard_RangeError.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#define Standard_GUID_SIZE 36
|
||||
#define Standard_GUID_SIZE_ALLOC Standard_GUID_SIZE+1
|
||||
|
||||
//Fixes incorrect treatment of GUID given as a string with invalid format
|
||||
|
||||
|
@ -32,7 +32,8 @@
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
|
||||
|
||||
#define Standard_GUID_SIZE 36
|
||||
#define Standard_GUID_SIZE_ALLOC Standard_GUID_SIZE+1
|
||||
|
||||
class Standard_GUID
|
||||
{
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
{
|
||||
theAttribute->Set (myValue);
|
||||
theAttribute->SetDimension (static_cast<TDataStd_RealEnum> (myDimension));
|
||||
theAttribute->SetID(TDataStd_Real::GetID());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -86,6 +86,44 @@ Handle(TDF_Attribute) StdLPersistent_Value::UAttribute::CreateAttribute()
|
||||
return this->myTransient;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_Value::Integer::CreateAttribute()
|
||||
{
|
||||
integer<TDataStd_Integer>::CreateAttribute();
|
||||
|
||||
if (this->myData)
|
||||
{
|
||||
this->myTransient->SetID (TDataStd_Integer::GetID());
|
||||
}
|
||||
|
||||
return this->myTransient;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_Value::Name::CreateAttribute()
|
||||
{
|
||||
string<TDataStd_Name>::CreateAttribute();
|
||||
|
||||
if (this->myData)
|
||||
{
|
||||
this->myTransient->SetID (TDataStd_Name::GetID());
|
||||
}
|
||||
|
||||
return this->myTransient;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_Value::AsciiString::CreateAttribute()
|
||||
{
|
||||
string<TDataStd_AsciiString, StdLPersistent_HString::Ascii>::CreateAttribute();
|
||||
|
||||
if (this->myData)
|
||||
{
|
||||
this->myTransient->SetID (TDataStd_AsciiString::GetID());
|
||||
}
|
||||
|
||||
return this->myTransient;
|
||||
}
|
||||
|
||||
template class StdLPersistent_Value::integer <TDataStd_Integer>;
|
||||
template class StdLPersistent_Value::integer <TDF_TagSource>;
|
||||
|
@ -47,14 +47,10 @@ class StdLPersistent_Value
|
||||
};
|
||||
|
||||
public:
|
||||
typedef integer <TDataStd_Integer> Integer;
|
||||
typedef integer <TDF_TagSource> TagSource;
|
||||
|
||||
typedef string <TDF_Reference> Reference;
|
||||
typedef string <TDataStd_Name> Name;
|
||||
typedef integer <TDF_TagSource> TagSource;
|
||||
typedef string <TDF_Reference> Reference;
|
||||
typedef string <TDataStd_Comment> Comment;
|
||||
typedef string <TDataStd_AsciiString,
|
||||
StdLPersistent_HString::Ascii> AsciiString;
|
||||
|
||||
class UAttribute : public string <TDataStd_UAttribute>
|
||||
{
|
||||
@ -62,6 +58,27 @@ public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
};
|
||||
|
||||
class Integer : public integer <TDataStd_Integer>
|
||||
{
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
};
|
||||
|
||||
class Name : public string <TDataStd_Name>
|
||||
{
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
};
|
||||
|
||||
class AsciiString : public string <TDataStd_AsciiString, StdLPersistent_HString::Ascii>
|
||||
{
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -51,7 +51,7 @@ const Standard_GUID& TDataStd_AsciiString::GetID()
|
||||
|
||||
const Standard_GUID& TDataStd_AsciiString::ID() const
|
||||
{
|
||||
return GetID();
|
||||
return myID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -67,12 +67,30 @@ Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
|
||||
if (!theLabel.FindAttribute(TDataStd_AsciiString::GetID(), A))
|
||||
{
|
||||
A = new TDataStd_AsciiString;
|
||||
A->SetID(GetID());
|
||||
theLabel.AddAttribute(A);
|
||||
}
|
||||
A->Set(theAsciiString);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose : Set user defined attribute
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const TCollection_AsciiString& theAsciiString)
|
||||
{
|
||||
Handle(TDataStd_AsciiString) A;
|
||||
if (!L.FindAttribute(theGuid, A)) {
|
||||
A = new TDataStd_AsciiString ();
|
||||
A->SetID(theGuid);
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (theAsciiString);
|
||||
return A;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
@ -80,6 +98,7 @@ Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
|
||||
|
||||
void TDataStd_AsciiString::Set (const TCollection_AsciiString& theAsciiString)
|
||||
{
|
||||
if(myString == theAsciiString) return;
|
||||
Backup();
|
||||
myString = theAsciiString;
|
||||
}
|
||||
@ -94,6 +113,19 @@ const TCollection_AsciiString& TDataStd_AsciiString::Get () const
|
||||
return myString;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_AsciiString::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
@ -101,7 +133,9 @@ const TCollection_AsciiString& TDataStd_AsciiString::Get () const
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_AsciiString::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_AsciiString();
|
||||
Handle(TDataStd_AsciiString) Att = new TDataStd_AsciiString();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -113,6 +147,7 @@ void TDataStd_AsciiString::Restore (const Handle(TDF_Attribute)& theWith)
|
||||
{
|
||||
Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast(theWith);
|
||||
myString = R->Get();
|
||||
myID = R->ID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -125,6 +160,7 @@ void TDataStd_AsciiString::Paste (const Handle(TDF_Attribute)& theInto,
|
||||
{
|
||||
Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast (theInto);
|
||||
R->Set(myString);
|
||||
R->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -144,5 +180,9 @@ Standard_OStream& TDataStd_AsciiString::Dump(Standard_OStream& theOS) const
|
||||
{
|
||||
Standard_OStream& anOS = TDF_Attribute::Dump( theOS );
|
||||
anOS << myString;
|
||||
anOS << " Name=|"<<myString<<"|";
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid << "|" <<endl;
|
||||
return anOS;
|
||||
}
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_GUID;
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
class TDF_Label;
|
||||
class TCollection_AsciiString;
|
||||
class TDF_Attribute;
|
||||
@ -50,11 +51,19 @@ public:
|
||||
//! AsciiString methods
|
||||
//! ===================
|
||||
Standard_EXPORT static Handle(TDataStd_AsciiString) Set (const TDF_Label& label, const TCollection_AsciiString& string);
|
||||
|
||||
|
||||
//! Finds, or creates, an AsciiString attribute with explicit user defined <guid> and sets <string>.
|
||||
//! The Name attribute is returned.
|
||||
Standard_EXPORT static Handle(TDataStd_AsciiString) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const TCollection_AsciiString& string);
|
||||
|
||||
Standard_EXPORT TDataStd_AsciiString();
|
||||
|
||||
Standard_EXPORT void Set (const TCollection_AsciiString& S);
|
||||
|
||||
//! Sets the explicit user defined GUID to the attribute.
|
||||
Standard_EXPORT void SetID (const Standard_GUID& guid);
|
||||
|
||||
Standard_EXPORT const TCollection_AsciiString& Get() const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsEmpty() const;
|
||||
@ -83,7 +92,7 @@ private:
|
||||
|
||||
|
||||
TCollection_AsciiString myString;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
class Standard_GUID;
|
||||
class TDF_Label;
|
||||
class TDF_Attribute;
|
||||
@ -47,12 +49,20 @@ public:
|
||||
|
||||
//! Finds, or creates, an Integer attribute and sets <value>
|
||||
//! the Integer attribute is returned.
|
||||
//! Integer methods
|
||||
//! ===============
|
||||
Standard_EXPORT static Handle(TDataStd_Integer) Set (const TDF_Label& label, const Standard_Integer value);
|
||||
|
||||
//! Finds, or creates, an Integer attribute with explicit user defined <guid> and sets <value>.
|
||||
//! The Integer attribute is returned.
|
||||
Standard_EXPORT static Handle(TDataStd_Integer) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const Standard_Integer value);
|
||||
|
||||
//! Integer methods
|
||||
//! ===============
|
||||
Standard_EXPORT void Set (const Standard_Integer V);
|
||||
|
||||
|
||||
//! Sets the explicit GUID (user defined) for the attribute.
|
||||
Standard_EXPORT void SetID (const Standard_GUID& guid);
|
||||
|
||||
//! Returns the integer value contained in the attribute.
|
||||
Standard_EXPORT Standard_Integer Get() const;
|
||||
|
||||
@ -85,7 +95,7 @@ private:
|
||||
|
||||
|
||||
Standard_Integer myValue;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,8 @@ Handle(TDataStd_Name) TDataStd_Name::Set
|
||||
{
|
||||
Handle(TDataStd_Name) N;
|
||||
if (!label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
N = new TDataStd_Name ();
|
||||
N = new TDataStd_Name ();
|
||||
N->SetID(GetID());
|
||||
label.AddAttribute(N);
|
||||
}
|
||||
N->Set(theString);
|
||||
@ -58,68 +59,22 @@ Handle(TDataStd_Name) TDataStd_Name::Set
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Find
|
||||
//purpose :
|
||||
//function : Set
|
||||
//purpose : Set user defined attribute
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const TDF_Label& label, Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
// if (label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
// name = N;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// TDF_Label L = label;
|
||||
// while (!L.IsRoot()) {
|
||||
// L = L.Father();
|
||||
// if (L.FindAttribute (TDataStd_Name::GetID(), N)) {
|
||||
// name = N;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : IsNamed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::IsNamed(const TDF_Label& label)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
|
||||
// return label.FindAttribute(TDataStd_Name::GetID(), N);
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : IsEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::IsEmpty(const TDF_Label& label)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
// if(label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
// return N->IsEmpty();
|
||||
// }
|
||||
|
||||
// Standard_DomainError::Raise("There isn't the Name Attribute on the label");
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Erase
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// void TDataStd_Name::Erase(const TDF_Label& label)
|
||||
// {
|
||||
// Handle(TDataStd_Name) N;
|
||||
|
||||
// if(label.FindAttribute(TDataStd_Name::GetID(), N)) {
|
||||
// N->SetEmpty();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Standard_DomainError::Raise("There isn't the Name Attribute on the label");
|
||||
// }
|
||||
|
||||
Handle(TDataStd_Name) TDataStd_Name::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const TCollection_ExtendedString& theString)
|
||||
{
|
||||
Handle(TDataStd_Name) N;
|
||||
if (!L.FindAttribute(theGuid, N)) {
|
||||
N = new TDataStd_Name ();
|
||||
N->SetID(theGuid);
|
||||
L.AddAttribute(N);
|
||||
}
|
||||
N->Set (theString);
|
||||
return N;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : TDataStd_Name
|
||||
//purpose : Empty Constructor
|
||||
@ -150,15 +105,26 @@ const TCollection_ExtendedString& TDataStd_Name::Get () const
|
||||
return myString;
|
||||
}
|
||||
|
||||
// TDF_Attribute methods
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_Name::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
|
||||
// TDF_Attribute methods
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& TDataStd_Name::ID () const { return GetID(); }
|
||||
|
||||
const Standard_GUID& TDataStd_Name::ID () const { return myID; }
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
@ -167,7 +133,9 @@ const Standard_GUID& TDataStd_Name::ID () const { return GetID(); }
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_Name::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_Name();
|
||||
Handle(TDataStd_Name) Att = new TDataStd_Name();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -177,7 +145,9 @@ Handle(TDF_Attribute) TDataStd_Name::NewEmpty () const
|
||||
|
||||
void TDataStd_Name::Restore(const Handle(TDF_Attribute)& with)
|
||||
{
|
||||
myString = Handle(TDataStd_Name)::DownCast (with)->Get();
|
||||
Handle(TDataStd_Name) anAtt = Handle(TDataStd_Name)::DownCast (with);
|
||||
myString = anAtt->Get();
|
||||
myID = anAtt->ID();
|
||||
}
|
||||
|
||||
|
||||
@ -189,7 +159,9 @@ void TDataStd_Name::Restore(const Handle(TDF_Attribute)& with)
|
||||
void TDataStd_Name::Paste (const Handle(TDF_Attribute)& into,
|
||||
const Handle(TDF_RelocationTable)&/* RT*/) const
|
||||
{
|
||||
Handle(TDataStd_Name)::DownCast (into)->Set (myString);
|
||||
Handle(TDataStd_Name) anAtt = Handle(TDataStd_Name)::DownCast (into);
|
||||
anAtt->Set (myString);
|
||||
anAtt->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -200,258 +172,9 @@ void TDataStd_Name::Paste (const Handle(TDF_Attribute)& into,
|
||||
Standard_OStream& TDataStd_Name::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
TDF_Attribute::Dump(anOS);
|
||||
anOS << " Name=|"<<myString<<"|"<<endl;
|
||||
anOS << " Name=|"<<myString<<"|";
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid << endl;
|
||||
return anOS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the full path)
|
||||
//purpose : Name
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const Handle(TDF_Data)& framework,
|
||||
// const TDataStd_ListOfExtendedString& fullPath,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// TDF_Label L, root = framework->Root();
|
||||
// TDF_ChildIterator ChItr (root, Standard_True);
|
||||
// TCollection_ExtendedString string, first = fullPath.First();
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// Standard_Boolean IsRootVisited = Standard_False;
|
||||
|
||||
// tmpPath.Assign(fullPath);
|
||||
// if(tmpPath.Extent() > 0 ) tmpPath.RemoveFirst();
|
||||
|
||||
// while( ChItr.More() ) {
|
||||
// if( !IsRootVisited ) L = root; //For the fisrt time visit the root label
|
||||
// else L = ChItr.Value();
|
||||
|
||||
// if( L.FindAttribute(TDataStd_Name::GetID(), Ncurrent) ) {
|
||||
// string = Ncurrent->Get();
|
||||
// if( (string == first ) && ((string.Length()) == (first.Length())) ) {
|
||||
// if( fullPath.Extent() == 1 ) {
|
||||
// name = Ncurrent;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// if (Ncurrent->Find(tmpPath, name) ) return Standard_True;
|
||||
// }
|
||||
// else {
|
||||
// if( !Ncurrent->IsEmpty() ) {
|
||||
// //The root contains String different from first name in the path
|
||||
// if( !IsRootVisited ) return Standard_False;
|
||||
// ChItr.NextBrother(); continue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if( !IsRootVisited ) {
|
||||
// IsRootVisited = Standard_True;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// ChItr.Next();
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the relative path)
|
||||
//purpose : Name
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const TDF_Label& currentLabel,
|
||||
// const TDataStd_ListOfExtendedString& relativePath,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// TDF_ChildIterator ChItr (currentLabel, Standard_True);
|
||||
// TCollection_ExtendedString string, first = relativePath.First();
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// tmpPath.Assign(relativePath);
|
||||
|
||||
// if( !currentLabel.FindAttribute(TDataStd_Name::GetID(), Ncurrent) )
|
||||
// Standard_DomainError::Raise("There isn't the Name attribute on the label");
|
||||
|
||||
|
||||
// while( ChItr.More() ) {
|
||||
// if( ChItr.Value().FindAttribute(TDataStd_Name::GetID(), Ncurrent) ) {
|
||||
// string = Ncurrent->Get();
|
||||
// if( (string == first ) && ((string.Length()) == (first.Length())) ) {
|
||||
// if( relativePath.Extent() == 1 ) { //it has reached the end of the relative path
|
||||
// name = Ncurrent;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// else {
|
||||
// if (tmpPath.Extent() > 0) tmpPath.RemoveFirst();
|
||||
// if (Find(ChItr.Value(), tmpPath, Ncurrent)) return Standard_True;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if( !Ncurrent->IsEmpty() ) {
|
||||
// ChItr.NextBrother(); continue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ChItr.Next();
|
||||
// }
|
||||
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the relative path)
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find(const TDF_Label& currentLabel,
|
||||
// const TCollection_ExtendedString& string,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// TDataStd_Name::MakePath(string, tmpPath,':');
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// if (TDataStd_Name::Find(currentLabel,Ncurrent)) {
|
||||
// return Ncurrent->Find(tmpPath, name);
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the full path)
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find(const Handle(TDF_Data)& framework,
|
||||
// const TCollection_ExtendedString& string,
|
||||
// Handle(TDataStd_Name)& name)
|
||||
// {
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// TDataStd_Name::MakePath(string, tmpPath,':');
|
||||
// return Find(framework, tmpPath, name);
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : FullPath
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::FullPath (TDF_AttributeList& path) const
|
||||
// {
|
||||
// path.Clear();
|
||||
// if( !IsEmpty() ) path.Append(this);
|
||||
// TDF_Label L = Label();
|
||||
// if(L.IsRoot() ) return Standard_True;
|
||||
// Handle(TDataStd_Name) Ncur;
|
||||
// while ( !L.IsRoot()) {
|
||||
// L = L.Father();
|
||||
// if(L.FindAttribute (TDataStd_Name::GetID(), Ncur)) {
|
||||
// if( !Ncur->IsEmpty() )path.Prepend(Ncur);
|
||||
// }
|
||||
// }
|
||||
// return Standard_True;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : MakePath
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::MakePath(const TCollection_ExtendedString& path,
|
||||
// TDataStd_ListOfExtendedString& pathlist,
|
||||
// const Standard_ExtCharacter Separator)
|
||||
// {
|
||||
// TCollection_ExtendedString tmpPath = path, str;
|
||||
|
||||
// str+=Separator; str+=Separator;
|
||||
// if( tmpPath.Search(str) != -1 ) return Standard_False; //Not valid path (contains two adjacent separators)
|
||||
|
||||
// if( tmpPath.Search(Separator) == -1 ) { //The path contains only one name.
|
||||
// pathlist.Append(path);
|
||||
// return Standard_True;
|
||||
// }
|
||||
// Standard_Integer i;
|
||||
// while( (i = tmpPath.SearchFromEnd(Separator) ) != -1 ) {
|
||||
// str = tmpPath.Split(i-1);
|
||||
// str.Remove(1);
|
||||
// pathlist.Prepend(str);
|
||||
// }
|
||||
// if( tmpPath.Length() > 0 ) pathlist.Prepend(tmpPath);
|
||||
// return Standard_True;
|
||||
// }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MakePath
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::MakePath(const TDF_AttributeList& pathlist,
|
||||
// TCollection_ExtendedString& path,
|
||||
// const Standard_ExtCharacter Separator)
|
||||
// {
|
||||
// TDF_ListIteratorOfAttributeList Itr(pathlist);
|
||||
// Handle(TDataStd_Name) N;
|
||||
|
||||
// if( pathlist.Extent() == 0 ) return Standard_False;
|
||||
// path.Clear();
|
||||
// for(; Itr.More(); Itr.Next() ) {
|
||||
// N = Handle(TDataStd_Name)::DownCast(Itr.Value());
|
||||
// path = path + N->Get();
|
||||
// path = path + Separator;
|
||||
// }
|
||||
// path.Remove(path.Length(), 1);
|
||||
// return Standard_True;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : Find (by the relative path)
|
||||
//purpose : Name
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::Find (const TDataStd_ListOfExtendedString& relativePath,
|
||||
// Handle(TDataStd_Name)& name) const
|
||||
// {
|
||||
// Handle(TDataStd_Name) Ncurrent;
|
||||
// TDF_ChildIterator ChItr (Label(), Standard_True);
|
||||
// TCollection_ExtendedString string, first = relativePath.First();
|
||||
// TDataStd_ListOfExtendedString tmpPath;
|
||||
// tmpPath.Assign(relativePath);
|
||||
// //
|
||||
// while( ChItr.More() ) {
|
||||
// if( ChItr.Value().FindAttribute(TDataStd_Name::GetID(), Ncurrent) ) {
|
||||
// string = Ncurrent->Get();
|
||||
// if( (string == first ) && ((string.Length()) == (first.Length())) ) {
|
||||
// if( relativePath.Extent() == 1 ) { //it has reached the end of the relative path
|
||||
// name = Ncurrent;
|
||||
// return Standard_True;
|
||||
// }
|
||||
// else {
|
||||
// if (tmpPath.Extent() > 0) tmpPath.RemoveFirst();
|
||||
// if (Ncurrent->Find(tmpPath, name)) return Standard_True;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (!Ncurrent->IsEmpty()) {
|
||||
// ChItr.NextBrother(); continue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ChItr.Next();
|
||||
// }
|
||||
// return Standard_False;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : ChildNames
|
||||
//purpose : NameTool
|
||||
//=======================================================================
|
||||
// Standard_Boolean TDataStd_Name::ChildNames (TDF_AttributeList& list) const
|
||||
// {
|
||||
// Standard_Boolean found = Standard_False;
|
||||
// TDF_ChildIterator ChItr (Label(), Standard_True);
|
||||
// Handle(TDataStd_Name) N;
|
||||
// list.Clear();
|
||||
// for(; ChItr.More(); ChItr.Next()) {
|
||||
// if( ChItr.Value().FindAttribute(TDataStd_Name::GetID(), N) ) {
|
||||
// list.Append(N);
|
||||
// found = Standard_True;
|
||||
// cout << N->Get() << endl;
|
||||
// }
|
||||
// }
|
||||
// return found;
|
||||
// }
|
||||
|
@ -23,8 +23,9 @@
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
class Standard_DomainError;
|
||||
class Standard_GUID;
|
||||
class TDF_Label;
|
||||
class TCollection_ExtendedString;
|
||||
class TDF_Attribute;
|
||||
@ -69,12 +70,18 @@ public:
|
||||
//! Name methods
|
||||
//! ============
|
||||
Standard_EXPORT static Handle(TDataStd_Name) Set (const TDF_Label& label, const TCollection_ExtendedString& string);
|
||||
|
||||
|
||||
//! Finds, or creates, a Name attribute with explicit user defined <guid> and sets <string>.
|
||||
//! The Name attribute is returned.
|
||||
Standard_EXPORT static Handle(TDataStd_Name) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const TCollection_ExtendedString& string);
|
||||
Standard_EXPORT TDataStd_Name();
|
||||
|
||||
//! Sets <S> as name. Raises if <S> is not a valid name.
|
||||
Standard_EXPORT void Set (const TCollection_ExtendedString& S);
|
||||
|
||||
//! Sets the explicit user defined GUID to the attribute.
|
||||
Standard_EXPORT void SetID (const Standard_GUID& guid);
|
||||
|
||||
//! Returns the name contained in this name attribute.
|
||||
Standard_EXPORT const TCollection_ExtendedString& Get() const;
|
||||
@ -103,7 +110,7 @@ private:
|
||||
|
||||
|
||||
TCollection_ExtendedString myString;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
@ -48,12 +48,30 @@ Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L,
|
||||
Handle(TDataStd_Real) A;
|
||||
if (!L.FindAttribute(TDataStd_Real::GetID(), A)) {
|
||||
A = new TDataStd_Real ();
|
||||
A->SetID(GetID());
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose : User defined attribute
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L, const Standard_GUID& theGuid,
|
||||
const Standard_Real V)
|
||||
{
|
||||
Handle(TDataStd_Real) A;
|
||||
if (!L.FindAttribute(theGuid, A)) {
|
||||
A = new TDataStd_Real ();
|
||||
A->SetID(theGuid);
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TDataStd_Real
|
||||
@ -78,8 +96,9 @@ Standard_Boolean TDataStd_Real::IsCaptured() const
|
||||
// pour test
|
||||
|
||||
if (Label().FindAttribute(TDF_Reference::GetID(),reference)) {
|
||||
const TDF_Label& label = reference->Get();
|
||||
return label.IsAttribute (TDataStd_Real::GetID());
|
||||
const TDF_Label& aLabel = reference->Get();
|
||||
return aLabel.IsAttribute (myID);
|
||||
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
@ -138,9 +157,20 @@ TDataStd_RealEnum TDataStd_Real::GetDimension () const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& TDataStd_Real::ID() const { return GetID(); }
|
||||
const Standard_GUID& TDataStd_Real::ID() const { return myID; }
|
||||
|
||||
//=======================================================================
|
||||
//function : SetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDataStd_Real::SetID( const Standard_GUID& theGuid)
|
||||
{
|
||||
if(myID == theGuid) return;
|
||||
|
||||
Backup();
|
||||
myID = theGuid;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
@ -148,7 +178,9 @@ const Standard_GUID& TDataStd_Real::ID() const { return GetID(); }
|
||||
|
||||
Handle(TDF_Attribute) TDataStd_Real::NewEmpty () const
|
||||
{
|
||||
return new TDataStd_Real();
|
||||
Handle(TDataStd_Real) Att = new TDataStd_Real();
|
||||
Att->SetID(myID);
|
||||
return Att;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -161,6 +193,7 @@ void TDataStd_Real::Restore(const Handle(TDF_Attribute)& With)
|
||||
Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (With);
|
||||
myValue = R->Get();
|
||||
myDimension = R->GetDimension();
|
||||
myID = R->ID();
|
||||
}
|
||||
|
||||
|
||||
@ -176,6 +209,7 @@ void TDataStd_Real::Paste (const Handle(TDF_Attribute)& Into,
|
||||
Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (Into);
|
||||
R->Set(myValue);
|
||||
R->SetDimension(myDimension);
|
||||
R->SetID(myID);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -187,6 +221,10 @@ Standard_OStream& TDataStd_Real::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
anOS << "Real ";
|
||||
TDataStd::Print(GetDimension(),anOS);
|
||||
anOS << myValue;
|
||||
Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
|
||||
myID.ToCString(sguid);
|
||||
anOS << sguid;
|
||||
return anOS;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,8 @@
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
class Standard_GUID;
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
class TDF_Label;
|
||||
class TDF_Attribute;
|
||||
class TDF_RelocationTable;
|
||||
@ -43,16 +44,23 @@ public:
|
||||
|
||||
//! class methods
|
||||
//! =============
|
||||
//! Returns the GUID for real numbers.
|
||||
//! Returns the default GUID for real numbers.
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
//! Finds, or creates, an Real attribute and sets <value> the
|
||||
//! Real attribute is returned. the Real dimension is
|
||||
//! Scalar by default. use SetDimension to overwrite.
|
||||
//! Finds, or creates, a Real attribute with default GUID and sets <value>.
|
||||
//! The Real attribute is returned. The Real dimension is Scalar by default.
|
||||
//! Use SetDimension to overwrite.
|
||||
//! Real methods
|
||||
//! ============
|
||||
Standard_EXPORT static Handle(TDataStd_Real) Set (const TDF_Label& label, const Standard_Real value);
|
||||
|
||||
//! Finds, or creates, a Real attribute with explicit GUID and sets <value>.
|
||||
//! The Real attribute is returned.
|
||||
//! Real methods
|
||||
//! ============
|
||||
Standard_EXPORT static Handle(TDataStd_Real) Set (const TDF_Label& label, const Standard_GUID& guid,
|
||||
const Standard_Real value);
|
||||
|
||||
Standard_EXPORT TDataStd_Real();
|
||||
|
||||
Standard_EXPORT void SetDimension (const TDataStd_RealEnum DIM);
|
||||
@ -60,9 +68,11 @@ public:
|
||||
Standard_EXPORT TDataStd_RealEnum GetDimension() const;
|
||||
|
||||
|
||||
//! Finds or creates the real number V.
|
||||
//! Sets the real number V.
|
||||
Standard_EXPORT void Set (const Standard_Real V);
|
||||
|
||||
//! Sets the explicit GUID for the attribute.
|
||||
Standard_EXPORT void SetID (const Standard_GUID& guid);
|
||||
|
||||
//! Returns the real number value contained in the attribute.
|
||||
Standard_EXPORT Standard_Real Get() const;
|
||||
@ -95,7 +105,7 @@ private:
|
||||
|
||||
Standard_Real myValue;
|
||||
TDataStd_RealEnum myDimension;
|
||||
|
||||
Standard_GUID myID;
|
||||
|
||||
};
|
||||
|
||||
|
@ -178,19 +178,11 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
|
||||
anIter.Value().ForgetAllAttributes();
|
||||
}
|
||||
if (!theObject->GetName().IsNull() && !theObject->GetName()->IsEmpty())
|
||||
{
|
||||
Handle(TDataStd_AsciiString) anAttName;
|
||||
if(!Label().FindChild(ChildLab_Name).FindAttribute(TDataStd_AsciiString::GetID(), anAttName))
|
||||
{
|
||||
anAttName = new TDataStd_AsciiString();
|
||||
Label().FindChild(ChildLab_Name).AddAttribute(anAttName);
|
||||
}
|
||||
anAttName->Set(theObject->GetName()->String());
|
||||
}
|
||||
Handle(TDataStd_AsciiString) anAttName = TDataStd_AsciiString::Set(Label().FindChild(ChildLab_Name),
|
||||
theObject->GetName()->String());
|
||||
|
||||
Handle(TDataStd_Integer) aPosition = new TDataStd_Integer();
|
||||
aPosition->Set(theObject->GetPosition());
|
||||
Label().FindChild(ChildLab_Position).AddAttribute(aPosition);
|
||||
Handle(TDataStd_Integer) aPosition = TDataStd_Integer::Set(Label().FindChild(ChildLab_Position),
|
||||
theObject->GetPosition());
|
||||
|
||||
if(theObject->GetModifiers().Length() > 0)
|
||||
{
|
||||
@ -211,31 +203,20 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
|
||||
theObject->GetModifierWithValue(aM, aV);
|
||||
if(aM != XCAFDimTolObjects_DatumModifWithValue_None)
|
||||
{
|
||||
Handle(TDataStd_Integer) aModifierWithValueM;
|
||||
if(!Label().FindChild(ChildLab_ModifierWithValue).FindAttribute(TDataStd_Integer::GetID(), aModifierWithValueM))
|
||||
{
|
||||
aModifierWithValueM = new TDataStd_Integer();
|
||||
Label().FindChild(ChildLab_ModifierWithValue).AddAttribute(aModifierWithValueM);
|
||||
}
|
||||
Handle(TDataStd_Real) aModifierWithValueV;
|
||||
if(!Label().FindChild(ChildLab_ModifierWithValue).FindAttribute(TDataStd_Real::GetID(), aModifierWithValueV))
|
||||
{
|
||||
aModifierWithValueV = new TDataStd_Real();
|
||||
Label().FindChild(ChildLab_ModifierWithValue).AddAttribute(aModifierWithValueV);
|
||||
}
|
||||
aModifierWithValueM->Set(aM);
|
||||
aModifierWithValueV->Set(aV);
|
||||
Handle(TDataStd_Integer) aModifierWithValueM =
|
||||
TDataStd_Integer::Set(Label().FindChild(ChildLab_ModifierWithValue), aM);
|
||||
|
||||
Handle(TDataStd_Real) aModifierWithValueV =
|
||||
TDataStd_Real::Set(Label().FindChild(ChildLab_ModifierWithValue), aV);
|
||||
}
|
||||
|
||||
Handle(TDataStd_Integer) aIsTarget = new TDataStd_Integer();
|
||||
aIsTarget->Set(theObject->IsDatumTarget());
|
||||
Label().FindChild(ChildLab_IsDTarget).AddAttribute(aIsTarget);
|
||||
Handle(TDataStd_Integer) aIsTarget = TDataStd_Integer::Set(Label().FindChild(ChildLab_IsDTarget),
|
||||
theObject->IsDatumTarget());
|
||||
|
||||
if(theObject->IsDatumTarget())
|
||||
{
|
||||
Handle(TDataStd_Integer) aType = new TDataStd_Integer();
|
||||
aType->Set(theObject->GetDatumTargetType());
|
||||
Label().FindChild(ChildLab_DTargetType).AddAttribute(aType);
|
||||
Handle(TDataStd_Integer) aType = TDataStd_Integer::Set(Label().FindChild(ChildLab_DTargetType),
|
||||
theObject->GetDatumTargetType());
|
||||
|
||||
if(theObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area)
|
||||
{
|
||||
@ -273,20 +254,15 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
|
||||
|
||||
if(theObject->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
|
||||
{
|
||||
Handle(TDataStd_Real) aLen = new TDataStd_Real();
|
||||
aLen->Set(theObject->GetDatumTargetLength());
|
||||
Label().FindChild(ChildLab_DTargetLength).AddAttribute(aLen);
|
||||
Handle(TDataStd_Real) aLen = TDataStd_Real::Set(Label().FindChild(ChildLab_DTargetLength),
|
||||
theObject->GetDatumTargetLength());
|
||||
if(theObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
|
||||
{
|
||||
Handle(TDataStd_Real) aWidth = new TDataStd_Real();
|
||||
aWidth->Set(theObject->GetDatumTargetWidth());
|
||||
Label().FindChild(ChildLab_DTargetWidth).AddAttribute(aWidth);
|
||||
}
|
||||
Handle(TDataStd_Real) aWidth = TDataStd_Real::Set(Label().FindChild(ChildLab_DTargetWidth),
|
||||
theObject->GetDatumTargetWidth());
|
||||
}
|
||||
}
|
||||
Handle(TDataStd_Integer) aNum = new TDataStd_Integer();
|
||||
aNum->Set(theObject->GetDatumTargetNumber());
|
||||
Label().FindChild(ChildLab_DTargetNumber).AddAttribute(aNum);
|
||||
Handle(TDataStd_Integer) aNum = TDataStd_Integer::Set(Label().FindChild(ChildLab_DTargetNumber),
|
||||
theObject->GetDatumTargetNumber());
|
||||
}
|
||||
|
||||
if (theObject->HasPlane())
|
||||
|
@ -106,9 +106,7 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
|
||||
{
|
||||
anIter.Value().ForgetAllAttributes();
|
||||
}
|
||||
Handle(TDataStd_Integer) aType = new TDataStd_Integer();
|
||||
Label().FindChild(ChildLab_Type).AddAttribute(aType);
|
||||
aType->Set(theObject->GetType());
|
||||
Handle(TDataStd_Integer) aType = TDataStd_Integer::Set(Label().FindChild(ChildLab_Type), theObject->GetType());
|
||||
|
||||
if(!theObject->GetValues().IsNull())
|
||||
{
|
||||
@ -117,9 +115,7 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
|
||||
aVal->ChangeArray(theObject->GetValues());
|
||||
}
|
||||
|
||||
Handle(TDataStd_Integer) aQualifier = new TDataStd_Integer();
|
||||
Label().FindChild(ChildLab_Qualifier).AddAttribute(aQualifier);
|
||||
aQualifier->Set(theObject->GetQualifier());
|
||||
Handle(TDataStd_Integer) aQualifier = TDataStd_Integer::Set(Label().FindChild(ChildLab_Qualifier), theObject->GetQualifier());
|
||||
|
||||
Standard_Boolean aH;
|
||||
XCAFDimTolObjects_DimensionFormVariance aF;
|
||||
|
@ -104,43 +104,26 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
|
||||
anIter.Value().ForgetAllAttributes();
|
||||
}
|
||||
|
||||
Handle(TDataStd_Integer) aType = new TDataStd_Integer();
|
||||
aType->Set(theObject->GetType());
|
||||
Label().FindChild(ChildLab_Type).AddAttribute(aType);
|
||||
Handle(TDataStd_Integer) aType = TDataStd_Integer::Set(Label().FindChild(ChildLab_Type), theObject->GetType());
|
||||
|
||||
if(theObject->GetTypeOfValue() != XCAFDimTolObjects_GeomToleranceTypeValue_None)
|
||||
{
|
||||
Handle(TDataStd_Integer) aTypeOfValue = new TDataStd_Integer();
|
||||
aTypeOfValue->Set(theObject->GetTypeOfValue());
|
||||
Label().FindChild(ChildLab_TypeOfValue).AddAttribute(aTypeOfValue);
|
||||
}
|
||||
Handle(TDataStd_Integer) aTypeOfValue = TDataStd_Integer::Set(Label().FindChild(ChildLab_TypeOfValue),
|
||||
theObject->GetTypeOfValue());
|
||||
|
||||
Handle(TDataStd_Real) aValue = new TDataStd_Real();
|
||||
aValue->Set(theObject->GetValue());
|
||||
Label().FindChild(ChildLab_Value).AddAttribute(aValue);
|
||||
Handle(TDataStd_Real) aValue = TDataStd_Real::Set(Label().FindChild(ChildLab_Value), theObject->GetValue());
|
||||
|
||||
Handle(TDataStd_Integer) aMatReqModif;
|
||||
if(theObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None)
|
||||
{
|
||||
Label().FindChild(ChildLab_MatReqModif).FindAttribute(TDataStd_Integer::GetID(), aMatReqModif);
|
||||
aMatReqModif = new TDataStd_Integer();
|
||||
Label().FindChild(ChildLab_MatReqModif).AddAttribute(aMatReqModif);
|
||||
aMatReqModif->Set(theObject->GetMaterialRequirementModifier());
|
||||
}
|
||||
aMatReqModif = TDataStd_Integer::Set(Label().FindChild(ChildLab_MatReqModif),
|
||||
theObject->GetMaterialRequirementModifier());
|
||||
|
||||
if(theObject->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_None)
|
||||
{
|
||||
Handle(TDataStd_Integer) aZoneModif = new TDataStd_Integer();
|
||||
aZoneModif->Set(theObject->GetZoneModifier());
|
||||
Label().FindChild(ChildLab_ZoneModif).AddAttribute(aZoneModif);
|
||||
}
|
||||
Handle(TDataStd_Integer) aZoneModif = TDataStd_Integer::Set(Label().FindChild(ChildLab_ZoneModif),
|
||||
theObject->GetZoneModifier());
|
||||
|
||||
if(theObject->GetValueOfZoneModifier() > 0)
|
||||
{
|
||||
Handle(TDataStd_Real) aValueOfZoneModif = new TDataStd_Real();
|
||||
aValueOfZoneModif->Set(theObject->GetValueOfZoneModifier());
|
||||
Label().FindChild(ChildLab_ValueOfZoneModif).AddAttribute(aValueOfZoneModif);
|
||||
}
|
||||
Handle(TDataStd_Real) aValueOfZoneModif = TDataStd_Real::Set(Label().FindChild(ChildLab_ValueOfZoneModif),
|
||||
theObject->GetValueOfZoneModifier());
|
||||
|
||||
if(theObject->GetModifiers().Length() > 0)
|
||||
{
|
||||
@ -153,11 +136,8 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
|
||||
}
|
||||
|
||||
if(theObject->GetMaxValueModifier() > 0)
|
||||
{
|
||||
Handle(TDataStd_Real) aMaxValueModif = new TDataStd_Real();
|
||||
aMaxValueModif->Set(theObject->GetMaxValueModifier());
|
||||
Label().FindChild(ChildLab_aMaxValueModif).AddAttribute(aMaxValueModif);
|
||||
}
|
||||
Handle(TDataStd_Real) aMaxValueModif = TDataStd_Real::Set(Label().FindChild(ChildLab_aMaxValueModif),
|
||||
theObject->GetMaxValueModifier());
|
||||
|
||||
if(theObject->HasAxis())
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <XmlObjMgt_SRelocationTable.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_AsciiStringDriver,XmlMDF_ADriver)
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "asciiguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_AsciiStringDriver
|
||||
//purpose : Constructor
|
||||
@ -54,9 +54,19 @@ Standard_Boolean XmlMDataStd_AsciiStringDriver::Paste
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
if(!theTarget.IsNull()) {
|
||||
const TCollection_AsciiString aString = XmlObjMgt::GetStringValue (theSource);
|
||||
Handle(TDataStd_AsciiString)::DownCast(theTarget) -> Set (aString);
|
||||
return Standard_True;
|
||||
const TCollection_AsciiString aString = XmlObjMgt::GetStringValue (theSource);
|
||||
Handle(TDataStd_AsciiString)::DownCast(theTarget) -> Set (aString);
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_AsciiString::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
Handle(TDataStd_AsciiString)::DownCast(theTarget)->SetID(aGUID);
|
||||
return Standard_True;
|
||||
}
|
||||
WriteMessage("error retrieving AsciiString for type TDataStd_AsciiString");
|
||||
return Standard_False;
|
||||
@ -74,4 +84,11 @@ void XmlMDataStd_AsciiStringDriver::Paste (const Handle(TDF_Attribute)& theSourc
|
||||
if (aS.IsNull()) return;
|
||||
XmlObjMgt_DOMString aString = aS->Get().ToCString();
|
||||
XmlObjMgt::SetStringValue (theTarget, aString);
|
||||
if(aS->ID() != TDataStd_AsciiString::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aS->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <XmlObjMgt_Persistent.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_IntegerDriver,XmlMDF_ADriver)
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "intattguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_IntegerDriver
|
||||
//purpose : Constructor
|
||||
@ -65,6 +65,17 @@ Standard_Boolean XmlMDataStd_IntegerDriver::Paste
|
||||
Handle(TDataStd_Integer) anInt= Handle(TDataStd_Integer)::DownCast(theTarget);
|
||||
anInt->Set(aValue);
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_Integer::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
Handle(TDataStd_Integer)::DownCast(theTarget)->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@ -78,4 +89,11 @@ void XmlMDataStd_IntegerDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
{
|
||||
Handle(TDataStd_Integer) anInt= Handle(TDataStd_Integer)::DownCast(theSource);
|
||||
XmlObjMgt::SetStringValue (theTarget, anInt->Get());
|
||||
if(anInt->ID() != TDataStd_Integer::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
anInt->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <XmlObjMgt_SRelocationTable.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_NameDriver,XmlMDF_ADriver)
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "nameguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_NameDriver
|
||||
//purpose : Constructor
|
||||
@ -53,11 +53,23 @@ Standard_Boolean XmlMDataStd_NameDriver::Paste
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
TCollection_ExtendedString aString;
|
||||
if (XmlObjMgt::GetExtendedString (theSource, aString))
|
||||
{
|
||||
Handle(TDataStd_Name)::DownCast(theTarget) -> Set (aString);
|
||||
return Standard_True;
|
||||
if(!theTarget.IsNull()) {
|
||||
TCollection_ExtendedString aString;
|
||||
if (XmlObjMgt::GetExtendedString (theSource, aString))
|
||||
{
|
||||
Handle(TDataStd_Name)::DownCast(theTarget) -> Set (aString);
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_Name::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
Handle(TDataStd_Name)::DownCast(theTarget)->SetID(aGUID);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
WriteMessage("error retrieving ExtendedString for type TDataStd_Name");
|
||||
return Standard_False;
|
||||
@ -65,12 +77,20 @@ Standard_Boolean XmlMDataStd_NameDriver::Paste
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste()
|
||||
//purpose :
|
||||
//purpose : store
|
||||
//=======================================================================
|
||||
void XmlMDataStd_NameDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_Name) aName = Handle(TDataStd_Name)::DownCast(theSource);
|
||||
if (aName.IsNull()) return;
|
||||
XmlObjMgt::SetExtendedString (theTarget, aName -> Get());
|
||||
if(aName->ID() != TDataStd_Name::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
aName->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_RealDriver,XmlMDF_ADriver)
|
||||
|
||||
IMPLEMENT_DOMSTRING (AttributeIDString, "realattguid")
|
||||
//=======================================================================
|
||||
//function : XmlMDataStd_RealDriver
|
||||
//purpose : Constructor
|
||||
@ -64,8 +64,19 @@ Standard_Boolean XmlMDataStd_RealDriver::Paste
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(TDataStd_Real) anInt = Handle(TDataStd_Real)::DownCast(theTarget);
|
||||
anInt->Set(aValue);
|
||||
Handle(TDataStd_Real) anAtt = Handle(TDataStd_Real)::DownCast(theTarget);
|
||||
anAtt->Set(aValue);
|
||||
|
||||
// attribute id
|
||||
Standard_GUID aGUID;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
XmlObjMgt_DOMString aGUIDStr = anElement.getAttribute(::AttributeIDString());
|
||||
if (aGUIDStr.Type() == XmlObjMgt_DOMString::LDOM_NULL)
|
||||
aGUID = TDataStd_Real::GetID(); //default case
|
||||
else
|
||||
aGUID = Standard_GUID(Standard_CString(aGUIDStr.GetString())); // user defined case
|
||||
|
||||
Handle(TDataStd_Real)::DownCast(theTarget)->SetID(aGUID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
@ -78,10 +89,17 @@ void XmlMDataStd_RealDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataStd_Real) anInt = Handle(TDataStd_Real)::DownCast(theSource);
|
||||
Handle(TDataStd_Real) anAtt = Handle(TDataStd_Real)::DownCast(theSource);
|
||||
char aValueChar[32];
|
||||
Sprintf(aValueChar, "%.17g", anInt->Get());
|
||||
Sprintf(aValueChar, "%.17g", anAtt->Get());
|
||||
TCollection_AsciiString aValueStr(aValueChar);
|
||||
// No occurrence of '&', '<' and other irregular XML characters
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
if(anAtt->ID() != TDataStd_Real::GetID()) {
|
||||
//convert GUID
|
||||
Standard_Character aGuidStr [Standard_GUID_SIZE_ALLOC];
|
||||
Standard_PCharacter pGuidStr = aGuidStr;
|
||||
anAtt->ID().ToCString (pGuidStr);
|
||||
theTarget.Element().setAttribute (::AttributeIDString(), aGuidStr);
|
||||
}
|
||||
}
|
||||
|
50
tests/caf/basic/A4
Normal file
50
tests/caf/basic/A4
Normal file
@ -0,0 +1,50 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Integer
|
||||
#
|
||||
# Testing command: SetInteger
|
||||
# Testing command: GetInteger
|
||||
#
|
||||
|
||||
puts "caf001-A4"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 100
|
||||
set aSetAttr2 200
|
||||
set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94542-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetInteger D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetInteger D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Forget the attribute
|
||||
ForgetAll D ${aLabel}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
Redo D
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetInteger D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add TDataStd_Integer attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetInteger D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add TDataStd_Integer attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_Integer attributes: OK"
|
52
tests/caf/basic/A5
Normal file
52
tests/caf/basic/A5
Normal file
@ -0,0 +1,52 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Integer
|
||||
#
|
||||
# Testing command: SetInteger
|
||||
# Testing command: GetInteger
|
||||
#
|
||||
|
||||
puts "caf001-A5"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 100
|
||||
set aSetAttr2 200
|
||||
set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94542-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetInteger D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetInteger D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Set a new value of the attributes
|
||||
set aSetAttr12 199
|
||||
SetInteger D ${aLabel} ${aSetAttr12} ${aGuid1}
|
||||
|
||||
set aSetAttr22 299
|
||||
SetInteger D ${aLabel} ${aSetAttr12} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetInteger D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add TDataStd_Integer attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetInteger D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add TDataStd_Integer attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_Integer attributes: OK"
|
58
tests/caf/basic/A6
Normal file
58
tests/caf/basic/A6
Normal file
@ -0,0 +1,58 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Integer
|
||||
#
|
||||
# Testing command: SetInteger
|
||||
# Testing command: GetInteger
|
||||
#
|
||||
|
||||
puts "caf001-A6"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 100
|
||||
set aSetAttr2 200
|
||||
set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94542-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetInteger D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetInteger D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Save the document
|
||||
set aFile ${imagedir}/caf001-A6.cbf
|
||||
file delete ${aFile}
|
||||
SaveAs D ${aFile}
|
||||
if { ![file exists ${aFile}] } {
|
||||
puts "There is not ${aFile} file; SaveAs command: Error"
|
||||
return
|
||||
}
|
||||
#catch {exec chmod 777 ${aFile}}
|
||||
|
||||
# Restore the document
|
||||
Close D
|
||||
Open ${aFile} DD
|
||||
|
||||
# Get a value of the attribute #1
|
||||
set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel} ${aGuid1}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr1}!=${aGetAttr3} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
|
||||
puts "Get a value of the first TDataStd_Integer attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
# Get a value of the attribute #2
|
||||
set IsDone [catch {set aGetAttr4 [GetInteger DD ${aLabel} ${aGuid2}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr2}!=${aGetAttr4} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
|
||||
puts "Get a value of the second TDataStd_Integer attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK"
|
50
tests/caf/basic/B4
Normal file
50
tests/caf/basic/B4
Normal file
@ -0,0 +1,50 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Real
|
||||
#
|
||||
# Testing command: SetReal
|
||||
# Testing command: GetReal
|
||||
#
|
||||
|
||||
puts "caf001-B4"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 100.11
|
||||
set aSetAttr2 200.11
|
||||
set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetReal D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetReal D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Forget the attribute
|
||||
ForgetAll D ${aLabel}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
Redo D
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetReal D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add TDataStd_Real attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetReal D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add TDataStd_Real attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_Real attributes: OK"
|
52
tests/caf/basic/B5
Executable file
52
tests/caf/basic/B5
Executable file
@ -0,0 +1,52 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Real
|
||||
#
|
||||
# Testing command: SetReal
|
||||
# Testing command: GetReal
|
||||
#
|
||||
|
||||
puts "caf001-B5"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 100.11
|
||||
set aSetAttr2 200.11
|
||||
set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetReal D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetReal D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Set a new value of the attributes
|
||||
set aSetAttr12 199.11
|
||||
SetReal D ${aLabel} ${aSetAttr12} ${aGuid1}
|
||||
|
||||
set aSetAttr22 299.11
|
||||
SetReal D ${aLabel} ${aSetAttr12} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetReal D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add user defined TDataStd_Real attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetReal D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add user defined TDataStd_Real attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_Real attributes: OK"
|
58
tests/caf/basic/B6
Normal file
58
tests/caf/basic/B6
Normal file
@ -0,0 +1,58 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Real
|
||||
#
|
||||
# Testing command: SetReal
|
||||
# Testing command: GetReal
|
||||
#
|
||||
|
||||
puts "caf001-B6"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 100.11
|
||||
set aSetAttr2 200.11
|
||||
set aGuid1 "12e94551-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetReal D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetReal D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Save the document
|
||||
set aFile ${imagedir}/caf001-B6.cbf
|
||||
file delete ${aFile}
|
||||
SaveAs D ${aFile}
|
||||
if { ![file exists ${aFile}] } {
|
||||
puts "There is not ${aFile} file; SaveAs command: Error"
|
||||
return
|
||||
}
|
||||
#catch {exec chmod 777 ${aFile}}
|
||||
|
||||
# Restore the document
|
||||
Close D
|
||||
Open ${aFile} DD
|
||||
|
||||
# Get a value of the attribute #1
|
||||
set IsDone [catch {set aGetAttr3 [GetReal DD ${aLabel} ${aGuid1}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr1}!=${aGetAttr3} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
|
||||
puts "Get a value of the first TDataStd_Real attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
# Get a value of the attribute #2
|
||||
set IsDone [catch {set aGetAttr4 [GetReal DD ${aLabel} ${aGuid2}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr2}!=${aGetAttr4} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
|
||||
puts "Get a value of the second TDataStd_Real attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK"
|
50
tests/caf/basic/E4
Normal file
50
tests/caf/basic/E4
Normal file
@ -0,0 +1,50 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Name
|
||||
#
|
||||
# Testing command: SetName
|
||||
# Testing command: GetName
|
||||
#
|
||||
|
||||
puts "caf001-E4"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 "New Attribute1"
|
||||
set aSetAttr2 "New Attribute2"
|
||||
set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetName D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetName D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Forget the attribute
|
||||
ForgetAll D ${aLabel}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
Redo D
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetName D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add user defined TDataStd_Name attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetName D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add user defined TDataStd_Name attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_Name attributes: OK"
|
52
tests/caf/basic/E5
Normal file
52
tests/caf/basic/E5
Normal file
@ -0,0 +1,52 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Name
|
||||
#
|
||||
# Testing command: SetName
|
||||
# Testing command: GetName
|
||||
#
|
||||
|
||||
puts "caf001-E5"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 "New Attribute_1"
|
||||
set aSetAttr2 "New Attribute_2"
|
||||
set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetName D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetName D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Set a new value of the attributes
|
||||
set aSetAttr12 "Modified Attribute_1"
|
||||
SetName D ${aLabel} ${aSetAttr12} ${aGuid1}
|
||||
|
||||
set aSetAttr22 "Modified Attribute_2"
|
||||
SetName D ${aLabel} ${aSetAttr12} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetName D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add user defined TDataStd_Name attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetName D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add user defined TDataStd_Name attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_Name attributes: OK"
|
58
tests/caf/basic/E6
Normal file
58
tests/caf/basic/E6
Normal file
@ -0,0 +1,58 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_Name
|
||||
#
|
||||
# Testing command: SetName
|
||||
# Testing command: GetName
|
||||
#
|
||||
|
||||
puts "caf001-E6"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 "New Attribute_1"
|
||||
set aSetAttr2 "New Attribute_2"
|
||||
set aGuid1 "12e94561-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetName D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetName D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Save the document
|
||||
set aFile ${imagedir}/caf001-E6.cbf
|
||||
file delete ${aFile}
|
||||
SaveAs D ${aFile}
|
||||
if { ![file exists ${aFile}] } {
|
||||
puts "There is not ${aFile} file; SaveAs command: Error"
|
||||
return
|
||||
}
|
||||
#catch {exec chmod 777 ${aFile}}
|
||||
|
||||
# Restore the document
|
||||
Close D
|
||||
Open ${aFile} DD
|
||||
|
||||
# Get a value of the attribute #1
|
||||
set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel} ${aGuid1}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr1}!=${aGetAttr3} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
|
||||
puts "Get a value of the first TDataStd_Name attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
# Get a value of the attribute #2
|
||||
set IsDone [catch {set aGetAttr4 [GetName DD ${aLabel} ${aGuid2}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr2}!=${aGetAttr4} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
|
||||
puts "Get a value of the second TDataStd_Name attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Get a value of user defined TDataStd_Name attributes from restoring document: OK"
|
50
tests/caf/basic/N4
Normal file
50
tests/caf/basic/N4
Normal file
@ -0,0 +1,50 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_AsciiString
|
||||
#
|
||||
# Testing command: SetAsciiString
|
||||
# Testing command: GetAsciiString
|
||||
#
|
||||
|
||||
puts "caf001-N4"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 "New Attribute1"
|
||||
set aSetAttr2 "New Attribute2"
|
||||
set aGuid1 "12e94571-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetAsciiString D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Forget the attribute
|
||||
ForgetAll D ${aLabel}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
Redo D
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetAsciiString D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add user defined TDataStd_AsciiString attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetAsciiString D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add user defined TDataStd_AsciiString attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_AsciiString attributes: OK"
|
52
tests/caf/basic/N5
Normal file
52
tests/caf/basic/N5
Normal file
@ -0,0 +1,52 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_AsciiString
|
||||
#
|
||||
# Testing command: SetAsciiString
|
||||
# Testing command: GetAsciiString
|
||||
#
|
||||
|
||||
puts "caf001-N5"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 "New Attribute_1"
|
||||
set aSetAttr2 "New Attribute_2"
|
||||
set aGuid1 "12e94571-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetAsciiString D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Set a new value of the attributes
|
||||
set aSetAttr12 "Modified Attribute_1"
|
||||
SetAsciiString D ${aLabel} ${aSetAttr12} ${aGuid1}
|
||||
|
||||
set aSetAttr22 "Modified Attribute_2"
|
||||
SetAsciiString D ${aLabel} ${aSetAttr12} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Undo-Redo-Undo
|
||||
Undo D
|
||||
|
||||
# Get a value of the attribute
|
||||
set aGetAttr1 [GetAsciiString D ${aLabel} ${aGuid1}]
|
||||
if { ${aSetAttr1}!=${aGetAttr1} } {
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr1=${aGetAttr1}"
|
||||
puts "Add user defined TDataStd_AsciiString attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
set aGetAttr2 [GetAsciiString D ${aLabel} ${aGuid2}]
|
||||
if { ${aSetAttr2}!=${aGetAttr2} } {
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr2=${aGetAttr2}"
|
||||
puts "Add user defined TDataStd_AsciiString attribute: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Add user defined TDataStd_AsciiString attributes: OK"
|
58
tests/caf/basic/N6
Normal file
58
tests/caf/basic/N6
Normal file
@ -0,0 +1,58 @@
|
||||
#INTERFACE CAF
|
||||
# Basic attributes
|
||||
#
|
||||
# Testing attribute: User defined (additional GUID) TDataStd_AsciiString
|
||||
#
|
||||
# Testing command: SetAsciiString
|
||||
# Testing command: GetAsciiString
|
||||
#
|
||||
|
||||
puts "caf001-N6"
|
||||
|
||||
# Add an attribute to a data framework
|
||||
set aSetAttr1 "New Attribute_1"
|
||||
set aSetAttr2 "New Attribute_2"
|
||||
set aGuid1 "12e94571-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b"
|
||||
set aLabel 0:2
|
||||
SetAsciiString D ${aLabel} ${aSetAttr1} ${aGuid1}
|
||||
SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2}
|
||||
|
||||
# Close/Open the transaction
|
||||
NewCommand D
|
||||
|
||||
# Save the document
|
||||
set aFile ${imagedir}/caf001-N6.cbf
|
||||
file delete ${aFile}
|
||||
SaveAs D ${aFile}
|
||||
if { ![file exists ${aFile}] } {
|
||||
puts "There is not ${aFile} file; SaveAs command: Error"
|
||||
return
|
||||
}
|
||||
#catch {exec chmod 777 ${aFile}}
|
||||
|
||||
# Restore the document
|
||||
Close D
|
||||
Open ${aFile} DD
|
||||
|
||||
# Get a value of the attribute #1
|
||||
set IsDone [catch {set aGetAttr3 [GetAsciiString DD ${aLabel} ${aGuid1}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr1}!=${aGetAttr3} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
|
||||
puts "Get a value of the first TDataStd_AsciiString attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
# Get a value of the attribute #2
|
||||
set IsDone [catch {set aGetAttr4 [GetAsciiString DD ${aLabel} ${aGuid2}]} aResult]
|
||||
if { ${IsDone} != 0 ||
|
||||
${aSetAttr2}!=${aGetAttr4} } {
|
||||
puts ${aResult}
|
||||
puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
|
||||
puts "Get a value of the second TDataStd_AsciiString attribute from restoring document: Error"
|
||||
return
|
||||
}
|
||||
|
||||
puts "Get a value of user defined TDataStd_AsciiString attributes from restoring document: OK"
|
Loading…
x
Reference in New Issue
Block a user