Documentation/Labs/Qt5-and-VTK8

From Slicer Wiki
Revision as of 20:53, 14 August 2017 by JChris.FillionR (talk | contribs)
Jump to: navigation, search
Home < Documentation < Labs < Qt5-and-VTK8

This page documents the update of Slicer to use Qt 5.

Overview

Because Qt4 is not actively developed (as documented here support ended), we need to work toward supporting Qt5. This page summarizes support status of the various components of Slicer stack and remaining tasks.


Building with Qt5 and VTK8

Status

2017-08-14

As of 2017-08-14, the support for Qt5 and VTK8 has been integrated into the trunk.

To configure Slicer:

cmake -DQt5_DIR:PATH=/home/jcfr/Software/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5 ...  ../Slicer

This will automatically build VTK8 with OpenGL2 backend enabled.

./Slicer-build/Slicer --enable-experimental-web-platform-features --enable-unsafe-es3-apis --remote-debugging-port=12117 --use-gl=desktop


  • Fix Slicer test failures:
    • Floating point exceptions ("SIGFPE with code FPE_FLTUND") on Mac (ModelToLabelMapTest, ModelToLabelMapTestLabelValue, N4ITKBiasFieldCorrectionTest).
    • py_LandmarkRegistration crash on exit.
    • qMRMLLayoutManagerWithCustomFactoryTest ("vtkPlaneSource: Bad plane coordinate system").
    • ResampleDTIVolumeBSplineInterpolationTest (image diff?).
    • py_VolumeRenderingThreeDOnlyLayout on Windows ("Shader object was not initialized, cannot attach it."). This is a similar issue as was fixed in r25239, but resurrected due to the behavior of QVTKOpenGLWidget. The old fix is insufficient.

2017-08-07

As of 2017-08-07 the relevant branches for testing are:


