b311480e |
1 | // Created on: 1999-08-19 |
2 | // Created by: Sergey RUIN |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <DDataStd.hxx> |
18 | #include <DDF.hxx> |
19 | #include <Draw_Interpretor.hxx> |
20 | #include <Draw_Appli.hxx> |
21 | #include <DrawTrSurf.hxx> |
22 | |
23 | #include <DDF.hxx> |
24 | |
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> |
31 | |
32 | // ATTRIBUTES |
33 | |
34 | #include <TDataStd.hxx> |
35 | #include <TDataStd_Name.hxx> |
36 | |
37 | #include <TCollection_AsciiString.hxx> |
38 | #include <TDataStd_ListOfExtendedString.hxx> |
39 | |
40 | |
41 | |
42 | |
43 | //======================================================================= |
44 | //function : DDataStd_SetName |
45 | //purpose : SetName (DF, entry, name) |
46 | //======================================================================= |
47 | |
48 | static Standard_Integer DDataStd_SetName (Draw_Interpretor& di, |
49 | Standard_Integer nb, |
50 | const char** arg) |
51 | { |
52 | // if (nb == 3) { |
53 | // Handle(TDF_Data) DF; |
54 | // if (!DDF::GetDF(arg[1],DF)) return 1; |
55 | // TDF_Label L; |
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); |
59 | // return 0; |
60 | // } |
61 | // else if (nb == 4) { |
62 | if (nb == 4) { |
63 | Handle(TDF_Data) DF; |
64 | if (!DDF::GetDF(arg[1],DF)) return 1; |
65 | TDF_Label L; |
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); |
70 | //N->Set(arg[3]); |
71 | N = TDataStd_Name::Set(L,arg[3]); |
72 | return 0; |
73 | } |
74 | di << "DDataStd_SetName : Error" << "\n"; |
75 | return 1; |
76 | } |
77 | |
78 | |
79 | //======================================================================= |
80 | //function : DDataStd_GetName |
81 | //purpose : GetName (DF, entry) |
82 | //======================================================================= |
83 | |
84 | static Standard_Integer DDataStd_GetName (Draw_Interpretor& di, |
85 | Standard_Integer nb, |
86 | const char** arg) |
87 | { |
88 | if (nb == 3) { |
89 | Handle(TDF_Data) DF; |
90 | if (!DDF::GetDF(arg[1],DF)) return 1; |
91 | TDF_Label L; |
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(),'?'); |
97 | di << s.ToCString(); |
98 | return 0; |
99 | } |
100 | di << "DDataStd_SetName : Error" << "\n"; |
101 | return 1; |
102 | } |
103 | |
104 | |
105 | |
106 | //======================================================================= |
107 | //function : LabelName (DF, [entry], path) |
108 | //======================================================================= |
109 | // static Standard_Integer DDataStd_LabelName (Draw_Interpretor& di, |
110 | // Standard_Integer nb, |
111 | // const char** arg) |
112 | // { |
113 | // Handle(TDF_Data) DF; |
114 | // TDF_Label label; |
115 | // Handle(TDataStd_Name) result; |
116 | // TDataStd_ListOfExtendedString myList; |
117 | // Standard_Integer i = 2; |
118 | // Standard_Boolean Found = Standard_False; |
119 | |
120 | // if (!DDF::GetDF(arg[1],DF)) return 1; |
121 | // if( nb == 4 ) { |
122 | // if( !DDF::FindLabel(DF, arg[2], label) ) { |
123 | // cout << "No label for entry" << endl; |
124 | // return 1; |
125 | // } |
126 | // i = 3; |
127 | // } |
128 | |
129 | // if( !TDataStd_Name::MakePath(arg[i], myList) ) return 1; |
130 | |
131 | // if( nb == 4 ) { |
132 | // Handle(TDataStd_Name) current; |
133 | // if (TDataStd_Name::Find(label,current)) { |
134 | // if (current->Find(myList ,result)) Found = Standard_True; |
135 | // } |
136 | // } |
137 | // else { |
138 | // if(TDataStd_Name::Find(DF, myList ,result)) Found = Standard_True; |
139 | // } |
140 | |
141 | // if(Found) { |
142 | // DDF::ReturnLabel(di, result->Label()); |
143 | // return 0; |
144 | // } |
145 | |
146 | // cout << "Label wasn't found" << endl; |
147 | // return 1; |
148 | // } |
149 | |
150 | |
151 | // //======================================================================= |
152 | // //function : FullPath (DF, entry) |
153 | // //======================================================================= |
154 | // static Standard_Integer DDataStd_FullPath (Draw_Interpretor& di, |
155 | // Standard_Integer nb, |
156 | // const char** arg) |
157 | // { |
158 | // Handle(TDF_Data) DF; |
159 | // if (!DDF::GetDF(arg[1],DF)) return 1; |
160 | // TDF_Label label; |
161 | // if( !DDF::FindLabel(DF, arg[2], label) ) { |
162 | // cout << "No label for entry" << endl; |
163 | // return 1; |
164 | // } |
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(); |
173 | // str+=":"; |
174 | // } |
175 | // str.Remove(str.Length()); //remove last ":" |
176 | // di << str.ToCString(); |
177 | // } |
0797d9d3 |
178 | // #ifndef OCCT_DEBUG |
7fd59977 |
179 | // return 0 ; |
180 | // #endif |
181 | // } |
182 | //======================================================================= |
183 | //function : SetCommands |
184 | //purpose : |
185 | //======================================================================= |
186 | |
187 | void DDataStd::NameCommands (Draw_Interpretor& theCommands) |
188 | { |
189 | |
190 | static Standard_Boolean done = Standard_False; |
191 | if (done) return; |
192 | done = Standard_True; |
193 | |
194 | const char* g = "DDataStd : Name attribute commands"; |
195 | |
196 | theCommands.Add ("SetName", |
197 | "SetName (DF, entry, name)", |
198 | __FILE__, DDataStd_SetName, g); |
199 | |
200 | theCommands.Add ("GetName", |
201 | "GetNmae (DF, entry)", |
202 | __FILE__, DDataStd_GetName, g); |
203 | |
204 | // theCommands.Add ("LabelName", |
205 | // "GetLabel (DF, [entry], path(name1:name2:...nameN)", |
206 | // __FILE__, DDataStd_LabelName, g); |
207 | |
208 | // theCommands.Add ("FullPath", |
209 | // "FullPath (DF, entry)", |
210 | // __FILE__, DDataStd_FullPath, g); |
211 | |
212 | } |
213 | |