1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
19 #include <DDF_Browser.hxx>
20 #include <DDF_Data.hxx>
23 #include <Draw_Appli.hxx>
24 #include <Draw_Drawable3D.hxx>
25 #include <Draw_Interpretor.hxx>
27 #include <TDF_Label.hxx>
28 #include <TDF_ChildIterator.hxx>
29 #include <TDF_AttributeIterator.hxx>
30 #include <TDF_Tool.hxx>
32 #include <TCollection_AsciiString.hxx>
33 #include <TCollection_HAsciiString.hxx>
34 #include <OSD_File.hxx>
40 //=======================================================================
44 // [arg 2] : Browser name
45 //=======================================================================
47 static Standard_Integer DFBrowse (Draw_Interpretor& di,
53 cout << "Use: " << a[0] << " document [brower_name]" << endl;
58 if (!DDF::GetDF (a[1], DF))
60 cout << "Error: document " << a[1] << " is not found" << endl;
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);
70 TCollection_AsciiString aTclScript (getenv ("CSF_DrawPluginDefaults"));
71 aTclScript.AssignCat ( "/dftree.tcl" );
72 OSD_File aTclScriptFile (aTclScript);
73 if (aTclScriptFile.Exists()) {
75 cout << "Load " << aTclScript << endl;
77 di.EvalFile( aTclScript.ToCString() );
81 cout << "Error: Could not load script " << aTclScript << endl;
82 cout << "Check environment variable CSF_DrawPluginDefaults" << endl;
85 // Call command dftree defined in dftree.tcl
86 TCollection_AsciiString aCommand = "dftree ";
87 aCommand.AssignCat(name);
88 di.Eval(aCommand.ToCString());
93 //=======================================================================
94 //function : DFOpenLabel
96 // arg 1 : Browser name
97 // [arg 2] : Label name
98 //=======================================================================
100 static Standard_Integer DFOpenLabel (Draw_Interpretor& di,
106 Handle(DDF_Browser) browser =
107 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
110 if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab);
112 TCollection_AsciiString list(lab.IsNull()? browser->OpenRoot() : browser->OpenLabel(lab));
113 di<<list.ToCString();
118 //=======================================================================
119 //function : DFOpenAttributeList
121 // arg 1 : Browser name
122 // arg 2 : Label name
123 //=======================================================================
125 static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di,
131 Handle(DDF_Browser) browser =
132 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
135 TDF_Tool::Label(browser->Data(),a[2],lab);
140 TCollection_AsciiString list(browser->OpenAttributeList(lab));
141 di << list.ToCString();
147 //=======================================================================
148 //function : DFOpenAttribute
150 // arg 1 : Browser name
151 // arg 2 : Attribute index
152 //=======================================================================
154 static Standard_Integer DFOpenAttribute (Draw_Interpretor& di,
160 Handle(DDF_Browser) browser =
161 Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
163 const Standard_Integer index = Draw::Atoi(a[2]);
164 TCollection_AsciiString list = browser->OpenAttribute(index);
165 di<<list.ToCString();
170 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
173 //=======================================================================
174 //function : BrowserCommands
176 //=======================================================================
178 void DDF::BrowserCommands (Draw_Interpretor& theCommands)
180 static Standard_Boolean done = Standard_False;
182 done = Standard_True;
184 const char* g = "DF browser commands";
188 "Creates a browser on a df: DFBrowse dfname [browsername]",
189 __FILE__, DFBrowse, g);
193 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the list of sub-label entries: DFOpenLabel browsername [label]",
194 __FILE__, DFOpenLabel, g);
197 ("DFOpenAttributeList",
198 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the attribute list of a label: DFOpenLabel browsername label",
199 __FILE__, DFOpenAttributeList, g);
203 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns the reference list of an attribute: DFOpenLabel browsername attributeindex",
204 __FILE__, DFOpenAttribute, g);
208 "DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns information about an attribute, a df or a label: DFDisplayInfo {#} | {browsername [label]}",
209 __FILE__, DFDisplayInfo, g);