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