0020716: Eliminate usage of "config.h" header file
[occt.git] / src / Draw / Draw_Main.cxx
CommitLineData
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
03155c18 44#ifdef _WIN32
7fd59977 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
64extern Draw_Viewer dout;
65
66static char* ColorNames[MAXCOLOR] = {
67 "White","Red","Green","Blue","Cyan","Gold","Magenta",
68 "Maroon","Orange","Pink","Salmon","Violet","Yellow","Khaki","Coral"
69 };
70
71static Standard_Boolean XLoop;
72
73// extern Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C21
bf03eb83 74Standard_IMPORT Standard_Boolean Draw_Interprete(const char* command); //for C30
7fd59977 75// true if complete command
76
77// necessary for WNT in C21 only
78static FDraw_InitAppli theDraw_InitAppli; //pointer to the Draw_InitAppli
7fd59977 79#endif
80
81#ifdef WNT
82//=======================================================================
83//NOTE: OCC11
84// On Windows NT, both console (UNIX-like) and windowed (classical on
85// WNT, with three separated windows - input, output and graphic)
86// modes are supported.
87// Depending on compilation mode of executable (CONSOLE or WINDOWS),
88// either _main_ or _WinMain_ becomes entry point;
89// the further different behaviour of DRAW is determined by variable
90// Draw_IsConsoleSubsystem which is set by _main_ only
91//=======================================================================
92
93
94extern Standard_Boolean Draw_IsConsoleSubsystem;
95
96//=======================================================================
97//function : _main_
98//purpose :
99//=======================================================================
100
35e08fe8 101Standard_Integer _main_ (int /*argc*/, char* argv[], char* /*envp*/[], const FDraw_InitAppli fDraw_InitAppli)
7fd59977 102{
103 Draw_IsConsoleSubsystem = Standard_True;
104 //return _WinMain_(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
105 theDraw_InitAppli = fDraw_InitAppli;
7fd59977 106 //ParseCommandLine(GetCommandLine());
107
108 // MKV 01.02.05
109#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
110 Tcl_FindExecutable(argv[0]);
111#endif
112
113 Draw_Appli(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
114 return 0;
115
116}
117
118//=======================================================================
119//function : _WinMain_
120//purpose :
121//=======================================================================
122
35e08fe8 123Standard_Integer _WinMain_ (HINSTANCE /*hInstance*/, HINSTANCE /*hPrevinstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/, const FDraw_InitAppli /*fDraw_InitAppli*/)
7fd59977 124{
125// theDraw_InitAppli = fDraw_InitAppli;
126// ParseCommandLine (lpCmdLine);
127// Draw_Appli(hInstance, hPrevinstance, lpCmdLine, nCmdShow, Draw_InitAppli); // for C30;
128 return 0;
129}
130#else
131//=======================================================================
132//function : _main_
133//purpose :
134//=======================================================================
135
136Standard_Integer _main_ (Standard_Integer argc, char* argv[], const FDraw_InitAppli fDraw_InitAppli)
137{
138 // MKV 01.02.05
139#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
140 Tcl_FindExecutable(argv[0]);
141#endif
142 Draw_Appli(argc, argv, fDraw_InitAppli);
143 return 0;
144}
145#endif
146