1 // Created on: 1998-06-29
2 // Created by: Denis PASCAL
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <DPrsStd.ixx>
24 #include <Draw_Interpretor.hxx>
27 #include <Draw_PluginMacro.hxx>
28 #include <DNaming.hxx>
29 #include <DDataStd.hxx>
31 #include <DDocStd.hxx>
32 //#include <AppStdL_Application.hxx>
33 #include <AppStd_Application.hxx>
34 #include <TCollection_AsciiString.hxx>
35 #include <OSD_Path.hxx>
36 #include <OSD_Environment.hxx>
37 #include <OSD_Directory.hxx>
38 #include <OSD_File.hxx>
40 // avoid warnings on 'extern "C"' functions returning C++ classes
42 #pragma warning(4:4190)
44 //static Handle(AppStdL_Application) stdApp;
45 static Handle(AppStd_Application) stdApp;
46 //=======================================================================
47 //function : AllComands
49 //=======================================================================
51 void DPrsStd::AllCommands (Draw_Interpretor& theCommands)
53 static Standard_Boolean done = Standard_False;
58 if (stdApp.IsNull()) stdApp = new AppStd_Application ();//new AppStdL_Application ();
60 DPrsStd::AISPresentationCommands(theCommands);
61 DPrsStd::AISViewerCommands(theCommands);
62 //DPrsStd::BasicCommands(theCommands);
65 //==============================================================================
66 // Found standard CAF Plugin
67 //==============================================================================
68 static Standard_Boolean FoundCAFPlugin () {
70 // Define Environment Variable
72 char *plugin, *casroot, *standard;
73 plugin = getenv("CSF_PluginDefaults");
74 standard = getenv("CSF_StandardDefaults");
75 casroot = getenv("CASROOT");
76 Standard_Boolean hasPlugin = Standard_False;
77 TCollection_AsciiString PluginName ;
80 PluginName = TCollection_AsciiString (casroot);
81 PluginName+="/src/StdResource" ;
82 hasPlugin = Standard_True ;
85 PluginName = TCollection_AsciiString (plugin);
86 hasPlugin = Standard_True ;
89 OSD_Path aPath ( PluginName );
90 OSD_Directory aDir(aPath);
91 if ( aDir.Exists () ) {
92 TCollection_AsciiString PluginFileName = PluginName + "/Plugin" ;
93 OSD_File PluginFile ( PluginFileName );
94 if ( PluginFile.Exists() ) {
96 OSD_Environment PluginEnv ( "CSF_PluginDefaults" , PluginName );
98 if ( PluginEnv.Failed() ) {
99 cout << " Problem when initialise CSF_PluginDefaults whith " << PluginName.ToCString() << endl;
103 OSD_Environment StandardEnv ( "CSF_StandardDefaults" , PluginName );
104 StandardEnv .Build();
105 if ( StandardEnv.Failed() ) {
106 cout << " Problem when initialise CSF_StandardDefaults whith " << PluginName.ToCString() << endl;
110 hasPlugin = Standard_False;
113 hasPlugin = Standard_False;
118 cout << " an environement variable named : CSF_PluginDefaults is mandatory to use OCAF " <<endl;
119 Standard_Failure::Raise ( "an environement variable named : CSF_PluginDefaults is mandatory to use OCAF" );
125 //==============================================================================
127 //==============================================================================
128 void DPrsStd::Factory(Draw_Interpretor& theDI)
130 if(!FoundCAFPlugin())
133 static Standard_Boolean DPrsStdFactoryDone = Standard_False;
134 if (DPrsStdFactoryDone) return;
135 DPrsStdFactoryDone = Standard_True;
137 DDF::AllCommands(theDI);
138 DNaming::AllCommands(theDI);
139 DDataStd::AllCommands(theDI);
140 DPrsStd::AllCommands(theDI);
141 DDocStd::AllCommands(theDI);
143 cout << "Draw Plugin : All DF commands are loaded" << endl;
147 // Declare entry point PLUGINFACTORY