]> OCCT Git - occt-copy.git/commitdiff
0027932: Improvement of standard attributes usability.
authorszy <szy@opencascade.com>
Thu, 27 Oct 2016 14:55:43 +0000 (17:55 +0300)
committerabv <abv@opencascade.com>
Tue, 8 Nov 2016 16:30:59 +0000 (19:30 +0300)
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.

39 files changed:
src/BinLDrivers/BinLDrivers.cxx
src/BinMDataStd/BinMDataStd_AsciiStringDriver.cxx
src/BinMDataStd/BinMDataStd_IntegerDriver.cxx
src/BinMDataStd/BinMDataStd_NameDriver.cxx
src/BinMDataStd/BinMDataStd_RealDriver.cxx
src/DDataStd/DDataStd_BasicCommands.cxx
src/DDataStd/DDataStd_NameCommands.cxx
src/Standard/Standard_GUID.cxx
src/Standard/Standard_GUID.hxx
src/StdLPersistent/StdLPersistent_Real.hxx
src/StdLPersistent/StdLPersistent_Value.cxx
src/StdLPersistent/StdLPersistent_Value.hxx
src/TDataStd/TDataStd_AsciiString.cxx
src/TDataStd/TDataStd_AsciiString.hxx
src/TDataStd/TDataStd_Integer.cxx
src/TDataStd/TDataStd_Integer.hxx
src/TDataStd/TDataStd_Name.cxx
src/TDataStd/TDataStd_Name.hxx
src/TDataStd/TDataStd_Real.cxx
src/TDataStd/TDataStd_Real.hxx
src/XCAFDoc/XCAFDoc_Datum.cxx
src/XCAFDoc/XCAFDoc_Dimension.cxx
src/XCAFDoc/XCAFDoc_GeomTolerance.cxx
src/XmlMDataStd/XmlMDataStd_AsciiStringDriver.cxx
src/XmlMDataStd/XmlMDataStd_IntegerDriver.cxx
src/XmlMDataStd/XmlMDataStd_NameDriver.cxx
src/XmlMDataStd/XmlMDataStd_RealDriver.cxx
tests/caf/basic/A4 [new file with mode: 0644]
tests/caf/basic/A5 [new file with mode: 0644]
tests/caf/basic/A6 [new file with mode: 0644]
tests/caf/basic/B4 [new file with mode: 0644]
tests/caf/basic/B5 [new file with mode: 0755]
tests/caf/basic/B6 [new file with mode: 0644]
tests/caf/basic/E4 [new file with mode: 0644]
tests/caf/basic/E5 [new file with mode: 0644]
tests/caf/basic/E6 [new file with mode: 0644]
tests/caf/basic/N4 [new file with mode: 0644]
tests/caf/basic/N5 [new file with mode: 0644]
tests/caf/basic/N6 [new file with mode: 0644]

index 2f0fa887fb8ec15e788af07af1b6302c07eb7c8c..d3d2fd0ecfccc4c2409a1d8e4bb92ac67029f083 100644 (file)
@@ -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
index 622a1bdfe0a746b6675cfccbecca565e47c13936..d95c89bfbd440c77f1d4a99635592f8239495edf 100644 (file)
@@ -23,6 +23,7 @@
 #include <Standard_Type.hxx>
 #include <TDataStd_AsciiString.hxx>
 #include <TDF_Attribute.hxx>
+#include <BinMDataStd.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_AsciiStringDriver,BinMDF_ADriver)
 
@@ -61,6 +62,19 @@ Standard_Boolean BinMDataStd_AsciiStringDriver::Paste
   Standard_Boolean ok = Source >> aString;
   if (ok)
     aStrAtt->Set( aString );
+  if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
+       const Standard_Integer& aPos = Source.Position();
+       Standard_GUID aGuid;
+       ok = Source >> aGuid;   
+       if (!ok) {
+         Source.SetPosition(aPos);       
+         aStrAtt->SetID(TDataStd_AsciiString::GetID());
+         ok = Standard_True;
+       } else {          
+         aStrAtt->SetID(aGuid);
+       }
+  } else
+       aStrAtt->SetID(TDataStd_AsciiString::GetID());
   return ok;
 }
 
@@ -76,4 +90,8 @@ void BinMDataStd_AsciiStringDriver::Paste
 {
   Handle(TDataStd_AsciiString) anAtt = Handle(TDataStd_AsciiString)::DownCast(Source);
   Target << anAtt->Get();
+ // process user defined guid
+  if(anAtt->ID() != TDataStd_AsciiString::GetID()) 
+       Target << anAtt->ID();
+
 }
index ce66050053db8a64d4794c360690360cc7ba0396..b963ca6bbdb2537da88cc6ece256c9910bc8d7db 100644 (file)
@@ -20,6 +20,7 @@
 #include <Standard_Type.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TDF_Attribute.hxx>
+#include <BinMDataStd.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_IntegerDriver,BinMDF_ADriver)
 
