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.
23 #include <DDF_Browser.hxx>
24 #include <DDF_Data.hxx>
27 #include <Draw_Appli.hxx>
28 #include <Draw_Drawable3D.hxx>
29 #include <Draw_Interpretor.hxx>
31 #include <TDF_Label.hxx>
32 #include <TDF_ChildIterator.hxx>
33 #include <TDF_AttributeIterator.hxx>
34 #include <TDF_Tool.hxx>
36 #include <TCollection_AsciiString.hxx>
37 #include <TCollection_HAsciiString.hxx>
38 #include <OSD_File.hxx>
44 //=======================================================================
48 // [arg 2] : Browser name
49 //=======================================================================
51 static Standard_Integer DFBrowse (Draw_Interpretor& di,
57 cout << "Use: " << a[0] << " document [brower_name]" << endl;
62 if (!DDF::GetDF (a[1], DF))
64 cout << "Error: document " << a[1] << " is not found" << endl;
68 Handle(DDF_Browser) NewDDFBrowser = new DDF_Browser(DF);
69 TCollection_AsciiString name("browser_");
70 name += ((n == 3)? a[2] : a[1]);
71 Draw::Set (name.ToCString(), NewDDFBrowser);
74 TCollection_AsciiString aTclScript (getenv ("CSF_DrawPluginDefaults"));
75 aTclScript.AssignCat ( "/dftree.tcl" );
76 OSD_File aTclScriptFile (aTclScript);
77 if (aTclScriptFile.Exists()) {
79 cout << "Load " << aTclScript << endl;
81 di.EvalFile( aTclScript.ToCString() );
85 cout << "Error: Could not load script " << aTclScript << endl;
86 cout << "Check environment variable CSF_DrawPluginDefaults" << endl;
89 // Call command dftree defined in dftree.tcl
90 TCollection_AsciiString aCommand = "dftree ";
91 aCommand.AssignCat(name);
92 di.Eval(aCommand.ToCString());
97 //=======================================================================
98 //function : DFOpenLabel
100 // arg 1 : Browser name
101 // [arg 2] : Label name
102 //=======================================================================
104 static Standard_Integer DFOpenLabel (Draw_Interpretor& di,
110 Handle(DDF_Browser) browser =
111 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
114 if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab);
116 TCollection_AsciiString list(lab.IsNull()? browser->OpenRoot() : browser->OpenLabel(lab));
117 di<<list.ToCString();
122 //=======================================================================
123 //function : DFOpenAttributeList
125 // arg 1 : Browser name
126 // arg 2 : Label name
127 //=======================================================================
129 static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di,
135 Handle(DDF_Browser) browser =
136 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
139 TDF_Tool::Label(browser->Data(),a[2],lab);
144 TCollection_AsciiString list(browser->OpenAttributeList(lab));
145 di << list.ToCString();
151 //=======================================================================
152 //function : DFOpenAttribute
154 // arg 1 : Browser name
155 // arg 2 : Attribute index
156 //=======================================================================
158 static Standard_Integer DFOpenAttribute (Draw_Interpretor& di,
164 Handle(DDF_Browser) browser =
165 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
167 const Standard_Integer index = atoi(a[2]);
168 TCollection_AsciiString list = browser->OpenAttribute(index);
169 di<<list.ToCString();
174 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
177 //=======================================================================
178 //function : BrowserCommands
180 //=======================================================================
182 void DDF::BrowserCommands (Draw_Interpretor& theCommands)
184 static Standard_Boolean done = Standard_False;
186 done = Standard_True;
188 const char* g = "DF browser commands";
192 "Creates a browser on a df: DFBrowse dfname [browsername]",
193 __FILE__, DFBrowse, g);
197 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the list of sub-label entries: DFOpenLabel browsername [label]",
198 __FILE__, DFOpenLabel, g);
201 ("DFOpenAttributeList",
202 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the attribute list of a label: DFOpenLabel browsername label",
203 __FILE__, DFOpenAttributeList, g);
207 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the reference list of an attribute: DFOpenLabel browsername attributeindex",
208 __FILE__, DFOpenAttribute, g);
212 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns information about an attribute, a df or a label: DFDisplayInfo {#} | {browsername [label]}",
213 __FILE__, DFDisplayInfo, g);