For VS2015 gotchas, see below.

  • Qt5/VTK8 integration TODO:
    • Properly initialize QVTKOpenGLWidget. Call QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance so that an OpenGL core profile context is requested.
    • Properly initialize QVTKOpenGLWidget for tests. Call QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance so that an OpenGL core profile context is requested. (Slicer, CTK)
    • Enable C++11 for Slicer, extensions, and libraries as appropriate.
    • Set OpenGL2 as default rendering backend.
    • CTK and Slicer QtTesting tests refer to QVTKWidget. Can they be converted to recognize QVTKOpenGLWidget?
    • Merge and update CTK: https://github.com/commontk/PythonQt/pull/57 ("Fix compile error on MSVC with Qt 5.7.1")
    • Merge and update VTK: https://gitlab.kitware.com/vtk/vtk/merge_requests/3014 ("Fix linking libvtkWrapping with Python wrapping and kits enabled on Mac")
    • Merge and update VTK: https://gitlab.kitware.com/vtk/vtk/merge_requests/3041 ("QVTKOpenGLWidget: Set screen size on render window")
    • Fix and update VTK: https://gitlab.kitware.com/vtk/vtk/issues/17091 ("QVTKOpenGLWidget: Picking vtkActor2D fails"). In Slicer one operation this issue affects is picking slice view ROI box handles. Merged in https://gitlab.kitware.com/vtk/vtk/merge_requests/3103.
    • Fix and update VTK: https://gitlab.kitware.com/vtk/vtk/issues/17076 ("OpenGL errors occur when destroying vtkWin32OpenGLRenderWindow") (Only affects old OpenGL backend.)
    • Merge and update VTK: QVTKOpenGLWidget can blit uninitialized framebuffers. On Mac, the bug is evident through visible artifacts when resizing the views. See https://gitlab.kitware.com/vtk/vtk/merge_requests/3138.
    • Clicking on module search result in popup does not open the module. ComboBox does not always show the selected item.
    • Fix Slicer test failures:
      • Floating point exceptions ("SIGFPE with code FPE_FLTUND") on Mac (ModelToLabelMapTest, ModelToLabelMapTestLabelValue, N4ITKBiasFieldCorrectionTest).
      • py_LandmarkRegistration crash on exit.
      • qMRMLLayoutManagerWithCustomFactoryTest ("vtkPlaneSource: Bad plane coordinate system").
      • ResampleDTIVolumeBSplineInterpolationTest (image diff?).
      • py_VolumeRenderingThreeDOnlyLayout on Windows ("Shader object was not initialized, cannot attach it."). This is a similar issue as was fixed in r25239, but resurrected due to the behavior of QVTKOpenGLWidget. The old fix is insufficient.
      • qMRMLColorPickerWidgetTest2 on Mac crashes due to changes in QColorDialog in Qt5. CTK should no longer assume the non-native dialog is constructed, i.e. the layouts exist, when ctkColorDialog is instantiated.
    • Fix CTK Qt5 test failures.
    • OpenSSL/DataStore/qRestAPI issues?
    • Packaging?
    • CTK needs to properly export CTK_USE_QVTKOPENGLWIDGET so that the preprocessor correctly handles #if CTK_USE_QVTKOPENGLWIDGET in its header files. Or, an alternative mechanism could be implemented.
    • Windows/Linux: CPU and GPU Volume Rendering display nothing or are corrupt. GPU Volume Rendering gives OpenGL errors. Disabling multisampling before creating the default surface format fixes this. See https://gitlab.kitware.com/vtk/vtk/issues/17095.
    • Mac: Slice views use only lower-left quarter of widget.
      • Set Qt::AA_EnableHighDpiScaling to enable automatic scaling based on the pixel density of the monitor. This enables High DPI for platforms other than Mac.
      • Call setEnableHiDPI(true) on QVTKOpenGLWidgets.
      • qMRMLSliceWidget: Scale SliceView geometry by its devicePixelRatio() before calling this->SliceController->setSliceViewSize().
      • qMRMLSliceWidget: Observe change in devicePixelRatio (i.e. app dragged to another screen) and recompute slice view size.
    • Volume Rendering transfer functions aren't displayed correctly. (ctkVTKChartView)
    • Fix vtkWindowToImageFilter usage of method deprecated in VTK8.1: https://github.com/Kitware/VTK/blob/b8eae1e022cc71de5dcac578f4087b71d8573324/Rendering/Core/vtkWindowToImageFilter.h#L95
    • Fix Qt deprecation warnings.
    • Find and fix layout changes. For example, some widgets likely need to set QSizePolicy::Expanding, such as the exit application confirmation dialog.
    • Address "Policy CMP0020 is not set: Automatically link Qt executables to qtmain target on Windows" warnings.
    • Test branch build with VTK7+OpenGL backend.
    • Test branch build with VTK7+OpenGL2 backend.
    • Test branch build with Qt4.
    • Test with Qt5.9.1.
    • Support VS2015 by updating to latest python-cmake-buildsystem. Prerequisite: make pre-compiled OpenSSL available for VS2015/VS2017.
    • Test with VS2015. Build shows errors in console at start:
      Failed to obtain reference to 'FileMenu'
      Failed to obtain reference to 'qSlicerAppMainWindow'
      No Data Probe frame - cannot create DataProbe
      Failed to obtain reference to 'qSlicerAppMainWindow'
      Failed to obtain reference to 'FileMenu'
    • Update MultiVolumeExplorer hash for Qt5 support.
    • Fix CTK warnings. See http://slicer.cdash.org/viewBuildError.php?type=1&buildid=1076772.

2017-08-02


2017-01

  • Original branch:

https://github.com/jcfr/Slicer/commits/support-qt5

2016-12

A first running example described in this commit
  • Superbuild configure command on mac using Qt 5.7 stock downloads
cmake \
  -DQT_QMAKE_EXECUTABLE:FILEPATH=/Users/pieper/Qt/5.7/clang_64/bin/qmake \
  -DCMAKE_PREFIX_PATH:PATH=/Users/pieper/Qt/5.7/clang_64/ \
  -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9 \
  -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \
  -DSlicer_USE_SimpleITK:BOOL=OFF \
  -DSlicer_USE_QtTesting:BOOL=OFF \
  -DSlicer_BUILD_EXTENSIONMANAGER_SUPPORT:BOOL=OFF \
  -DSlicer_QT_VERSION:STRING=5 \
  ../Slicer

Platform Notes

Experimental build on Window:

  • Visual Studio Community 2015
  • Qt 5.7
    • Include QtWebEngine and QtScript during install
    • Select 2015 64 bit install
  • Qt 5.8
    • Use Visual Studio Community 2015 or above. Qt-5.8 does not support QtWebEngine for msvc 2013.

Known Issues

  • Slice viewers do not have the expected size after changing layout

To Do List

