1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0032232: Draw Harness - make Tk dependency optional

This commit is contained in:
kgv 2021-03-20 13:10:49 +03:00 committed by bugmaster
parent e76471b558
commit 87b68a0fd6
14 changed files with 126 additions and 122 deletions

View File

@ -364,6 +364,7 @@ if (MSVC)
endif() endif()
# whether use optional 3rdparty or not # whether use optional 3rdparty or not
set (USE_TK ON CACHE BOOL "${USE_TK_DESCR}")
set (USE_FREETYPE ON CACHE BOOL "${USE_FREETYPE_DESCR}") set (USE_FREETYPE ON CACHE BOOL "${USE_FREETYPE_DESCR}")
set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}") set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
set (USE_FFMPEG OFF CACHE BOOL "${USE_FFMPEG_DESCR}") set (USE_FFMPEG OFF CACHE BOOL "${USE_FFMPEG_DESCR}")
@ -501,6 +502,7 @@ endif()
# search for CSF variable in EXTERNLIB of each being used toolkit # search for CSF variable in EXTERNLIB of each being used toolkit
OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE) OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE)
OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL) OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
OCCT_IS_PRODUCT_REQUIRED (CSF_TclTkLibs CAN_USE_TK)
OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE CAN_USE_FREETYPE) OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE CAN_USE_FREETYPE)
OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_OPENGL) OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_OPENGL)
OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlesLibs CAN_USE_GLES2) OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlesLibs CAN_USE_GLES2)
@ -510,17 +512,28 @@ OCCT_IS_PRODUCT_REQUIRED (CSF_EIGEN CAN_USE_EIGEN)
# define CSF variable # define CSF variable
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf") OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
# Tcl (mandatory for Draw Harness)
if (USE_TCL) if (USE_TCL)
message (STATUS "Info: TCL is used by OCCT") message (STATUS "Info: TCL is used by OCCT")
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl") OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
message (STATUS "Info: TK is used by OCCT")
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
else() else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL") OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
OCCT_CHECK_AND_UNSET ("INSTALL_TCL") OCCT_CHECK_AND_UNSET ("INSTALL_TCL")
endif()
# Tk (optional for Draw Harness)
if (CAN_USE_TK)
if (USE_TK)
message (STATUS "Info: TK is used by OCCT")
add_definitions (-DHAVE_TK)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
OCCT_CHECK_AND_UNSET ("INSTALL_TK")
endif()
else()
OCCT_CHECK_AND_UNSET ("USE_TK")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
OCCT_CHECK_AND_UNSET ("INSTALL_TK") OCCT_CHECK_AND_UNSET ("INSTALL_TK")
endif() endif()

View File

@ -49,17 +49,27 @@ else()
set (CSF_OpenVR) set (CSF_OpenVR)
endif() endif()
# TCL/TK # TCL
if (USE_TCL) if (USE_TCL)
if (WIN32) if (WIN32)
set (CSF_TclLibs "tcl86") set (CSF_TclLibs "tcl86")
else()
if(APPLE)
set (CSF_TclLibs Tcl)
elseif(UNIX)
set (CSF_TclLibs "tcl8.6")
endif()
endif()
endif()
# TK
if (USE_TK)
if (WIN32)
set (CSF_TclTkLibs "tk86") set (CSF_TclTkLibs "tk86")
else() else()
if(APPLE) if(APPLE)
set (CSF_TclTkLibs Tk) set (CSF_TclTkLibs Tk)
set (CSF_TclLibs Tcl)
elseif(UNIX) elseif(UNIX)
set (CSF_TclLibs "tcl8.6")
set (CSF_TclTkLibs "tk8.6") set (CSF_TclTkLibs "tk8.6")
endif() endif()
endif() endif()

View File

@ -155,6 +155,9 @@ set (3RDPARTY_DIR_DESCR
third-party product have been found - corresponding CMake variables will be specified third-party product have been found - corresponding CMake variables will be specified
(VTK: 3RDPARTY_VTK_DIR, 3RDPARTY_VTK_INCLUDE_DIR, 3RDPARTY_VTK_LIBRARY_DIR)") (VTK: 3RDPARTY_VTK_DIR, 3RDPARTY_VTK_INCLUDE_DIR, 3RDPARTY_VTK_LIBRARY_DIR)")
set (USE_TK_DESCR
"Indicates whether Tk product should be used by Draw Harness for user interface")
set (USE_FREETYPE_DESCR set (USE_FREETYPE_DESCR
"Indicates whether FreeType product should be used in OCCT for text rendering using external font files") "Indicates whether FreeType product should be used in OCCT for text rendering using external font files")

