mirror of https://github.com/CGAL/cgal
Upgrade of AABB_Tree Demo to Qt5
- setBackgroudColor was called too soon(in the constructor of the viewer), now called in InitializeGL
This commit is contained in:
parent
65061d2c4a
commit
85c8e7e270
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
project( AABB_demo )
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
cmake_minimum_required(VERSION 2.6.2)
|
||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
|
||||
cmake_policy(VERSION 2.8.4)
|
||||
|
|
@ -11,52 +15,46 @@ endif()
|
|||
|
||||
# Include this package's headers first
|
||||
include_directories( BEFORE ./ ./include ../../include )
|
||||
|
||||
# Find CGAL and CGAL Qt4
|
||||
find_package(CGAL COMPONENTS Qt4)
|
||||
# Find CGAL and CGAL Qt5
|
||||
find_package(CGAL REQUIRED COMPONENTS Qt5 )
|
||||
include( ${CGAL_USE_FILE} )
|
||||
|
||||
# Find Qt4 itself
|
||||
set( QT_USE_QTXML TRUE )
|
||||
set( QT_USE_QTMAIN TRUE )
|
||||
set( QT_USE_QTSCRIPT TRUE )
|
||||
set( QT_USE_QTOPENGL TRUE )
|
||||
find_package(Qt4)
|
||||
# Find Qt5 itself
|
||||
find_package(Qt5 COMPONENTS Xml Script OpenGL)
|
||||
|
||||
# Find OpenGL
|
||||
find_package(OpenGL)
|
||||
|
||||
# Find QGLViewer
|
||||
if(QT4_FOUND)
|
||||
include(${QT_USE_FILE})
|
||||
if(Qt5_FOUND)
|
||||
find_package(QGLViewer )
|
||||
endif(QT4_FOUND)
|
||||
endif(Qt5_FOUND)
|
||||
|
||||
if(CGAL_FOUND AND CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||
if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||
|
||||
include_directories ( ${QGLVIEWER_INCLUDE_DIR} )
|
||||
|
||||
qt4_wrap_ui( UI_FILES MainWindow.ui )
|
||||
qt5_wrap_ui( UI_FILES MainWindow.ui )
|
||||
|
||||
include(AddFileDependencies)
|
||||
|
||||
qt4_generate_moc( "MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" )
|
||||
qt5_generate_moc( "MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" )
|
||||
add_file_dependencies( MainWindow_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h" )
|
||||
|
||||
qt4_generate_moc( "Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" )
|
||||
qt5_generate_moc( "Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" )
|
||||
add_file_dependencies( Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" )
|
||||
|
||||
qt4_generate_moc( "Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp" )
|
||||
qt5_generate_moc( "Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp" )
|
||||
add_file_dependencies( Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" )
|
||||
|
||||
qt4_add_resources ( RESOURCE_FILES AABB_demo.qrc )
|
||||
qt5_add_resources ( RESOURCE_FILES AABB_demo.qrc )
|
||||
|
||||
add_file_dependencies( AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp" )
|
||||
|
||||
add_executable ( AABB_demo AABB_demo.cpp ${UI_FILES} ${RESOURCE_FILES} )
|
||||
|
||||
qt5_use_modules(AABB_demo Gui OpenGL Xml Widgets Script )
|
||||
# Link with Qt libraries
|
||||
target_link_libraries( AABB_demo ${QT_LIBRARIES} )
|
||||
|
||||
|
|
@ -69,7 +67,7 @@ if(CGAL_FOUND AND CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FO
|
|||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS AABB_demo )
|
||||
|
||||
|
||||
else (CGAL_FOUND AND CGAL_CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||
else (CGAL_FOUND AND CGAL_CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||
|
||||
set(AABB_MISSING_DEPS "")
|
||||
|
||||
|
|
@ -77,12 +75,12 @@ else (CGAL_FOUND AND CGAL_CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLV
|
|||
set(AABB_MISSING_DEPS "the CGAL library, ${AABB_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT CGAL_Qt4_FOUND)
|
||||
set(AABB_MISSING_DEPS "the CGAL Qt4 library, ${AABB_MISSING_DEPS}")
|
||||
if(NOT CGAL_Qt5_FOUND)
|
||||
set(AABB_MISSING_DEPS "the CGAL Qt5 library, ${AABB_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT QT4_FOUND)
|
||||
set(AABB_MISSING_DEPS "Qt4, ${AABB_MISSING_DEPS}")
|
||||
if(NOT Qt5_FOUND)
|
||||
set(AABB_MISSING_DEPS "Qt5, ${AABB_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT OPENGL_FOUND)
|
||||
|
|
@ -95,4 +93,4 @@ else (CGAL_FOUND AND CGAL_CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLV
|
|||
|
||||
message(STATUS "NOTICE: This demo requires ${AABB_MISSING_DEPS}and will not be compiled.")
|
||||
|
||||
endif (CGAL_FOUND AND CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||
endif (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
#include "Scene.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
|
||||
|
||||
Viewer::Viewer(QWidget* parent)
|
||||
: QGLViewer(parent),
|
||||
m_pScene(NULL),
|
||||
m_custom_mouse(false)
|
||||
{
|
||||
setBackgroundColor(::Qt::white);
|
||||
}
|
||||
|
||||
void Viewer::setScene(Scene* pScene)
|
||||
|
|
@ -28,6 +29,7 @@ void Viewer::draw()
|
|||
void Viewer::initializeGL()
|
||||
{
|
||||
QGLViewer::initializeGL();
|
||||
setBackgroundColor(::Qt::white);
|
||||
}
|
||||
|
||||
void Viewer::mousePressEvent(QMouseEvent* e)
|
||||
|
|
|
|||
|
|
@ -11,37 +11,33 @@ else()
|
|||
endif()
|
||||
|
||||
# Find CGAL
|
||||
find_package(CGAL)
|
||||
find_package(CGAL REQUIRED COMPONENTS Qt5)
|
||||
include( ${CGAL_USE_FILE} )
|
||||
|
||||
# Find Qt4 itself
|
||||
set ( QT_USE_QTXML TRUE )
|
||||
set ( QT_USE_QTMAIN TRUE )
|
||||
set ( QT_USE_QTOPENGL TRUE )
|
||||
find_package(Qt4)
|
||||
# Find Qt5 itself
|
||||
find_package(Qt5 COMPONENTS Xml OpenGL Core)
|
||||
|
||||
# Find OpenGL
|
||||
find_package(OpenGL)
|
||||
|
||||
# Find QGLViewer
|
||||
if(QT4_FOUND)
|
||||
include( ${QT_USE_FILE} )
|
||||
if(Qt5_FOUND)
|
||||
find_package(QGLViewer)
|
||||
endif(QT4_FOUND)
|
||||
endif(Qt5_FOUND)
|
||||
|
||||
if (CGAL_FOUND AND OPENGL_FOUND AND QT4_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||
if (CGAL_FOUND AND OPENGL_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||
|
||||
include_directories( ${QGLVIEWER_INCLUDE_DIR} )
|
||||
|
||||
# UI files (Qt Designer files)
|
||||
qt4_wrap_ui ( UI_FILES MainWindow.ui )
|
||||
qt5_wrap_ui ( UI_FILES MainWindow.ui )
|
||||
|
||||
# qrc files (resource files)
|
||||
qt4_add_resources( RESOURCE_FILES ./Periodic_3_triangulation_3.qrc )
|
||||
qt5_add_resources( RESOURCE_FILES ./Periodic_3_triangulation_3.qrc )
|
||||
|
||||
# use the Qt MOC preprocessor on classes that derive from QObject
|
||||
qt4_generate_moc( "Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/moc_Scene.cpp" )
|
||||
qt4_generate_moc( "MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/moc_MainWindow.cpp" )
|
||||
qt5_generate_moc( "Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/moc_Scene.cpp" )
|
||||
qt5_generate_moc( "MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/moc_MainWindow.cpp" )
|
||||
|
||||
if(DEFINED QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||
else()
|
||||
|
|
@ -68,21 +64,23 @@ if (CGAL_FOUND AND OPENGL_FOUND AND QT4_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLEC
|
|||
MainWindow.ui moc_MainWindow.cpp
|
||||
${UI_FILES} ${RESOURCE_FILES} Periodic_3_triangulation_3.qhc)
|
||||
|
||||
qt5_use_modules(periodic_3_triangulation_3_demo Xml OpenGL)
|
||||
|
||||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS periodic_3_triangulation_3_demo)
|
||||
|
||||
# Link the executable to CGAL and third-party libraries
|
||||
target_link_libraries(periodic_3_triangulation_3_demo ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} )
|
||||
|
||||
else (CGAL_FOUND AND OPENGL_FOUND AND QT4_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||
else (CGAL_FOUND AND OPENGL_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||
|
||||
set(PERIODIC_TRIANGULATION_MISSING_DEPS "")
|
||||
|
||||
if(NOT CGAL_FOUND)
|
||||
set(PERIODIC_TRIANGULATION_MISSING_DEPS "the CGAL Qt4 library, ${PERIODIC_TRIANGULATION_MISSING_DEPS}")
|
||||
set(PERIODIC_TRIANGULATION_MISSING_DEPS "the CGAL Qt5 library, ${PERIODIC_TRIANGULATION_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT QT4_FOUND)
|
||||
set(PERIODIC_TRIANGULATION_MISSING_DEPS "Qt4, ${PERIODIC_TRIANGULATION_MISSING_DEPS}")
|
||||
if(NOT Qt5_FOUND)
|
||||
set(PERIODIC_TRIANGULATION_MISSING_DEPS "Qt5, ${PERIODIC_TRIANGULATION_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT OPENGL_FOUND)
|
||||
|
|
@ -99,4 +97,4 @@ else (CGAL_FOUND AND OPENGL_FOUND AND QT4_FOUND AND QGLVIEWER_FOUND AND QT_QCOLL
|
|||
|
||||
message(STATUS "NOTICE: This demo requires ${PERIODIC_TRIANGULATION_MISSING_DEPS}and will not be compiled.")
|
||||
|
||||
endif (CGAL_FOUND AND OPENGL_FOUND AND QT4_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||
endif (CGAL_FOUND AND OPENGL_FOUND AND Qt5_FOUND AND QGLVIEWER_FOUND AND QT_QCOLLECTIONGENERATOR_EXECUTABLE)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
|
||||
project (Triangulation_demo_3)
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
cmake_minimum_required(VERSION 2.6.2)
|
||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
|
||||
cmake_policy(VERSION 2.8.4)
|
||||
|
|
@ -10,22 +15,17 @@ else()
|
|||
cmake_policy(VERSION 2.6)
|
||||
endif()
|
||||
|
||||
find_package(CGAL COMPONENTS Qt4)
|
||||
find_package(CGAL COMPONENTS Qt5)
|
||||
include(${CGAL_USE_FILE})
|
||||
|
||||
|
||||
set( QT_USE_QTXML TRUE )
|
||||
set( QT_USE_QTMAIN TRUE )
|
||||
set( QT_USE_QTSCRIPT TRUE )
|
||||
set( QT_USE_QTOPENGL TRUE )
|
||||
find_package(Qt4)
|
||||
find_package(Qt5 COMPONENTS Xml Script OpenGL)
|
||||
|
||||
find_package(OpenGL)
|
||||
|
||||
if(QT4_FOUND)
|
||||
include( ${QT_USE_FILE} )
|
||||
if(Qt5_FOUND)
|
||||
find_package(QGLViewer)
|
||||
endif(QT4_FOUND)
|
||||
endif(Qt5_FOUND)
|
||||
|
||||
# Activate concurrency ? (turned OFF by default)
|
||||
option(ACTIVATE_CONCURRENT_TRIANGULATION_3
|
||||
|
|
@ -49,21 +49,16 @@ if( TBB_FOUND )
|
|||
include(${TBB_USE_FILE})
|
||||
endif()
|
||||
|
||||
if ( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
||||
|
||||
include(${QT_USE_FILE})
|
||||
if ( CGAL_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
||||
|
||||
include_directories (${QGLVIEWER_INCLUDE_DIR})
|
||||
include_directories (BEFORE ../../include ./ )
|
||||
|
||||
# ui files, created with Qt Designer
|
||||
qt4_wrap_ui( uis MainWindow.ui )
|
||||
qt5_wrap_ui( uis MainWindow.ui )
|
||||
|
||||
# qrc files (resources files, that contain icons, at least)
|
||||
qt4_add_resources ( RESOURCE_FILES ./T3_demo.qrc )
|
||||
|
||||
# moc files (meta object compiler files, run moc preprocessor on the files with Widget defs)
|
||||
qt4_automoc( MainWindow.cpp Viewer.cpp PreferenceDlg.cpp )
|
||||
qt5_add_resources ( RESOURCE_FILES ./T3_demo.qrc )
|
||||
|
||||
|
||||
# cpp files
|
||||
|
|
@ -72,22 +67,23 @@ if ( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
|||
PreferenceDlg.cpp
|
||||
Scene.cpp ${uis} ${RESOURCE_FILES} )
|
||||
|
||||
qt5_use_modules(T3_demo Xml Script OpenGL)
|
||||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS T3_demo )
|
||||
|
||||
target_link_libraries( T3_demo ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES})
|
||||
target_link_libraries( T3_demo ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES} ${TBB_LIBRARIES})
|
||||
target_link_libraries( T3_demo ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} )
|
||||
|
||||
else( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
||||
else( CGAL_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
||||
|
||||
set(TRIANGULATION_3_MISSING_DEPS "")
|
||||
|
||||
if(NOT CGAL_FOUND)
|
||||
set(TRIANGULATION_3_MISSING_DEPS "the CGAL Qt4 library, ${TRIANGULATION_3_MISSING_DEPS}")
|
||||
set(TRIANGULATION_3_MISSING_DEPS "the CGAL Qt5 library, ${TRIANGULATION_3_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT QT4_FOUND)
|
||||
set(TRIANGULATION_3_MISSING_DEPS "Qt4, ${TRIANGULATION_3_MISSING_DEPS}")
|
||||
if(NOT Qt5_FOUND)
|
||||
set(TRIANGULATION_3_MISSING_DEPS "Qt5, ${TRIANGULATION_3_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT OPENGL_FOUND)
|
||||
|
|
@ -101,4 +97,4 @@ else( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
|||
|
||||
message(STATUS "NOTICE: This demo requires ${TRIANGULATION_3_MISSING_DEPS}and will not be compiled.")
|
||||
|
||||
endif( CGAL_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
||||
endif( CGAL_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND )
|
||||
|
|
|
|||
Loading…
Reference in New Issue