-// File: DDF_BrowserCommands.cxx
-// -----------------------
-// Author: DAUTRY Philippe
-// <fid@fox.paris1.matra-dtv.fr>
-// Copyright: Matra Datavision 1997
-
-// Version: 0.0
-// History: Version Date Purpose
-// 0.0 Oct 3 1997 Creation
+// Created by: DAUTRY Philippe
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#include <stdio.h>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
-#ifdef WNT
+#include <OSD_File.hxx>
+
+#ifdef _MSC_VER
#include <stdio.h>
#endif
//=======================================================================
static Standard_Integer DFBrowse (Draw_Interpretor& di,
- Standard_Integer n,
- const char** a)
+ Standard_Integer n,
+ const char** a)
{
- if (n<2) return 1;
+ if (n<2)
+ {
+ cout << "Use: " << a[0] << " document [brower_name]" << endl;
+ return 1;
+ }
Handle(TDF_Data) DF;
- if (!DDF::GetDF (a[1], DF)) return 1;
+ if (!DDF::GetDF (a[1], DF))
+ {
+ cout << "Error: document " << a[1] << " is not found" << endl;
+ return 1;
+ }
Handle(DDF_Browser) NewDDFBrowser = new DDF_Browser(DF);
- char *name = new char[50];
- if (n == 3) sprintf(name,"browser_%s",a[2]);
- else sprintf(name,"browser_%s",a[1]);
-
- Draw::Set (name, NewDDFBrowser);
- TCollection_AsciiString inst1("dftree ");
- inst1.AssignCat(name);
- di.Eval(inst1.ToCString());
+ TCollection_AsciiString name("browser_");
+ name += ((n == 3)? a[2] : a[1]);
+ Draw::Set (name.ToCString(), NewDDFBrowser);
+
+ // Load Tcl Script
+ TCollection_AsciiString aTclScript (getenv ("CSF_DrawPluginDefaults"));
+ aTclScript.AssignCat ( "/dftree.tcl" );
+ OSD_File aTclScriptFile (aTclScript);
+ if (aTclScriptFile.Exists()) {
+#ifdef OCCT_DEBUG
+ cout << "Load " << aTclScript << endl;
+#endif
+ di.EvalFile( aTclScript.ToCString() );
+ }
+ else
+ {
+ cout << "Error: Could not load script " << aTclScript << endl;
+ cout << "Check environment variable CSF_DrawPluginDefaults" << endl;
+ }
+
+ // Call command dftree defined in dftree.tcl
+ TCollection_AsciiString aCommand = "dftree ";
+ aCommand.AssignCat(name);
+ di.Eval(aCommand.ToCString());
return 0;
}
//=======================================================================
static Standard_Integer DFOpenLabel (Draw_Interpretor& di,
- Standard_Integer n,
- const char** a)
+ Standard_Integer n,
+ const char** a)
{
if (n < 2) return 1;
TDF_Label lab;
if (n == 3) TDF_Tool::Label(browser->Data(),a[2],lab);
- if (lab.IsNull()) {
- TCollection_AsciiString list = browser->OpenRoot();
- di<<list.ToCString();
- }
- else {
- TCollection_AsciiString list = browser->OpenLabel(lab);
- di<<list.ToCString();
- }
+ TCollection_AsciiString list(lab.IsNull()? browser->OpenRoot() : browser->OpenLabel(lab));
+ di<<list.ToCString();
return 0;
}
//=======================================================================
static Standard_Integer DFOpenAttributeList(Draw_Interpretor& di,
- Standard_Integer n,
- const char** a)
+ Standard_Integer n,
+ const char** a)
{
if (n < 3) return 1;
TDF_Label lab;
TDF_Tool::Label(browser->Data(),a[2],lab);
- if (lab.IsNull()) {
+ if (lab.IsNull())
return 1;
- }
- TCollection_AsciiString list = browser->OpenAttributeList(lab);
+ TCollection_AsciiString list(browser->OpenAttributeList(lab));
di << list.ToCString();
return 0;
}
//=======================================================================
static Standard_Integer DFOpenAttribute (Draw_Interpretor& di,
- Standard_Integer n,
- const char** a)
+ Standard_Integer n,
+ const char** a)
{
if (n < 3) return 1;
Handle(DDF_Browser) browser =
Handle(DDF_Browser)::DownCast (Draw::Get(a[1], Standard_True));
- Standard_Integer index = atoi(a[2]);
-
+ const Standard_Integer index = Draw::Atoi(a[2]);
TCollection_AsciiString list = browser->OpenAttribute(index);
-
di<<list.ToCString();
return 0;
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-
//=======================================================================
//function : BrowserCommands
//purpose :
void DDF::BrowserCommands (Draw_Interpretor& theCommands)
{
-/*
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
"DON'T USE THIS COMMAND RESERVED TO THE BROWSER!\nReturns information about an attribute, a df or a label: DFDisplayInfo {#} | {browsername [label]}",
__FILE__, DFDisplayInfo, g);
#endif
-*/
}