Skip to content

Commit

Permalink
Updating to Qt 6
Browse files Browse the repository at this point in the history
* Remove some deprecated calls.

* Update CMake Lists

* Update OIGTL/OIGTLIO

* VTK fix
  • Loading branch information
errollgarner committed Nov 25, 2024
1 parent 3f9474e commit 38fd077
Show file tree
Hide file tree
Showing 36 changed files with 182 additions and 210 deletions.
6 changes: 2 additions & 4 deletions CMakeCommon/windeployqt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

find_package(Qt5Core REQUIRED)
find_package(Qt6Core REQUIRED)

# Retrieve the absolute path to qmake and then use that path to find
# the windeployqt binary
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")

Expand All @@ -44,7 +44,6 @@ function(windeployqt target directory)
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--verbose 0
--no-compiler-runtime
--no-angle
--no-opengl-sw
\"$<TARGET_FILE:${target}>\"
)
Expand All @@ -65,7 +64,6 @@ function(windeployqt target directory)
env PATH=\"${_qt_bin_dir}\" \"${WINDEPLOYQT_EXECUTABLE}\"
--dry-run
--no-compiler-runtime
--no-angle
--no-opengl-sw
--list mapping
\${_file}
Expand Down
34 changes: 14 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,22 @@ endif()
if( IBIS_USE_QT_NETWORK )
list( APPEND IbisQtModules Network )
endif()
if( UNIX AND NOT APPLE )
list( APPEND IbisQtModules X11Extras )
MESSAGE("MODULES: ${IbisQtModules}")
foreach( module IN LISTS ${IbisQtModules} )
message("module::${module}")
endforeach()
find_package( Qt6 COMPONENTS ${IbisQtModules} REQUIRED )

if( NOT Qt6Widgets_FOUND )
message( SEND_ERROR "The Qt6Widgets library could not be found!" )
endif()
find_package( Qt5 COMPONENTS ${IbisQtModules} REQUIRED )

# Qt support by Qt Company: QT 5.1.0 to 5.5.0 support ended. 5.6.0 still supported until March 2019.
# ibis was never tested with versions 5.6.0, 5.7.0 and 5.8.0. It might work with 5.8.0.
# it worked with 5.9.3
cmake_path(GET Qt6_DIR PARENT_PATH Qt6_root)

