Commit 1d163252 authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

ENH: Add support for building without Tk. Add option VTK_USE_TK which is ON by...

ENH: Add support for building without Tk. Add option VTK_USE_TK which is ON by default. On cocoa disable this. Also, this way you can do off-screen only testing. Add an option to do off screen testing called VTK_USE_OFFSCREEN
parent 79fbe460
......@@ -860,6 +860,13 @@ VTK_DEPENDENT_OPTION(VTK_USE_MANGLED_MESA "Use mangled Mesa with OpenGL." OFF
VTK_DEPENDENT_OPTION(VTK_OPENGL_HAS_OSMESA
"The opengl library being used supports off screen Mesa calls." OFF
"VTK_USE_RENDERING;UNIX" OFF)
SET(VTK_CAN_DO_OFF_SCREEN)
IF(VTK_USE_MANGLED_MESA OR VTK_OPENGL_HAS_OSMESA)
SET(VTK_CAN_DO_OFF_SCREEN 1)
ENDIF(VTK_USE_MANGLED_MESA OR VTK_OPENGL_HAS_OSMESA)
VTK_DEPENDENT_OPTION(VTK_USE_OFFSCREEN
"The opengl library being used supports off screen Mesa calls." OFF
"VTK_CAN_DO_OFF_SCREEN" OFF)
VTK_DEPENDENT_OPTION(VTK_USE_MPI
"Use Message Passing Interface (MPI) library for parallel support." OFF
"VTK_USE_PARALLEL" OFF)
......@@ -872,7 +879,20 @@ VTK_DEPENDENT_OPTION(VTK_USE_VIDEO_FOR_WINDOWS
VTK_DEPENDENT_OPTION(VTK_USE_GL2PS "Build VTK with gl2ps support." OFF
"VTK_USE_RENDERING" ON)
SET(VTK_CAN_USE_TK)
IF(VTK_WRAP_PYTHON OR VTK_WRAP_TCL)
IF(NOT VTK_USE_COCOA)
IF(NOT VTK_DISABLE_TK_INIT)
SET(VTK_CAN_USE_TK 1)
ENDIF(NOT VTK_DISABLE_TK_INIT)
ENDIF(NOT VTK_USE_COCOA)
ENDIF(VTK_WRAP_PYTHON OR VTK_WRAP_TCL)
VTK_DEPENDENT_OPTION(VTK_USE_TK "Build VTK with Tk support" ON
"VTK_CAN_USE_TK" OFF)
MARK_AS_ADVANCED(VTK_OPENGL_HAS_OSMESA
VTK_USE_OFFSCREEN
VTK_USE_TK
VTK_USE_GL2PS
VTK_USE_MANGLED_MESA
VTK_USE_MATROX_IMAGING
......@@ -1114,9 +1134,9 @@ IF(VTK_WRAP_TCL OR VTK_WRAP_PYTHON)
SET(VTK_INCLUDE_NEED_TCL 1)
ENDIF(VTK_USE_RENDERING OR VTK_WRAP_TCL)
IF(VTK_USE_RENDERING)
SET(VTK_INCLUDE_NEED_TK 1)
SET(VTK_DISABLE_TK_INIT ${VTK_USE_COCOA} CACHE INTERNAL
"Disables the automatic initialization of Tk widgets when loading the rendering library.")
IF(VTK_USE_TK)
SET(VTK_INCLUDE_NEED_TK 1)
ENDIF(VTK_USE_TK)
ENDIF(VTK_USE_RENDERING)
ENDIF(VTK_WRAP_TCL OR VTK_WRAP_PYTHON)
......@@ -1138,9 +1158,6 @@ ENDIF(VTK_INCLUDE_NEED_TK)
# Need Tk internal headers for Tk initialization.
SET(VTK_RENDERING_NEED_TK_INTERNAL ${VTK_INCLUDE_NEED_TK})
IF(VTK_DISABLE_TK_INIT)
SET(VTK_RENDERING_NEED_TK_INTERNAL 0)
ENDIF(VTK_DISABLE_TK_INIT)
IF(VTK_INCLUDE_NEED_TK)
# Need Tk Internal headers to include tk.h on Cocoa
......
......@@ -14,14 +14,20 @@
=========================================================================*/
#include "vtkWindow.h"
vtkCxxRevisionMacro(vtkWindow, "1.26");
#include "vtkToolkits.h"
vtkCxxRevisionMacro(vtkWindow, "1.27");
// Construct an instance of vtkRenderWindow with its screen size
// set to 300x300, borders turned on, positioned at (0,0), double
// buffering turned on.
vtkWindow::vtkWindow()
{
#ifdef VTK_USE_OFFSCREEN
this->OffScreenRendering = 1;
#else
this->OffScreenRendering = 0;
#endif
this->Size[0] = this->Size[1] = 0;
this->Position[0] = this->Position[1] = 0;
this->Mapped = 0;
......
......@@ -20,7 +20,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
-V Baseline/Filtering/${tfile}.png
-A ${VTK_SOURCE_DIR}/Wrapping/Tcl)
ENDFOREACH( tfile )
IF(NOT VTK_USE_COCOA)
IF(VTK_USE_TK)
ADD_TEST(squadViewer-image ${VTK_EXECUTABLE}
${VTK_SOURCE_DIR}/Common/Testing/Tcl/rtImageTest.tcl
${VTK_SOURCE_DIR}/Filtering/Testing/Tcl/squadViewer.tcl
......@@ -28,7 +28,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
-T ${VTK_BINARY_DIR}/Testing/Temporary
-V Baseline/Filtering/squadViewer.png
-A ${VTK_SOURCE_DIR}/Wrapping/Tcl)
ENDIF(NOT VTK_USE_COCOA)
ENDIF(VTK_USE_TK)
#
# If we do not have the data, still run the tests that we can
#
......
......@@ -358,6 +358,7 @@ SET(KIT_TCL_DEPS)
SET(KIT_PYTHON_DEPS)
SET(KIT_JAVA_DEPS)
IF(NOT VTK_USE_OFFSCREEN)
IF (TK_LIBRARY)
SET (HAVE_LIMITS_H ${CMAKE_HAVE_LIMITS_H})
SET (HAVE_UNISTD_H ${CMAKE_HAVE_UNISTD_H})
......@@ -370,29 +371,27 @@ IF (TK_LIBRARY)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
ENDIF (TK_LIBRARY)
ENDIF(NOT VTK_USE_OFFSCREEN)
IF (VTK_WRAP_TCL)
IF(NOT VTK_USE_COCOA)
SET(KitTCL_SRCS
vtkTkRenderWidget.cxx
vtkTkImageViewerWidget.cxx)
IF(NOT VTK_USE_OFFSCREEN)
SET(KitTCL_SRCS
vtkTkRenderWidget.cxx
vtkTkImageViewerWidget.cxx)
ENDIF(NOT VTK_USE_OFFSCREEN)
ENDIF(NOT VTK_USE_COCOA)
# Use special interactor for X and Tk.
IF(VTK_USE_X)
SET(KitTCL_SRCS ${KitTCL_SRCS}
vtkXRenderWindowTclInteractor.cxx)
ENDIF(VTK_USE_X)
# if VTK_DISABLE_TK_INIT is not defined, then those widgets *will* be
# initialized by the Rendering kit. If *not* defined we need to do it
# manually when needed (for example, in vtkTkAppInit so that
# we can use them from the vtk executable
IF (NOT VTK_DISABLE_TK_INIT)
SET(Kit_TCL_EXTRA_CMDS
vtkTkRenderWidget
vtkTkImageViewerWidget)
ENDIF (NOT VTK_DISABLE_TK_INIT)
IF (VTK_USE_TK)
# Use special interactor for X and Tk.
IF(VTK_USE_X)
SET(KitTCL_SRCS ${KitTCL_SRCS}
vtkXRenderWindowTclInteractor.cxx)
ENDIF(VTK_USE_X)
SET(Kit_TCL_EXTRA_CMDS
vtkTkRenderWidget
vtkTkImageViewerWidget)
ENDIF (VTK_USE_TK)
ENDIF (VTK_WRAP_TCL)
#-----------------------------------------------------------------------------
......@@ -407,8 +406,8 @@ IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
IF (VTK_WRAP_PYTHON)
IF (TK_LIBRARY)
IF(NOT VTK_USE_COCOA)
IF(VTK_USE_TK)
IF (TK_LIBRARY)
SET(RenderingPythonTkWidgets_SRCS
vtkTkWidgetsInit.cxx
vtkTkRenderWidgetPython.cxx
......@@ -429,8 +428,8 @@ IF (VTK_WRAP_PYTHON)
IF(NOT VTK_INSTALL_NO_LIBRARIES)
INSTALL_TARGETS(${VTK_INSTALL_LIB_DIR} vtkRenderingPythonTkWidgets)
ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
ENDIF(NOT VTK_USE_COCOA)
ENDIF (TK_LIBRARY)
ENDIF (TK_LIBRARY)
ENDIF(VTK_USE_TK)
ENDIF (VTK_WRAP_PYTHON)
IF(VTK_USE_X)
......
......@@ -5,7 +5,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
#
IF (VTK_DATA_ROOT)
IF (VTK_PYTHON_EXE)
IF(NOT VTK_USE_COCOA)
IF(VTK_USE_TK)
FOREACH ( tfile
TestTkRenderWidget
TestTkRenderWindowInteractor
......@@ -15,7 +15,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
-B ${VTK_DATA_ROOT}/Baseline/Rendering
-D ${VTK_DATA_ROOT}/Data)
ENDFOREACH( tfile )
ENDIF(NOT VTK_USE_COCOA)
ENDIF(VTK_USE_TK)
#############################
# Add GL2PS specific tests.
......
......@@ -76,9 +76,16 @@
#include "stdlib.h"
static vtkSimpleCriticalSection vtkUseMesaClassesCriticalSection;
static vtkSimpleCriticalSection vtkOffScreenOnlyModeCriticalSection;
int vtkGraphicsFactory::UseMesaClasses = 0;
vtkCxxRevisionMacro(vtkGraphicsFactory, "1.37");
#ifdef VTK_USE_OFFSCREEN
int vtkGraphicsFactory::OffScreenOnlyMode = 1;
#else
int vtkGraphicsFactory::OffScreenOnlyMode = 0;
#endif
vtkCxxRevisionMacro(vtkGraphicsFactory, "1.38");
vtkStandardNewMacro(vtkGraphicsFactory);
const char *vtkGraphicsFactory::GetRenderLibrary()
......@@ -157,16 +164,22 @@ vtkObject* vtkGraphicsFactory::CreateInstance(const char* vtkclassname )
return vtkXOpenGLRenderWindow::New();
}
}
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
if ( !vtkGraphicsFactory::GetOffScreenOnlyMode() )
{
return vtkXRenderWindowInteractor::New();
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
{
return vtkXRenderWindowInteractor::New();
}
}
#endif
#ifdef VTK_DISPLAY_WIN32_OGL
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
if ( !vtkGraphicsFactory::GetOffScreenOnlyMode() )
{
return vtkWin32RenderWindowInteractor::New();
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
{
return vtkWin32RenderWindowInteractor::New();
}
}
if (!strcmp("Win32OpenGL",rl))
{
......@@ -178,9 +191,12 @@ vtkObject* vtkGraphicsFactory::CreateInstance(const char* vtkclassname )
#endif
#ifdef VTK_USE_CARBON
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
if ( !vtkGraphicsFactory::GetOffScreenOnlyMode() )
{
return vtkCarbonRenderWindowInteractor::New();
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
{
return vtkCarbonRenderWindowInteractor::New();
}
}
if(strcmp(vtkclassname, "vtkRenderWindow") == 0)
{
......@@ -188,9 +204,12 @@ vtkObject* vtkGraphicsFactory::CreateInstance(const char* vtkclassname )
}
#endif
#ifdef VTK_USE_COCOA
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
if ( !vtkGraphicsFactory::GetOffScreenOnlyMode() )
{
return vtkCocoaRenderWindowInteractor::New();
if(strcmp(vtkclassname, "vtkRenderWindowInteractor") == 0)
{
return vtkCocoaRenderWindowInteractor::New();
}
}
if(strcmp(vtkclassname, "vtkRenderWindow") == 0)
{
......@@ -287,6 +306,7 @@ vtkObject* vtkGraphicsFactory::CreateInstance(const char* vtkclassname )
return 0;
}
//----------------------------------------------------------------------------
void vtkGraphicsFactory::SetUseMesaClasses(int use)
{
vtkUseMesaClassesCriticalSection.Lock();
......@@ -294,11 +314,26 @@ void vtkGraphicsFactory::SetUseMesaClasses(int use)
vtkUseMesaClassesCriticalSection.Unlock();
}
//----------------------------------------------------------------------------
int vtkGraphicsFactory::GetUseMesaClasses()
{
return vtkGraphicsFactory::UseMesaClasses;
}
//----------------------------------------------------------------------------
void vtkGraphicsFactory::SetOffScreenOnlyMode(int use)
{
vtkOffScreenOnlyModeCriticalSection.Lock();
vtkGraphicsFactory::OffScreenOnlyMode = use;
vtkOffScreenOnlyModeCriticalSection.Unlock();
}
//----------------------------------------------------------------------------
int vtkGraphicsFactory::GetOffScreenOnlyMode()
{
return vtkGraphicsFactory::OffScreenOnlyMode;
}
//----------------------------------------------------------------------------
void vtkGraphicsFactory::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -43,10 +43,17 @@ public:
static void SetUseMesaClasses(int use);
static int GetUseMesaClasses();
// Description:
// This option enables the off-screen only mode. In this mode no X calls will
// be made even when interactor is used.
static void SetOffScreenOnlyMode(int use);
static int GetOffScreenOnlyMode();
protected:
vtkGraphicsFactory() {};
static int UseMesaClasses;
static int OffScreenOnlyMode;
private:
vtkGraphicsFactory(const vtkGraphicsFactory&); // Not implemented.
......
......@@ -23,8 +23,9 @@
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRendererCollection.h"
#include "vtkDebugLeaks.h"
vtkCxxRevisionMacro(vtkRenderWindowInteractor, "1.107");
vtkCxxRevisionMacro(vtkRenderWindowInteractor, "1.108");
//----------------------------------------------------------------------------
// Needed when we don't use the vtkStandardNewMacro.
......@@ -92,7 +93,14 @@ vtkRenderWindowInteractor *vtkRenderWindowInteractor::New()
// First try to create the object from the vtkObjectFactory
vtkObject* ret =
vtkGraphicsFactory::CreateInstance("vtkRenderWindowInteractor");
return (vtkRenderWindowInteractor *)ret;
if ( ret )
{
return (vtkRenderWindowInteractor *)ret;
}
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkRenderWindowInteractor");
#endif
return new vtkRenderWindowInteractor;
}
void vtkRenderWindowInteractor::Render()
......
......@@ -84,7 +84,7 @@ vtkXOpenGLRenderWindowInternal::vtkXOpenGLRenderWindowInternal(
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkXOpenGLRenderWindow, "1.53");
vtkCxxRevisionMacro(vtkXOpenGLRenderWindow, "1.54");
vtkStandardNewMacro(vtkXOpenGLRenderWindow);
#endif
......@@ -973,6 +973,12 @@ int vtkXOpenGLRenderWindow::GetEventPending()
XEvent report;
vtkXOpenGLRenderWindowFoundMatch = 0;
#if defined(VTK_OPENGL_HAS_OSMESA)
if (this->OffScreenRendering)
{
return vtkXOpenGLRenderWindowFoundMatch;
}
#endif
XCheckIfEvent(this->DisplayId, &report, vtkXOpenGLRenderWindowPredProc,
(char *)this->WindowId);
return vtkXOpenGLRenderWindowFoundMatch;
......
......@@ -55,7 +55,7 @@ SET(VTK_LANGUAGES "@VTK_LANGUAGES@")
# VTK Configuration options.
SET(VTK_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
SET(VTK_DEBUG_LEAKS "@VTK_DEBUG_LEAKS@")
SET(VTK_DISABLE_TK_INIT "@VTK_DISABLE_TK_INIT@")
SET(VTK_USE_TK "@VTK_USE_TK@")
SET(VTK_HAVE_VP1000 "@VTK_HAVE_VP1000@")
SET(VTK_USE_MANGLED_MESA "@VTK_USE_MANGLED_MESA@")
SET(VTK_MPIRUN_EXE "@VTK_MPIRUN_EXE_CONFIG@")
......
......@@ -28,7 +28,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
-V Baseline/VolumeRendering/${tfile}.png
-A ${VTK_SOURCE_DIR}/Wrapping/Tcl)
ENDFOREACH( tfile )
IF(NOT VTK_USE_COCOA)
IF(VTK_USE_TK)
ADD_TEST(imageCursor3D-image ${VTK_EXECUTABLE}
${VTK_SOURCE_DIR}/Common/Testing/Tcl/rtImageTest.tcl
${VTK_SOURCE_DIR}/VolumeRendering/Testing/Tcl/cursor3D.tcl
......@@ -36,7 +36,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
-T ${VTK_BINARY_DIR}/Testing/Temporary
-V Baseline/VolumeRendering/cursor3D.png
-A ${VTK_SOURCE_DIR}/Wrapping/Tcl)
ENDIF(NOT VTK_USE_COCOA)
ENDIF(VTK_USE_TK)
#
# If we do not have the data, still run the tests that we can
#
......
......@@ -39,7 +39,7 @@ PURPOSE. See the above copyright notice for more information.
#include <sys/stat.h>
#endif
#ifdef VTK_USE_RENDERING
#ifndef VTK_USE_TK
# include "vtkTk.h"
#else
# include "vtkTcl.h"
......@@ -141,7 +141,7 @@ main(int argc, char **argv)
vtkstd::string av0 = vtksys::SystemTools::CollapseFullPath(argv[0]);
Tcl_FindExecutable(av0.c_str());
#ifdef VTK_USE_RENDERING
#ifndef VTK_USE_TK
Tk_Main(argc, argv, Tcl_AppInit);
#else
Tcl_Main(argc, argv, Tcl_AppInit);
......@@ -179,12 +179,7 @@ extern "C" int Vtkiotcl_Init(Tcl_Interp *interp);
#ifdef VTK_USE_RENDERING
extern "C" int Vtkrenderingtcl_Init(Tcl_Interp *interp);
// if VTK_DISABLE_TK_INIT is defined, then those widgets were *not*
// initialized by the Rendering kit, thus we need to do it here so
// that we can use them from the vtk executable
// Also, Cocoa does not suport those widgets yet
#if defined(VTK_DISABLE_TK_INIT) && !defined(VTK_USE_COCOA)
#if defined(VTK_USE_TK)
extern "C" int Vtktkrenderwidget_Init(Tcl_Interp *interp);
extern "C" int Vtktkimageviewerwidget_Init(Tcl_Interp *interp);
#endif
......@@ -387,7 +382,7 @@ int Tcl_AppInit(Tcl_Interp *interp)
return TCL_ERROR;
}
#ifdef VTK_USE_RENDERING
#ifndef VTK_USE_TK
if (Tk_Init(interp) == TCL_ERROR)
{
return TCL_ERROR;
......@@ -422,12 +417,7 @@ int Tcl_AppInit(Tcl_Interp *interp)
return TCL_ERROR;
}
// if VTK_DISABLE_TK_INIT is defined, then those widgets were *not*
// initialized by the Rendering kit, thus we need to do it here so
// that we can use them from the vtk executable
// Also, Cocoa does not suport those widgets yet
#if defined(VTK_DISABLE_TK_INIT) && !defined(VTK_USE_COCOA)
#if defined(VTK_USE_TK)
if (Vtktkrenderwidget_Init(interp) == TCL_ERROR)
{
return TCL_ERROR;
......
......@@ -732,13 +732,13 @@ void vtkParseOutput(FILE *fp, FileInfo *data)
if (strcmp(data->ClassName, "vtkRenderWindowInteractor") == 0)
{
fprintf(fp,"#include \"vtkToolkits.h\"\n");
fprintf(fp,"#ifdef VTK_USE_X\n");
fprintf(fp,"#if defined( VTK_USE_X ) && !defined( VTK_USE_TK )\n");
fprintf(fp,"# include \"vtkXRenderWindowTclInteractor.h\"\n");
fprintf(fp,"#endif\n");
fprintf(fp,"\nClientData %sNewCommand()\n{\n",data->ClassName);
fprintf(fp,"#ifdef VTK_USE_X\n");
fprintf(fp,"#if defined( VTK_USE_X ) && !defined( VTK_USE_TK )\n");
fprintf(fp," %s *temp = vtkXRenderWindowTclInteractor::New();\n",
data->ClassName);
fprintf(fp,"#else\n");
......
......@@ -87,7 +87,7 @@
#cmakedefine VTK_TCL_TK_STATIC
/* Whether Tk widgets are NOT initialized when vtkRendering loads. */
#cmakedefine VTK_DISABLE_TK_INIT
#cmakedefine VTK_USE_TK
/* Wheter the Tcl/Tk support files are copied to the build dir */
#cmakedefine VTK_TCL_TK_COPY_SUPPORT_LIBRARY
......
......@@ -121,11 +121,11 @@ SET(VTK_INCLUDE_DIRS_BUILD_TREE_CXX
${VTK_BINARY_DIR}/Utilities/ftgl
)
IF(VTK_RENDERING_NEED_TK_INTERNAL)
IF(VTK_USE_TK)
# Need access to internal Tk headers for the vtkTk... widget .cxx files.
SET(VTK_INCLUDE_DIRS_BUILD_TREE_CXX ${VTK_INCLUDE_DIRS_BUILD_TREE_CXX}
${TK_INTERNAL_PATH})
ENDIF(VTK_RENDERING_NEED_TK_INTERNAL)
ENDIF(VTK_USE_TK)
IF (VTK_USE_MATROX_IMAGING)
# Need access to mil.h include file for vtkMILVideoSource.cxx.
......
......@@ -37,6 +37,7 @@
#cmakedefine VTK_USE_MANGLED_MESA
#cmakedefine VTK_USE_OPENGL_LIBRARY
#cmakedefine VTK_OPENGL_HAS_OSMESA
#cmakedefine VTK_USE_OFFSCREEN
/*--------------------------------------------------------------------------*/
/* Wrapping Configuration */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment