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.
20 // -----------------------
23 //Version Date Purpose
24 // 0.0 Oct 3 1997 Creation
29 #include <DDF_Browser.hxx>
30 #include <DDF_Data.hxx>
33 #include <Draw_Appli.hxx>
34 #include <Draw_Drawable3D.hxx>
35 #include <Draw_Interpretor.hxx>
37 #include <TDF_Label.hxx>
38 #include <TDF_ChildIterator.hxx>
39 #include <TDF_AttributeIterator.hxx>
40 #include <TDF_Tool.hxx>
42 #include <TCollection_AsciiString.hxx>
43 #include <TCollection_HAsciiString.hxx>
48 //=======================================================================
52 // [arg 2] : Browser name
53 //=======================================================================
55 static Standard_Integer DFBrowse (Draw_Interpretor& di,
62 if (!DDF::GetDF (a[1], DF)) return 1;
64 Handle(DDF_Browser) NewDDFBrowser = new DDF_Browser(DF);
65 TCollection_AsciiString name("browser_");
66 name += ((n == 3)? a[2] : a[1]);
67 Draw::Set (name.ToCString(), NewDDFBrowser);
69 TCollection_AsciiString inst1("dftree ");
70 inst1.AssignCat(name);
71 di.Eval(inst1.ToCString());
76 //=======================================================================
77 //function : DFOpenLabel
79 // arg 1 : Browser name
80 // [arg 2] : Label name
81 //=======================================================================
83 static Standard_Integer DFOpenLabel (Draw_Interpretor& di,
89 Handle(DDF_Browser) browser =
90 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
93 if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab);
95 TCollection_AsciiString list(lab.IsNull()? browser->OpenRoot() : browser->OpenLabel(lab));
101 //=======================================================================
102 //function : DFOpenAttributeList
104 // arg 1 : Browser name
105 // arg 2 : Label name
106 //=======================================================================
108 static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di,
114 Handle(DDF_Browser) browser =
115 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
118 TDF_Tool::Label(browser->Data(),a[2],lab);
123 TCollection_AsciiString list(browser->OpenAttributeList(lab));
124 di << list.ToCString();
130 //=======================================================================
131 //function : DFOpenAttribute
133 // arg 1 : Browser name
134 // arg 2 : Attribute index
135 //=======================================================================
137 static Standard_Integer DFOpenAttribute (Draw_Interpretor& di,
143 Handle(DDF_Browser) browser =
144 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
146 const Standard_Integer index = atoi(a[2]);
147 TCollection_AsciiString list = browser->OpenAttribute(index);
148 di<<list.ToCString();
153 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
156 //=======================================================================
157 //function : BrowserCommands
159 //=======================================================================
161 void DDF::BrowserCommands (Draw_Interpretor& theCommands)
163 static Standard_Boolean done = Standard_False;
165 done = Standard_True;
167 const char* g = "DF browser commands";
171 "Creates a browser on a df: DFBrowse dfname [browsername]",
172 __FILE__, DFBrowse, g);
176 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the list of sub-label entries: DFOpenLabel browsername [label]",
177 __FILE__, DFOpenLabel, g);
180 ("DFOpenAttributeList",
181 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the attribute list of a label: DFOpenLabel browsername label",
182 __FILE__, DFOpenAttributeList, g);
186 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the reference list of an attribute: DFOpenLabel browsername attributeindex",
187 __FILE__, DFOpenAttribute, g);
191 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns information about an attribute, a df or a label: DFDisplayInfo {#} | {browsername [label]}",
192 __FILE__, DFDisplayInfo, g);