@@ -58,6 +59,19 @@ Standard_Boolean BinMDataStd_IntegerDriver::Paste
   Standard_Boolean ok = theSource >> aValue;
   if (ok)
     anAtt->Set(aValue);
+  if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
+       const Standard_Integer& aPos = theSource.Position();
+       Standard_GUID aGuid;
+       ok = theSource >> aGuid;        
+       if (!ok) {
+         theSource.SetPosition(aPos);    
+         anAtt->SetID(TDataStd_Integer::GetID());
+         ok = Standard_True;
+       } else {          
+         anAtt->SetID(aGuid);
+       }
+  } else 
+       anAtt->SetID(TDataStd_Integer::GetID());
   return ok;
 }
 
@@ -72,4 +86,7 @@ void BinMDataStd_IntegerDriver::Paste (const Handle(TDF_Attribute)& theSource,
 {
   Handle(TDataStd_Integer) anAtt = Handle(TDataStd_Integer)::DownCast(theSource);
   theTarget << anAtt->Get();
+  // process user defined guid
+  if(anAtt->ID() != TDataStd_Integer::GetID()) 
+       theTarget << anAtt->ID();
 }
index be94e0d330373ed8a822c95948361b136ea70235..96817dcfaa7e83fe5307a568510eda1288a4b4b5 100644 (file)
@@ -20,6 +20,7 @@
 #include <Standard_Type.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDF_Attribute.hxx>
+#include <BinMDataStd.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_NameDriver,BinMDF_ADriver)
 
@@ -58,6 +59,19 @@ Standard_Boolean BinMDataStd_NameDriver::Paste
   Standard_Boolean ok = Source >> aStr;
   if (ok)
     aName->Set( aStr );
+  if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
+       const Standard_Integer& aPos = Source.Position();
+       Standard_GUID aGuid;
+       ok = Source >> aGuid;   
+       if (!ok) {
+         Source.SetPosition(aPos);       
+         aName->SetID(TDataStd_Name::GetID());
+         ok = Standard_True;
+       } else {          
+         aName->SetID(aGuid);
+       }
+  } else
+       aName->SetID(TDataStd_Name::GetID());
   return ok;
 }
 
@@ -73,4 +87,7 @@ void BinMDataStd_NameDriver::Paste
 {
   Handle(TDataStd_Name) aName = Handle(TDataStd_Name)::DownCast(Source);
   Target << aName->Get();
+  // process user defined guid
+  if(aName->ID() != TDataStd_Name::GetID()) 
+       Target << aName->ID();
 }
index ed6fe17027e9342e19fdf717cda2db9b29c3ea65..a987ccbc3c7df023769bd80e561de98feaf424f1 100644 (file)
@@ -20,6 +20,7 @@
 #include <Standard_Type.hxx>
 #include <TDataStd_Real.hxx>
 #include <TDF_Attribute.hxx>
+#include <BinMDataStd.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_RealDriver,BinMDF_ADriver)
 
@@ -58,6 +59,19 @@ Standard_Boolean BinMDataStd_RealDriver::Paste
   Standard_Boolean ok = theSource >> aValue;
   if (ok)
     anAtt->Set(aValue);
+  if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
+       const Standard_Integer& aPos = theSource.Position();
+       Standard_GUID aGuid;
+       ok = theSource >> aGuid;        
+       if (!ok) {
+         theSource.SetPosition(aPos);    
+         anAtt->SetID(TDataStd_Real::GetID());
+         ok = Standard_True;
+       } else {          
+         anAtt->SetID(aGuid);
+       }
+  } else
+       anAtt->SetID(TDataStd_Real::GetID());
   return ok;
 }
 
@@ -72,4 +86,7 @@ void BinMDataStd_RealDriver::Paste (const Handle(TDF_Attribute)& theSource,
 {
   Handle(TDataStd_Real) anAtt= Handle(TDataStd_Real)::DownCast(theSource);
   theTarget << anAtt->Get();
+  // process user defined guid
+  if(anAtt->ID() != TDataStd_Real::GetID()) 
+       theTarget << anAtt->ID();
 }
index 88226d176d8a53dc1afc70991a57654fc3f42e95..3e1cdfcc7f65f0b1800578c451c811d349f0163e 100644 (file)
 #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", 
index 16131732135f435c3ccb5532148fb339d6c11cb3..85096844c09d3b042c910be291a6e34bc9523cae 100644 (file)
 
 //=======================================================================
 //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);
 
 }
 
index 142bff55cad35ce9bda0898cd6cbd8f071c76b61..aa000651f7d81f919b3f6dd630d0abf856268357 100644 (file)
@@ -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
 
