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