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 | |
03155c18 |
17 | #ifdef _WIN32 |
ad03c234 |
18 | #include <windows.h> |
7fd59977 |
19 | #endif |
20 | |
21 | #include <Draw_Main.hxx> |
22 | #include <stdlib.h> |
23 | #include <string.h> |
24 | #include <Draw_Appli.hxx> |
25 | #include <OSD.hxx> |
ad03c234 |
26 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
27 | |
28 | #include <tcl.h> |
29 | |
57c28b61 |
30 | #ifdef _WIN32 |
7fd59977 |
31 | #include <sys/stat.h> |
32 | #include <Draw_Window.hxx> |
33 | |
34 | #include <stdio.h> |
35 | #include <io.h> |
36 | #include <fcntl.h> |
37 | |
38 | extern Draw_Viewer dout; |
39 | |
7fd59977 |
40 | // extern Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C21 |
bf03eb83 |
41 | Standard_IMPORT Standard_Boolean Draw_Interprete(const char* command); //for C30 |
7fd59977 |
42 | // true if complete command |
43 | |
44 | // necessary for WNT in C21 only |
45 | static FDraw_InitAppli theDraw_InitAppli; //pointer to the Draw_InitAppli |
7fd59977 |
46 | #endif |
47 | |
57c28b61 |
48 | #ifdef _WIN32 |
cf0786da |
49 | |
7fd59977 |
50 | //======================================================================= |
51 | //NOTE: OCC11 |
52 | // On Windows NT, both console (UNIX-like) and windowed (classical on |
53 | // WNT, with three separated windows - input, output and graphic) |
54 | // modes are supported. |
55 | // Depending on compilation mode of executable (CONSOLE or WINDOWS), |
cf0786da |
56 | // either Draw_Main or Draw_WinMain becomes entry point; |
7fd59977 |
57 | // the further different behaviour of DRAW is determined by variable |
cf0786da |
58 | // Draw_IsConsoleSubsystem which is set by Draw_Main only |
7fd59977 |
59 | //======================================================================= |
60 | |
7fd59977 |
61 | extern Standard_Boolean Draw_IsConsoleSubsystem; |
62 | |
63 | //======================================================================= |
cf0786da |
64 | //function : Draw_Main |
7fd59977 |
65 | //purpose : |
66 | //======================================================================= |
67 | |
cf0786da |
68 | Standard_Integer Draw_Main (int /*argc*/, char* argv[], const FDraw_InitAppli fDraw_InitAppli) |
7fd59977 |
69 | { |
70 | Draw_IsConsoleSubsystem = Standard_True; |
7fd59977 |
71 | theDraw_InitAppli = fDraw_InitAppli; |
7fd59977 |
72 | |
8f00325d |
73 | // Set console code page to UTF-8 so that input from cin and output to cout |
74 | // pass Unicode symbols as expected |
75 | SetConsoleCP(CP_UTF8); |
76 | SetConsoleOutputCP(CP_UTF8); |
77 | |
7fd59977 |
78 | // MKV 01.02.05 |
79 | #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) |
80 | Tcl_FindExecutable(argv[0]); |
81 | #endif |
82 | |
ad03c234 |
83 | int aNbArgs = 0; |
84 | wchar_t** anArgVec = CommandLineToArgvW (GetCommandLineW(), &aNbArgs); |
85 | Draw_Appli (::GetModuleHandleW (NULL), NULL, SW_SHOW, aNbArgs, anArgVec, fDraw_InitAppli); |
86 | LocalFree (anArgVec); |
7fd59977 |
87 | return 0; |
7fd59977 |
88 | } |
89 | |
90 | //======================================================================= |
cf0786da |
91 | //function : Draw_WinMain |
7fd59977 |
92 | //purpose : |
93 | //======================================================================= |
94 | |
cf0786da |
95 | Standard_Integer Draw_WinMain (HINSTANCE hInstance, HINSTANCE hPrevinstance, LPSTR /*lpCmdLine*/, int nCmdShow, const FDraw_InitAppli fDraw_InitAppli) |
7fd59977 |
96 | { |
ad03c234 |
97 | theDraw_InitAppli = fDraw_InitAppli; |
98 | int aNbArgs = 0; |
99 | wchar_t** anArgVec = CommandLineToArgvW(GetCommandLineW(), &aNbArgs); |
100 | Draw_Appli (hInstance, hPrevinstance, nCmdShow, aNbArgs, anArgVec, fDraw_InitAppli); |
101 | LocalFree (anArgVec); |
7fd59977 |
102 | return 0; |
103 | } |
cf0786da |
104 | |
7fd59977 |
105 | #else |
cf0786da |
106 | |
7fd59977 |
107 | //======================================================================= |
cf0786da |
108 | //function : Draw_Main |
7fd59977 |
109 | //purpose : |
110 | //======================================================================= |
111 | |
cf0786da |
112 | Standard_Integer Draw_Main (Standard_Integer argc, char* argv[], const FDraw_InitAppli fDraw_InitAppli) |
7fd59977 |
113 | { |
114 | // MKV 01.02.05 |
115 | #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) |
116 | Tcl_FindExecutable(argv[0]); |
117 | #endif |
118 | Draw_Appli(argc, argv, fDraw_InitAppli); |
119 | return 0; |
120 | } |
cf0786da |
121 | |
7fd59977 |
122 | #endif |