1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
19 //Version Date Purpose
20 // 0.0 Oct 3 1997 Creation
23 #include <DDF_Browser.ixx>
25 #include <DDF_AttributeBrowser.hxx>
27 #include <TDF_Tool.hxx>
28 #include <TDF_ChildIterator.hxx>
29 #include <TDF_AttributeIterator.hxx>
30 #include <TDF_Attribute.hxx>
33 #include <TDataStd_Name.hxx>
35 #include <TCollection_ExtendedString.hxx>
37 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 // Communication convention with tcl:
39 // tcl waits for a string of characters, being an information list.
40 // In this list, each item is separated from another by a separator: '\'.
41 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 #define TDF_BrowserSeparator1 '\\'
44 #define TDF_BrowserSeparator2 ' '
45 #define TDF_BrowserSeparator3 '#'
46 #define TDF_BrowserSeparator4 ','
49 //=======================================================================
50 //function : DDF_Browser
52 //=======================================================================
54 DDF_Browser::DDF_Browser(const Handle(TDF_Data)& aDF)
59 //=======================================================================
62 //=======================================================================
64 void DDF_Browser::DrawOn(Draw_Display& /*dis*/) const
66 //cout<<"DDF_Browser"<<endl;
70 //=======================================================================
73 //=======================================================================
75 Handle(Draw_Drawable3D) DDF_Browser::Copy() const
76 { return new DDF_Browser(myDF); }
79 //=======================================================================
82 //=======================================================================
84 void DDF_Browser::Dump(Standard_OStream& S) const
86 S<<"DDF_Browser on a DF:"<<endl;
91 //=======================================================================
94 //=======================================================================
96 void DDF_Browser::Whatis(Draw_Interpretor& I) const
97 { I<<"Data Framework Browser"; }
100 //=======================================================================
103 //=======================================================================
105 void DDF_Browser::Data(const Handle(TDF_Data)& aDF)
109 //=======================================================================
112 //=======================================================================
114 Handle(TDF_Data) DDF_Browser::Data() const
118 //=======================================================================
119 //function : OpenRoot
121 //=======================================================================
123 TCollection_AsciiString DDF_Browser::OpenRoot() const
125 TCollection_AsciiString list;
126 const TDF_Label& root = myDF->Root();
127 TDF_Tool::Entry(root,list);
128 Handle(TDataStd_Name) name;
129 list.AssignCat(TDF_BrowserSeparator2);
130 list.AssignCat("\"");
131 if (root.FindAttribute(TDataStd_Name::GetID(),name))
133 TCollection_AsciiString tmpStr(name->Get(),'?');
134 tmpStr.ChangeAll(' ','_');
135 list.AssignCat(tmpStr);
137 list.AssignCat("\"");
138 list.AssignCat(TDF_BrowserSeparator2);
139 if (!root.MayBeModified()) list.AssignCat("Not");
140 list.AssignCat("Modified");
141 list.AssignCat(TDF_BrowserSeparator2);
142 list.AssignCat((root.HasAttribute() || root.HasChild())? "1" : "0");
147 //=======================================================================
148 //function : OpenLabel
150 // an item is composed as follows:
151 // "Entry "Name" Modified|NotModified 0|1"
152 // the end bit shows if the label has attributes or children.
154 // "AttributeList Modified|NotModified"
155 // The items are separated by "\\".
156 //=======================================================================
158 TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const
160 Standard_Boolean split = Standard_False;
161 TCollection_AsciiString entry, list;
162 if (aLab.HasAttribute() || aLab.AttributesModified())
164 list.AssignCat("AttributeList");
165 list.AssignCat(TDF_BrowserSeparator2);
166 if (!aLab.AttributesModified()) list.AssignCat("Not");
167 list.AssignCat("Modified");
168 split = Standard_True;
170 Handle(TDataStd_Name) name;
171 for (TDF_ChildIterator itr(aLab); itr.More(); itr.Next())
173 if (split) list.AssignCat(TDF_BrowserSeparator1);
174 TDF_Tool::Entry(itr.Value(),entry);
175 list.AssignCat(entry);
176 list.AssignCat(TDF_BrowserSeparator2);
177 list.AssignCat("\"");
178 if (itr.Value().FindAttribute(TDataStd_Name::GetID(),name))
180 TCollection_AsciiString tmpStr(name->Get(),'?');
181 tmpStr.ChangeAll(' ','_');
182 list.AssignCat(tmpStr);
184 list.AssignCat("\"");
185 list.AssignCat(TDF_BrowserSeparator2);
186 if (!itr.Value().MayBeModified()) list.AssignCat("Not");
187 list.AssignCat("Modified");
188 list.AssignCat(TDF_BrowserSeparator2);
190 list.AssignCat((itr.Value().HasAttribute() || itr.Value().HasChild())? "1" : "0");
191 split = Standard_True;
197 //=======================================================================
198 //function : OpenAttributeList
200 // an item is composed as follows:
201 // "DynamicType#MapIndex TransactionIndex Valid|Notvalid Forgotten|NotForgotten Backuped|NotBackuped"
202 // The items are separated by "\\".
203 //=======================================================================
205 TCollection_AsciiString DDF_Browser::OpenAttributeList
206 (const TDF_Label& aLab)
208 TCollection_AsciiString list;
209 Standard_Boolean split1 = Standard_False;
210 for (TDF_AttributeIterator itr(aLab,Standard_False);itr.More();itr.Next())
212 if (split1) list.AssignCat(TDF_BrowserSeparator1);
213 const Handle(TDF_Attribute)& att = itr.Value();
214 const Standard_Integer index = myAttMap.Add(att);
215 TCollection_AsciiString indexStr(index);
216 list.AssignCat(att->DynamicType()->Name());
217 list.AssignCat(TDF_BrowserSeparator3);
218 list.AssignCat(indexStr);
219 list.AssignCat(TDF_BrowserSeparator2);
220 list.AssignCat(att->Transaction());
222 list.AssignCat(TDF_BrowserSeparator2);
223 if (!att->IsValid()) list.AssignCat("Not");
224 list.AssignCat("Valid");
226 list.AssignCat(TDF_BrowserSeparator2);
227 if (!att->IsForgotten()) list.AssignCat("Not");
228 list.AssignCat("Forgotten");
230 list.AssignCat(TDF_BrowserSeparator2);
231 if (!att->IsBackuped()) list.AssignCat("Not");
232 list.AssignCat("Backuped");
234 list.AssignCat(TDF_BrowserSeparator2);
235 DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
236 list.AssignCat(br? "1" : "0");
237 split1 = Standard_True;
243 //=======================================================================
244 //function : OpenAttribute
245 //purpose : Attribute's intrinsic information given by an attribute browser.
246 //=======================================================================
248 TCollection_AsciiString DDF_Browser::OpenAttribute
249 (const Standard_Integer anIndex)
251 TCollection_AsciiString list;
252 Handle(TDF_Attribute) att = myAttMap.FindKey(anIndex);
253 DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
254 if (br) list = br->Open(att);
259 //=======================================================================
260 //function : Information
261 //purpose : Information about <myDF>.
262 //=======================================================================
264 TCollection_AsciiString DDF_Browser::Information() const
266 TCollection_AsciiString list;
271 //=======================================================================
272 //function : Information
273 //purpose : Information about a label.
274 //=======================================================================
276 TCollection_AsciiString DDF_Browser::Information(const TDF_Label& /*aLab*/) const
278 TCollection_AsciiString list;
283 //=======================================================================
284 //function : Information
285 //purpose : Information about an attribute.
286 //=======================================================================
288 TCollection_AsciiString DDF_Browser::Information(const Standard_Integer /*anIndex*/) const
290 TCollection_AsciiString list;