index ecd1c0c483565ed7bfc58480d93ea3721462e730..e7b1851b332ce5fdbcf329e01029a46ecacb8d8a 100644 (file)
@@ -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 
 {
index 18be36ff7cb6e8f451000761164b113b2f434ad1..227c5fbb619bc3595314df9b1052e19b0ec82373 100644 (file)
@@ -32,6 +32,7 @@ public:
   {
     theAttribute->Set          (myValue);
     theAttribute->SetDimension (static_cast<TDataStd_RealEnum> (myDimension));
+       theAttribute->SetID(TDataStd_Real::GetID());
   }
 
 private:
index 98dde817cef8793f602313c65248505747fa69db..a06abeb1991dcb9f393127782539c6e0f8f3d052 100644 (file)
@@ -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>;
index 9bffe45bbba41ebba74fb55ddd12ae10b6ed78e4..d68806c4ca382e3e57e485d6abcf62770ec47fc5 100644 (file)
@@ -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
index 44b969d5ce18fde1e45b70dea75db6cad7a0d850..a900ac0a2d4b414a73959517623142a68f7700a6 100644 (file)
@@ -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;
 }
index 52a837ebf545ffb6dd8a0e04bc0bfd6901d25c87..54c8207f6832154b821fa4e022f0e1c9cde6d4fc 100644 (file)
@@ -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;
 
 };
 
index ccf1e3ba7da7673bcd0830e7c91207bff87d223f..e91df8adc59dd4aded28c3cc8af43759130608a8 100644 (file)
@@ -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);
index f18b587d15b985e45a3e66e3e3d50ce44ee6fde9..731b60e0d458f0441a1f66c92bae4e591022719d 100644 (file)
@@ -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;
 
 };
 
index 46afe8b63f9ba67f4f6b801e8be55a55465f80f4..636b1578c8fe5c447a8bdcf40af8be2916bba440 100644 (file)
@@ -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  : 
-//=======================================================================
-// 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  : 
+//function : Set
+//purpose  : Set user defined attribute
 //=======================================================================
-// 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;
-// }
index 727f69432fdff8529c7256e16ac71180438e5c32..82c6f348f5b03c77d7903d87b7485d620047b7f4 100644 (file)
@@ -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;
 
 };
 
index 1cd67b15d64c92d9d8cfcda39cca1a2aee39c9f3..d46efc0993a3458dc3e30e6c8d3f3575669e3f14 100644 (file)
@@ -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;
 }
  
index f76752d1244531ae8853664c645f1a4b16f4c609..ff92996a514e30b71fd01f695b0c1df965070269 100644 (file)
@@ -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;
 
 };
 
index 8cc394c969ec483d466f37bfcb1a6a7ade96d700..b242d765b1ef9e33386c670c9eca96e8962318e4 100644 (file)
@@ -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())
index 3d5e412b18db6643e55f31f9b7cb29b745535430..a210dac8ceb4b9416585a92f17a3756029fef4cc 100644 (file)
@@ -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;
index 0dc6236238b0f74475b24e0a617002d94715cf1f..0ef458fef3cf5b60a9709f007c6c03c78f7a0193 100644 (file)
@@ -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())
   {
index 3c082194130e8e51afc343b3654a0673f127bfd9..70f77f50ce59e7dc88d0caaa324d21cc146cbb6b 100644 (file)
@@ -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);
+  }
 }
index 9e5b7e864e5525bcd349c61b44c3c1959975717b..505c052eccec41e48cf4e8c833dccdbf4e94d1dd 100644 (file)
@@ -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);
+  }
 }
index 4880fefbd6e768d2aecb76e6361caf70ed5b0e5e..5745223dce01ab609395c30c2c15f29c9f039527 100644 (file)
@@ -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);
+  }
 }
index 6ca17521ee2156a221fc40ca631ad78092d91f79..902d3d66cfba653aa1a0e16fbdc820ba61e96ab5 100644 (file)
@@ -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);
+  }
 }
diff --git a/tests/caf/basic/A4 b/tests/caf/basic/A4
new file mode 100644 (file)
index 0000000..2179573
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/A5 b/tests/caf/basic/A5
new file mode 100644 (file)
index 0000000..4a7738d
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/A6 b/tests/caf/basic/A6
new file mode 100644 (file)
index 0000000..2128877
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/B4 b/tests/caf/basic/B4
new file mode 100644 (file)
index 0000000..5f00365
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/B5 b/tests/caf/basic/B5
new file mode 100755 (executable)
index 0000000..934132e
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/B6 b/tests/caf/basic/B6
new file mode 100644 (file)
index 0000000..e85536d
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/E4 b/tests/caf/basic/E4
new file mode 100644 (file)
index 0000000..29cd7ad
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/E5 b/tests/caf/basic/E5
new file mode 100644 (file)
index 0000000..8be7ded
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/E6 b/tests/caf/basic/E6
new file mode 100644 (file)
index 0000000..b064c67
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/N4 b/tests/caf/basic/N4
new file mode 100644 (file)
index 0000000..5d65267
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/N5 b/tests/caf/basic/N5
new file mode 100644 (file)
index 0000000..c1f4212
--- /dev/null
@@ -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"
diff --git a/tests/caf/basic/N6 b/tests/caf/basic/N6
new file mode 100644 (file)
index 0000000..f26d506
--- /dev/null
@@ -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"