From 4c85bee79172ccc6caf97ecd90d4804598fdee74 Mon Sep 17 00:00:00 2001 From: Aurelien Vialon Date: Thu, 17 Jul 2014 13:03:23 +0200 Subject: [PATCH] Add of Apollonius_graph_2 demonstration of GraphicView and all GraphicView demonstrations works on Windows. --- .../Apollonius_graph_2/Apollonius_graph_2.cpp | 30 +++++++++---- .../demo/Apollonius_graph_2/CMakeLists.txt | 45 ++++++++++++++----- 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp b/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp index c8c3f4c45ab..fa69b389885 100644 --- a/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp +++ b/GraphicsView/demo/Apollonius_graph_2/Apollonius_graph_2.cpp @@ -176,15 +176,29 @@ MainWindow::on_actionInsertRandomPoints_triggered() CGAL::Random_points_in_iso_rectangle_2 pg((isor.min)(), (isor.max)()); bool ok = false; + + //New for Qt5 version ! + #if QT_VERSION >= 0x050000 const int number_of_points = - QInputDialog::getInteger(this, + QInputDialog::getInt(this, tr("Number of random points"), tr("Enter number of random points"), - 100, - 0, - (std::numeric_limits::max)(), - 1, - &ok); + 100, + 0, + (std::numeric_limits::max)(), + 1, + &ok); + #else + const int number_of_points = + QInputDialog::getInteger(this, + tr("Number of random points"), + tr("Enter number of random points"), + 100, + 0, + (std::numeric_limits::max)(), + 1, + &ok); + #endif if(!ok) { return; @@ -282,9 +296,9 @@ int main(int argc, char **argv) app.setOrganizationName("GeometryFactory"); app.setApplicationName("Apollonius_graph_2 demo"); - // Import resources from libCGALQt4. + // Import resources from libCGAL (Qt4 or Qt5). // See http://doc.trolltech.com/4.4/qdir.html#Q_INIT_RESOURCE - CGAL_QT4_INIT_RESOURCES; + CGAL_QT_INIT_RESOURCES; //New for Qt5 version ! Q_INIT_RESOURCE(Apollonius_graph_2); MainWindow mainWindow; diff --git a/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt b/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt index 914fdbb4c44..55c105ccefc 100644 --- a/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt +++ b/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt @@ -10,33 +10,56 @@ else() cmake_policy(VERSION 2.6) endif() -find_package(CGAL COMPONENTS Qt4) - -include(${CGAL_USE_FILE}) - set( QT_USE_QTXML TRUE ) set( QT_USE_QTMAIN TRUE ) set( QT_USE_QTSCRIPT TRUE ) set( QT_USE_QTOPENGL TRUE ) +#New for Qt5 version ! +option (USE_QT5 "Use Qt5 version instead of Qt4" ON) + +if(USE_QT5) + + find_package(CGAL COMPONENTS Qt5) + + include(${CGAL_USE_FILE}) + + find_package(Qt5) + + set(CMAKE_AUTOMOC OFF) + +else (USE_QT5) + + find_package(CGAL COMPONENTS Qt4) + + include(${CGAL_USE_FILE}) + + find_package(Qt4) + + if(CGAL_Qt4_FOUND AND QT4_FOUND) + include(${QT_USE_FILE}) + message("Qt4 found") + set(QT4 TRUE) + endif() + +endif (USE_QT5) + +include(QtChoice) -find_package(Qt4) include_directories (BEFORE ../../include) -if ( CGAL_FOUND AND CGAL_Qt4_FOUND AND QT4_FOUND ) - -include(${QT_USE_FILE}) +if ( CGAL_FOUND AND (QT4 OR QT5) ) #-------------------------------- # UI files (Qt Designer files) -qt4_wrap_ui( DT_UI_FILES Apollonius_graph_2.ui ) +qt_wrap_ui( DT_UI_FILES Apollonius_graph_2.ui ) # qrc files (resources files, that contain icons, at least) -qt4_add_resources ( DT_RESOURCE_FILES ./Apollonius_graph_2.qrc ) +qt_add_resources ( DT_RESOURCE_FILES ./Apollonius_graph_2.qrc ) # use the Qt MOC preprocessor on classes that derives from QObject -qt4_generate_moc( Apollonius_graph_2.cpp Apollonius_graph_2.moc ) +qt_generate_moc( Apollonius_graph_2.cpp Apollonius_graph_2.moc ) # The executable itself. add_executable ( Apollonius_graph_2 Apollonius_graph_2.cpp Apollonius_graph_2.moc ${DT_UI_FILES} ${DT_RESOURCE_FILES} )