1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
23 //Version Date Purpose
24 // 0.0 Oct 3 1997 Creation
27 #include <DDF_Browser.ixx>
29 #include <DDF_AttributeBrowser.hxx>
31 #include <TDF_Tool.hxx>
32 #include <TDF_ChildIterator.hxx>
33 #include <TDF_AttributeIterator.hxx>
34 #include <TDF_Attribute.hxx>
37 #include <TDataStd_Name.hxx>
39 #include <TCollection_ExtendedString.hxx>
41 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42 // Communication convention with tcl:
43 // tcl waits for a string of characters, being an information list.
44 // In this list, each item is separated from another by a separator: '\'.
45 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47 #define TDF_BrowserSeparator1 '\\'
48 #define TDF_BrowserSeparator2 ' '
49 #define TDF_BrowserSeparator3 '#'
50 #define TDF_BrowserSeparator4 ','
53 //=======================================================================
54 //function : DDF_Browser
56 //=======================================================================
58 DDF_Browser::DDF_Browser(const Handle(TDF_Data)& aDF)
63 //=======================================================================
66 //=======================================================================
68 void DDF_Browser::DrawOn(Draw_Display& /*dis*/) const
70 //cout<<"DDF_Browser"<<endl;
74 //=======================================================================
77 //=======================================================================
79 Handle(Draw_Drawable3D) DDF_Browser::Copy() const
80 { return new DDF_Browser(myDF); }
83 //=======================================================================
86 //=======================================================================
88 void DDF_Browser::Dump(Standard_OStream& S) const
90 S<<"DDF_Browser on a DF:"<<endl;
95 //=======================================================================
98 //=======================================================================
100 void DDF_Browser::Whatis(Draw_Interpretor& I) const
101 { I<<"Data Framework Browser"; }
104 //=======================================================================
107 //=======================================================================
109 void DDF_Browser::Data(const Handle(TDF_Data)& aDF)
113 //=======================================================================
116 //=======================================================================
118 Handle(TDF_Data) DDF_Browser::Data() const
122 //=======================================================================
123 //function : OpenRoot
125 //=======================================================================
127 TCollection_AsciiString DDF_Browser::OpenRoot() const
129 TCollection_AsciiString list;
130 const TDF_Label& root = myDF->Root();
131 TDF_Tool::Entry(root,list);
132 Handle(TDataStd_Name) name;
133 list.AssignCat(TDF_BrowserSeparator2);
134 list.AssignCat("\"");
135 if (root.FindAttribute(TDataStd_Name::GetID(),name))
137 TCollection_AsciiString tmpStr(name->Get(),'?');
138 tmpStr.ChangeAll(' ','_');
139 list.AssignCat(tmpStr);
141 list.AssignCat("\"");
142 list.AssignCat(TDF_BrowserSeparator2);
143 if (!root.MayBeModified()) list.AssignCat("Not");
144 list.AssignCat("Modified");
145 list.AssignCat(TDF_BrowserSeparator2);
146 list.AssignCat((root.HasAttribute() || root.HasChild())? "1" : "0");
151 //=======================================================================
152 //function : OpenLabel
154 // an item is composed as follows:
155 // "Entry "Name" Modified|NotModified 0|1"
156 // the end bit shows if the label has attributes or children.
158 // "AttributeList Modified|NotModified"
159 // The items are separated by "\\".
160 //=======================================================================
162 TCollection_AsciiString DDF_Browser::OpenLabel(const TDF_Label& aLab) const
164 Standard_Boolean split = Standard_False;
165 TCollection_AsciiString entry, list;
166 if (aLab.HasAttribute() || aLab.AttributesModified())
168 list.AssignCat("AttributeList");
169 list.AssignCat(TDF_BrowserSeparator2);
170 if (!aLab.AttributesModified()) list.AssignCat("Not");
171 list.AssignCat("Modified");
172 split = Standard_True;
174 Handle(TDataStd_Name) name;
175 for (TDF_ChildIterator itr(aLab); itr.More(); itr.Next())
177 if (split) list.AssignCat(TDF_BrowserSeparator1);
178 TDF_Tool::Entry(itr.Value(),entry);
179 list.AssignCat(entry);
180 list.AssignCat(TDF_BrowserSeparator2);
181 list.AssignCat("\"");
182 if (itr.Value().FindAttribute(TDataStd_Name::GetID(),name))
184 TCollection_AsciiString tmpStr(name->Get(),'?');
185 tmpStr.ChangeAll(' ','_');
186 list.AssignCat(tmpStr);
188 list.AssignCat("\"");
189 list.AssignCat(TDF_BrowserSeparator2);
190 if (!itr.Value().MayBeModified()) list.AssignCat("Not");
191 list.AssignCat("Modified");
192 list.AssignCat(TDF_BrowserSeparator2);
194 list.AssignCat((itr.Value().HasAttribute() || itr.Value().HasChild())? "1" : "0");
195 split = Standard_True;
201 //=======================================================================
202 //function : OpenAttributeList
204 // an item is composed as follows:
205 // "DynamicType#MapIndex TransactionIndex Valid|Notvalid Forgotten|NotForgotten Backuped|NotBackuped"
206 // The items are separated by "\\".
207 //=======================================================================
209 TCollection_AsciiString DDF_Browser::OpenAttributeList
210 (const TDF_Label& aLab)
212 TCollection_AsciiString list;
213 Standard_Boolean split1 = Standard_False;
214 for (TDF_AttributeIterator itr(aLab,Standard_False);itr.More();itr.Next())
216 if (split1) list.AssignCat(TDF_BrowserSeparator1);
217 const Handle(TDF_Attribute)& att = itr.Value();
218 const Standard_Integer index = myAttMap.Add(att);
219 TCollection_AsciiString indexStr(index);
220 list.AssignCat(att->DynamicType()->Name());
221 list.AssignCat(TDF_BrowserSeparator3);
222 list.AssignCat(indexStr);
223 list.AssignCat(TDF_BrowserSeparator2);
224 list.AssignCat(att->Transaction());
226 list.AssignCat(TDF_BrowserSeparator2);
227 if (!att->IsValid()) list.AssignCat("Not");
228 list.AssignCat("Valid");
230 list.AssignCat(TDF_BrowserSeparator2);
231 if (!att->IsForgotten()) list.AssignCat("Not");
232 list.AssignCat("Forgotten");
234 list.AssignCat(TDF_BrowserSeparator2);
235 if (!att->IsBackuped()) list.AssignCat("Not");
236 list.AssignCat("Backuped");
238 list.AssignCat(TDF_BrowserSeparator2);
239 DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
240 list.AssignCat(br? "1" : "0");
241 split1 = Standard_True;
247 //=======================================================================
248 //function : OpenAttribute
249 //purpose : Attribute's intrinsic information given by an attribute browser.
250 //=======================================================================
252 TCollection_AsciiString DDF_Browser::OpenAttribute
253 (const Standard_Integer anIndex)
255 TCollection_AsciiString list;
256 Handle(TDF_Attribute) att = myAttMap.FindKey(anIndex);
257 DDF_AttributeBrowser* br = DDF_AttributeBrowser::FindBrowser(att);
258 if (br) list = br->Open(att);
263 //=======================================================================
264 //function : Information
265 //purpose : Information about <myDF>.
266 //=======================================================================
268 TCollection_AsciiString DDF_Browser::Information() const
270 TCollection_AsciiString list;
275 //=======================================================================
276 //function : Information
277 //purpose : Information about a label.
278 //=======================================================================
280 TCollection_AsciiString DDF_Browser::Information(const TDF_Label& /*aLab*/) const
282 TCollection_AsciiString list;
287 //=======================================================================
288 //function : Information
289 //purpose : Information about an attribute.
290 //=======================================================================
292 TCollection_AsciiString DDF_Browser::Information(const Standard_Integer /*anIndex*/) const
294 TCollection_AsciiString list;