if( Qt5Widgets_FOUND )
if( Qt5Widgets_VERSION VERSION_LESS 5.6.0 )
message( SEND_ERROR "Qt version 5.5.x or lower is no longer supported.\nCurrently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} "." )
elseif( Qt5Widgets_VERSION VERSION_LESS 5.9.0 )
message( SEND_ERROR "Currently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} ". It may work." )
endif()
else()
message( SEND_ERROR "The Qt5Widgets library could not be found!" )
endif()

include_directories( ${Qt5Widgets_INCLUDE_DIRS} )
include_directories( ${Qt5Xml_INCLUDE_DIRS} )
include_directories( ${Qt5Multimedia_INCLUDE_DIRS} )
MESSAGE("INCLUDES:${Qt6Widgets_INCLUDE_DIRS}::${Qt6Xml_INCLUDE_DIRS}::${Qt6Multimedia_INCLUDE_DIRS}")
include_directories( ${Qt6Widgets_INCLUDE_DIRS} )
include_directories( ${Qt6Xml_INCLUDE_DIRS} )
include_directories( ${Qt6Multimedia_INCLUDE_DIRS} )

#==================================================================
# Look for VTK (required)
Expand Down Expand Up @@ -178,4 +172,4 @@ if( IBIS_BUILD_DOCUMENTATION )
else( DOXYGEN_FOUND )
message( "Doxygen needs to be installed to generate documentation" )
endif()
endif()
endif()
27 changes: 18 additions & 9 deletions Ibis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PROJECT ( IBIS_MAIN )

# define sources
SET( IBIS_SRC main.cpp commandlinearguments.cpp )
SET( IBIS_HDR commandlinearguments.h )
set( IBIS_SRC main.cpp commandlinearguments.cpp )
set( IBIS_HDR commandlinearguments.h )
set( exec_name ibis )

# option to turn on vtk warnings
Expand All @@ -12,7 +12,7 @@ if( NOT IBIS_ENABLE_VTK_WARNINGS )
endif()

# moc Qt source file without a ui file
qt5_wrap_cpp( IBIS_MOC ${IBIS_HDR_MOC} )
qt6_wrap_cpp( IBIS_MOC ${IBIS_HDR_MOC} )

# make rules to create c++ source from Qt resource files

Expand Down Expand Up @@ -70,7 +70,7 @@ endif()
#================================
# Define executable
#================================
SET( SOURCE ${IBIS_HDR} ${IBIS_HDR_MOC} ${IBIS_SRC} ${ImportPluginsSourceFile} ${IBIS_MOC} ${IBIS_SRC_ICNS} ${platform_src} )
set( SOURCE ${IBIS_HDR} ${IBIS_HDR_MOC} ${IBIS_SRC} ${ImportPluginsSourceFile} ${IBIS_MOC} ${IBIS_SRC_ICNS} ${platform_src} )
ADD_EXECUTABLE( ${exec_name} ${executable_flags} ${SOURCE} )

if (APPLE)
Expand All @@ -90,10 +90,19 @@ if( USE_POINT_GREY_CAMERA )
set( flycaptureLib flycapture )
endif()

TARGET_LINK_LIBRARIES( ${exec_name} ${PluginLibs} ${PluginExternalLibs} ${HardwareModulesLibs} ${libsToUse} ${QT_LIBRARIES}
${VTK_LIBRARIES} ${MINC4ITK_LIBRARIES} ${ELASTIX_LIBRARIES}
target_link_libraries( ${exec_name} ${PluginLibs} ${PluginExternalLibs} ${HardwareModulesLibs} ${libsToUse}
${VTK_LIBRARIES} ${MINC4ITK_LIBRARIES} ${ELASTIX_LIBRARIES}
${itkLibsToUse} ${OpenCV_LIBS} ${flycaptureLib} svl ${gpuLibs} )
qt5_use_modules( ${exec_name} ${IbisQtModules} )
message("MODULES:${IbisQtModules}")
message("QTLIBRARIES:${QT_LIBRARIES}")
#target_link_libraries( ${exec_name} Qt6::Widgets )
#target_link_libraries( ${exec_name} Qt6::Xml )
#target_link_libraries( ${exec_name} Qt6::OpenGL )
#qt6_use_modules( ${exec_name} ${IbisQtModules} )
foreach( module IN LISTS IbisQtModules )
message( STATUS "Linking against Qt6::${module}" )
target_link_libraries( ${exec_name} "Qt6::${module}" )
endforeach()

vtk_module_autoinit( TARGETS ${exec_name} MODULES ${VTK_LIBRARIES})

Expand All @@ -117,7 +126,7 @@ endif()
#================================
if( APPLE )
# On mac, we need to run macdeployqt on the installed bundle (should eventually implement a better solution)
get_target_property( QMakeLocation Qt5::qmake LOCATION)
get_target_property( QMakeLocation Qt6::qmake LOCATION)
get_filename_component( QtBinLocation ${QMakeLocation} DIRECTORY )
set( MacDeployQtExec ${QtBinLocation}/macdeployqt )
set( BuiltExecFullPath ${CMAKE_CURRENT_BINARY_DIR}/${exec_name}.app )
Expand Down Expand Up @@ -148,7 +157,7 @@ endif()
#================================
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ibis image-guided neurosurgery program and viewer")
set( CPACK_PACKAGE_NAME ${exec_name} )
set( CPACK_PACKAGE_CONTACT "Simon Drouin and Anka Kochanowska")
set( CPACK_PACKAGE_CONTACT "Étienne Léger")
set( CPACK_PACKAGE_VENDOR "NeuroImaging and Surgical Technologies (NIST) Lab - McConnell Brain Imaging Centre - Montreal Neurological Institute")
set( CPACK_PACKAGE_VERSION_MAJOR ${IBIS_MAJOR_VERSION})
set( CPACK_PACKAGE_VERSION_MINOR ${IBIS_MINOR_VERSION})
Expand Down
4 changes: 2 additions & 2 deletions IbisHardwareIGSIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ set( IbisHardwareIgsioHdrMoc ibishardwareIGSIO.h plusserverinterface.h ibishardw
set( IbisHardwareIgsioUi ibishardwareIGSIOsettingswidget.ui )

# moc Qt source file without a ui file
qt5_wrap_cpp( IbisHardwareIgsioMoc ${IbisHardwareIgsioHdrMoc} )
qt6_wrap_cpp( IbisHardwareIgsioMoc ${IbisHardwareIgsioHdrMoc} )

# Generate code for .ui files -> ui_xxx.h
qt5_wrap_ui( IbisHardwareIgsioUiHdr ${IbisHardwareIgsioUi} )
qt6_wrap_ui( IbisHardwareIgsioUiHdr ${IbisHardwareIgsioUi} )

#================================
# Define output
Expand Down
4 changes: 2 additions & 2 deletions IbisHardwareIGSIO/ibishardwareIGSIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ See Copyright.txt or http://ibisneuronav.org/Copyright.html for details.
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef __IbisHardwareIGSIO_h_
#define __IbisHardwareIGSIO_h_
#ifndef IBISHARDWAREIGSIO_H
#define IBISHARDWAREIGSIO_H

#include <igtlioDevice.h>

Expand Down
6 changes: 3 additions & 3 deletions IbisLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ set( IBISLIB_UI


# moc Qt source file without a ui file
qt5_wrap_cpp( IBISLIB_MOC ${IBISLIB_HDR_MOC} )
qt6_wrap_cpp( IBISLIB_MOC ${IBISLIB_HDR_MOC} )

# Generate code for .ui files -> ui_xxx.h
qt5_wrap_ui( IBISLIB_HDR_UI ${IBISLIB_UI} )
qt6_wrap_ui( IBISLIB_HDR_UI ${IBISLIB_UI} )

# make rules to create c++ source from Qt resource files
set( IBISLIB_RCC IbisLib.qrc )
qt5_add_resources( IBISLIB_RCC_SRC ${IBISLIB_RCC})
qt6_add_resources( IBISLIB_RCC_SRC ${IBISLIB_RCC})

#================================
# Define output
Expand Down
23 changes: 13 additions & 10 deletions IbisLib/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void ApplicationSettings::LoadSettings( QSettings & settings )
ViewBackgroundColor.setGreen( settings.value( "ViewBackgroundColor_g", 50 ).toInt() );
ViewBackgroundColor.setBlue( settings.value( "ViewBackgroundColor_b", 50 ).toInt() );
// then 3D view, if not found in settings, set the same as 2D.
double bgColor[3];
float bgColor[3];
ViewBackgroundColor.getRgbF( &bgColor[0], &bgColor[1], &bgColor[2] );
View3DBackgroundColor.setRed( settings.value( "View3DBackgroundColor_r", int( bgColor[0] * 255 ) ).toInt() );
View3DBackgroundColor.setGreen( settings.value( "View3DBackgroundColor_g", int( bgColor[1] * 255 ) ).toInt() );
Expand Down Expand Up @@ -221,14 +221,17 @@ Application::~Application()

void Application::ApplyApplicationSettings()
{
double bgColor[3];
float bgColor[3];
m_settings.ViewBackgroundColor.getRgbF( &bgColor[0], &bgColor[1], &bgColor[2] );
m_sceneManager->SetViewBackgroundColor( bgColor );
double bgColord[3] = { bgColor[0], bgColor[1], bgColor[2] };
m_sceneManager->SetViewBackgroundColor( bgColord );
m_settings.View3DBackgroundColor.getRgbF( &bgColor[0], &bgColor[1], &bgColor[2] );
m_sceneManager->SetView3DBackgroundColor( bgColor );
//TODO
//double bgColord[3] = { bgColor[0], bgColor[1], bgColor[2] };
m_sceneManager->SetView3DBackgroundColor( bgColord );
m_sceneManager->Set3DCameraViewAngle( m_settings.CameraViewAngle3D );

double cursorColor[3];
float cursorColor[3];
m_settings.CutPlanesCursorColor.getRgbF( &cursorColor[0], &cursorColor[1], &cursorColor[2] );
WorldObject * world = WorldObject::SafeDownCast( m_sceneManager->GetSceneRoot() );
world->SetCursorColor( cursorColor );
Expand Down Expand Up @@ -445,7 +448,7 @@ void Application::OpenFiles( OpenFileParams * params, bool addToScene )
{
QString message( "No read permission on file: " );
message.append( cur.fileName );
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
return;
}
if( m_fileReader->IsMINC1( cur.fileName.toUtf8().data() ) )
Expand Down Expand Up @@ -557,7 +560,7 @@ bool Application::GetPointsFromTagFile( QString fileName, PointsObject * pts1, P
{
QString message( "No read permission on file: " );
message.append( fileName );
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
return false;
}
bool ok = m_fileReader->GetPointsDataFromTagFile( fileName, pts1, pts2 );
Expand Down Expand Up @@ -1014,7 +1017,7 @@ int Application::GetNumberOfComponents( QString filename )
{
QString message( "No read permission on file: " );
message.append( filename );
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
return false;
}
int n = m_fileReader->GetNumberOfComponents( filename );
Expand All @@ -1031,7 +1034,7 @@ bool Application::GetGrayFrame( QString filename, IbisItkUnsignedChar3ImageType:
{
QString message( "No read permission on file: " );
message.append( filename );
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
return false;
}
bool ok = m_fileReader->GetGrayFrame( filename, itkImage );
Expand All @@ -1049,7 +1052,7 @@ bool Application::GetRGBFrame( QString filename, IbisRGBImageType::Pointer itkIm
{
QString message( "No read permission on file: " );
message.append( filename );
QMessageBox::critical( nullptr, "Error", message, 1, 0 );
QMessageBox::critical( nullptr, "Error", message, QMessageBox::Ok );
return false;
}
bool ok = m_fileReader->GetRGBFrame( filename, itkImage );
Expand Down
10 changes: 5 additions & 5 deletions IbisLib/filereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void FileReader::SetIbisAPI( IbisAPI * api )
QString mincDir = m_ibisAPI->GetCustomPath( MINCToolsPathVarName );
if( !mincDir.isNull() && !mincDir.isEmpty() )
{
if( mincDir.at( mincDir.count() - 1 ) != '/' ) mincDir.append( "/" );
if( mincDir.at( mincDir.size() - 1 ) != '/' ) mincDir.append( "/" );
m_mincconvert.clear();
m_mincconvert.append( mincDir );
m_mincconvert.append( "mincconvert" );
Expand Down Expand Up @@ -183,7 +183,7 @@ bool FileReader::ConvertMINC1toMINC2( QString & inputileName, QString & outputil
tmp.append( inputileName + " is of MINC1 type and needs to be converted to MINC2.\n" +
"Tool mincconvert was not found in standard paths on your file system.\n" +
"Please convert using command: \nmincconvert -2 <input> <output>" );
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
return false;
}
QString dirname( QDir::homePath() );
Expand Down Expand Up @@ -247,7 +247,7 @@ bool FileReader::ConvertMINC1toMINC2( QString & inputileName, QString & outputil
QString tmp( "File " );
tmp.append( inputileName + " is an acquired frame of MINC1 type and needs to be converted to MINC2.\n" +
"Tool minccalc was not found in standard paths on your file system.\n" );
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
return false;
}
}
Expand Down Expand Up @@ -346,7 +346,7 @@ bool FileReader::OpenFile( QList<SceneObject *> & readObjects, QString filename,
QString tmp( "File " );
tmp.append( filename + " is of MINC1 type and needs to be converted to MINC2.\n" +
"Open Settings/Preferences and set path to the directory containing MINC tools.\n" );
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
return false;
}
if( this->ConvertMINC1toMINC2( filename, fileMINC2, true ) )
Expand Down Expand Up @@ -847,7 +847,7 @@ int FileReader::GetNumberOfComponents( QString filename )
QString tmp( "File " );
tmp.append( filename + " is an acquired frame of MINC1 type and needs to be converted to MINC2.\n" +
"Open Settings/Preferences and set path to the directory containing MINC tools.\n" );
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
return 0;
}
if( this->ConvertMINC1toMINC2( filename, fileMINC2, true ) )
Expand Down
1 change: 0 additions & 1 deletion IbisLib/gui/opendatafiledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ See Copyright.txt or http://ibisneuronav.org/Copyright.html for details.
#include <QObject>
#include <QString>

class QStringList;
class OpenFileParams;
class SceneManager;

Expand Down
2 changes: 1 addition & 1 deletion IbisLib/gui/pathform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void PathForm::PathLineEditChanged()
QString tmp( "File/Directory:\n" );
tmp.append( ui->pathLineEdit->text() );
tmp.append( "\ndoes not exist. Please enter a valid path." );
QMessageBox::critical( 0, "Error", tmp, 1, 0 );
QMessageBox::critical( 0, "Error", tmp, QMessageBox::Ok );
ui->pathLineEdit->setText( "" );
}
emit PathChanged( ui->label->text(), ui->pathLineEdit->text() );
Expand Down
34 changes: 0 additions & 34 deletions IbisLib/gui/pointercalibrationdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -220,38 +220,4 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>calibrateButton</sender>
<signal>clicked()</signal>
<receiver>PointerCalibrationDialog</receiver>
<slot>CalibrateButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>PointerCalibrationDialog</receiver>
<slot>CancelButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>
4 changes: 1 addition & 3 deletions IbisLib/gui/quadviewwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,13 @@ void QuadViewWindow::AddBottomWidget( QWidget * w )

void QuadViewWindow::RemoveBottomWidget( QWidget * w ) { w->close(); }

#include <QDesktopWidget>

void QuadViewWindow::Detach3DView( QWidget * /*parent*/ )
{
Q_ASSERT( !m_detachedWidget );

m_detachedWidget = new QWidget();
QVBoxLayout * layout = new QVBoxLayout( m_detachedWidget );
layout->setMargin( 0 );
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( m_vtkWidgets[1] );

int nbScreens = QGuiApplication::screens().size();
Expand Down
1 change: 0 additions & 1 deletion IbisLib/ibispreferences.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "ibispreferences.h"

#include <QApplication>
#include <QDesktopWidget>
#include <QRect>
#include <QScreen>

Expand Down
Loading

0 comments on commit 38fd077

Please sign in to comment.