Integration of OCCT 6.5.0 from SVN
[occt.git] / src / DDF / DDF_BrowserCommands.cxx
CommitLineData
7fd59977 1// File: DDF_BrowserCommands.cxx
2// -----------------------
3// Author: DAUTRY Philippe
4// <fid@fox.paris1.matra-dtv.fr>
5// Copyright: Matra Datavision 1997
6
7// Version: 0.0
8// History: Version Date Purpose
9// 0.0 Oct 3 1997 Creation
10
11#include <stdio.h>
12
13#include <DDF.hxx>
14#include <DDF_Browser.hxx>
15#include <DDF_Data.hxx>
16
17#include <Draw.hxx>
18#include <Draw_Appli.hxx>
19#include <Draw_Drawable3D.hxx>
20#include <Draw_Interpretor.hxx>
21
22#include <TDF_Label.hxx>
23#include <TDF_ChildIterator.hxx>
24#include <TDF_AttributeIterator.hxx>
25#include <TDF_Tool.hxx>
26
27#include <TCollection_AsciiString.hxx>
28#include <TCollection_HAsciiString.hxx>
29#ifdef WNT
30#include <stdio.h>
31#endif
32
33//=======================================================================
34//function : DFBrowse
35//purpose :
36// arg 1 : DF name
37// [arg 2] : Browser name
38//=======================================================================
39
40static Standard_Integer DFBrowse (Draw_Interpretor& di,
41 Standard_Integer n,
42 const char** a)
43{
44 if (n<2) return 1;
45
46 Handle(TDF_Data) DF;
47 if (!DDF::GetDF (a[1], DF)) return 1;
48
49 Handle(DDF_Browser) NewDDFBrowser = new DDF_Browser(DF);
50 char *name = new char[50];
51 if (n == 3) sprintf(name,"browser_%s",a[2]);
52 else sprintf(name,"browser_%s",a[1]);
53
54 Draw::Set (name, NewDDFBrowser);
55 TCollection_AsciiString inst1("dftree ");
56 inst1.AssignCat(name);
57 di.Eval(inst1.ToCString());
58 return 0;
59}
60
61
62//=======================================================================
63//function : DFOpenLabel
64//purpose :
65// arg 1 : Browser name
66// [arg 2] : Label name
67//=======================================================================
68
69static Standard_Integer DFOpenLabel (Draw_Interpretor& di,
70 Standard_Integer n,
71 const char** a)
72{
73 if (n < 2) return 1;
74
75 Handle(DDF_Browser) browser =
76 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
77
78 TDF_Label lab;
79 if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab);
80
81 if (lab.IsNull()) {
82 TCollection_AsciiString list = browser->OpenRoot();
83 di<<list.ToCString();
84 }
85 else {
86 TCollection_AsciiString list = browser->OpenLabel(lab);
87 di<<list.ToCString();
88 }
89 return 0;
90}
91
92
93//=======================================================================
94//function : DFOpenAttributeList
95//purpose :
96// arg 1 : Browser name
97// arg 2 : Label name
98//=======================================================================
99
100static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di,
101 Standard_Integer n,
102 const char** a)
103{
104 if (n < 3) return 1;
105
106 Handle(DDF_Browser) browser =
107 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
108
109 TDF_Label lab;
110 TDF_Tool::Label(browser->Data(),a[2],lab);
111
112 if (lab.IsNull()) {
113 return 1;
114 }
115
116 TCollection_AsciiString list = browser->OpenAttributeList(lab);
117 di << list.ToCString();
118 return 0;
119}
120
121
122
123//=======================================================================
124//function : DFOpenAttribute
125//purpose :
126// arg 1 : Browser name
127// arg 2 : Attribute index
128//=======================================================================
129
130static Standard_Integer DFOpenAttribute (Draw_Interpretor& di,
131 Standard_Integer n,
132 const char** a)
133{
134 if (n < 3) return 1;
135
136 Handle(DDF_Browser) browser =
137 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
138
139 Standard_Integer index = atoi(a[2]);
140
141 TCollection_AsciiString list = browser->OpenAttribute(index);
142
143 di<<list.ToCString();
144 return 0;
145}
146
147
148// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
149
150
151
152
153//=======================================================================
154//function : BrowserCommands
155//purpose :
156//=======================================================================
157
158void DDF::BrowserCommands (Draw_Interpretor& theCommands)
159{
160/*
161 static Standard_Boolean done = Standard_False;
162 if (done) return;
163 done = Standard_True;
164
165 const char* g = "DF browser commands";
166
167 theCommands.Add
168 ("DFBrowse",
169 "Creates a browser on a df: DFBrowse dfname [browsername]",
170 __FILE__, DFBrowse, g);
171
172 theCommands.Add
173 ("DFOpenLabel",
174 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the list of sub-label entries: DFOpenLabel browsername [label]",
175 __FILE__, DFOpenLabel, g);
176
177 theCommands.Add
178 ("DFOpenAttributeList",
179 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the attribute list of a label: DFOpenLabel browsername label",
180 __FILE__, DFOpenAttributeList, g);
181
182 theCommands.Add
183 ("DFOpenAttribute",
184 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the reference list of an attribute: DFOpenLabel browsername attributeindex",
185 __FILE__, DFOpenAttribute, g);
186#if 0
187 theCommands.Add
188 ("DFDisplayInfo",
189 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns information about an attribute, a df or a label: DFDisplayInfo {#} | {browsername [label]}",
190 __FILE__, DFDisplayInfo, g);
191#endif
192*/
193}