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)
46 //=======================================================================
48 static Standard_Integer DDataStd_SetName (Draw_Interpretor& di,
53 // Handle(TDF_Data) DF;
54 // if (!DDF::GetDF(arg[1],DF)) return 1;
56 // DDF::FindLabel(DF, arg[2], L);
57 // if(L.IsNull()) cout << "Label is not found" << endl;
58 // Handle(TDataStd_Name) N = TDataStd_Name::Set(L);
61 // else if (nb == 4) {
64 if (!DDF::GetDF(arg[1],DF)) return 1;
66 DDF::FindLabel(DF, arg[2], L);
67 if(L.IsNull()) di << "Label is not found" << "\n";
68 Handle(TDataStd_Name) N;
69 //if( !L.FindAttribute(TDataStd_Name::GetID(), N) ) N = TDataStd_Name::Set(L);
71 N = TDataStd_Name::Set(L,arg[3]);
74 di << "DDataStd_SetName : Error\n";
79 //=======================================================================
80 //function : DDataStd_GetName
81 //purpose : GetName (DF, entry)
82 //=======================================================================
84 static Standard_Integer DDataStd_GetName (Draw_Interpretor& di,
90 if (!DDF::GetDF(arg[1],DF)) return 1;
92 DDF::FindLabel(DF, arg[2], L);
93 if(L.IsNull()) di << "Label is not found" << "\n";
94 Handle(TDataStd_Name) N;
95 if( !L.FindAttribute(TDataStd_Name::GetID(), N) ) return 1;
96 TCollection_AsciiString s(N->Get(),'?');
100 di << "DDataStd_SetName : Error\n";
106 //=======================================================================
107 //function : LabelName (DF, [entry], path)
108 //=======================================================================
109 // static Standard_Integer DDataStd_LabelName (Draw_Interpretor& di,
110 // Standard_Integer nb,
113 // Handle(TDF_Data) DF;
115 // Handle(TDataStd_Name) result;
116 // TDataStd_ListOfExtendedString myList;
117 // Standard_Integer i = 2;
118 // Standard_Boolean Found = Standard_False;
120 // if (!DDF::GetDF(arg[1],DF)) return 1;
122 // if( !DDF::FindLabel(DF, arg[2], label) ) {
123 // cout << "No label for entry" << endl;
129 // if( !TDataStd_Name::MakePath(arg[i], myList) ) return 1;
132 // Handle(TDataStd_Name) current;
133 // if (TDataStd_Name::Find(label,current)) {
134 // if (current->Find(myList ,result)) Found = Standard_True;
138 // if(TDataStd_Name::Find(DF, myList ,result)) Found = Standard_True;
142 // DDF::ReturnLabel(di, result->Label());
146 // cout << "Label wasn't found" << endl;
151 // //=======================================================================
152 // //function : FullPath (DF, entry)
153 // //=======================================================================
154 // static Standard_Integer DDataStd_FullPath (Draw_Interpretor& di,
155 // Standard_Integer nb,
158 // Handle(TDF_Data) DF;
159 // if (!DDF::GetDF(arg[1],DF)) return 1;
161 // if( !DDF::FindLabel(DF, arg[2], label) ) {
162 // cout << "No label for entry" << endl;
165 // Handle(TDataStd_Name) current;
166 // if (TDataStd_Name::Find(label,current)) {
167 // TDF_AttributeList myList;
168 // if (!current->FullPath(myList)) return 1;
169 // TDF_ListIteratorOfAttributeList itr(myList);
170 // TCollection_AsciiString str;
171 // for(;itr.More(); itr.Next() ) {
172 // str+=Handle(TDataStd_Name)::DownCast(itr.Value())->Get();
175 // str.Remove(str.Length()); //remove last ":"
176 // di << str.ToCString();
178 // #ifndef OCCT_DEBUG
182 //=======================================================================
183 //function : SetCommands
185 //=======================================================================
187 void DDataStd::NameCommands (Draw_Interpretor& theCommands)
190 static Standard_Boolean done = Standard_False;
192 done = Standard_True;
194 const char* g = "DDataStd : Name attribute commands";
196 theCommands.Add ("SetName",
197 "SetName (DF, entry, name)",
198 __FILE__, DDataStd_SetName, g);
200 theCommands.Add ("GetName",
201 "GetNmae (DF, entry)",
202 __FILE__, DDataStd_GetName, g);
204 // theCommands.Add ("LabelName",
205 // "GetLabel (DF, [entry], path(name1:name2:...nameN)",
206 // __FILE__, DDataStd_LabelName, g);
208 // theCommands.Add ("FullPath",
209 // "FullPath (DF, entry)",
210 // __FILE__, DDataStd_FullPath, g);