0022312: Translation of french commentaries in OCCT files
[occt.git] / src / Draw / Draw_Main.cxx
1 // File:        Draw_Main.cxx
2 // Created:     Thu Dec 30 10:40:46 1999
3 // Author:      Roman LYGIN
4 //              <rln@burnax.nnov.matra-dtv.fr>
5
6 // *******************************************************************
7 //    RLN  06 January 2000
8 // *******************************************************************
9 // This file is built from former NTMain.pxx duplicated in many executables
10 // extending DRAW Test Harness.
11 // Now is implemented only in one instance.
12
13 // Differences between CAS.CADE versions:
14 //  - in C21 Draw_Appli is defined in Draw.cxx (DRAW UL) and calls externally
15 // defined Draw_InitAppli. Moreover, on WNT Draw_Appli was not declared as 
16 // Standard_EXPORT and therefore it has to be duplicated explicitly in this
17 // code as in Draw.cxx.
18 //  - in C30 Draw_Appli accepts Draw_InitAppli as parameter which is given to
19 // it in each executable. Draw_Appli is declared as Standard_EXPORT and
20 // therefore it needs not to be duplicated.
21   
22 // To have only one instance of this file and to call it from all the executables
23 // thereare defined macros in .hxx that replace main/WinMain functions and which
24 // calls _main_/_WinMain_ defined in this file with specified Draw_InitAppli.
25 // To avoid Unresolved symbols on WNT, Draw_InitAppli is explicitly defined in this
26 // file as simple invoker of the function statically stored in this file and which
27 // is initialized by main/_WinMain_.  
28
29 // WARNING: Although versions C21 and C30 are synchronised as much as they can,
30 // there are two versions of this file for both configurations. This is explained by:
31 // - Standard_IMPOR is differently defined,
32 // - Draw_Appli is differently declared.
33   
34
35
36 #ifdef HAVE_CONFIG_H
37 # include <config.h>
38 #endif
39
40 #ifdef HAVE_STRINGS_H
41 # include <strings.h>
42 #endif
43   
44 #ifdef WNT
45 #include <windows.h> /* SW_SHOW */
46 #endif
47
48 #include <Draw_Main.hxx>
49 #include <stdlib.h>
50 #include <string.h>
51 #include <Draw_Appli.hxx>
52 #include <OSD.hxx>
53
54 #include <tcl.h>
55
56 #ifdef WNT
57 #include <sys/stat.h>
58 #include <Draw_Window.hxx>
59
60 #include <stdio.h>
61 #include <io.h>
62 #include <fcntl.h>
63
64 extern Draw_Viewer dout;
65
66 static char* ColorNames[MAXCOLOR] = {
67   "White","Red","Green","Blue","Cyan","Gold","Magenta",
68   "Maroon","Orange","Pink","Salmon","Violet","Yellow","Khaki","Coral"
69   };
70
71 static   Standard_Boolean XLoop;
72
73 // extern Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C21
74 Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C30
75 // true if complete command
76
77 // necessary for WNT in C21 only
78 static FDraw_InitAppli theDraw_InitAppli; //pointer to the Draw_InitAppli
79 static void Draw_InitAppli(Draw_Interpretor& theCommands)
80 {
81   theDraw_InitAppli (theCommands);
82 }
83 #endif
84
85 #ifdef WNT
86 //=======================================================================
87 //NOTE: OCC11
88 //     On Windows NT, both console (UNIX-like) and windowed (classical on 
89 //     WNT, with three separated windows - input, output and graphic)
90 //     modes are supported.
91 //     Depending on compilation mode of executable (CONSOLE or WINDOWS),
92 //     either _main_ or _WinMain_ becomes entry point;
93 //     the further different behaviour of DRAW is determined by variable 
94 //     Draw_IsConsoleSubsystem which is set by _main_ only
95 //=======================================================================
96
97   
98 extern Standard_Boolean Draw_IsConsoleSubsystem;
99
100 //=======================================================================
101 //function : _main_
102 //purpose  : 
103 //=======================================================================
104
105 Standard_Integer _main_ (int argc, char* argv[], char* envp[], const FDraw_InitAppli fDraw_InitAppli)
106 {
107   Draw_IsConsoleSubsystem = Standard_True;
108   //return _WinMain_(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
109   theDraw_InitAppli = fDraw_InitAppli;
110   Standard_Boolean CONSOLE = Standard_True;
111   //ParseCommandLine(GetCommandLine());
112
113   // MKV 01.02.05
114 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
115   Tcl_FindExecutable(argv[0]);
116 #endif
117
118   Draw_Appli(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
119   return 0;
120
121 }
122
123 //=======================================================================
124 //function : _WinMain_
125 //purpose  : 
126 //=======================================================================
127
128 Standard_Integer _WinMain_ (HINSTANCE hInstance, HINSTANCE hPrevinstance, LPSTR lpCmdLine, int nCmdShow, const FDraw_InitAppli fDraw_InitAppli)
129 {
130 //  theDraw_InitAppli = fDraw_InitAppli;
131 //  ParseCommandLine (lpCmdLine);
132 //  Draw_Appli(hInstance, hPrevinstance, lpCmdLine, nCmdShow, Draw_InitAppli); // for C30;
133   return 0;
134 }
135 #else
136 //=======================================================================
137 //function : _main_
138 //purpose  : 
139 //=======================================================================
140
141 Standard_Integer _main_ (Standard_Integer argc, char* argv[], const FDraw_InitAppli fDraw_InitAppli)
142 {
143   // MKV 01.02.05
144 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
145   Tcl_FindExecutable(argv[0]);
146 #endif
147   Draw_Appli(argc, argv, fDraw_InitAppli);
148   return 0;
149 }
150 #endif
151