1 // Created on: 1998-06-29
2 // Created by: Denis PASCAL
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <AppStd_Application.hxx>
19 #include <DDataStd.hxx>
21 #include <DDocStd.hxx>
22 #include <DNaming.hxx>
23 #include <DPrsStd.hxx>
25 #include <Draw_Interpretor.hxx>
26 #include <Draw_PluginMacro.hxx>
27 #include <OSD_Directory.hxx>
28 #include <OSD_Environment.hxx>
29 #include <OSD_File.hxx>
30 #include <OSD_Path.hxx>
31 #include <TCollection_AsciiString.hxx>
33 //#include <AppStdL_Application.hxx>
34 // avoid warnings on 'extern "C"' functions returning C++ classes
36 #pragma warning(4:4190)
38 //static Handle(AppStdL_Application) stdApp;
39 static Handle(AppStd_Application) stdApp;
40 //=======================================================================
41 //function : AllComands
43 //=======================================================================
45 void DPrsStd::AllCommands (Draw_Interpretor& theCommands)
47 static Standard_Boolean done = Standard_False;
52 if (stdApp.IsNull()) stdApp = new AppStd_Application ();//new AppStdL_Application ();
54 DPrsStd::AISPresentationCommands(theCommands);
55 DPrsStd::AISViewerCommands(theCommands);
56 //DPrsStd::BasicCommands(theCommands);
59 //==============================================================================
60 // Found standard CAF Plugin
61 //==============================================================================
62 static Standard_Boolean FoundCAFPlugin () {
64 // Define Environment Variable
66 char *plugin, *casroot, *standard;
67 plugin = getenv("CSF_PluginDefaults");
68 standard = getenv("CSF_StandardDefaults");
69 casroot = getenv("CASROOT");
70 Standard_Boolean hasPlugin = Standard_False;
71 TCollection_AsciiString PluginName ;
74 PluginName = TCollection_AsciiString (casroot);
75 PluginName+="/src/StdResource" ;
76 hasPlugin = Standard_True ;
79 PluginName = TCollection_AsciiString (plugin);
80 hasPlugin = Standard_True ;
83 OSD_Path aPath ( PluginName );
84 OSD_Directory aDir(aPath);
85 if ( aDir.Exists () ) {
86 TCollection_AsciiString PluginFileName = PluginName + "/Plugin" ;
87 OSD_File PluginFile ( PluginFileName );
88 if ( PluginFile.Exists() ) {
90 OSD_Environment PluginEnv ( "CSF_PluginDefaults" , PluginName );
92 if ( PluginEnv.Failed() ) {
93 cout << " Problem when initialise CSF_PluginDefaults whith " << PluginName.ToCString() << endl;
97 OSD_Environment StandardEnv ( "CSF_StandardDefaults" , PluginName );
99 if ( StandardEnv.Failed() ) {
100 cout << " Problem when initialise CSF_StandardDefaults whith " << PluginName.ToCString() << endl;
104 hasPlugin = Standard_False;
107 hasPlugin = Standard_False;
112 cout << " an environement variable named : CSF_PluginDefaults is mandatory to use OCAF " <<endl;
113 Standard_Failure::Raise ( "an environement variable named : CSF_PluginDefaults is mandatory to use OCAF" );
119 //==============================================================================
121 //==============================================================================
122 void DPrsStd::Factory(Draw_Interpretor& theDI)
124 if(!FoundCAFPlugin())
127 static Standard_Boolean DPrsStdFactoryDone = Standard_False;
128 if (DPrsStdFactoryDone) return;
129 DPrsStdFactoryDone = Standard_True;
131 DDF::AllCommands(theDI);
132 DNaming::AllCommands(theDI);
133 DDataStd::AllCommands(theDI);
134 DPrsStd::AllCommands(theDI);
135 DDocStd::AllCommands(theDI);
137 cout << "Draw Plugin : All DF commands are loaded" << endl;
141 // Declare entry point PLUGINFACTORY