diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f96872c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +CMakeLists.txt.user* +.vs +CMakeSettings.json + diff --git a/cmake/build_opt.cmake b/cmake/build_opt.cmake index 3e6b2a91..59eb61e1 100644 --- a/cmake/build_opt.cmake +++ b/cmake/build_opt.cmake @@ -31,17 +31,26 @@ option(CLITK_BUILD_REGISTRATION "Build command-line registration tools" OFF) option(CLITK_BUILD_VV "Build vv the 4D visualizer (requires VTK and QT)" ON) if(CLITK_BUILD_VV) - if(VTK_VERSION VERSION_LESS 6.0.0) - set(vv_QT_VERSION "4" CACHE INTERNAL "Expected Qt version") + #if(VTK_VERSION VERSION_LESS 6.0.0) + # set(vv_QT_VERSION "4" CACHE INTERNAL "Expected Qt version") + #else() + # if(VTK_QT_VERSION VERSION_LESS 5) + # set(vv_QT_VERSION "4" CACHE INTERNAL "Expected Qt version") + # else() + # set(vv_QT_VERSION "5" CACHE INTERNAL "Expected Qt version") + # endif() + #endif() + # set(vv_QT_VERSION "5" CACHE INTERNAL "Expected Qt version") + #find_package(Qt4) + #find_package(Qt5 COMPONENTS Core) + if(VTK_QT_VERSION VERSION_LESS 5) + set(vv_QT_VERSION "4" CACHE INTERNAL "Expected Qt version") + elseif(VTK_QT_VERSION VERSION_LESS 6) + set(vv_QT_VERSION "5" CACHE INTERNAL "Expected Qt version") else() - if(VTK_QT_VERSION VERSION_LESS 5) - set(vv_QT_VERSION "4" CACHE INTERNAL "Expected Qt version") - else() - set(vv_QT_VERSION "5" CACHE INTERNAL "Expected Qt version") - endif() + message(FATAL_ERROR "VTK needs to be compiled with Qt4 or Qt5 is needed if you want to build vv.") endif() - set(vv_QT_VERSION "5" CACHE INTERNAL "Expected Qt version") - add_subdirectory(${CLITK_SOURCE_DIR}/vv ${PROJECT_BINARY_DIR}/vv) + add_subdirectory(${CLITK_SOURCE_DIR}/vv ${PROJECT_BINARY_DIR}/vv) endif(CLITK_BUILD_VV) #========================================================= diff --git a/common/rtkEdfImageIO.cxx b/common/rtkEdfImageIO.cxx index a01c5e90..f90d27d1 100644 --- a/common/rtkEdfImageIO.cxx +++ b/common/rtkEdfImageIO.cxx @@ -169,7 +169,11 @@ void rtk::EdfImageIO::ReadImageInformation() { NULL, OrderNotApplicable } }; - auto byteorder = LittleEndian; +#if (ITK_VERSION_MAJOR == 5 && ITK_VERSION_MINOR < 1) || ITK_VERSION_MAJOR < 5 + itk::ImageIOBase::ByteOrder byteorder = LittleEndian; +#else + itk::ImageIOBase::IOByteOrderEnum byteorder = LittleEndian; +#endif if ( (p = edf_findInHeader(header, "ByteOrder") ) ) { k = lookup_table_nth(edf_byteorder_table, p); if (k >= 0) { diff --git a/common/rtkEdfImageIO.h b/common/rtkEdfImageIO.h index 57f9bd13..466a1e0d 100644 --- a/common/rtkEdfImageIO.h +++ b/common/rtkEdfImageIO.h @@ -100,7 +100,11 @@ class EdfImageIO : public itk::ImageIOBase // table key-value structure struct table { const char *key; +#if (ITK_VERSION_MAJOR == 5 && ITK_VERSION_MINOR < 1) || ITK_VERSION_MAJOR < 5 + itk::ImageIOBase::ByteOrder value; +#else itk::ImageIOBase::IOByteOrderEnum value; +#endif }; struct table3 { diff --git a/common/vvImage.txx b/common/vvImage.txx index cc047bb1..44537abe 100644 --- a/common/vvImage.txx +++ b/common/vvImage.txx @@ -17,6 +17,7 @@ ===========================================================================*/ #include #include +#include //-------------------------------------------------------------------- template diff --git a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h index df052838..aee0c112 100644 --- a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h +++ b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h @@ -152,7 +152,7 @@ namespace clitk { #if ITK_VERSION_MAJOR <= 4 virtual void VerifyInputInformation() ITK_OVERRIDE { } #else - virtual void VerifyInputInformation() const ITK_OVERRIDE { } + virtual void VerifyInputInformation() ITKv5_CONST override { } #endif // For debug diff --git a/itk/clitkBooleanOperatorLabelImageFilter.h b/itk/clitkBooleanOperatorLabelImageFilter.h index 523a179f..3aded45b 100644 --- a/itk/clitkBooleanOperatorLabelImageFilter.h +++ b/itk/clitkBooleanOperatorLabelImageFilter.h @@ -102,7 +102,7 @@ namespace clitk { #if ITK_VERSION_MAJOR <= 4 virtual void VerifyInputInformation() ITK_OVERRIDE { } #else - virtual void VerifyInputInformation() const ITK_OVERRIDE { } + virtual void VerifyInputInformation() ITKv5_CONST override { } #endif protected: diff --git a/itk/clitkCropLikeImageFilter.h b/itk/clitkCropLikeImageFilter.h index 6e636089..95e5cb04 100644 --- a/itk/clitkCropLikeImageFilter.h +++ b/itk/clitkCropLikeImageFilter.h @@ -74,7 +74,7 @@ namespace clitk { #if ITK_VERSION_MAJOR <= 4 virtual void VerifyInputInformation() ITK_OVERRIDE { } #else - virtual void VerifyInputInformation() const ITK_OVERRIDE { } + virtual void VerifyInputInformation() ITKv5_CONST override { } #endif protected: diff --git a/itk/clitkLabelImageOverlapMeasureFilter.h b/itk/clitkLabelImageOverlapMeasureFilter.h index b2b79aca..f6a461fe 100644 --- a/itk/clitkLabelImageOverlapMeasureFilter.h +++ b/itk/clitkLabelImageOverlapMeasureFilter.h @@ -96,7 +96,7 @@ namespace clitk { #if ITK_VERSION_MAJOR <= 4 virtual void VerifyInputInformation() ITK_OVERRIDE { } #else - virtual void VerifyInputInformation() const ITK_OVERRIDE { } + virtual void VerifyInputInformation() ITKv5_CONST override { } #endif protected: diff --git a/itk/clitkPasteImageFilter.h b/itk/clitkPasteImageFilter.h index 3429ab66..2e0857b0 100644 --- a/itk/clitkPasteImageFilter.h +++ b/itk/clitkPasteImageFilter.h @@ -21,7 +21,7 @@ namespace clitk #if ITK_VERSION_MAJOR <= 4 virtual void VerifyInputInformation() ITK_OVERRIDE { } #else - virtual void VerifyInputInformation() const ITK_OVERRIDE { } + virtual void VerifyInputInformation() ITKv5_CONST override { } #endif /** Standard class typedefs. */ diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 8b102e4d..36c13a2c 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -10,10 +10,36 @@ endif(COMMAND cmake_policy) OPTION(CLITK_USE_PACS_CONNECTION "USE PACS CONNECTION" OFF) #========================================================= -# Look for OpenGL2 version -if (VTK_RENDERING_BACKEND STREQUAL "OpenGL2") - add_definitions(-DVTK_OPENGL2) -endif () +# Look for VTK OpenGL version +if(VTK_MAJOR_VERSION VERSION_LESS "6") + if(CMAKE_VERSION VERSION_LESS "3.12.0") + add_definitions(-DVTK_OPENGL=1) + else() + add_compile_definitions(VTK_OPENGL=1) + endif() +elseif(VTK_MAJOR_VERSION VERSION_EQUAL "6") + # Look for OpenGL version + if(VTK_RENDERING_BACKEND STREQUAL "OpenGL") + if(CMAKE_VERSION VERSION_LESS "3.12.0") + add_definitions(-DVTK_OPENGL=1) + else() + add_compile_definitions(VTK_OPENGL=1) + endif() + # Look for OpenGL2 version + else() + if(CMAKE_VERSION VERSION_LESS "3.12.0") + add_definitions(-DVTK_OPENGL=2) + else() + add_compile_definitions(VTK_OPENGL=2) + endif() + endif() +else() + if(CMAKE_VERSION VERSION_LESS "3.12.0") + add_definitions(-DVTK_OPENGL=2) + else() + add_compile_definitions(VTK_OPENGL=2) + endif() +endif() #List of vv tools to compile set(vv_TOOLS diff --git a/vv/vtkVOXImageWriter.h b/vv/vtkVOXImageWriter.h index e9546675..0f8b637b 100644 --- a/vv/vtkVOXImageWriter.h +++ b/vv/vtkVOXImageWriter.h @@ -19,13 +19,20 @@ #define __vtkVOXImageWriter_h #include "vtkImageWriter.h" #include +#include class vtkVOXImageWriter : public vtkImageWriter { public: vtkTypeMacro(vtkVOXImageWriter,vtkImageWriter); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif // Description: static vtkVOXImageWriter *New(); @@ -36,7 +43,13 @@ class vtkVOXImageWriter : public vtkImageWriter // This is called by the superclass. // This is the method you should override. +#if VTK_MAJOR_VERSION >= 8 + virtual void Write() override; +#elif VTK_MAJOR_VERSION >= 7 virtual void Write() VTK_OVERRIDE; +#else + virtual void Write(); +#endif protected: vtkVOXImageWriter(); diff --git a/vv/vv.cxx b/vv/vv.cxx index 742464a8..93e85d7d 100644 --- a/vv/vv.cxx +++ b/vv/vv.cxx @@ -42,9 +42,12 @@ #include "vvReadState.h" #include "vvToolsList.h" #include "vvConfiguration.h" -#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9 +#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION < 2) #include #endif +#if (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 2) +#include +#endif #include #include @@ -118,8 +121,11 @@ int main( int argc, char** argv ) { #endif -#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9 +#if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 2) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION < 2) QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat()); +#endif +#if (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 2) + QSurfaceFormat::setDefaultFormat(QVTKOpenGLStereoWidget::defaultFormat()); #endif CLITK_INIT; diff --git a/vv/vvAnimatedGIFWriter.h b/vv/vvAnimatedGIFWriter.h index 32c4d8e5..18e17442 100644 --- a/vv/vvAnimatedGIFWriter.h +++ b/vv/vvAnimatedGIFWriter.h @@ -5,6 +5,7 @@ #include #include +#include class vtkImageAppend; @@ -13,14 +14,30 @@ class vvAnimatedGIFWriter : public vtkGenericMovieWriter //test this if link err public: static vvAnimatedGIFWriter *New(); vtkTypeMacro(vvAnimatedGIFWriter,vtkGenericMovieWriter); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif // Description: // These methods start writing an Movie file, write a frame to the file // and then end the writing process. +#if VTK_MAJOR_VERSION >= 8 + void Start() override; + void Write() override; + void End() override; +#elif VTK_MAJOR_VERSION >= 7 void Start() VTK_OVERRIDE; void Write() VTK_OVERRIDE; void End() VTK_OVERRIDE; +#else + void Start(); + void Write(); + void End(); +#endif // Description: // Set/Get the frame rate, in frame/s. diff --git a/vv/vvBlendImageActor.cxx b/vv/vvBlendImageActor.cxx index ccb5907a..433bcc04 100644 --- a/vv/vvBlendImageActor.cxx +++ b/vv/vvBlendImageActor.cxx @@ -3,7 +3,7 @@ Program: vv http://www.creatis.insa-lyon.fr/rio/vv Authors belong to: - University of LYON http://www.universite-lyon.fr/ -- Léon Bérard cancer center http://www.centreleonberard.fr +- Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -17,7 +17,14 @@ It is distributed under dual licence ===========================================================================**/ #include "vvBlendImageActor.h" -#include +#if VTK_OPENGL == 1 + #include + #include +#elif VTK_OPENGL > 1 + #include //VTK_OPENGL2 +#else + #error "You need to compile VTK with OpenGL!" +#endif #include #include #include @@ -38,13 +45,7 @@ void vvBlendImageActor::Render(vtkRenderer *ren) { //Change blending to maximum per component instead of weighted sum vtkOpenGLRenderWindow *renwin = dynamic_cast(ren->GetRenderWindow()); -#ifdef VTK_OPENGL2 - const char *extensions = renwin->ReportCapabilities(); - - //Call normal render - VTK_IMAGE_ACTOR::Render(ren); - -#else +#if VTK_OPENGL == 1 vtkOpenGLExtensionManager *extensions = renwin->GetExtensionManager(); if (extensions->ExtensionSupported("GL_EXT_blend_minmax")) { extensions->LoadExtension("GL_EXT_blend_minmax"); @@ -58,6 +59,12 @@ void vvBlendImageActor::Render(vtkRenderer *ren) if (vtkgl::BlendEquationEXT!=0) { vtkgl::BlendEquationEXT( vtkgl::FUNC_ADD ); } +#else + //VTK_OPENGL>1 + const char *extensions = renwin->ReportCapabilities(); + + //Call normal render + VTK_IMAGE_ACTOR::Render(ren); #endif } diff --git a/vv/vvBlendImageActor.h b/vv/vvBlendImageActor.h index 0ac1e71f..69846a27 100644 --- a/vv/vvBlendImageActor.h +++ b/vv/vvBlendImageActor.h @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://www.centreleonberard.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -21,6 +21,7 @@ #include #include +#include #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) #define VTK_IMAGE_ACTOR vtkImageActor @@ -35,11 +36,23 @@ class vvBlendImageActor : public VTK_IMAGE_ACTOR public: static vvBlendImageActor *New(); vtkTypeMacro(vvBlendImageActor, VTK_IMAGE_ACTOR); +#if VTK_MAJOR_VERSION >= 8 + virtual void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + virtual void PrintSelf(ostream& os, vtkIndent indent); +#endif // Description: // Implement base class method. +#if VTK_MAJOR_VERSION >= 8 + void Render(vtkRenderer *ren) override; +#elif VTK_MAJOR_VERSION >= 7 void Render(vtkRenderer *ren) VTK_OVERRIDE; +#else + void Render(vtkRenderer *ren); +#endif protected: vvBlendImageActor(); diff --git a/vv/vvClipPolyData.h b/vv/vvClipPolyData.h index d31697e5..3f4057ed 100644 --- a/vv/vvClipPolyData.h +++ b/vv/vvClipPolyData.h @@ -7,7 +7,13 @@ class vvClipPolyData : public vtkClipPolyData { public: vtkTypeMacro(vvClipPolyData,vtkClipPolyData); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif static vvClipPolyData *New(); @@ -15,7 +21,13 @@ class vvClipPolyData : public vtkClipPolyData vvClipPolyData(); ~vvClipPolyData(); +#if VTK_MAJOR_VERSION >= 8 + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override; +#elif VTK_MAJOR_VERSION >= 7 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE; +#else + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); +#endif private: vvClipPolyData(const vvClipPolyData&); // Not implemented. diff --git a/vv/vvGlyph2D.h b/vv/vvGlyph2D.h index 75cb7bde..be55d8f7 100644 --- a/vv/vvGlyph2D.h +++ b/vv/vvGlyph2D.h @@ -23,7 +23,13 @@ class vvGlyph2D : public vtkGlyph3D { public: vtkTypeMacro(vvGlyph2D,vtkGlyph3D); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif // Description // Construct object with scaling on, scaling mode is by scalar value, @@ -44,7 +50,13 @@ class vvGlyph2D : public vtkGlyph3D vvGlyph2D(); ~vvGlyph2D() {}; +#if VTK_MAJOR_VERSION >= 8 + virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override; +#elif VTK_MAJOR_VERSION >= 7 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE; +#else + virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); +#endif private: vvGlyph2D(const vvGlyph2D&); // Not implemented. diff --git a/vv/vvGlyphSource.h b/vv/vvGlyphSource.h index 92c1d009..d85aaa75 100644 --- a/vv/vvGlyphSource.h +++ b/vv/vvGlyphSource.h @@ -26,7 +26,13 @@ class vvGlyphSource: public vtkGlyphSource2D public: static vvGlyphSource *New(); vtkTypeMacro(vvGlyphSource,vtkGlyphSource2D); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif void SetGlyphTypeToSpecificArrow() { this->SetGlyphType(VTK_SPECIFICARROW_GLYPH); @@ -38,7 +44,13 @@ class vvGlyphSource: public vtkGlyphSource2D void CreateSpecificArrow(vtkPoints *pts, vtkCellArray *lines, vtkCellArray *polys, vtkUnsignedCharArray *colors); +#if VTK_MAJOR_VERSION >= 8 + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override; +#elif VTK_MAJOR_VERSION >= 7 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE; +#else + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); +#endif private: diff --git a/vv/vvInteractorStyleNavigator.h b/vv/vvInteractorStyleNavigator.h index a9f37598..2e02fa6e 100644 --- a/vv/vvInteractorStyleNavigator.h +++ b/vv/vvInteractorStyleNavigator.h @@ -18,6 +18,7 @@ #ifndef __vvInteractorStyleNavigator_h #define __vvInteractorStyleNavigator_h #include "vtkInteractorStyle.h" +#include // Motion flags @@ -30,7 +31,13 @@ class vvInteractorStyleNavigator : public vtkInteractorStyle public: static vvInteractorStyleNavigator *New(); vtkTypeMacro(vvInteractorStyleNavigator, vtkInteractorStyle); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif // Description: // Some useful information for handling window level @@ -40,6 +47,19 @@ class vvInteractorStyleNavigator : public vtkInteractorStyle // Description: // Event bindings controlling the effects of pressing mouse buttons // or moving the mouse. +#if VTK_MAJOR_VERSION >= 8 + virtual void OnMouseMove() override; + virtual void OnLeftButtonDown() override; + virtual void OnLeftButtonUp() override; + virtual void OnRightButtonDown() override; + virtual void OnRightButtonUp() override; + virtual void OnMiddleButtonDown() override; + virtual void OnMiddleButtonUp() override; + virtual void OnEnter() override; + virtual void OnLeave() override; + virtual void OnMouseWheelForward() override; + virtual void OnMouseWheelBackward() override; +#elif VTK_MAJOR_VERSION >= 7 virtual void OnMouseMove() VTK_OVERRIDE; virtual void OnLeftButtonDown() VTK_OVERRIDE; virtual void OnLeftButtonUp() VTK_OVERRIDE; @@ -51,10 +71,29 @@ class vvInteractorStyleNavigator : public vtkInteractorStyle virtual void OnLeave() VTK_OVERRIDE; virtual void OnMouseWheelForward() VTK_OVERRIDE; virtual void OnMouseWheelBackward() VTK_OVERRIDE; +#else + virtual void OnMouseMove(); + virtual void OnLeftButtonDown(); + virtual void OnLeftButtonUp(); + virtual void OnRightButtonDown(); + virtual void OnRightButtonUp(); + virtual void OnMiddleButtonDown(); + virtual void OnMiddleButtonUp(); + virtual void OnEnter(); + virtual void OnLeave(); + virtual void OnMouseWheelForward(); + virtual void OnMouseWheelBackward(); +#endif // Description: // Override the "fly-to" (f keypress) for images. +#if VTK_MAJOR_VERSION >= 8 + virtual void OnChar() override; +#elif VTK_MAJOR_VERSION >= 7 virtual void OnChar() VTK_OVERRIDE; +#else + virtual void OnChar(); +#endif // These methods for the different interactions in different modes // are overridden in subclasses to perform the correct motion. Since @@ -68,8 +107,16 @@ class vvInteractorStyleNavigator : public vtkInteractorStyle virtual void EndWindowLevel(); virtual void StartPick(); virtual void EndPick(); - virtual void Dolly()VTK_OVERRIDE; +#if VTK_MAJOR_VERSION >= 8 + virtual void Dolly() override; + virtual void Pan() override; +#elif VTK_MAJOR_VERSION >= 7 + virtual void Dolly() VTK_OVERRIDE; virtual void Pan() VTK_OVERRIDE; +#else + virtual void Dolly(); + virtual void Pan(); +#endif // We need to reimplement this because otherwise it returns the top renderer, // not the active one diff --git a/vv/vvLandmarksGlyph.h b/vv/vvLandmarksGlyph.h index 87b0114e..f068d794 100644 --- a/vv/vvLandmarksGlyph.h +++ b/vv/vvLandmarksGlyph.h @@ -24,7 +24,13 @@ class vvLandmarksGlyph : public vtkTextSource { public: vtkTypeMacro(vvLandmarksGlyph,vtkTextSource); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif // Description: // Construct object with no string set and backing enabled. @@ -39,7 +45,13 @@ class vvLandmarksGlyph : public vtkTextSource void AddCrossGlyph(vtkPoints* newPts,vtkCellArray* newLines); void ChangeOrientation(double v[3], int orientation); +#if VTK_MAJOR_VERSION >= 8 + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override; +#elif VTK_MAJOR_VERSION >= 7 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE; +#else + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); +#endif private: vvLandmarksGlyph(const vvLandmarksGlyph&); // Not implemented. diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index ccde1276..8b3d494d 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -1571,10 +1571,17 @@ void vvMainWindow::InitSlicers() { if (mSlicerManagers.size()) { mSlicerManagers.back()->GenerateDefaultLookupTable(); +#if VTK_MAJOR_VERSION >= 9 + mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->renderWindow()); + mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->renderWindow()); + mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->renderWindow()); + mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->renderWindow()); +#else mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->GetRenderWindow()); mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->GetRenderWindow()); mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->GetRenderWindow()); mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->GetRenderWindow()); +#endif #if VTK_MAJOR_VERSION <= 5 mSlicerManagers.back()->Render(); // SR: displayed #slice is wrong without this / TB: With VTK6 and multiple images, all slicers are updated, not only the first #endif @@ -3347,7 +3354,11 @@ void vvMainWindow::SaveScreenshotAllSlices() vvSlicer * slicer = SM->GetSlicer(0); int orientation = slicer->GetOrientation(); int nbSlices = image->GetSize()[orientation]; +#if VTK_MAJOR_VERSION >= 9 + vtkSmartPointer renderWindow = widget->renderWindow(); +#else vtkSmartPointer renderWindow = widget->GetRenderWindow(); +#endif // Select filename base QString filename = QFileDialog::getSaveFileName(this, @@ -3422,7 +3433,11 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) if (!fileName.isEmpty()) { vtkSmartPointer w2i = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION >= 9 + w2i->SetInput(widget->renderWindow()); +#else w2i->SetInput(widget->GetRenderWindow()); +#endif #if (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 2) || VTK_MAJOR_VERSION >= 9 w2i->SetScale(1); #else @@ -3532,7 +3547,11 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) for(int i=0; i<=nSlice; i++) { mSlicerManagers[smIndex]->SetNextTSlice(0); vtkSmartPointer w2i = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION >= 9 + w2i->SetInput(widget->renderWindow()); +#else w2i->SetInput(widget->GetRenderWindow()); +#endif w2i->Update(); #if VTK_MAJOR_VERSION <= 5 vidwriter->SetInput(w2i->GetOutput()); @@ -3649,10 +3668,17 @@ void vvMainWindow::UpdateRenderWindows() mSlicerManagers[i]->GetSlicer(j)->DisplayLandmarks(); } } +#if VTK_MAJOR_VERSION >= 9 + if (NOViewWidget->renderWindow()) NOViewWidget->renderWindow()->Render(); + if (NEViewWidget->renderWindow()) NEViewWidget->renderWindow()->Render(); + if (SOViewWidget->renderWindow()) SOViewWidget->renderWindow()->Render(); + if (SEViewWidget->renderWindow()) SEViewWidget->renderWindow()->Render(); +#else if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render(); if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render(); if (SOViewWidget->GetRenderWindow()) SOViewWidget->GetRenderWindow()->Render(); if (SEViewWidget->GetRenderWindow()) SEViewWidget->GetRenderWindow()->Render(); +#endif } //------------------------------------------------------------------------------ diff --git a/vv/vvSegmentationDialog.cxx b/vv/vvSegmentationDialog.cxx index b538b9d6..19c17396 100644 --- a/vv/vvSegmentationDialog.cxx +++ b/vv/vvSegmentationDialog.cxx @@ -183,7 +183,11 @@ void vvSegmentationDialog::SetImage(vvImage::Pointer image) QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); mManager->SetImage(image); +#if VTK_MAJOR_VERSION >= 9 + mManager->SetSlicerWindow(0,viewWidget->renderWindow()); +#else mManager->SetSlicerWindow(0,viewWidget->GetRenderWindow()); +#endif vvInteractorStyleNavigator* style = vvInteractorStyleNavigator::New(); mManager->SetInteractorStyleNavigator(0,style); style->Delete(); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index c42e6fa3..ad798ed8 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -78,9 +78,9 @@ #include #include #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) -# include -# include -# include + #include + #include + #include #endif vtkStandardNewMacro(vvSlicer); diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index e952cc9e..c6e8ea7b 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -67,7 +67,13 @@ Q_OBJECT public: static vvSlicer *New(); vtkTypeMacro(vvSlicer,vtkImageViewer2); +#if VTK_MAJOR_VERSION >= 8 + void PrintSelf(ostream& os, vtkIndent indent) override; +#elif VTK_MAJOR_VERSION >= 7 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; +#else + void PrintSelf(ostream& os, vtkIndent indent); +#endif void SetImage(vvImage::Pointer inputImages); vvImage::Pointer GetImage() { @@ -108,14 +114,26 @@ Q_OBJECT void SetFusionSequenceTSlice(int t); +#if VTK_MAJOR_VERSION >= 8 + void SetSliceOrientation(int orientation) override; +#elif VTK_MAJOR_VERSION >= 7 void SetSliceOrientation(int orientation) VTK_OVERRIDE; +#else + void SetSliceOrientation(int orientation); +#endif void AdjustResliceToSliceOrientation(vtkImageReslice *reslice); int GetTSlice(); int GetFusionTSlice(); int GetOverlayTSlice(); int GetMaxCurrentTSlice(); ///Reimplemented from vtkImageViewer2 to add polydata support +#if VTK_MAJOR_VERSION >= 8 + void SetSlice(int s) override; +#elif VTK_MAJOR_VERSION >= 7 void SetSlice(int s) VTK_OVERRIDE; +#else + void SetSlice(int s); +#endif int GetTMax(); void SetOpacity(double s); @@ -124,7 +142,13 @@ Q_OBJECT void FlipHorizontalView(); void FlipVerticalView(); double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component=0); +#if VTK_MAJOR_VERSION >= 8 + void Render() override; +#elif VTK_MAJOR_VERSION >= 7 void Render() VTK_OVERRIDE; +#else + void Render(); +#endif ///Sets the camera to fit the image in the window void ResetCamera(); @@ -183,8 +207,16 @@ Q_OBJECT void ToggleContourSuperposition(); void SetInterpolationImageReslice(int interpolation); +#if VTK_MAJOR_VERSION >= 8 + virtual void SetColorWindow(double s) override; + virtual void SetColorLevel(double s) override; +#elif VTK_MAJOR_VERSION >= 7 virtual void SetColorWindow(double s) VTK_OVERRIDE; virtual void SetColorLevel(double s) VTK_OVERRIDE; +#else + virtual void SetColorWindow(double s); + virtual void SetColorLevel(double s); +#endif double GetOverlayColorWindow(); double GetOverlayColorLevel(); @@ -301,8 +333,16 @@ Q_OBJECT bool showFusionLegend; private: +#if VTK_MAJOR_VERSION >= 8 + void UpdateOrientation() override; + void UpdateDisplayExtent() override; +#elif VTK_MAJOR_VERSION >= 7 void UpdateOrientation() VTK_OVERRIDE; void UpdateDisplayExtent() VTK_OVERRIDE; +#else + void UpdateOrientation(); + void UpdateDisplayExtent(); +#endif void ConvertImageToImageDisplayExtent(vtkInformation *sourceImage, const int sourceExtent[6], vtkImageData *targetImage, int targetExtent[6]); void ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6], diff --git a/vv/vvSurfaceViewerDialog.cxx b/vv/vvSurfaceViewerDialog.cxx index da0381a4..18efd9c4 100644 --- a/vv/vvSurfaceViewerDialog.cxx +++ b/vv/vvSurfaceViewerDialog.cxx @@ -132,18 +132,31 @@ void vvSurfaceViewerDialog::LoadSurface() if (!mRenderer) { mRenderer = vtkRenderer::New(); mRenderer->AddActor(mActor); +#if VTK_MAJOR_VERSION >= 9 + renderWidget->renderWindow()->AddRenderer(mRenderer); +#else renderWidget->GetRenderWindow()->AddRenderer(mRenderer); +#endif } mRenderer->ResetCamera(); +#if VTK_MAJOR_VERSION >= 9 + renderWidget->renderWindow()->Render(); +#else renderWidget->GetRenderWindow()->Render(); +#endif vvManagerCallback *smc = vvManagerCallback::New(); smc->IV = this; - +#if VTK_MAJOR_VERSION >= 9 + if (renderWidget->renderWindow()->GetInteractor()) + renderWidget->renderWindow()->GetInteractor()-> + GetInteractorStyle()->AddObserver(vtkCommand::KeyPressEvent, smc); +#else if (renderWidget->GetRenderWindow()->GetInteractor()) renderWidget->GetRenderWindow()->GetInteractor()-> GetInteractorStyle()->AddObserver(vtkCommand::KeyPressEvent, smc); +#endif //readHeader->Delete(); } @@ -158,7 +171,11 @@ void vvSurfaceViewerDialog::NextTime() mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort()); #endif mMapper->Modified(); +#if VTK_MAJOR_VERSION >= 9 + renderWidget->renderWindow()->Render(); +#else renderWidget->GetRenderWindow()->Render(); +#endif } void vvSurfaceViewerDialog::PreviousTime() @@ -172,7 +189,11 @@ void vvSurfaceViewerDialog::PreviousTime() mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort()); #endif mMapper->Modified(); +#if VTK_MAJOR_VERSION >= 9 + renderWidget->renderWindow()->Render(); +#else renderWidget->GetRenderWindow()->Render(); +#endif } #endif /* end #define _vvSurfaceViewerDialog_CXX */ diff --git a/vv/vvToolHistogram.cxx b/vv/vvToolHistogram.cxx index 9ae1e1e0..27210f7b 100644 --- a/vv/vvToolHistogram.cxx +++ b/vv/vvToolHistogram.cxx @@ -94,8 +94,13 @@ vvToolHistogram::vvToolHistogram(vvMainWindowBase * parent, Qt::WindowFlags f) chart->SetRenderEmpty(true); mView->GetScene()->AddItem(chart); mView->GetRenderer()->SetBackground(1.0, 1.0, 1.0); +#if VTK_MAJOR_VERSION >= 9 + this->HistogramWidget->renderWindow()->GetRenderers()->RemoveAllItems(); + this->HistogramWidget->renderWindow()->AddRenderer(mView->GetRenderer()); +#else this->HistogramWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); this->HistogramWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); +#endif HistogramWidget->show(); #ifdef Q_OS_OSX @@ -201,8 +206,13 @@ void vvToolHistogram::displayHistogram() chart->GetAxis(vtkAxis::LEFT)->SetTitle("#Voxels"); chart->GetAxis(vtkAxis::BOTTOM)->SetTitle("Intensity"); +#if VTK_MAJOR_VERSION >= 9 + this->HistogramWidget->renderWindow()->GetRenderers()->RemoveAllItems(); + this->HistogramWidget->renderWindow()->AddRenderer(mView->GetRenderer()); +#else this->HistogramWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); this->HistogramWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); +#endif HistogramWidget->show(); QApplication::restoreOverrideCursor(); @@ -300,10 +310,17 @@ void vvToolHistogram::InputIsSelected(vvSlicerManager * m) // Connect signals & slots vvToolHistogramCommand *smc = vvToolHistogramCommand::New(); smc->mHist = this; +#if VTK_MAJOR_VERSION >= 9 + HistogramWidget->renderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::LeftButtonPressEvent, smc); + HistogramWidget->renderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseMoveEvent, smc); + HistogramWidget->renderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelForwardEvent, smc); + HistogramWidget->renderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelBackwardEvent, smc); +#else HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::LeftButtonPressEvent, smc); HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseMoveEvent, smc); HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelForwardEvent, smc); HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelBackwardEvent, smc); +#endif smc->Delete(); } diff --git a/vv/vvToolHistogramCommand.cxx b/vv/vvToolHistogramCommand.cxx index 585f16ce..d003a255 100644 --- a/vv/vvToolHistogramCommand.cxx +++ b/vv/vvToolHistogramCommand.cxx @@ -64,7 +64,11 @@ void vvToolHistogramCommand::Execute(vtkObject *caller, } if (event == vtkCommand::MouseMoveEvent) { if (mFollowMouse) { +#if VTK_MAJOR_VERSION >= 9 + vtkSmartPointer interactor = mHist->GetHistogramWidget()->renderWindow()->GetInteractor(); +#else vtkSmartPointer interactor = mHist->GetHistogramWidget()->GetRenderWindow()->GetInteractor(); +#endif if (interactor->GetEventPosition()[0] != interactor->GetLastEventPosition()[0]) mHist->translateWindow(interactor->GetEventPosition()[0] - interactor->GetLastEventPosition()[0]); } diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx index ee6b3e0c..357aa17c 100644 --- a/vv/vvToolProfile.cxx +++ b/vv/vvToolProfile.cxx @@ -106,8 +106,13 @@ vvToolProfile::vvToolProfile(vvMainWindowBase * parent, Qt::WindowFlags f) chart->SetAutoSize(false); chart->SetRenderEmpty(true); mView->GetScene()->AddItem(chart); +#if VTK_MAJOR_VERSION >= 9 + this->ProfileWidget->renderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->renderWindow()->AddRenderer(mView->GetRenderer()); +#else this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); +#endif ProfileWidget->show(); #ifdef Q_OS_OSX @@ -145,8 +150,13 @@ void vvToolProfile::selectPoint1() chart->SetRenderEmpty(true); mView->GetScene()->ClearItems(); mView->GetScene()->AddItem(chart); +#if VTK_MAJOR_VERSION >= 9 + this->ProfileWidget->renderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->renderWindow()->AddRenderer(mView->GetRenderer()); +#else this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); +#endif ProfileWidget->show(); mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P1", mPoint1[3]); } @@ -205,8 +215,13 @@ void vvToolProfile::selectPoint2() chart->SetRenderEmpty(true); mView->GetScene()->ClearItems(); mView->GetScene()->AddItem(chart); +#if VTK_MAJOR_VERSION >= 9 + this->ProfileWidget->renderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->renderWindow()->AddRenderer(mView->GetRenderer()); +#else this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); +#endif ProfileWidget->show(); mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P2", mPoint2[3]); } @@ -321,8 +336,13 @@ void vvToolProfile::computeProfile() chart->GetAxis(vtkAxis::LEFT)->SetTitle("Intensity"); chart->GetAxis(vtkAxis::BOTTOM)->SetTitle("Distance (mm)"); +#if VTK_MAJOR_VERSION >= 9 + this->ProfileWidget->renderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->renderWindow()->AddRenderer(mView->GetRenderer()); +#else this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); +#endif ProfileWidget->show(); QApplication::restoreOverrideCursor(); @@ -343,8 +363,13 @@ void vvToolProfile::cancelPoints() chart->SetRenderEmpty(true); mView->GetScene()->ClearItems(); mView->GetScene()->AddItem(chart); +#if VTK_MAJOR_VERSION >= 9 + this->ProfileWidget->renderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->renderWindow()->AddRenderer(mView->GetRenderer()); +#else this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); +#endif ProfileWidget->show(); QString position = "";