From 48e4a3f385ff89b0e013d11177cecceccbde2d87 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 20 Jan 2020 13:11:20 -0500 Subject: [PATCH] COMP: Add support for building against VTK >= 8.90 * Pass Python3_* variables required by FindPython3 CMake module used by VTK * Add VTK_OVERRIDE to ctkExport because it is not defined in newer VTK version. * Update ctkMacroBuildLib adding support for EXPORT_CUSTOM_CONTENT_FROM_VARIABLE parameter allowing to specify custom content. Co-authored-by: Csaba Pinter Co-authored-by: Jean-Christophe Fillion-Robin --- CMake/ctkMacroBuildLib.cmake | 12 +- CMakeExternals/VTK.cmake | 13 +++ Libs/Visualization/VTK/Core/CMakeLists.txt | 74 +++++++++++- Libs/Visualization/VTK/Widgets/CMakeLists.txt | 107 ++++++++++++++---- .../VTK/Widgets/Testing/Cpp/CMakeLists.txt | 4 +- .../VTK/Widgets/ctkVTKAbstractView.cpp | 4 + .../VTK/Widgets/ctkVTKChartView.cpp | 16 +++ ...ctkVTKDiscretizableColorTransferWidget.cpp | 19 ++++ .../VTK/Widgets/ctkVTKMagnifyView.cpp | 12 ++ .../VTK/Widgets/ctkVTKOpenGLNativeWidget.h | 11 -- .../VTK/Widgets/ctkVTKWidgetsUtils.cpp | 10 +- Libs/ctkExport.h.in | 2 + 12 files changed, 240 insertions(+), 44 deletions(-) diff --git a/CMake/ctkMacroBuildLib.cmake b/CMake/ctkMacroBuildLib.cmake index 8334881aaf..d05b2e8297 100644 --- a/CMake/ctkMacroBuildLib.cmake +++ b/CMake/ctkMacroBuildLib.cmake @@ -28,7 +28,7 @@ #! \ingroup CMakeAPI macro(ctkMacroBuildLib) ctkMacroParseArguments(MY - "NAME;EXPORT_DIRECTIVE;SRCS;MOC_SRCS;GENERATE_MOC_SRCS;UI_FORMS;INCLUDE_DIRECTORIES;TARGET_LIBRARIES;RESOURCES;LIBRARY_TYPE" + "NAME;EXPORT_DIRECTIVE;SRCS;MOC_SRCS;GENERATE_MOC_SRCS;UI_FORMS;INCLUDE_DIRECTORIES;TARGET_LIBRARIES;RESOURCES;LIBRARY_TYPE;EXPORT_CUSTOM_CONTENT_FROM_VARIABLE" "ENABLE_QTTESTING" ${ARGN} ) @@ -91,6 +91,16 @@ macro(ctkMacroBuildLib) string(REGEX REPLACE "^CTK" "ctk" MY_EXPORT_HEADER_PREFIX ${MY_EXPORT_HEADER_PREFIX}) set(MY_LIBNAME ${lib_name}) + set(CTK_EXPORT_CUSTOM_CONTENT "") + if(MY_EXPORT_CUSTOM_CONTENT_FROM_VARIABLE) + if(DEFINED "${MY_EXPORT_CUSTOM_CONTENT_FROM_VARIABLE}") + set(CTK_EXPORT_CUSTOM_CONTENT "// ------- Expanded from \@CTK_EXPORT_CUSTOM_CONTENT\@ ------- +${${MY_EXPORT_CUSTOM_CONTENT_FROM_VARIABLE}} +// ------------------------------------------------ +") + endif() + endif() + configure_file( ${CTK_SOURCE_DIR}/Libs/ctkExport.h.in ${CMAKE_CURRENT_BINARY_DIR}/${MY_EXPORT_HEADER_PREFIX}Export.h diff --git a/CMakeExternals/VTK.cmake b/CMakeExternals/VTK.cmake index 3844bec0e0..a9ffc712bf 100644 --- a/CMakeExternals/VTK.cmake +++ b/CMakeExternals/VTK.cmake @@ -108,3 +108,16 @@ mark_as_superbuild( VARS VTK_DIR:PATH LABELS "FIND_PACKAGE" ) + +if(VTK_PYTHON_VERSION VERSION_GREATER "2.7") + # Propagate variables expected when VTK searches for python + mark_as_superbuild( + VARS + Python3_INCLUDE_DIR:PATH + Python3_ROOT_DIR:PATH + Python3_LIBRARY:FILEPATH + Python3_LIBRARY_DEBUG:FILEPATH + Python3_LIBRARY_RELEASE:FILEPATH + Python3_EXECUTABLE:FILEPATH + ) +endif() diff --git a/Libs/Visualization/VTK/Core/CMakeLists.txt b/Libs/Visualization/VTK/Core/CMakeLists.txt index c293a8398f..7bfc606024 100644 --- a/Libs/Visualization/VTK/Core/CMakeLists.txt +++ b/Libs/Visualization/VTK/Core/CMakeLists.txt @@ -3,7 +3,41 @@ project(CTKVisualizationVTKCore) # # 3rd party dependencies # -include(${VTK_USE_FILE}) + +if(${VTK_VERSION} VERSION_LESS "8.90") + include(${VTK_USE_FILE}) +else() + # VTK >= 8.90 defines VTK_MAJOR_VERSION + set(VTK_VERSION_MAJOR ${VTK_MAJOR_VERSION}) + + find_package(VTK + COMPONENTS + ChartsCore + CommonCore + CommonDataModel + FiltersCore + FiltersGeneral + FiltersModeling + FiltersSources + FiltersStatistics + IOLegacy + IOXML + InfovisCore + InfovisLayout + InteractionStyle + RenderingAnnotation + RenderingCore + RenderingFreeType + RenderingOpenGL2 + ViewsCore + ViewsInfovis + WrappingPythonCore + ViewsContext2D + OPTIONAL_COMPONENTS + TestingRendering + ) +endif() + if(NOT DEFINED VTK_RENDERING_BACKEND) set(VTK_RENDERING_BACKEND "OpenGL") endif() @@ -62,7 +96,9 @@ if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_ endif() # Set VTK_LIBRARIES variable -if(${VTK_VERSION_MAJOR} GREATER 5) +if(${VTK_VERSION} VERSION_EQUAL 8.90 OR ${VTK_VERSION} VERSION_GREATER 8.90 ) + # VTK_LIBRARIES is automatically set based on selected components +elseif(${VTK_VERSION_MAJOR} GREATER 5) set(VTK_LIBRARIES # a few of these have to be specified explicitly to workaround # underlinked libraries from the debian VTK package @@ -126,7 +162,9 @@ if(${CTK_USE_CHARTS}) vtkScalarsToColorsPreviewChart.cpp vtkScalarsToColorsPreviewChart.h ${KIT_SRCS}) - if(${VTK_VERSION_MAJOR} GREATER 5) + if(${VTK_VERSION} VERSION_EQUAL 8.90 OR ${VTK_VERSION} VERSION_GREATER 8.90 ) + # VTK_LIBRARIES is automatically set based on selected components + elseif(${VTK_VERSION_MAJOR} GREATER 5) set(VTK_LIBRARIES vtkChartsCore ${VTK_LIBRARIES}) @@ -136,14 +174,20 @@ if(${CTK_USE_CHARTS}) ${VTK_LIBRARIES}) endif() add_definitions(-DCTK_USE_CHARTS) + + if(${VTK_VERSION} VERSION_LESS "8.90") set(VTK_LIBRARIES vtkViewsContext2D - ${VTK_LIBRARIES}) + ${VTK_LIBRARIES}) if(TARGET vtkRenderingContext${VTK_RENDERING_BACKEND}) list(APPEND VTK_LIBRARIES vtkRenderingContext${VTK_RENDERING_BACKEND}) endif() + endif() + endif() +if(${VTK_VERSION} VERSION_LESS "8.90") + if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK) ctkFunctionExtractOptimizedLibrary(PYTHON_LIBRARIES PYTHON_LIBRARY) list(APPEND VTK_LIBRARIES ${PYTHON_LIBRARY} ${PYTHONQT_LIBRARIES}) @@ -163,6 +207,18 @@ if(Q_WS_X11) list(APPEND VTK_LIBRARIES ${X11_LIBRARIES}) endif() +endif() + +# Custom export content +if(${VTK_VERSION} VERSION_LESS "8.90") + set(CTK_VTK_EXPORT_CUSTOM_CONTENT "") +else() + set(CTK_VTK_EXPORT_CUSTOM_CONTENT "#ifndef VTK_OVERRIDE +#define VTK_OVERRIDE override; +#endif +") +endif() + # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake # The following macro will read the target libraries from the file 'target_libraries.cmake' ctkFunctionGetTargetLibraries(KIT_target_libraries) @@ -173,9 +229,10 @@ ctkMacroBuildLib( SRCS ${KIT_SRCS} MOC_SRCS ${KIT_MOC_SRCS} UI_FORMS ${KIT_UI_FORMS} - TARGET_LIBRARIES ${KIT_target_libraries} + TARGET_LIBRARIES ${KIT_target_libraries} ${PYTHONQT_LIBRARIES} RESOURCES ${KIT_resources} LIBRARY_TYPE ${CTK_LIBRARY_MODE} + EXPORT_CUSTOM_CONTENT_FROM_VARIABLE "CTK_VTK_EXPORT_CUSTOM_CONTENT" ) if(CTK_WRAP_PYTHONQT_LIGHT) @@ -186,6 +243,13 @@ if(CTK_WRAP_PYTHONQT_LIGHT) ) endif() + if (NOT VTK_VERSION VERSION_LESS "8.90.0") + vtk_module_autoinit( + TARGETS ${PROJECT_NAME} + MODULES ${VTK_LIBRARIES} + ) + endif() + # Plugins #if(CTK_BUILD_QTDESIGNER_PLUGINS) # add_subdirectory(Plugins) diff --git a/Libs/Visualization/VTK/Widgets/CMakeLists.txt b/Libs/Visualization/VTK/Widgets/CMakeLists.txt index 077162e51a..255b29f69c 100644 --- a/Libs/Visualization/VTK/Widgets/CMakeLists.txt +++ b/Libs/Visualization/VTK/Widgets/CMakeLists.txt @@ -1,6 +1,41 @@ project(CTKVisualizationVTKWidgets) -include(${VTK_USE_FILE}) +# +# 3rd party dependencies +# + +if(${VTK_VERSION} VERSION_LESS "8.90") + include(${VTK_USE_FILE}) +else() + # VTK >= 8.90 defines VTK_MAJOR_VERSION + set(VTK_VERSION_MAJOR ${VTK_MAJOR_VERSION}) + + find_package(VTK COMPONENTS + ChartsCore + CommonCore + CommonDataModel + #Context2D + FiltersCore + FiltersGeneral + FiltersModeling + FiltersSources + GUISupportQt + ImagingStatistics + IOLegacy + IOXML + InfovisCore + InfovisLayout + InteractionStyle + RenderingContextOpenGL2 + RenderingCore + RenderingFreeType + RenderingOpenGL2 + ViewsCore + ViewsInfovis + OPTIONAL_COMPONENTS + TestingRendering + ) +endif() # # See CTK/CMake/ctkMacroBuildLib.cmake for details @@ -115,7 +150,9 @@ set(KIT_resources ) # Set VTK_LIBRARIES variable -if(${VTK_VERSION_MAJOR} GREATER 5) +if(${VTK_VERSION} VERSION_EQUAL 8.90 OR ${VTK_VERSION} VERSION_GREATER 8.90 ) + # VTK_LIBRARIES is automatically set based on selected components +elseif(${VTK_VERSION_MAJOR} GREATER 5) set(VTK_LIBRARIES vtkChartsCore vtkCommonMath @@ -170,7 +207,9 @@ if(${CTK_USE_CHARTS}) Resources/UI/ctkVTKVolumePropertyWidget.ui Resources/UI/ctkVTKScalarsToColorsWidget.ui ${KIT_UI_FORMS}) - if(${VTK_VERSION_MAJOR} GREATER 5) + if(${VTK_VERSION} VERSION_EQUAL 8.90 OR ${VTK_VERSION} VERSION_GREATER 8.90 ) + # VTK_LIBRARIES is automatically set based on selected components + elseif(${VTK_VERSION_MAJOR} GREATER 5) set(VTK_LIBRARIES vtkChartsCore ${VTK_LIBRARIES}) @@ -203,10 +242,12 @@ endif() # Prefer QVTKOpenGLWidget to QVTKWidget when using Qt5 set(_use_qvtkopenglwidget 1) -if(CTK_QT_VERSION VERSION_LESS "5" - OR VTK_VERSION VERSION_LESS "8" - OR (NOT VTK_RENDERING_BACKEND STREQUAL "OpenGL2")) - set(_use_qvtkopenglwidget 0) +if(VTK_VERSION VERSION_LESS "8.90") + if(CTK_QT_VERSION VERSION_LESS "5" + OR VTK_VERSION VERSION_LESS "8" + OR (NOT VTK_RENDERING_BACKEND STREQUAL "OpenGL2")) + set(_use_qvtkopenglwidget 0) + endif() endif() if(_use_qvtkopenglwidget) @@ -214,27 +255,42 @@ if(_use_qvtkopenglwidget) endif() # Detect if QVTKOpenGLNativeWidget.h is available -set(_has_QVTKOpenGLNativeWidget_h 0) -if(_use_qvtkopenglwidget) - set(_msg "Checking if QVTKOpenGLNativeWidget.h exists") - message(STATUS "${_msg}") - foreach(include_dir IN ITEMS ${vtkGUISupportQt_INCLUDE_DIRS}) - if(EXISTS "${include_dir}/QVTKOpenGLNativeWidget.h") - set(_has_QVTKOpenGLNativeWidget_h 1) - break() +if(VTK_VERSION VERSION_LESS "8.90") + set(_has_QVTKOpenGLNativeWidget_h 0) + if(_use_qvtkopenglwidget) + set(_msg "Checking if QVTKOpenGLNativeWidget.h exists") + message(STATUS "${_msg}") + foreach(include_dir IN ITEMS ${vtkGUISupportQt_INCLUDE_DIRS}) + if(EXISTS "${include_dir}/QVTKOpenGLNativeWidget.h") + set(_has_QVTKOpenGLNativeWidget_h 1) + break() + endif() + endforeach() + if(_has_QVTKOpenGLNativeWidget_h) + message(STATUS "${_msg} - found") + else() + message(STATUS "${_msg} - not found") endif() - endforeach() - if(_has_QVTKOpenGLNativeWidget_h) - message(STATUS "${_msg} - found") - else() - message(STATUS "${_msg} - not found") endif() -endif() +else() + set(_has_QVTKOpenGLNativeWidget_h 1) +endif () + if(_has_QVTKOpenGLNativeWidget_h) add_definitions(-DCTK_HAS_QVTKOPENGLNATIVEWIDGET_H) endif() +# Custom export content +if(${VTK_VERSION} VERSION_LESS "8.90") + set(CTK_VTK_EXPORT_CUSTOM_CONTENT "") +else() + set(CTK_VTK_EXPORT_CUSTOM_CONTENT "#ifndef VTK_OVERRIDE +#define VTK_OVERRIDE override; +#endif +") +endif() + ctkMacroBuildLib( NAME ${PROJECT_NAME} EXPORT_DIRECTIVE ${KIT_export_directive} @@ -244,6 +300,7 @@ ctkMacroBuildLib( TARGET_LIBRARIES ${KIT_target_libraries} RESOURCES ${KIT_resources} LIBRARY_TYPE ${CTK_LIBRARY_MODE} + EXPORT_CUSTOM_CONTENT_FROM_VARIABLE "CTK_VTK_EXPORT_CUSTOM_CONTENT" ) if(_use_qvtkopenglwidget) @@ -270,6 +327,14 @@ if(CTK_WRAP_PYTHONQT_LIGHT) ) endif() +if(NOT VTK_VERSION VERSION_LESS "8.90.0") + vtk_module_autoinit( + TARGETS ${PROJECT_NAME} + MODULES ${VTK_LIBRARIES} + ) +endif() + + # Plugins if(CTK_BUILD_QTDESIGNER_PLUGINS) add_subdirectory(Plugins) diff --git a/Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt b/Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt index da895ca109..9563360268 100644 --- a/Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt +++ b/Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt @@ -132,7 +132,9 @@ else() endif() ctk_add_executable_utf8(${KIT}CppTests ${Tests} ${TEST_MOC_CPP} ${TEST_UI_CPP} ${Tests_RESOURCES_SRCS}) -if(${VTK_VERSION_MAJOR} GREATER 5) +if(${VTK_VERSION} VERSION_EQUAL 8.90 OR ${VTK_VERSION} VERSION_GREATER 8.90 ) + set(VTK_CHARTS_LIB) +elseif(${VTK_VERSION_MAJOR} GREATER 5) set(VTK_CHARTS_LIB vtkChartsCore) else() set(VTK_CHARTS_LIB vtkCharts) diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.cpp b/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.cpp index 179a14541c..e587a38c91 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.cpp +++ b/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.cpp @@ -118,7 +118,11 @@ void ctkVTKAbstractViewPrivate::setupRendering() } this->RenderWindow->SetMultiSamples(nSamples); this->RenderWindow->StereoCapableWindowOn(); +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + this->VTKWidget->setRenderWindow(this->RenderWindow); +#else this->VTKWidget->SetRenderWindow(this->RenderWindow); +#endif } //--------------------------------------------------------------------------- diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKChartView.cpp b/Libs/Visualization/VTK/Widgets/ctkVTKChartView.cpp index baae9bfa7c..842b4e7456 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKChartView.cpp +++ b/Libs/Visualization/VTK/Widgets/ctkVTKChartView.cpp @@ -85,18 +85,34 @@ ctkVTKChartViewPrivate::ctkVTKChartViewPrivate(ctkVTKChartView& object) void ctkVTKChartViewPrivate::init() { Q_Q(ctkVTKChartView); + #ifdef CTK_USE_QVTKOPENGLWIDGET +# if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + q->setRenderWindow(this->RenderWindow); +# else q->SetRenderWindow(this->RenderWindow); +# endif this->ContextView->SetRenderWindow(this->RenderWindow); #endif + +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + this->ContextView->SetInteractor(q->interactor()); + q->setRenderWindow(this->ContextView->GetRenderWindow()); +#else this->ContextView->SetInteractor(q->GetInteractor()); q->SetRenderWindow(this->ContextView->GetRenderWindow()); +#endif + // low def for now (faster) //q->GetRenderWindow()->SetMultiSamples(0); //vtkOpenGLContextDevice2D::SafeDownCast(this->ContextView->GetContext()->GetDevice()) // ->SetStringRendererToQt(); #ifndef Q_WS_X11 +# if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + q->renderWindow()->SetLineSmoothing(true); +# else q->GetRenderWindow()->SetLineSmoothing(true); +# endif #endif this->Chart->SetActionToButton(vtkChart::PAN, vtkContextMouseEvent::MIDDLE_BUTTON); this->Chart->SetActionToButton(vtkChart::SELECT, vtkContextMouseEvent::RIGHT_BUTTON); diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKDiscretizableColorTransferWidget.cpp b/Libs/Visualization/VTK/Widgets/ctkVTKDiscretizableColorTransferWidget.cpp index 5cdf440f22..edf9d05593 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKDiscretizableColorTransferWidget.cpp +++ b/Libs/Visualization/VTK/Widgets/ctkVTKDiscretizableColorTransferWidget.cpp @@ -165,13 +165,24 @@ void ctkVTKDiscretizableColorTransferWidgetPrivate::setupUi(QWidget* widget) #ifdef CTK_USE_QVTKOPENGLWIDGET vtkSmartPointer renwin = vtkSmartPointer::New(); +# if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + this->ScalarsToColorsView->setRenderWindow(renwin); +# else this->ScalarsToColorsView->SetRenderWindow(renwin); +# endif #endif +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + this->scalarsToColorsContextView->SetRenderWindow( + this->ScalarsToColorsView->renderWindow()); + this->scalarsToColorsContextView->SetInteractor( + this->ScalarsToColorsView->interactor()); +#else this->scalarsToColorsContextView->SetRenderWindow( this->ScalarsToColorsView->GetRenderWindow()); this->scalarsToColorsContextView->SetInteractor( this->ScalarsToColorsView->GetInteractor()); +#endif this->scalarsToColorsContextView->GetScene()->AddItem( this->scalarsToColorsContextItem.Get()); @@ -365,7 +376,11 @@ ctkVTKDiscretizableColorTransferWidgetPrivate::colorTransferFunctionModifiedCall QColor selected = QColor::fromRgbF(r, g, b); self->nanButton->setColor(selected); +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + self->ScalarsToColorsView->interactor()->Render(); +#else self->ScalarsToColorsView->GetInteractor()->Render(); +#endif } // ---------------------------------------------------------------------------- @@ -743,7 +758,11 @@ void ctkVTKDiscretizableColorTransferWidget::onPaletteIndexChanged( Q_D(ctkVTKDiscretizableColorTransferWidget); d->addRangesInHistory(this->getColorTransferFunctionRange(), this->getVisibleRange()); this->copyColorTransferFunction(ctf); +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + d->ScalarsToColorsView->interactor()->Render(); +#else d->ScalarsToColorsView->GetInteractor()->Render(); +#endif } // ---------------------------------------------------------------------------- diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp b/Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp index f4a08f90f5..8d69316169 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp +++ b/Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp @@ -174,7 +174,11 @@ void ctkVTKMagnifyViewPrivate::connectRenderWindow(ctkVTKOpenGLNativeWidget * wi Q_ASSERT(widget); Q_ASSERT(this->ObserveRenderWindowEvents); +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + vtkRenderWindow * renderWindow = widget->renderWindow(); +#else vtkRenderWindow * renderWindow = widget->GetRenderWindow(); +#endif if (renderWindow) { this->qvtkConnect(renderWindow, vtkCommand::EndEvent, @@ -187,7 +191,11 @@ void ctkVTKMagnifyViewPrivate::disconnectRenderWindow(ctkVTKOpenGLNativeWidget * { Q_ASSERT(widget); +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + vtkRenderWindow * renderWindow = widget->renderWindow(); +#else vtkRenderWindow * renderWindow = widget->GetRenderWindow(); +#endif if (renderWindow) { this->qvtkDisconnect(renderWindow, vtkCommand::EndEvent, @@ -253,7 +261,11 @@ void ctkVTKMagnifyViewPrivate::updatePixmap() Q_Q(ctkVTKMagnifyView); // Retrieve buffer of given QVTKWidget from its render window +#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) + vtkRenderWindow * renderWindow = this->EventHandler.Widget.data()->renderWindow(); +#else vtkRenderWindow * renderWindow = this->EventHandler.Widget.data()->GetRenderWindow(); +#endif if (!renderWindow) { return; diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKOpenGLNativeWidget.h b/Libs/Visualization/VTK/Widgets/ctkVTKOpenGLNativeWidget.h index 0629c953f9..2950924666 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKOpenGLNativeWidget.h +++ b/Libs/Visualization/VTK/Widgets/ctkVTKOpenGLNativeWidget.h @@ -58,17 +58,6 @@ class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKOpenGLNativeWidget : public QVT Q_DISABLE_COPY(ctkVTKOpenGLNativeWidget); }; # endif -#else -class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKOpenGLNativeWidget : public QVTKWidget -{ - Q_OBJECT -public: - typedef QVTKWidget Superclass; - explicit ctkVTKOpenGLNativeWidget(QWidget* parent = 0) : Superclass(parent){} - virtual ~ctkVTKOpenGLNativeWidget(){} -private: - Q_DISABLE_COPY(ctkVTKOpenGLNativeWidget); -}; #endif #endif diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKWidgetsUtils.cpp b/Libs/Visualization/VTK/Widgets/ctkVTKWidgetsUtils.cpp index 82b765d287..aaabdac9c5 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKWidgetsUtils.cpp +++ b/Libs/Visualization/VTK/Widgets/ctkVTKWidgetsUtils.cpp @@ -27,15 +27,11 @@ #include // ctkWidgets includes +#include "ctkVTKOpenGLNativeWidget.h" #include "ctkVTKWidgetsUtils.h" #include "ctkWidgetsUtils.h" // VTK includes -#if CTK_USE_QVTKOPENGLWIDGET -#include -#else -#include -#endif #include #include #include @@ -58,7 +54,11 @@ QImage ctk::grabVTKWidget(QWidget* widget, QRect rectangle) QPainter painter; painter.begin(&widgetImage); #if CTK_USE_QVTKOPENGLWIDGET +# if CTK_HAS_QVTKOPENGLNATIVEWIDGET_H + foreach(QVTKOpenGLNativeWidget* vtkWidget, widget->findChildren()) +# else foreach(QVTKOpenGLWidget* vtkWidget, widget->findChildren()) +# endif #else foreach(QVTKWidget* vtkWidget, widget->findChildren()) #endif diff --git a/Libs/ctkExport.h.in b/Libs/ctkExport.h.in index d64589ca9b..d1c603474b 100644 --- a/Libs/ctkExport.h.in +++ b/Libs/ctkExport.h.in @@ -29,5 +29,7 @@ //# endif #endif +@CTK_EXPORT_CUSTOM_CONTENT@ + #endif