View File

@ -68,8 +68,9 @@ if { [info exists ::env(SHORTCUT_HEADERS)] } {
} }
# fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name # fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name
set THE_ENV_VARIABLES {HAVE_FREETYPE HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENVR HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo BUILD_Inspector} set THE_ENV_VARIABLES {HAVE_TK HAVE_FREETYPE HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENVR HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo BUILD_Inspector}
foreach anEnvIter $THE_ENV_VARIABLES { set ${anEnvIter} "false" } foreach anEnvIter $THE_ENV_VARIABLES { set ${anEnvIter} "false" }
set HAVE_TK "true"
set HAVE_FREETYPE "true" set HAVE_FREETYPE "true"
foreach anEnvIter $THE_ENV_VARIABLES { foreach anEnvIter $THE_ENV_VARIABLES {
if { [info exists ::env(${anEnvIter})] } { if { [info exists ::env(${anEnvIter})] } {

View File

@ -1416,7 +1416,9 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
set aLibsMap(CSF_FREETYPE) "freetype" set aLibsMap(CSF_FREETYPE) "freetype"
} }
set aLibsMap(CSF_TclLibs) "tcl8.6" set aLibsMap(CSF_TclLibs) "tcl8.6"
if { "$::HAVE_TK" == "true" } {
set aLibsMap(CSF_TclTkLibs) "tk8.6" set aLibsMap(CSF_TclTkLibs) "tk8.6"
}
if { "$::HAVE_FREEIMAGE" == "true" } { if { "$::HAVE_FREEIMAGE" == "true" } {
if { "$theOS" == "wnt" } { if { "$theOS" == "wnt" } {
set aLibsMap(CSF_FreeImagePlus) "FreeImage" set aLibsMap(CSF_FreeImagePlus) "FreeImage"
@ -1472,7 +1474,9 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
# the naming is different on Windows # the naming is different on Windows
set aLibsMap(CSF_TclLibs) "tcl86" set aLibsMap(CSF_TclLibs) "tcl86"
if { "$::HAVE_TK" == "true" } {
set aLibsMap(CSF_TclTkLibs) "tk86" set aLibsMap(CSF_TclTkLibs) "tk86"
}
if { "$theRelease" == "true" } { if { "$theRelease" == "true" } {
set aLibsMap(CSF_QT) "Qt5Gui Qt5Widgets Qt5Xml Qt5Core" set aLibsMap(CSF_QT) "Qt5Gui Qt5Widgets Qt5Xml Qt5Core"
} else { } else {
@ -1501,10 +1505,12 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
set aFrmsMap(CSF_Appkit) "AppKit" set aFrmsMap(CSF_Appkit) "AppKit"
} }
set aFrmsMap(CSF_IOKit) "IOKit" set aFrmsMap(CSF_IOKit) "IOKit"
set aFrmsMap(CSF_TclLibs) "Tcl"
set aLibsMap(CSF_TclLibs) "" set aLibsMap(CSF_TclLibs) ""
set aFrmsMap(CSF_TclTkLibs) "Tk"
set aLibsMap(CSF_TclTkLibs) "" set aLibsMap(CSF_TclTkLibs) ""
set aFrmsMap(CSF_TclLibs) "Tcl"
if { "$::HAVE_TK" == "true" } {
set aFrmsMap(CSF_TclTkLibs) "Tk"
}
set aLibsMap(CSF_QT) "QtCore QtGui" set aLibsMap(CSF_QT) "QtCore QtGui"
} elseif { "$theOS" == "android" } { } elseif { "$theOS" == "android" } {
set aLibsMap(CSF_androidlog) "log" set aLibsMap(CSF_androidlog) "log"
@ -1516,7 +1522,9 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
# CSF_ThreadLibs - pthread API is part of libc on QNX # CSF_ThreadLibs - pthread API is part of libc on QNX
} else { } else {
set aLibsMap(CSF_ThreadLibs) "pthread rt" set aLibsMap(CSF_ThreadLibs) "pthread rt"
set aLibsMap(CSF_TclTkLibs) "X11 tk8.6" if { "$::HAVE_TK" == "true" } {
set aLibsMap(CSF_TclTkLibs) "tk8.6"
}
set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi" set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
set aLibsMap(CSF_MotifLibs) "X11" set aLibsMap(CSF_MotifLibs) "X11"
} }

View File

@ -17,6 +17,7 @@ set "ARCH=64"
set "VCVARS=" set "VCVARS="
set "HAVE_TBB=false" set "HAVE_TBB=false"
set "HAVE_OPENCL=false" set "HAVE_OPENCL=false"
set "HAVE_TK=true"
set "HAVE_FREETYPE=true" set "HAVE_FREETYPE=true"
set "HAVE_FREEIMAGE=false" set "HAVE_FREEIMAGE=false"
set "HAVE_FFMPEG=false" set "HAVE_FFMPEG=false"
@ -183,6 +184,7 @@ set "CSF_OPT_CMPL="
set "PRODUCTS_DEFINES=" set "PRODUCTS_DEFINES="
if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" & set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%" if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" & set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%"
if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" & set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%" if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" & set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%"
if ["%HAVE_TK%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TK" & set "CSF_DEFINES=HAVE_TK;%CSF_DEFINES%"
if ["%HAVE_FREETYPE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREETYPE;%CSF_DEFINES%" if ["%HAVE_FREETYPE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREETYPE;%CSF_DEFINES%"
if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%" if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%"
if ["%HAVE_FFMPEG%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FFMPEG" & set "CSF_DEFINES=HAVE_FFMPEG;%CSF_DEFINES%" if ["%HAVE_FFMPEG%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FFMPEG" & set "CSF_DEFINES=HAVE_FFMPEG;%CSF_DEFINES%"

View File

@ -9,6 +9,7 @@ export CASDEB=""
export PRJFMT=""; export PRJFMT="";
export HAVE_TBB="false"; export HAVE_TBB="false";
export HAVE_OPENCL="false"; export HAVE_OPENCL="false";
export HAVE_TK="true";
export HAVE_FREETYPE="true"; export HAVE_FREETYPE="true";
export HAVE_FREEIMAGE="false"; export HAVE_FREEIMAGE="false";
export HAVE_FFMPEG="false"; export HAVE_FFMPEG="false";
@ -101,6 +102,7 @@ export CSF_OPT_CMPL=""
# Optiona 3rd-parties should be enabled by HAVE macros # Optiona 3rd-parties should be enabled by HAVE macros
if [ "$HAVE_TBB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_TBB"; fi if [ "$HAVE_TBB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_TBB"; fi
if [ "$HAVE_OPENCL" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENCL"; fi if [ "$HAVE_OPENCL" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENCL"; fi
if [ "$HAVE_TK" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_TK"; fi
if [ "$HAVE_FREETYPE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREETYPE"; fi if [ "$HAVE_FREETYPE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREETYPE"; fi
if [ "$HAVE_FREEIMAGE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREEIMAGE"; fi if [ "$HAVE_FREEIMAGE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREEIMAGE"; fi
if [ "$HAVE_FFMPEG" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FFMPEG"; fi if [ "$HAVE_FFMPEG" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FFMPEG"; fi

View File

@ -343,6 +343,11 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
#elif defined(_DEBUG) #elif defined(_DEBUG)
di << "Debug mode\n"; di << "Debug mode\n";
#endif #endif
#ifdef HAVE_TK
di << "Tk enabled (HAVE_TK)\n";
#else
di << "Tk disabled\n";
#endif
#ifdef HAVE_TBB #ifdef HAVE_TBB
di << "TBB enabled (HAVE_TBB)\n"; di << "TBB enabled (HAVE_TBB)\n";
#else #else

View File

@ -28,6 +28,7 @@
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx> #include <TCollection_ExtendedString.hxx>
#include <Image_AlienPixMap.hxx> #include <Image_AlienPixMap.hxx>
#include <Message.hxx>
#include <NCollection_List.hxx> #include <NCollection_List.hxx>
extern Standard_Boolean Draw_Batch; extern Standard_Boolean Draw_Batch;
@ -109,6 +110,7 @@ defaultPrompt:
#include <Draw_Window.hxx> #include <Draw_Window.hxx>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_TK
#if defined(__APPLE__) && !defined(MACOSX_USE_GLX) #if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
// use forward declaration for small subset of used Tk functions // use forward declaration for small subset of used Tk functions
// to workaround broken standard Tk framework installation within OS X SDKs // to workaround broken standard Tk framework installation within OS X SDKs
@ -127,6 +129,7 @@ defaultPrompt:
#else #else
#include <tk.h> #include <tk.h>
#endif #endif
#endif
/* /*
* Global variables used by the main program: * Global variables used by the main program:
@ -926,41 +929,38 @@ void Draw_Window::WConfigureNotify(const Standard_Integer,
//function : WUnmapNotify //function : WUnmapNotify
//purpose : //purpose :
//======================================================================= //=======================================================================
void Draw_Window::WUnmapNotify() void Draw_Window::WUnmapNotify()
{ {
} }
//====================================================== //======================================================
// function : ProcessEvents // function : ProcessEvents
// purpose : process pending X events // purpose : process pending X events
//====================================================== //======================================================
static void ProcessEvents(ClientData,int) static void ProcessEvents(ClientData,int)
{ {
// test for X Event // test for X Event
while (XPending (Draw_WindowDisplay))
{
XEvent anEvent = {};
XNextEvent (Draw_WindowDisplay, &anEvent);
while (XPending(Draw_WindowDisplay)) { // search the window in the window list
bool isFound = false;
XEvent xev; for (Draw_Window* aWinIter = Draw_Window::firstWindow; aWinIter != NULL; aWinIter = aWinIter->next)
xev.type = 0; {
if (anEvent.xany.window == aWinIter->win)
XNextEvent(Draw_WindowDisplay,&xev); {
ProcessEvent (*aWinIter, anEvent);
/* search the window in the window list */ isFound = true;
Draw_Window* w = Draw_Window::firstWindow;
Standard_Integer found=0;
while (w) {
if (xev.xany.window == w->win) {
ProcessEvent(*w, xev);
found=1;
break; break;
} }
w = w->next;
} }
if (found==0) { if (!isFound)
Tk_HandleEvent(&xev); {
#ifdef _TK
Tk_HandleEvent (&anEvent);
#endif
} }
} }
} }
@ -998,96 +998,59 @@ void GetNextEvent(Event& ev)
// function :Run_Appli // function :Run_Appli
// purpose : // purpose :
//====================================================== //======================================================
static Standard_Boolean(*Interprete) (const char*); static Standard_Boolean(*Interprete) (const char*);
void Run_Appli(Standard_Boolean (*interprete) (const char*)) void Run_Appli(Standard_Boolean (*interprete) (const char*))
{ {
Tcl_Channel outChannel, inChannel ;
Interprete = interprete; Interprete = interprete;
#ifdef _TK // Commands will come from standard input, so set up an event handler for standard input.
// If the input device is aEvaluate the .rc file, if one has been specified,
/* // set up an event handler for standard input, and print a prompt if the input device is a terminal.
* Commands will come from standard input, so set up an event Tcl_Channel anInChannel = Tcl_GetStdChannel(TCL_STDIN);
* handler for standard input. If the input device is aEvaluate the if (anInChannel)
* .rc file, if one has been specified, set up an event handler {
* for standard input, and print a prompt if the input Tcl_CreateChannelHandler (anInChannel, TCL_READABLE, StdinProc, (ClientData )anInChannel);
* device is a terminal.
*/
inChannel = Tcl_GetStdChannel(TCL_STDIN);
if (inChannel) {
Tcl_CreateChannelHandler(inChannel, TCL_READABLE, StdinProc,
(ClientData) inChannel);
} }
// Create a handler for the draw display // Create a handler for the draw display
// Adding of the casting into void* to be able to compile on AO1
// ConnectionNumber(Draw_WindowDisplay) is an int 32 bits
// (void*) is a pointer 64 bits ???????
#if !defined(__APPLE__) || defined(MACOSX_USE_GLX) #if !defined(__APPLE__) || defined(MACOSX_USE_GLX)
#if TCL_MAJOR_VERSION < 8 Tcl_CreateFileHandler (ConnectionNumber(Draw_WindowDisplay), TCL_READABLE, ProcessEvents, (ClientData) 0);
Tk_CreateFileHandler((void*) ConnectionNumber(Draw_WindowDisplay),
TK_READABLE, ProcessEvents,(ClientData) 0 );
#else
Tk_CreateFileHandler(ConnectionNumber(Draw_WindowDisplay),
TK_READABLE, ProcessEvents,(ClientData) 0 );
#endif
#endif // __APPLE__ #endif // __APPLE__
#endif
Draw_Interpretor& aCommands = Draw::GetInterpretor(); Draw_Interpretor& aCommands = Draw::GetInterpretor();
if (tty) Prompt(aCommands.Interp(), 0); if (tty) { Prompt (aCommands.Interp(), 0); }
Prompt (aCommands.Interp(), 0); Prompt (aCommands.Interp(), 0);
outChannel = Tcl_GetStdChannel(TCL_STDOUT); Tcl_Channel anOutChannel = Tcl_GetStdChannel(TCL_STDOUT);
if (outChannel) { if (anOutChannel)
Tcl_Flush(outChannel); {
Tcl_Flush (anOutChannel);
} }
Tcl_DStringInit (&command); Tcl_DStringInit (&command);
/*
* Loop infinitely, waiting for commands to execute. When there
* are no windows left, Tk_MainLoop returns and we exit.
*/
#ifdef _TK #ifdef _TK
if (Draw_VirtualWindows)
if (Draw_VirtualWindows) { {
// main window will never shown // main window will never shown
// but main loop will parse all Xlib messages // but main loop will parse all Xlib messages
Tcl_Eval(aCommands.Interp(), "wm withdraw ."); Tcl_Eval(aCommands.Interp(), "wm withdraw .");
} }
// Loop infinitely, waiting for commands to execute.
// When there are no windows left, Tk_MainLoop returns and we exit.
Tk_MainLoop(); Tk_MainLoop();
#else #else
for (;;)
fd_set readset;
Standard_Integer count = ConnectionNumber(Draw_WindowDisplay);
Standard_Integer numfd;
while (1) {
FD_ZERO(&readset);
FD_SET(0,&readset);
FD_SET(count,&readset);
#ifdef HPUX
numfd = select(count+1,(Integer*)&readset,NULL,NULL,NULL);
#else
numfd = select(count+1,&readset,NULL,NULL,NULL);
#endif
if (FD_ISSET(0,&readset)) StdinProc((ClientData)0,0);
if (FD_ISSET(count,&readset)) ProcessEvents((ClientData)0,0);
}
#endif
NCollection_List<Draw_Window::FCallbackBeforeTerminate>::Iterator Iter(MyCallbacks);
for(; Iter.More(); Iter.Next())
{ {
(*Iter.Value())(); Tcl_DoOneEvent (0); // practically the same as Tk_MainLoop()
}
#endif
for (NCollection_List<Draw_Window::FCallbackBeforeTerminate>::Iterator anIter (MyCallbacks);
anIter.More(); anIter.Next())
{
(*anIter.Value())();
} }
} }
@ -1102,11 +1065,15 @@ Standard_Boolean Init_Appli()
Tcl_Interp *interp = aCommands.Interp(); Tcl_Interp *interp = aCommands.Interp();
Tcl_Init (interp); Tcl_Init (interp);
try { #ifdef _TK
try
{
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
Tk_Init (interp); Tk_Init (interp);
} catch (Standard_Failure const&) { }
std::cout <<" Pb au lancement de TK_Init "<<std::endl; catch (Standard_Failure const& theFail)
{
Message::SendFail() << "TK_Init() failed with " << theFail;
} }
Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL); Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
@ -1127,6 +1094,7 @@ Standard_Boolean Init_Appli()
#endif #endif
Tk_GeometryRequest (aMainWindow, 200, 200); Tk_GeometryRequest (aMainWindow, 200, 200);
#endif
#if !defined(__APPLE__) || defined(MACOSX_USE_GLX) #if !defined(__APPLE__) || defined(MACOSX_USE_GLX)
if (Draw_DisplayConnection.IsNull()) if (Draw_DisplayConnection.IsNull())
@ -1135,9 +1103,9 @@ Standard_Boolean Init_Appli()
{ {
Draw_DisplayConnection = new Aspect_DisplayConnection(); Draw_DisplayConnection = new Aspect_DisplayConnection();
} }
catch (Standard_Failure const&) catch (Standard_Failure const& theFail)
{ {
std::cout << "Cannot open display. Interpret commands in batch mode." << std::endl; std::cout << "Cannot open display (" << theFail << "). Interpret commands in batch mode." << std::endl;
return Standard_False; return Standard_False;
} }
} }
@ -1313,7 +1281,9 @@ prompt:
#include <Draw_Appli.hxx> #include <Draw_Appli.hxx>
#include <OSD.hxx> #include <OSD.hxx>
#ifdef HAVE_TK
#include <tk.h> #include <tk.h>
#endif
#define PENWIDTH 1 #define PENWIDTH 1
#define CLIENTWND 0 #define CLIENTWND 0

View File

@ -83,7 +83,6 @@
#include <Xw_Window.hxx> #include <Xw_Window.hxx>
#include <vtkXRenderWindowInteractor.h> #include <vtkXRenderWindowInteractor.h>
#include <vtkXOpenGLRenderWindow.h> #include <vtkXOpenGLRenderWindow.h>
#include <tk.h>
#endif #endif
#include <Standard_WarningsRestore.hxx> #include <Standard_WarningsRestore.hxx>

View File

@ -202,13 +202,8 @@ void IVtkDraw_Interactor::Enable()
SetWindowLongPtr(this->myWindowId, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtr(this->myWindowId, GWLP_USERDATA, (LONG_PTR)this);
SetWindowLongPtr(this->myWindowId, GWLP_WNDPROC, (LONG_PTR)WndProc); SetWindowLongPtr(this->myWindowId, GWLP_WNDPROC, (LONG_PTR)WndProc);
#else #else
#if TCL_MAJOR_VERSION < 8 Tcl_CreateFileHandler (ConnectionNumber(this->myDisplayId),
Tk_CreateFileHandler((void*)ConnectionNumber(this->myDisplayId), TCL_READABLE, ProcessEvents, (ClientData) this);
TK_READABLE, ProcessEvents, (ClientData) this);
#else
Tk_CreateFileHandler(ConnectionNumber(this->myDisplayId),
TK_READABLE, ProcessEvents, (ClientData) this);
#endif
#endif #endif
this->Enabled = 1; this->Enabled = 1;

View File

@ -1,6 +1,5 @@
CSF_VTK CSF_VTK
CSF_TclLibs CSF_TclLibs
CSF_TclTkLibs
CSF_XwLibs CSF_XwLibs
CSF_user32 CSF_user32
TKernel TKernel

View File

@ -18,7 +18,6 @@ TKMesh
TKV3d TKV3d
TKDraw TKDraw
CSF_TclLibs CSF_TclLibs
CSF_TclTkLibs
CSF_XwLibs CSF_XwLibs
CSF_user32 CSF_user32
CSF_gdi32 CSF_gdi32

View File

@ -107,7 +107,6 @@
#include <Xw_Window.hxx> #include <Xw_Window.hxx>
#include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */ #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <tk.h>
#endif #endif
//============================================================================== //==============================================================================
@ -2086,9 +2085,8 @@ static int VDriver (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const c
//============================================================================== //==============================================================================
//function : Vinit //function : Vinit
//purpose : Create the window viewer and initialize all the global variable //purpose : Create the window viewer and initialize all the global variable
// Use Tk_CreateFileHandler on UNIX to catch the X11 Viewer event // Use Tcl_CreateFileHandler on UNIX to catch the X11 Viewer event
//============================================================================== //==============================================================================
static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
{ {
TCollection_AsciiString aViewName, aDisplayName; TCollection_AsciiString aViewName, aDisplayName;