1 // Created on: 1999-12-30
2 // Created by: Roman LYGIN
3 // Copyright (c) 1999-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.
22 // *******************************************************************
23 // RLN 06 January 2000
24 // *******************************************************************
25 // This file is built from former NTMain.pxx duplicated in many executables
26 // extending DRAW Test Harness.
27 // Now is implemented only in one instance.
29 // Differences between CAS.CADE versions:
30 // - in C21 Draw_Appli is defined in Draw.cxx (DRAW UL) and calls externally
31 // defined Draw_InitAppli. Moreover, on WNT Draw_Appli was not declared as
32 // Standard_EXPORT and therefore it has to be duplicated explicitly in this
33 // code as in Draw.cxx.
34 // - in C30 Draw_Appli accepts Draw_InitAppli as parameter which is given to
35 // it in each executable. Draw_Appli is declared as Standard_EXPORT and
36 // therefore it needs not to be duplicated.
38 // To have only one instance of this file and to call it from all the executables
39 // thereare defined macros in .hxx that replace main/WinMain functions and which
40 // calls _main_/_WinMain_ defined in this file with specified Draw_InitAppli.
41 // To avoid Unresolved symbols on WNT, Draw_InitAppli is explicitly defined in this
42 // is initialized by main/_WinMain_.
44 // WARNING: Although versions C21 and C30 are synchronised as much as they can,
45 // there are two versions of this file for both configurations. This is explained by:
46 // - Standard_IMPOR is differently defined,
47 // - Draw_Appli is differently declared.
60 #include <windows.h> /* SW_SHOW */
63 #include <Draw_Main.hxx>
66 #include <Draw_Appli.hxx>
73 #include <Draw_Window.hxx>
79 extern Draw_Viewer dout;
81 static char* ColorNames[MAXCOLOR] = {
82 "White","Red","Green","Blue","Cyan","Gold","Magenta",
83 "Maroon","Orange","Pink","Salmon","Violet","Yellow","Khaki","Coral"
86 static Standard_Boolean XLoop;
88 // extern Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C21
89 Standard_IMPORT Standard_Boolean Draw_Interprete(const char* command); //for C30
90 // true if complete command
92 // necessary for WNT in C21 only
93 static FDraw_InitAppli theDraw_InitAppli; //pointer to the Draw_InitAppli
94 static void Draw_InitAppli(Draw_Interpretor& theCommands)
96 theDraw_InitAppli (theCommands);
101 //=======================================================================
103 // On Windows NT, both console (UNIX-like) and windowed (classical on
104 // WNT, with three separated windows - input, output and graphic)
105 // modes are supported.
106 // Depending on compilation mode of executable (CONSOLE or WINDOWS),
107 // either _main_ or _WinMain_ becomes entry point;
108 // the further different behaviour of DRAW is determined by variable
109 // Draw_IsConsoleSubsystem which is set by _main_ only
110 //=======================================================================
113 extern Standard_Boolean Draw_IsConsoleSubsystem;
115 //=======================================================================
118 //=======================================================================
120 Standard_Integer _main_ (int /*argc*/, char* argv[], char* /*envp*/[], const FDraw_InitAppli fDraw_InitAppli)
122 Draw_IsConsoleSubsystem = Standard_True;
123 //return _WinMain_(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
124 theDraw_InitAppli = fDraw_InitAppli;
125 //ParseCommandLine(GetCommandLine());
128 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
129 Tcl_FindExecutable(argv[0]);
132 Draw_Appli(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
137 //=======================================================================
138 //function : _WinMain_
140 //=======================================================================
142 Standard_Integer _WinMain_ (HINSTANCE /*hInstance*/, HINSTANCE /*hPrevinstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/, const FDraw_InitAppli /*fDraw_InitAppli*/)
144 // theDraw_InitAppli = fDraw_InitAppli;
145 // ParseCommandLine (lpCmdLine);
146 // Draw_Appli(hInstance, hPrevinstance, lpCmdLine, nCmdShow, Draw_InitAppli); // for C30;
150 //=======================================================================
153 //=======================================================================
155 Standard_Integer _main_ (Standard_Integer argc, char* argv[], const FDraw_InitAppli fDraw_InitAppli)
158 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
159 Tcl_FindExecutable(argv[0]);
161 Draw_Appli(argc, argv, fDraw_InitAppli);