endif()
# 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_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
set (USE_FFMPEG OFF CACHE BOOL "${USE_FFMPEG_DESCR}")
# 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_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_OpenGlLibs CAN_USE_OPENGL)
OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlesLibs CAN_USE_GLES2)
# define CSF variable
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
+# Tcl (mandatory for Draw Harness)
if (USE_TCL)
message (STATUS "Info: TCL is used by OCCT")
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
-
- message (STATUS "Info: TK is used by OCCT")
- OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL")
- OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK")
-
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")
endif()
set aLibsMap(CSF_FREETYPE) "freetype"
}
set aLibsMap(CSF_TclLibs) "tcl8.6"
- set aLibsMap(CSF_TclTkLibs) "tk8.6"
+ if { "$::HAVE_TK" == "true" } {
+ set aLibsMap(CSF_TclTkLibs) "tk8.6"
+ }
if { "$::HAVE_FREEIMAGE" == "true" } {
if { "$theOS" == "wnt" } {
set aLibsMap(CSF_FreeImagePlus) "FreeImage"
# the naming is different on Windows
set aLibsMap(CSF_TclLibs) "tcl86"
- set aLibsMap(CSF_TclTkLibs) "tk86"
+ if { "$::HAVE_TK" == "true" } {
+ set aLibsMap(CSF_TclTkLibs) "tk86"
+ }
if { "$theRelease" == "true" } {
set aLibsMap(CSF_QT) "Qt5Gui Qt5Widgets Qt5Xml Qt5Core"
} else {
set aFrmsMap(CSF_Appkit) "AppKit"
}
set aFrmsMap(CSF_IOKit) "IOKit"
- set aFrmsMap(CSF_TclLibs) "Tcl"
set aLibsMap(CSF_TclLibs) ""
- set aFrmsMap(CSF_TclTkLibs) "Tk"
set aLibsMap(CSF_TclTkLibs) ""
+ set aFrmsMap(CSF_TclLibs) "Tcl"
+ if { "$::HAVE_TK" == "true" } {
+ set aFrmsMap(CSF_TclTkLibs) "Tk"
+ }
set aLibsMap(CSF_QT) "QtCore QtGui"
} elseif { "$theOS" == "android" } {
set aLibsMap(CSF_androidlog) "log"
# CSF_ThreadLibs - pthread API is part of libc on QNX
} else {
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_MotifLibs) "X11"
}
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Image_AlienPixMap.hxx>
+#include <Message.hxx>
#include <NCollection_List.hxx>
extern Standard_Boolean Draw_Batch;
#include <Draw_Window.hxx>
#include <unistd.h>
+#ifdef HAVE_TK
#if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
// use forward declaration for small subset of used Tk functions
// to workaround broken standard Tk framework installation within OS X SDKs
#else
#include <tk.h>
#endif
+#endif
/*
* Global variables used by the main program:
//function : WUnmapNotify
//purpose :
//=======================================================================
-
void Draw_Window::WUnmapNotify()
{
}
-
//======================================================
// function : ProcessEvents
// purpose : process pending X events
//======================================================
-
static void ProcessEvents(ClientData,int)
{
// test for X Event
+ while (XPending (Draw_WindowDisplay))
+ {
+ XEvent anEvent = {};
+ XNextEvent (Draw_WindowDisplay, &anEvent);
- while (XPending(Draw_WindowDisplay)) {
-
- XEvent xev;
- xev.type = 0;
-
- XNextEvent(Draw_WindowDisplay,&xev);
-
- /* search the window in the window list */
- Draw_Window* w = Draw_Window::firstWindow;
- Standard_Integer found=0;
- while (w) {
- if (xev.xany.window == w->win) {
- ProcessEvent(*w, xev);
- found=1;
+ // search the window in the window list
+ bool isFound = false;
+ for (Draw_Window* aWinIter = Draw_Window::firstWindow; aWinIter != NULL; aWinIter = aWinIter->next)
+ {
+ if (anEvent.xany.window == aWinIter->win)
+ {
+ ProcessEvent (*aWinIter, anEvent);
+ isFound = true;
break;
}
- w = w->next;
}
- if (found==0) {
- Tk_HandleEvent(&xev);
+ if (!isFound)
+ {
+ #ifdef _TK
+ Tk_HandleEvent (&anEvent);
+ #endif
}
}
}
// function :Run_Appli
// purpose :
//======================================================
-
-
static Standard_Boolean(*Interprete) (const char*);
void Run_Appli(Standard_Boolean (*interprete) (const char*))
{
- Tcl_Channel outChannel, inChannel ;
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.
- */
- inChannel = Tcl_GetStdChannel(TCL_STDIN);
- if (inChannel) {
- Tcl_CreateChannelHandler(inChannel, TCL_READABLE, StdinProc,
- (ClientData) inChannel);
- }
+ // 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.
+ Tcl_Channel anInChannel = Tcl_GetStdChannel(TCL_STDIN);
+ if (anInChannel)
+ {
+ Tcl_CreateChannelHandler (anInChannel, TCL_READABLE, StdinProc, (ClientData )anInChannel);
+ }
// 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 TCL_MAJOR_VERSION < 8
- Tk_CreateFileHandler((void*) ConnectionNumber(Draw_WindowDisplay),
- TK_READABLE, ProcessEvents,(ClientData) 0 );
-#else
- Tk_CreateFileHandler(ConnectionNumber(Draw_WindowDisplay),
- TK_READABLE, ProcessEvents,(ClientData) 0 );
-#endif
+ Tcl_CreateFileHandler (ConnectionNumber(Draw_WindowDisplay), TCL_READABLE, ProcessEvents, (ClientData) 0);
#endif // __APPLE__
-#endif
-
Draw_Interpretor& aCommands = Draw::GetInterpretor();
- if (tty) Prompt(aCommands.Interp(), 0);
- Prompt(aCommands.Interp(), 0);
-
- outChannel = Tcl_GetStdChannel(TCL_STDOUT);
- if (outChannel) {
- Tcl_Flush(outChannel);
- }
- Tcl_DStringInit(&command);
+ if (tty) { Prompt (aCommands.Interp(), 0); }
+ Prompt (aCommands.Interp(), 0);
- /*
- * Loop infinitely, waiting for commands to execute. When there
- * are no windows left, Tk_MainLoop returns and we exit.
- */
+ Tcl_Channel anOutChannel = Tcl_GetStdChannel(TCL_STDOUT);
+ if (anOutChannel)
+ {
+ Tcl_Flush (anOutChannel);
+ }
+ Tcl_DStringInit (&command);
#ifdef _TK
-
- if (Draw_VirtualWindows) {
+ if (Draw_VirtualWindows)
+ {
// main window will never shown
// but main loop will parse all Xlib messages
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();
-
-#else
-
- 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);
+ for (;;)
+ {
+ Tcl_DoOneEvent (0); // practically the same as Tk_MainLoop()
+ }
#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())
+ for (NCollection_List<Draw_Window::FCallbackBeforeTerminate>::Iterator anIter (MyCallbacks);
+ anIter.More(); anIter.Next())
{
- (*Iter.Value())();
+ (*anIter.Value())();
}
}
Tcl_Interp *interp = aCommands.Interp();
Tcl_Init (interp);
- try {
+#ifdef _TK
+ try
+ {
OCC_CATCH_SIGNALS
- Tk_Init(interp) ;
- } catch (Standard_Failure const&) {
- std::cout <<" Pb au lancement de TK_Init "<<std::endl;
+ Tk_Init (interp);
+ }
+ catch (Standard_Failure const& theFail)
+ {
+ Message::SendFail() << "TK_Init() failed with " << theFail;
}
Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
#endif
Tk_GeometryRequest (aMainWindow, 200, 200);
+#endif
#if !defined(__APPLE__) || defined(MACOSX_USE_GLX)
if (Draw_DisplayConnection.IsNull())
{
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;
}
}
#include <Draw_Appli.hxx>
#include <OSD.hxx>
-#include <tk.h>
+#ifdef HAVE_TK
+ #include <tk.h>
+#endif
#define PENWIDTH 1
#define CLIENTWND 0