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