0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / DDataStd / DDataStd_TreeBrowser.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 Nov 27 1997 Creation
20
7fd59977 21#include <DDataStd.hxx>
42cf5bc1 22#include <DDataStd_TreeBrowser.hxx>
23#include <Draw_Display.hxx>
24#include <Draw_Drawable3D.hxx>
25#include <Standard_Type.hxx>
7fd59977 26#include <TCollection_AsciiString.hxx>
42cf5bc1 27#include <TDataStd_Name.hxx>
28#include <TDataStd_TreeNode.hxx>
7fd59977 29#include <TDF.hxx>
42cf5bc1 30#include <TDF_Label.hxx>
31#include <TDF_Tool.hxx>
7fd59977 32
92efcf78 33IMPLEMENT_STANDARD_RTTIEXT(DDataStd_TreeBrowser,Draw_Drawable3D)
34
7fd59977 35//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36// Communication convention with tcl:
37// tcl waits for a string of characters, being an information list.
38// In this list, each item is separated from another by a separator: '\'.
39//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7fd59977 40#define TDF_BrowserSeparator1 '\\'
41#define TDF_BrowserSeparator2 ' '
42#define TDF_BrowserSeparator3 '#'
43#define TDF_BrowserSeparator4 ','
44
45
46//=======================================================================
47//function : DDesign_TreeNodeBrowser
48//purpose :
49//=======================================================================
50
51DDataStd_TreeBrowser::DDataStd_TreeBrowser(const TDF_Label& aLabel)
52: myRoot(aLabel)
53{}
54
55
56//=======================================================================
57//function : DrawOn
58//purpose :
59//=======================================================================
60
35e08fe8 61void DDataStd_TreeBrowser::DrawOn(Draw_Display& /*dis*/) const
04232180 62{ std::cout<<"DDataStd_TreeBrowser"<<std::endl; }
7fd59977 63
64
65//=======================================================================
66//function : Copy
67//purpose :
68//=======================================================================
69
70Handle(Draw_Drawable3D) DDataStd_TreeBrowser::Copy() const
71{ return new DDataStd_TreeBrowser(myRoot); }
72
73
74//=======================================================================
75//function : Dump
76//purpose :
77//=======================================================================
78
79void DDataStd_TreeBrowser::Dump(Standard_OStream& S) const
80{
04232180 81 S<<"DDataStd_TreeBrowser on a label: "<<std::endl;
7fd59977 82 S<<myRoot;
83}
84
85
86//=======================================================================
87//function : Whatis
88//purpose :
89//=======================================================================
90
91void DDataStd_TreeBrowser::Whatis(Draw_Interpretor& I) const
92{ I<<"function browser"; }
93
94
95//=======================================================================
96//function : Label
97//purpose :
98//=======================================================================
99
100void DDataStd_TreeBrowser::Label(const TDF_Label& aLabel)
101{ myRoot = aLabel; }
102
103
104//=======================================================================
105//function : Label
106//purpose :
107//=======================================================================
108
109TDF_Label DDataStd_TreeBrowser::Label() const
110{ return myRoot; }
111
112
113//=======================================================================
114//function : OpenRoot
115//purpose :
116//=======================================================================
117
118TCollection_AsciiString DDataStd_TreeBrowser::OpenRoot() const
119{
120 TCollection_AsciiString list;
121 Handle(TDataStd_TreeNode) TN;
122 if (myRoot.FindAttribute (TDataStd_TreeNode::GetDefaultTreeID(),TN)) {
123 OpenNode(TN,list);
124 }
125 return list;
126}
127
128
129//=======================================================================
130//function : OpenNode
131//purpose :
132// the items are separated by "\\".
133//=======================================================================
134
135TCollection_AsciiString DDataStd_TreeBrowser::OpenNode(const TDF_Label& aLabel) const
136{
137 TCollection_AsciiString list;
138 Handle(TDataStd_TreeNode) nodeToOpen;
139 if (aLabel.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), nodeToOpen)) {
140 Standard_Boolean split = Standard_False;
141 Handle(TDataStd_TreeNode) current = nodeToOpen->First();
142 while (!current.IsNull()) {
143 if (split) list.AssignCat(TDF_BrowserSeparator1);
144 OpenNode(current,list);
145 split = Standard_True;
146 current = current->Next();
147 }
148 }
149 return list;
150}
151
152
153//=======================================================================
154//function : OpenNode
155//purpose :
156// An item is composed as follows:
157// "LabelEntry "Name" DynamicType Executable|Forgotten Failed|Success First|Null [ LabelFather]"
158// First/Null : has/has not child
159//=======================================================================
160
161void DDataStd_TreeBrowser::OpenNode (const Handle(TDataStd_TreeNode)& aTreeNode,
162 TCollection_AsciiString& aList) const
163{
164 // Label entry. -0
165 TCollection_AsciiString tmp;
166 TDF_Tool::Entry(aTreeNode->Label(),tmp);
167 aList.AssignCat(tmp);
168 // Name -1
169 aList.AssignCat(TDF_BrowserSeparator2);
170 Handle(TDataStd_Name) name;
171 aList.AssignCat("\"");
172 if (aTreeNode->Label().FindAttribute(TDataStd_Name::GetID(),name)) {
ae9f4b64 173 aList.AssignCat(name->Get());
7fd59977 174 }
175 aList.AssignCat("\"");
176 // Dynamic type. -2
177 aList.AssignCat(TDF_BrowserSeparator2);
178 TCollection_ExtendedString ext;
179 if (TDF::ProgIDFromGUID(aTreeNode->ID(), ext))
ae9f4b64 180 aList.AssignCat(ext);
7fd59977 181 else aList.AssignCat(aTreeNode->DynamicType()->Name());
182 // Executable or Forgotten? -3
183 // aList.AssignCat(TDF_BrowserSeparator2);
184 // if (aTreeNode->IsExecutable()) aList.AssignCat("Executable");
185 // else aList.AssignCat("Forgotten");
186 // Failed or Success? -4
187 // aList.AssignCat(TDF_BrowserSeparator2);
188 // if (aTreeNode->Failed()) aList.AssignCat("Failed");
189 // else aList.AssignCat("Success");
190 //Children? -3
191 aList.AssignCat(TDF_BrowserSeparator2);
192 if (aTreeNode->First().IsNull()) aList.AssignCat("Null");
193 else aList.AssignCat("First");
194 // Father? -4
195 aList.AssignCat(TDF_BrowserSeparator2);
196 if (!aTreeNode->HasFather()) aList.AssignCat("Null");
197 else {
198 TDF_Tool::Entry(aTreeNode->Father()->Label(),tmp);
199 aList.AssignCat(tmp);
200 }
201 // First? -5
202 aList.AssignCat(TDF_BrowserSeparator2);
203 if (!aTreeNode->HasFirst()) aList.AssignCat("Null");
204 else {
205 TDF_Tool::Entry(aTreeNode->First()->Label(),tmp);
206 aList.AssignCat(tmp);
207 }
208 // Next? -6
209 aList.AssignCat(TDF_BrowserSeparator2);
210 if (!aTreeNode->HasNext()) aList.AssignCat("Null");
211 else {
212 TDF_Tool::Entry(aTreeNode->Next()->Label(),tmp);
213 aList.AssignCat(tmp);
214 }
215 // Previous? -7
216 aList.AssignCat(TDF_BrowserSeparator2);
217 if (!aTreeNode->HasPrevious()) aList.AssignCat("Null");
218 else {
219 TDF_Tool::Entry(aTreeNode->Previous()->Label(),tmp);
220 aList.AssignCat(tmp);
221 }
222}