All platforms
  • Slicer build system upgrade: To be done UnderConstruction.png
    • Add Slicer_QT_VERSION option that could be set to either 4 or 5 - See what is done in CTK Check.svg
    • Fix qRestAPI to support Qt5 (or turn off Slicer_BUILD_EXTENSIONMANAGER_SUPPORT for testing) Check.svg
    • Update use of QT4_* macros (see below) - See what is done in CTK Check.svg
      • The QT5_ versions of the macros appear to be directly compatible Check.svg
    • Port from QtWebKit to QtWebEngine
      • Update of classes using WebKit to work with WebEngineView (these includes "Extension Manager", "Data Store", "Chart View" and `qMRMLExpandingWebView`).
      • `qSlicerWebWidget` should be improved, moved to CTK and used for all widgets making use of a web view.
    • update PythonQt to the latest Qt version Check.svg
      • Look at updating PythonQt to support QWebEngine
    • Fix differences in plugin loading Check.svg
  • Qt5::Network is now a dependency of Base/QTCore (Networking module in Qt5 has classes like QNetworkProxyFactory that were in Qt4's QtCore module)
  • CTK Python wrapping doesn't expose grabWidget.
Linux
  • fix fox `libpng warning: iCCP: known incorrect sRGB profile`

Minimal working release experimental build (no cli, ssl, simpleitk, ...) built on ubuntu 16.04, tested on debian 8

  • needed to manually copy shared libraries:
    • libasound.so.2
    • libxslt.so.1
    • libsmime3
    • libstdc++.so.6 (glibc mismatch, needed GLIBCXX_3.4.21) should build instead with manylinux
  • like on mac, need to create bin/platfrms and bin/sqldrivers and copy in platforms/libqxcb.so and sqldrivers/libqsqlite.so
Mac
    • on Mac, QT_NO_OPENSSL is defined, but so is QSslError leading to redefined symbol [1](here).
    • Mac crash in qSlicerUnitsSettingsPanelPrivate::addQuantity, appears to be corrupted model. partly addressed by r25855 , finally resolved r25883. Most expedient solution is probably to disable the units settings panel in the application settings since is not widely used in the application.
    • Add libqcocoa.dylib and libqsqlite.dylib to package for mac
  mkdir Slicer-build/bin/Slicer.app/Contents/MacOS/sqldrivers
  cp ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlite.dylib Slicer-build/bin/Slicer.app/Contents/MacOS/sqldrivers/
  mkdir Slicer-build/bin/Slicer.app/Contents/MacOS/platforms
  cp ~/Qt/5.7/clang_64/plugins/platforms/libqcocoa.dylib Slicer-build/bin/Slicer.app/Contents/MacOS/platforms/
  • Workarounds here:

https://gist.github.com/pieper/59de820ad08cf3c0f7a33926397e612d

Windows
  • qtstyleplugins library needs to be removed or ported to support windows Check.svg
    • add declspec exports/imports
    • create .lib for use in QTGUI
    • support shared/static build?
  • AppLauncher settings need to be update
    • Add to PYTHONPATH: <superbuild>/VTKv7-build/bin/Debug (currently lib not bin) Check.svg
    • Add to PATH: <Qt>/5.7/msvc2013_64/bin
  • Debug build runs very slowly - can it be improved? Build is very slow too, but the application runs so slowly in debug mode that it is basically unusable (this is a change from previous version that were usable for testing real workflows in debug mode).
  • Setting Slicer_USE_SimpleITK to ON in CMake results in compile-time errors.
  • Creating a debug build (MSVC 2013, Qt5.7) creates a compile time error on PythonQt.cpp while building the CTK project with message:
    • Error 1220 error C1128: number of sections exceeded object file format limit: compile with /bigobj 

Example starting point command:

cmake \
  -DQt5_DIR:FILEPATH=c:/Qt/5.7/msvc2013_64/lib/cmake/Qt5 \
  -DCMAKE_CONFIGUREATION_TYPES:STRING=Release \
  -DADDITIONAL_C_FLAGS:STRING=" /MP8" \
  -DADDITIONAL_CXX_FLAGS:STRING=" /MP8" \
  -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \
  -DSlicer_USE_SimpleITK:BOOL=OFF \
  -DSlicer_USE_QtTesting:BOOL=OFF \
  -DSlicer_BUILD_EXTENSIONMANAGER_SUPPORT:BOOL=OFF \
  -DSlicer_BUILD_DataStore:BOOL=OFF \
  -DSlicer_QT_VERSION:STRING=5 \
  -DBUILD_TESTING:BOOL=OFF \
  -G"Visual Studio 12 2013 Win64" \
  c:/pieper/slicer4/latest/Slicer


Migration Guide

Also see https://www.slicer.org/wiki/Documentation/Labs/VTK8#Migration_guide.

To do items (partial list):

  • update loadable modules to use new plugin macros
  • any use of QWebKit needs to switch to QWebEngine

List of extensions that may require updates

TBD (probably all extensions need work)

References