1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
// File: DDF_Browser.cxx
// ---------------
// Author: DAUTRY Philippe
// <fid@fox.paris1.matra-dtv.fr>
// Copyright: Matra Datavision 1997
// Version: 0.0
// History: Version Date Purpose
// 0.0 Oct 3 1997 Creation
#include <DDF_Browser.ixx>
#include <DDF_AttributeBrowser.hxx>
#include <TDF_Tool.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_AttributeIterator.hxx>
#include <TDF_Attribute.hxx>
#include <TDF.hxx>
#include <TDataStd_Name.hxx>
#include <TCollection_ExtendedString.hxx>
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Communication convention with tcl:
// tcl waits for a string of characters, being an information list.
// In this list, each item is separated from another by a separator: '\'.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define TDF_BrowserSeparator1 '\\'
#define TDF_BrowserSeparator2 ' '
#define TDF_BrowserSeparator3 '#'
#define TDF_BrowserSeparator4 ','
//=======================================================================
//function : DDF_Browser
//purpose :
//=======================================================================
DDF_Browser::DDF_Browser(const Handle(TDF_Data)& aDF)
: myDF(aDF)
{}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DDF_Browser::DrawOn(Draw_Display& /*dis*/) const
{
//cout<<"DDF_Browser"<<endl;
}
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Draw_Drawable3D) DDF_Browser::Copy() const
{ return new DDF_Browser(myDF); }
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void DDF_Browser::Dump(Standard_OStream& S) const
{
S<<"DDF_Browser on a DF:"<<endl;
S<<myDF;
}
//=======================================================================
//function : Whatis
//purpose :
//=======================================================================
void DDF_Browser::Whatis(Draw_Interpretor& I) const
{ I<<"Data Framework Browser"; }
//=======================================================================
//function : Data
//purpose :
//=======================================================================
void DDF_Browser::Data(const Handle(TDF_Data)& aDF)
{ myDF = aDF; }
//=======================================================================
//function : Data
//purpose :
//=======================================================================
Handle(TDF_Data) DDF_Browser::Data() const
{ return myDF; }
//=======================================================================
//function : OpenRoot
//purpose :
//=======================================================================
TCollection_AsciiString DDF_Browser::OpenRoot() const
{
TCollection_AsciiString list;
const TDF_Label& root = myDF->Root();
TDF_Tool::Entry(root,list);
Handle(TDataStd_Name) name;
list.AssignCat(TDF_BrowserSeparator2);
list.AssignCat("\"");
if (root.FindAttribute(TDataStd_Name::GetID(),name)) {
TCollection_AsciiString tmpStr(name->Get(),'?');
tmpStr.ChangeAll(' ','_');
list.AssignCat(tmpStr);
}
list.AssignCat("\"");
list.AssignCat(TDF_BrowserSeparator2);
if (!root.MayBeModified()) list.AssignCat("Not");
list.AssignCat("Modified");
list.AssignCat(TDF_BrowserSeparator2);
if (root.HasAttribute() || (root.HasChild())) {
list.AssignCat("1");
}
else {
list.AssignCat("0");
}
//cout<<"OpenRoot: "<<list<<endl;
return list;
}
//=======================================================================
//function : OpenLabel
//purpose :
// an item is composed as follows:
// "Entry "Name" Modified|NotModified 0|1"
// the end bit shows if the label has attributes or children.
// The 1st can be
// "AttributeList Modified|NotModified"
// The items are separated by "\\".
//=======================================================================
TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const
{
Standard_Boolean split = Standard_False;
TCollection_AsciiString entry, list;
if (aLab.HasAttribute() || aLab.AttributesModified()) {
list.AssignCat("AttributeList");
list.AssignCat(TDF_BrowserSeparator2);
if (!aLab.AttributesModified()) list.AssignCat("Not");
list.AssignCat("Modified");
split = Standard_True;
}
Handle(TDataStd_Name) name;
for (TDF_ChildIterator itr(aLab); itr.More(); itr.Next()) {
if (split) list.AssignCat(TDF_BrowserSeparator1);
TDF_Tool::Entry(itr.Value(),entry);
list.AssignCat(entry);
list.AssignCat(TDF_BrowserSeparator2);
list.AssignCat("\"");
if (itr.Value().FindAttribute(TDataStd_Name::GetID(),name)) {
TCollection_AsciiString tmpStr(name->Get(),'?');
tmpStr.ChangeAll(' ','_');
list.AssignCat(tmpStr);
}
list.AssignCat("\"");
list.AssignCat(TDF_BrowserSeparator2);
if (!itr.Value().MayBeModified()) list.AssignCat("Not");
list.AssignCat("Modified");
list.AssignCat(TDF_BrowserSeparator2);
// May be open.
if (itr.Value().HasAttribute() || (itr.Value().HasChild()))
list.AssignCat("1");
else
list.AssignCat("0");
split = Standard_True;
}
//cout<<"OpenLabel: "<<list<<endl;
return list;
}
//=======================================================================
//function : OpenAttributeList
//purpose :
// an item is composed as follows:
// "DynamicType#MapIndex TransactionIndex Valid|Notvalid Forgotten|NotForgotten Backuped|NotBackuped"
// The items are separated by "\\".
//=======================================================================
TCollection_AsciiString DDF_Browser::OpenAttributeList
(const TDF_Label& aLab)
{
TCollection_AsciiString list;
Standard_Boolean split1 = Standard_False;
for (TDF_AttributeIterator itr(aLab,Standard_False);itr.More();itr.Next()) {
if (split1) list.AssignCat(TDF_BrowserSeparator1);
const Handle(TDF_Attribute)& att = itr.Value();
const Standard_Integer index = myAttMap.Add(att);
TCollection_AsciiString indexStr(index);
list.AssignCat(att->DynamicType()->Name());
list.AssignCat(TDF_BrowserSeparator3);
list.AssignCat(indexStr);
list.AssignCat(TDF_BrowserSeparator2);
list.AssignCat(att->Transaction());
// Valid.
list.AssignCat(TDF_BrowserSeparator2);
if (!att->IsValid()) list.AssignCat("Not");
list.AssignCat("Valid");
// Forgotten.
list.AssignCat(TDF_BrowserSeparator2);
if (!att->IsForgotten()) list.AssignCat("Not");
list.AssignCat("Forgotten");
// Backuped.
list.AssignCat(TDF_BrowserSeparator2);
if (!att->IsBackuped()) list.AssignCat("Not");
list.AssignCat("Backuped");
// May be open.
list.AssignCat(TDF_BrowserSeparator2);
DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
if (br) list.AssignCat("1");
else list.AssignCat("0");
split1 = Standard_True;
}
//cout<<"OpenAttributeList: "<<list<<endl;
return list;
}
//=======================================================================
//function : OpenAttribute
//purpose : Attribute's intrinsic information given by an attribute browser.
//=======================================================================
TCollection_AsciiString DDF_Browser::OpenAttribute
(const Standard_Integer anIndex)
{
TCollection_AsciiString list;
Handle(TDF_Attribute) att = myAttMap.FindKey(anIndex);
DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
if (br) list = br->Open(att);
//cout<<"OpenAttribute: "<<list<<endl;
return list;
}
//=======================================================================
//function : Information
//purpose : Information about <myDF>.
//=======================================================================
TCollection_AsciiString DDF_Browser::Information() const
{
TCollection_AsciiString list;
return list;
}
//=======================================================================
//function : Information
//purpose : Information about a label.
//=======================================================================
TCollection_AsciiString DDF_Browser::Information(const TDF_Label& /*aLab*/) const
{
TCollection_AsciiString list;
return list;
}
//=======================================================================
//function : Information
//purpose : Information about an attribute.
//=======================================================================
TCollection_AsciiString DDF_Browser::Information(const Standard_Integer /*anIndex*/) const
{
TCollection_AsciiString list;
return list;
}
|