1 // Created on: 1999-08-19
2 // Created by: Sergey RUIN
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <DDataStd.hxx>
19 #include <Draw_Interpretor.hxx>
20 #include <Draw_Appli.hxx>
21 #include <DrawTrSurf.hxx>
25 #include <TDF_Data.hxx>
26 #include <TDF_Label.hxx>
27 #include <TDF_Tool.hxx>
28 #include <TDF_AttributeSequence.hxx>
29 #include <TDF_AttributeList.hxx>
30 #include <TDF_ListIteratorOfAttributeList.hxx>
34 #include <TDataStd.hxx>
35 #include <TDataStd_Name.hxx>
37 #include <TCollection_AsciiString.hxx>
38 #include <TDataStd_ListOfExtendedString.hxx>
43 //=======================================================================
44 //function : DDataStd_SetName
45 //purpose : SetName (DF, entry, name [,guid])
46 //=======================================================================
48 static Standard_Integer DDataStd_SetName (Draw_Interpretor& di,
53 if (nb == 4 || nb == 5) {
55 if (!DDF::GetDF(arg[1],DF)) return 1;
57 DDF::AddLabel(DF, arg[2], L);
58 if(L.IsNull()) di << "Label is not found" << "\n";
60 TDataStd_Name::Set(L,TCollection_ExtendedString(arg[3],Standard_True));
62 if (!Standard_GUID::CheckGUIDFormat(arg[4])) {
63 di<<"DDataStd_SetReal: The format of GUID is invalid\n";
66 Standard_GUID guid(arg[4]);
67 TDataStd_Name::Set(L, guid, TCollection_ExtendedString(arg[3],Standard_True));
71 di << "DDataStd_SetName : Error\n";
75 //#define DEB_DDataStd
76 //=======================================================================
77 //function : DDataStd_GetName
78 //purpose : GetName (DF, entry [,guid])
79 //=======================================================================
81 static Standard_Integer DDataStd_GetName (Draw_Interpretor& di,
85 if (nb == 3 || nb == 4) {
87 if (!DDF::GetDF(arg[1],DF)) return 1;
89 DDF::FindLabel(DF, arg[2], L);
90 if(L.IsNull()) di << "Label is not found" << "\n";
91 Standard_GUID aGuid (TDataStd_Name::GetID());
93 if (!Standard_GUID::CheckGUIDFormat(arg[3])) {
94 di<<"DDataStd_GetAsciiString: The format of GUID is invalid\n";
97 aGuid = Standard_GUID(arg[3]);
99 Handle(TDataStd_Name) N;
100 if( !L.FindAttribute(aGuid, N) ) {
101 cout << "Name attribute is not found or not set" << endl;
106 cout << "String = " << TCollection_AsciiString(N->Get(), '?').ToCString() << endl;
108 TCollection_AsciiString s(N->Get(),'?');
112 di << "DDataStd_SetName : Error\n";
119 //=======================================================================
120 //function : SetCommands
122 //=======================================================================
124 void DDataStd::NameCommands (Draw_Interpretor& theCommands)
127 static Standard_Boolean done = Standard_False;
129 done = Standard_True;
131 const char* g = "DDataStd : Name attribute commands";
133 theCommands.Add ("SetName",
134 "SetName (DF, entry, name [,guid])",
135 __FILE__, DDataStd_SetName, g);
137 theCommands.Add ("GetName",
138 "GetNmae (DF, entry [,guid])",
139 __FILE__, DDataStd_GetName, g);