Fusion of CGAL_Qt4 and CGAL_Qt5 into just one CGAL_Qt.

This commit is contained in:
Aurélien Vialon 2014-07-31 22:41:44 +02:00
parent 4653c4344c
commit 6784800dd1
27 changed files with 159 additions and 1421 deletions

View File

@ -22,8 +22,8 @@
#include <QtCore/qglobal.h>
#if defined(CGAL_Qt4_DLL) || defined(CGAL_Qt5_DLL)
# if defined(CGAL_Qt4_EXPORTS) || defined(CGAL_Qt5_EXPORTS)
#if (defined(CGAL_Qt_DLL))
# if defined(CGAL_Qt_EXPORTS)
# define CGAL_QT_EXPORT Q_DECL_EXPORT
# else
# define CGAL_QT_EXPORT Q_DECL_IMPORT

View File

@ -23,19 +23,15 @@
#include <CGAL/config.h>
#include <QtCore/qglobal.h>
#if (! defined (CGAL_NO_AUTOLINK_QT4)) && ((!defined CGAL_NO_AUTOLINK_QT5))
#if ( ! defined( CGAL_EXPORTS ) ) && (! defined ( CGAL_Qt4_EXPORTS ) && (! defined (CGAL_Qt5_EXPORTS) ) )
#if (! defined (CGAL_NO_AUTOLINK_QT))
#if ( ! defined( CGAL_EXPORTS ) ) && (! defined ( CGAL_Qt_EXPORTS ))
// If CGAL_EXPORTS is defined it means that we are building the CGAL
// library as a DLL. The CGAL.dll does not really depend on CGAL_Qt,
// whatever the header inclusion graph says.
//New for Qt5 version !
#if QT_VERSION >= 0x050000
#define CGAL_LIB_NAME CGAL_Qt5
#else
#define CGAL_LIB_NAME CGAL_Qt4
#endif //QT_VERSION
#define CGAL_LIB_NAME CGAL_Qt
#include <CGAL/auto_link/auto_link.h>

View File

@ -25,17 +25,17 @@
#if defined(CGAL_BUILD_SHARED_LIBS)
# if defined(CGAL_Qt4_EXPORTS) || defined(CGAL_Qt5_EXPORTS) // defined by CMake or in cpp files of the dll
# if (defined(CGAL_Qt_EXPORTS)) // defined by CMake or in cpp files of the dll
# define CGAL_QT_EXPORT CGAL_DLL_EXPORT
# define CGAL_QT_EXPIMP_TEMPLATE
# else // not CGAL_Qt4_EXPORTS
# else // not CGAL_Qt_EXPORTS
# define CGAL_QT_EXPORT CGAL_DLL_IMPORT
# define CGAL_QT_EXPIMP_TEMPLATE extern
# endif // not CGAL_QT4_EXPORTS
# endif // not CGAL_QT_EXPORTS
#else // not CGAL_BUILD_SHARED_LIBS
@ -44,6 +44,6 @@
#endif // not CGAL_BUILD_SHARED_LIBS
#endif // CGAL_QT4_EXPORT_H
#endif // CGAL_QT_EXPORT_H

View File

@ -0,0 +1,91 @@
#This file propose the choice between versions 4 and 5 of Qt.
set (USE_QT_VERSION "5" CACHE STRING "Choice of Qt version for CGAL compilation")
SET_PROPERTY(CACHE USE_QT_VERSION PROPERTY STRINGS 4 5)
cache_set(CGAL_Qt_version "Qt${USE_QT_VERSION}" )
message("Configuring libCGAL_${CGAL_Qt_version}")
set( QT_USE_QTMAIN TRUE )
set( QT_USE_QTOPENGL TRUE )
find_package(Qt QUIET)
find_package(OpenGL QUIET )
if( QT${USE_QT_VERSION} )
if( OPENGL_FOUND )
include_directories (BEFORE ../../include)
get_dependency_version(OPENGL)
get_dependency_version(QT${USE_QT_VERSION} QT)
if(COMMAND add_config_flag)
set( CGAL_HAS_QT${USE_QT_VERSION} TRUE )
add_config_flag( CGAL_HAS_QT${USE_QT_VERSION} )
endif()
message( STATUS "OpenGL include: ${OPENGL_INCLUDE_DIR}" )
message( STATUS "OpenGL libraries: ${OPENGL_LIBRARIES}" )
message( STATUS "OpenGL definitions: ${OPENGL_DEFINITIONS}" )
message( STATUS "${CGAL_Qt_version} include: ${QT_INCLUDE_DIR}" )
message( STATUS "${CGAL_Qt_version} libraries: ${QT_LIBRARIES}" )
message( STATUS "${CGAL_Qt_version} definitions: ${QT_DEFINITIONS}" )
message( STATUS "moc executable: ${QT_MOC_EXECUTABLE}" )
message( STATUS "uic executable: ${QT_UIC_EXECUTABLE}" )
cache_set(CGAL_Qt_3RD_PARTY_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} )
cache_set(CGAL_Qt_3RD_PARTY_LIBRARIES ${QT_LIBRARIES} ${OPENGL_LIBRARIES} )
cache_set(CGAL_Qt_3RD_PARTY_DEFINITIONS ${QT_DEFINITIONS} ${OPENGL_DEFINITIONS} -DNOMINMAX)
set(mocfiles "")
set(RESOURCE_FILES "")
foreach (package ${CGAL_CONFIGURED_PACKAGES} )
file(GLOB PACKAGE_QTMOC_FILES "${package}/src/CGAL_Qt/*.qtmoc.cmake")
foreach(package_qtmoc_file ${PACKAGE_QTMOC_FILES})
# includes 'moccing' for sources/headers in package + collects lists of moc-files for dependency (to properly build the lib)
include(${package_qtmoc_file})
# message(STATUS QTMOC------------FILE: ${package_qtmoc_file})
endforeach()
endforeach()
foreach(mocfile ${mocfiles})
list(APPEND additional_files ${mocfile})
endforeach()
foreach(resfile ${RESOURCE_FILES})
list(APPEND additional_files ${resfile})
endforeach()
# message(STATUS "Additional input files: ${additional_files}")
use_essential_libs()
include_directories( SYSTEM ${CGAL_3RD_PARTY_INCLUDE_DIRS} ${CGAL_Qt_3RD_PARTY_INCLUDE_DIRS} )
link_directories ( ${CGAL_LIBRARIES_DIR} ${CGAL_3RD_PARTY_LIBRARIES_DIRS})
collect_cgal_library( CGAL_Qt "${additional_files}")
add_dependencies( CGAL_Qt CGAL )
target_link_libraries( CGAL_Qt ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${CGAL_Qt_3RD_PARTY_LIBRARIES} )
add_definitions ( ${CGAL_3RD_PARTY_DEFINITIONS} ${CGAL_Qt_3RD_PARTY_DEFINITIONS} )
if($ENV{CGAL_FAKE_PUBLIC_RELEASE})
add_definitions( -DCGAL_FAKE_PUBLIC_RELEASE )
endif()
message("libCGAL_${CGAL_Qt_version} is configured")
else()
message( STATUS "libCGAL_${CGAL_Qt_version} needs OpenGL, cannot be configured.")
endif()
else()
message( STATUS "libCGAL_${CGAL_Qt_version} needs ${CGAL_Qt_version}, cannot be configured.")
endif()

View File

@ -37,6 +37,11 @@
#include <QDesktopWidget>
#include <QRegExp>
//New for Qt5 version !
#include <QtCore>
#include <QtOpenGL>
//End of the news things for Qt5 version !
#include <CGAL/config.h> // needed to get CGAL_VERSION_STR
#include <CGAL/Qt/DemosMainWindow.h>
#include <iostream>

View File

@ -1,9 +1,9 @@
# moc files that are compiled directly as cpp files
qt5_wrap_cpp(mocfiles ../../include/CGAL/Qt/GraphicsViewNavigation.h
qt_wrap_cpp(mocfiles ../../include/CGAL/Qt/GraphicsViewNavigation.h
../../include/CGAL/Qt/DemosMainWindow.h
../../include/CGAL/Qt/GraphicsItem.h
../../include/CGAL/Qt/GraphicsViewInput.h)
# qrc files (resources files, that contain icons, at least)
qt5_add_resources ( RESOURCE_FILES ../../demo/resources/CGAL.qrc ../../demo/icons/Input.qrc ../../demo/icons/File.qrc ../../demo/icons/Triangulation_2.qrc)
qt_add_resources ( RESOURCE_FILES ../../demo/resources/CGAL.qrc ../../demo/icons/Input.qrc ../../demo/icons/File.qrc ../../demo/icons/Triangulation_2.qrc)

View File

@ -1,86 +0,0 @@
message("Configuring libCGAL_Qt4")
set( QT_USE_QTMAIN TRUE )
set( QT_USE_QTOPENGL TRUE )
find_package(Qt4 QUIET)
find_package(OpenGL QUIET )
if( QT4_FOUND )
if( OPENGL_FOUND )
include_directories (BEFORE ../../include)
include(${QT_USE_FILE})
get_dependency_version(OPENGL)
get_dependency_version(QT4 QT)
if(COMMAND add_config_flag)
set( CGAL_HAS_QT4 TRUE )
add_config_flag( CGAL_HAS_QT4 )
endif()
message( STATUS "OpenGL include: ${OPENGL_INCLUDE_DIR}" )
message( STATUS "OpenGL libraries: ${OPENGL_LIBRARIES}" )
message( STATUS "OpenGL definitions: ${OPENGL_DEFINITIONS}" )
message( STATUS "Qt4 include: ${QT_INCLUDE_DIR}" )
message( STATUS "Qt4 libraries: ${QT_LIBRARIES}" )
message( STATUS "Qt4 definitions: ${QT_DEFINITIONS}" )
message( STATUS "moc executable: ${QT_MOC_EXECUTABLE}" )
message( STATUS "uic executable: ${QT_UIC_EXECUTABLE}" )
cache_set(CGAL_Qt4_3RD_PARTY_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} )
cache_set(CGAL_Qt4_3RD_PARTY_LIBRARIES ${QT_LIBRARIES} ${OPENGL_LIBRARIES} )
cache_set(CGAL_Qt4_3RD_PARTY_DEFINITIONS ${QT_DEFINITIONS} ${OPENGL_DEFINITIONS} )
set(mocfiles "")
set(RESOURCE_FILES "")
foreach (package ${CGAL_CONFIGURED_PACKAGES} )
file(GLOB PACKAGE_QTMOC_FILES "${package}/src/CGAL_Qt4/*.qtmoc.cmake")
foreach(package_qtmoc_file ${PACKAGE_QTMOC_FILES})
# includes 'moccing' for sources/headers in package + collects lists of moc-files for dependency (to properly build the lib)
include(${package_qtmoc_file})
# message(STATUS QTMOC------------FILE: ${package_qtmoc_file})
endforeach()
endforeach()
foreach(mocfile ${mocfiles})
list(APPEND additional_files ${mocfile})
endforeach()
foreach(resfile ${RESOURCE_FILES})
list(APPEND additional_files ${resfile})
endforeach()
# message(STATUS "Additional input files: ${additional_files}")
use_essential_libs()
include_directories( SYSTEM ${CGAL_3RD_PARTY_INCLUDE_DIRS} ${CGAL_Qt4_3RD_PARTY_INCLUDE_DIRS} )
link_directories ( ${CGAL_LIBRARIES_DIR} ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
collect_cgal_library( CGAL_Qt4 "${additional_files}")
add_dependencies( CGAL_Qt4 CGAL )
target_link_libraries( CGAL_Qt4 ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${CGAL_Qt4_3RD_PARTY_LIBRARIES} )
add_definitions ( ${CGAL_3RD_PARTY_DEFINITIONS} ${CGAL_Qt4_3RD_PARTY_DEFINITIONS} )
if($ENV{CGAL_FAKE_PUBLIC_RELEASE})
add_definitions( -DCGAL_FAKE_PUBLIC_RELEASE )
endif()
message("libCGAL_Qt4 is configured")
else()
message( STATUS "libCGAL_Qt4 needs OpenGL, cannot be configured.")
endif()
else()
message( STATUS "libCGAL_Qt4 needs Qt4, cannot be configured.")
endif()

View File

@ -1,9 +0,0 @@
# moc files that are compiled directly as cpp files
qt4_wrap_cpp(mocfiles ../../include/CGAL/Qt/GraphicsViewNavigation.h
../../include/CGAL/Qt/DemosMainWindow.h
../../include/CGAL/Qt/GraphicsItem.h
../../include/CGAL/Qt/GraphicsViewInput.h)
# qrc files (resources files, that contain icons, at least)
qt4_add_resources ( RESOURCE_FILES ../../demo/resources/CGAL.qrc ../../demo/icons/Input.qrc ../../demo/icons/File.qrc ../../demo/icons/Triangulation_2.qrc)

View File

@ -1,104 +0,0 @@
message("Configuring libCGAL_Qt5")
if(WIN32)
message("Qt5 on Windows needs Windows SDK.")
set(CMAKE_LIBRARY_PATH "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x64")
endif()
set( QT_USE_QTMAIN TRUE )
set( QT_USE_QTOPENGL TRUE )
find_package(OpenGL QUIET )
cmake_policy(SET CMP0020 NEW)
FIND_PACKAGE(Qt5Core QUIET)
FIND_PACKAGE(Qt5Gui QUIET)
FIND_PACKAGE(Qt5Widgets QUIET)
FIND_PACKAGE(Qt5OpenGL QUIET)
list(APPEND QT_INCLUDE_DIR ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS})
list(APPEND QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES})
list(APPEND QT_DEFINITIONS ${Qt5Core_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5OpenGL_DEFINITIONS})
if( Qt5Widgets_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5OpenGL_FOUND )
if( OPENGL_FOUND )
include_directories (BEFORE ../../include)
#Marche pas car vide
#include(${QT_USE_FILE})
get_dependency_version(OPENGL)
get_dependency_version(QT5 QT)
if(COMMAND add_config_flag)
set( CGAL_HAS_QT5 TRUE )
add_config_flag( CGAL_HAS_QT5 )
endif()
message( STATUS "OpenGL include: ${OPENGL_INCLUDE_DIR}" )
message( STATUS "OpenGL libraries: ${OPENGL_LIBRARIES}" )
message( STATUS "OpenGL definitions: ${OPENGL_DEFINITIONS}" )
message( STATUS "Qt5 include: ${QT_INCLUDE_DIR}" )
message( STATUS "Qt5 libraries: ${QT_LIBRARIES}")
message( STATUS "Qt5 definitions: ${QT_DEFINITIONS}" )
message( STATUS "moc executable: ${QT_MOC_EXECUTABLE}" )
message( STATUS "uic executable: ${QT_UIC_EXECUTABLE}" )
cache_set(CGAL_Qt5_3RD_PARTY_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} )
cache_set(CGAL_Qt5_3RD_PARTY_LIBRARIES ${QT_LIBRARIES} ${OPENGL_LIBRARIES} )
cache_set(CGAL_Qt5_3RD_PARTY_DEFINITIONS ${QT_DEFINITIONS} ${OPENGL_DEFINITIONS} -DNOMINMAX)
set(mocfiles "")
set(RESOURCE_FILES "")
foreach (package ${CGAL_CONFIGURED_PACKAGES} )
file(GLOB PACKAGE_QTMOC_FILES "${package}/src/CGAL_Qt5/*.qtmoc.cmake")
foreach(package_qtmoc_file ${PACKAGE_QTMOC_FILES})
# includes 'moccing' for sources/headers in package + collects lists of moc-files for dependency (to properly build the lib)
include(${package_qtmoc_file})
#message(STATUS QTMOC------------FILE: ${package_qtmoc_file})
endforeach()
endforeach()
foreach(mocfile ${mocfiles})
list(APPEND additional_files ${mocfile})
endforeach()
foreach(resfile ${RESOURCE_FILES})
list(APPEND additional_files ${resfile})
endforeach()
# message(STATUS "Additional input files: ${additional_files}")
use_essential_libs()
include_directories( SYSTEM ${CGAL_3RD_PARTY_INCLUDE_DIRS} ${CGAL_Qt5_3RD_PARTY_INCLUDE_DIRS} )
link_directories ( ${CGAL_LIBRARIES_DIR} ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
collect_cgal_library( CGAL_Qt5 "${additional_files}")
add_dependencies( CGAL_Qt5 CGAL )
target_link_libraries( CGAL_Qt5 ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${CGAL_Qt5_3RD_PARTY_LIBRARIES} )
add_definitions ( ${CGAL_3RD_PARTY_DEFINITIONS} ${CGAL_Qt5_3RD_PARTY_DEFINITIONS} )
if($ENV{CGAL_FAKE_PUBLIC_RELEASE})
add_definitions( -DCGAL_FAKE_PUBLIC_RELEASE )
endif()
message("libCGAL_Qt5 is configured")
else()
message( STATUS "libCGAL_Qt5 needs OpenGL, cannot be configured.")
endif()
else()
message( STATUS "libCGAL_Qt5 needs Qt5, cannot be configured.")
endif()

View File

@ -1,416 +0,0 @@
// Copyright (c) 2008 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri <Andreas.Fabri@geometryfactory.com>
// Laurent Rineau <Laurent.Rineau@geometryfactory.com>
#include <CGAL/Qt/GraphicsViewNavigation.h>
#include <QApplication>
#include <QLabel>
#include <QFile>
#include <QFileInfo>
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QMessageBox>
#include <QStatusBar>
#include <QGraphicsView>
//New for Qt5 version !
//Doesn't work on Linux kernel.
//#include <QtCore\QMimeData>
//#include <QtOpenGL\QGLWidget>
#include <QtCore>
#include <QtOpenGL>
//End of the news things for Qt5 version !
#include <QTextStream>
#include <QSettings>
#include <QUrl>
#include <QDesktopWidget>
#include <QRegExp>
#include <CGAL/config.h> // needed to get CGAL_VERSION_STR
#include <CGAL/Qt/DemosMainWindow.h>
#include <iostream>
namespace CGAL {
namespace Qt {
DemosMainWindow::DemosMainWindow(QWidget * parent, ::Qt::WindowFlags flags)
: QMainWindow(parent, flags),
maxNumRecentFiles(10),
recentFileActs(maxNumRecentFiles)
{
// prepare the QLabel xycoord for inclusion in the statusBar()
xycoord = new QLabel(" -0.00000 , -0.00000 ", this);
xycoord->setAlignment(::Qt::AlignHCenter);
xycoord->setMinimumSize(xycoord->sizeHint());
xycoord->clear();
actionUse_OpenGL = new QAction(this);
actionUse_OpenGL->setObjectName("actionUse_OpenGL");
actionUse_OpenGL->setCheckable(true);
actionUse_OpenGL->setText(tr("Use &OpenGL"));
actionUse_OpenGL->setStatusTip(tr("Make Qt use OpenGL to display the graphical items, instead of its native painting system."));
actionUse_OpenGL->setShortcut(tr("Ctrl+G"));
actionUse_Antialiasing = new QAction(this);
actionUse_Antialiasing->setObjectName("actionUse_Antialiasing");
actionUse_Antialiasing->setCheckable(true);
actionUse_Antialiasing->setText(tr("Use &anti-aliasing"));
actionUse_Antialiasing->setStatusTip(tr("Make Qt use anti-aliasing when displaying the graphical items."));
actionUse_Antialiasing->setShortcut(tr("Ctrl+A"));
actionAboutCGAL = new QAction(this);
actionAboutCGAL->setObjectName("actionAboutCGAL");
actionAboutCGAL->setText(tr("About &CGAL..."));
actionAbout = new QAction(this);
actionAbout->setObjectName("actionAbout");
actionAbout->setText(tr("&About..."));
setAcceptDrops(true);
}
void
DemosMainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}
void
DemosMainWindow::dropEvent(QDropEvent *event)
{
Q_FOREACH(QUrl url, event->mimeData()->urls())
{
QString filename = url.toLocalFile();
this->open(filename);
}
event->acceptProposedAction();
}
void
DemosMainWindow::addNavigation(QGraphicsView* graphicsView)
{
navigation = new CGAL::Qt::GraphicsViewNavigation();
graphicsView->viewport()->installEventFilter(navigation);
graphicsView->installEventFilter(navigation);
QObject::connect(navigation, SIGNAL(mouseCoordinates(QString)),
xycoord, SLOT(setText(QString)));
view = graphicsView;
}
void
DemosMainWindow::setupStatusBar()
{
this->statusBar()->addWidget(new QLabel(this), 1);
this->statusBar()->addWidget(xycoord, 0);
}
void
DemosMainWindow::setupOptionsMenu(QMenu* menuOptions)
{
// search for the Options menu
if(!menuOptions) {
menuOptions = getMenu("menuOptions", tr("&Options"));
}
// if not found, then create it
if(!menuOptions) {
menuOptions = new QMenu(this->menuBar());
menuOptions->setTitle(tr("&Options"));
this->menuBar()->addAction(menuOptions->menuAction());
menuOptions->setObjectName("menuOptions");
}
if(!menuOptions->isEmpty()) {
menuOptions->addSeparator();
}
menuOptions->addAction(actionUse_OpenGL);
menuOptions->addAction(actionUse_Antialiasing);
connect(actionUse_Antialiasing, SIGNAL(toggled(bool)),
this, SLOT(setUseAntialiasing(bool)));
connect(actionUse_OpenGL, SIGNAL(toggled(bool)),
this, SLOT(setUseOpenGL(bool)));
actionUse_Antialiasing->setChecked(true);
}
void
DemosMainWindow::setUseAntialiasing(bool checked)
{
view->setRenderHint(QPainter::Antialiasing, checked);
#if QT_VERSION >= 0x040300
view->setRenderHint(QPainter::HighQualityAntialiasing, checked);
#endif
statusBar()->showMessage(tr("Antialiasing %1activated").arg(checked?"":"de-"),
1000);
}
void
DemosMainWindow::setUseOpenGL(bool checked)
{
if(checked) {
QGLWidget* new_viewport = new QGLWidget;
// Setup the format to allow antialiasing with OpenGL:
// one need to activate the SampleBuffers, if the graphic driver allows
// this.
QGLFormat glformat = new_viewport->format();
glformat.setOption(QGL::SampleBuffers);
new_viewport->setFormat(glformat);
view->setViewport(new_viewport);
}
else {
view->setViewport(new QWidget);
}
statusBar()->showMessage(tr("OpenGL %1activated").arg(checked?"":"de-"),
1000);
view->viewport()->installEventFilter(navigation);
view->setFocus();
}
QMenu*
DemosMainWindow::getMenu(QString objectName, QString title)
{
QMenu* menu = NULL;
QString title2 = title;
title2.remove('&');
// search if a menu has objectName()==objectName
menu = this->findChild<QMenu*>(objectName);
// then search if a menu has title()==title
if(menu) {
return menu;
} else {
Q_FOREACH(menu, this->findChildren<QMenu*>()) {
if(menu->title() == title ||
menu->title() == title2) {
return menu;
}
}
}
return NULL;
}
void
DemosMainWindow::popupAboutBox(QString title, QString html_resource_name)
{
QFile about_CGAL(html_resource_name);
about_CGAL.open(QIODevice::ReadOnly);
QString about_CGAL_txt = QTextStream(&about_CGAL).readAll();
#ifdef CGAL_VERSION_STR
QString cgal_version(CGAL_VERSION_STR);
# ifdef CGAL_FAKE_PUBLIC_RELEASE
cgal_version.replace(QRegExp("-Ic?.*"), "");
# endif
about_CGAL_txt.replace("<!--CGAL_VERSION-->",
QString(" (version %1)")
.arg(cgal_version));
#endif
QMessageBox mb(QMessageBox::NoIcon,
title,
about_CGAL_txt,
QMessageBox::Ok,
this);
QLabel* mb_label = mb.findChild<QLabel*>("qt_msgbox_label");
if(mb_label) {
mb_label->setTextInteractionFlags(mb_label->textInteractionFlags() |
::Qt::LinksAccessibleByMouse |
::Qt::LinksAccessibleByKeyboard);
}
else {
std::cerr << "Cannot find child \"qt_msgbox_label\" in QMessageBox\n"
<< " with Qt version " << QT_VERSION_STR << "!\n";
}
mb.exec();
}
QMenu* DemosMainWindow::getHelpMenu()
{
QMenu* menuHelp = getMenu("menuHelp", tr("&Help"));
if(!menuHelp) {
menuHelp = new QMenu(this->menuBar());
menuHelp->setTitle(tr("&Help"));
this->menuBar()->addAction(menuHelp->menuAction());
menuHelp->setObjectName("menuHelp");
}
return menuHelp;
}
void
DemosMainWindow::addAboutCGAL(QMenu* menuHelp)
{
if(!menuHelp) {
menuHelp = getHelpMenu();
}
menuHelp->addAction(actionAboutCGAL);
connect(actionAboutCGAL, SIGNAL(triggered()),
this, SLOT(popupAboutCGAL()));
}
void
DemosMainWindow::addAboutDemo(QString htmlResourceName, QMenu* menuHelp)
{
if(!menuHelp) {
menuHelp = getHelpMenu();
}
menuHelp->addAction(actionAbout);
aboutHtmlResource = htmlResourceName;
connect(actionAbout, SIGNAL(triggered()),
this, SLOT(popupAboutDemo()));
}
void
DemosMainWindow::popupAboutCGAL()
{
popupAboutBox(tr("About CGAL..."),
":/cgal/help/about_CGAL.html");
}
void
DemosMainWindow::popupAboutDemo()
{
popupAboutBox(tr("About the demo..."),
aboutHtmlResource);
}
void
DemosMainWindow::setMaxNumberOfRecentFiles(const unsigned int i)
{
maxNumRecentFiles = i;
recentFileActs.resize(maxNumRecentFiles);
}
unsigned int
DemosMainWindow::maxNumberOfRecentFiles() const
{
return maxNumRecentFiles;
}
void
DemosMainWindow::openRecentFile_aux()
{
QAction *action = qobject_cast<QAction *>(sender());
if (action)
emit openRecentFile(action->data().toString());
}
void
DemosMainWindow::addToRecentFiles(QString fileName)
{
QSettings settings;
QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(fileName);
files.prepend(fileName);
while (files.size() > (int)maxNumberOfRecentFiles())
files.removeLast();
settings.setValue("recentFileList", files);
updateRecentFileActions();
}
void
DemosMainWindow::addRecentFiles(QMenu* menu, QAction* insertBeforeAction)
{
if(!insertBeforeAction) {
recentFilesSeparator = menu->addSeparator();
}
for (unsigned int i = 0; i < maxNumberOfRecentFiles(); ++i) {
recentFileActs[i] = new QAction(this);
recentFileActs[i]->setVisible(false);
connect(recentFileActs[i], SIGNAL(triggered()),
this, SLOT(openRecentFile_aux()));
if(insertBeforeAction)
menu->insertAction(insertBeforeAction, recentFileActs[i]);
else
menu->addAction(recentFileActs[i]);
}
if(insertBeforeAction) {
recentFilesSeparator = menu->insertSeparator(insertBeforeAction);
}
recentFilesSeparator->setVisible(false);
updateRecentFileActions();
}
void
DemosMainWindow::updateRecentFileActions()
{
QSettings settings;
QStringList files = settings.value("recentFileList").toStringList();
int numRecentFiles = qMin(files.size(), (int)this->maxNumberOfRecentFiles());
for (int i = 0; i < numRecentFiles; ++i) {
QString strippedName = QFileInfo(files[i]).fileName();
QString text = tr("&%1 %2").arg(i).arg(strippedName);
recentFileActs[i]->setText(text);
recentFileActs[i]->setData(files[i]);
recentFileActs[i]->setVisible(true);
}
for (unsigned int j = numRecentFiles; j < maxNumberOfRecentFiles(); ++j)
recentFileActs[j]->setVisible(false);
recentFilesSeparator->setVisible(numRecentFiles > 0);
}
void DemosMainWindow::writeState(QString groupname)
{
QSettings settings;
settings.beginGroup(groupname);
settings.setValue("size", size());
settings.setValue("pos", pos());
settings.setValue("state", saveState());
settings.endGroup();
}
void DemosMainWindow::readState(QString groupname, Options /*what_to_save*/)
{
QSettings settings;
settings.beginGroup(groupname);
resize(settings.value("size", this->size()).toSize());
QDesktopWidget* desktop = qApp->desktop();
QPoint pos = settings.value("pos", this->pos()).toPoint();
if(desktop->availableGeometry(pos).contains(pos)) {
move(pos);
}
QByteArray mainWindowState = settings.value("state").toByteArray();
if(!mainWindowState.isNull()) {
this->restoreState(mainWindowState);
}
settings.endGroup();
}
} // namespace Qt
} // namespace CGAL

View File

@ -1,338 +0,0 @@
// Copyright (c) 2008 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri <Andreas.Fabri@geometryfactory.com>
// Laurent Rineau <Laurent.Rineau@geometryfactory.com>
#include <CGAL/Qt/GraphicsViewNavigation.h>
#include <CGAL/Qt/utility.h> // for mapToScene(QGraphicsView*, QRect)
#include <cmath>
#include <iostream>
#include <boost/format.hpp>
#include <QEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsRectItem>
#include <QFlags>
#include <QScrollBar>
namespace CGAL {
namespace Qt {
GraphicsViewNavigation::GraphicsViewNavigation()
: rectItem(new QGraphicsRectItem),
dragging(false)
{
QColor rect_color(250, 221, 0);
rect_color.setAlpha(50);
rectItem->setBrush(rect_color);
rect_color.setAlpha(255);
rectItem->setPen(QPen(rect_color, 0, ::Qt::DashLine));
rectItem->hide();
rectItem->setZValue(10000);
}
GraphicsViewNavigation::~GraphicsViewNavigation()
{
delete rectItem;
}
bool
GraphicsViewNavigation::eventFilter(QObject *obj, QEvent *event)
{
QGraphicsView* v = qobject_cast<QGraphicsView*>(obj);
if(v == NULL) {
QWidget* viewport = qobject_cast<QWidget*>(obj);
if(viewport == NULL) {
return false;
}
v = qobject_cast<QGraphicsView*>(viewport->parent());
if(v == NULL) {
return false;
}
}
switch(event->type())
{
case QEvent::KeyPress: {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
int offset = 10;
if( (keyEvent->modifiers() & ::Qt::ShiftModifier)
|| (keyEvent->modifiers() & ::Qt::ControlModifier) ) {
offset = 20;
}
switch (keyEvent->key()) {
case ::Qt::Key_Up:
translateView(v, 0, -offset);
break;
case ::Qt::Key_Down:
translateView(v, 0, offset);
break;
case ::Qt::Key_Left:
translateView(v, -offset, 0);
break;
case ::Qt::Key_Right:
translateView(v, offset, 0);
break;
case ::Qt::Key_PageUp:
v->rotate(-6);
break;
case ::Qt::Key_PageDown:
v->rotate(6);
break;
case ::Qt::Key_Plus:
scaleView(v, 1.2);
break;
case ::Qt::Key_Minus:
scaleView(v, 1 / 1.2);
break;
case ::Qt::Key_Control:
cursor_backup = v->cursor();
v->setCursor(::Qt::CrossCursor);
default:
return false;
}
// display_parameters();
return true;
break;
} // end case KeyPress
case QEvent::KeyRelease: {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if(keyEvent->key() == ::Qt::Key_Control) {
if(rectItem->isVisible() ) {
dragging = false;
v->scene()->removeItem(rectItem);
rectItem->hide();
}
v->setCursor(cursor_backup);
return true;
}
return false;
break;
} // end case KeyRelease
case QEvent::Wheel: {
QWheelEvent *wheelEvent = static_cast<QWheelEvent*>(event);
if(wheelEvent->orientation() != ::Qt::Vertical) {
return false;
}
double zoom_ratio = 240.0;
if( (wheelEvent->modifiers() & ::Qt::ShiftModifier)
|| (wheelEvent->modifiers() & ::Qt::ControlModifier) ) {
zoom_ratio = 120.0;
}
scaleView(v, pow((double)2, -wheelEvent->delta() / zoom_ratio));
// display_parameters();
return true;
break;
} // end case Wheel
case QEvent::MouseButtonPress: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
if( (mouseEvent->modifiers() == (::Qt::ControlModifier | ::Qt::ShiftModifier))
&& mouseEvent->button() == ::Qt::RightButton )
{
QPoint offset = mouseEvent->pos() - v->viewport()->rect().center();
translateView(v, offset.x(), offset.y());
return true;
}
else if( mouseEvent->modifiers() == ::Qt::ControlModifier ) {
if(mouseEvent->button() == ::Qt::LeftButton) {
rect_first_point = v->mapToScene(mouseEvent->pos());
rectItem->setRect(QRectF(rect_first_point, QSizeF(0.,0.)));
rectItem->show();
v->scene()->addItem(rectItem);
return true;
}
else if( mouseEvent->button() == ::Qt::RightButton) {
dragging = true;
dragging_start = v->mapToScene(mouseEvent->pos());
v->setCursor(::Qt::ClosedHandCursor);
return true;
}
}
return false;
break;
} // end case MouseRelease
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF pos = v->mapToScene(mouseEvent->pos());
QString xy = QString(" ") + QString::number(pos.x(),'g', 6) + " , " + QString::number(pos.y(),'g', 6) + " ";
emit mouseCoordinates(xy);
if(rectItem->isVisible()) {
QPointF size = v->mapToScene(mouseEvent->pos());
size = size - rect_first_point;
rectItem->setRect(rect_first_point.x(),
rect_first_point.y(),
size.x(),
size.y());
}
if( dragging )
{
// std::cerr << boost::format("mouseMove: globalpos=(%1%, %2%)\n"
// " pos=(%3%, %4%)\n"
// " sender=%5% (class %6%), parent class %7%\n")
// % mouseEvent->globalPos().x()
// % mouseEvent->globalPos().y()
// % mouseEvent->pos().x()
// % mouseEvent->pos().y()
// % (&*obj)
// % obj->metaObject()->className()
// % obj->parent()->metaObject()->className();
// drag_to(mouseEvent->pos());
}
break;
} // end MouseMove
case QEvent::MouseButtonRelease: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
if(rectItem->isVisible() && mouseEvent->button() == ::Qt::LeftButton){
v->setSceneRect(v->sceneRect() | rectItem->rect());
v->fitInView(rectItem->rect(), ::Qt::KeepAspectRatio);
v->scene()->removeItem(rectItem);
rectItem->hide();
return true;
}
else if( mouseEvent->button() == ::Qt::RightButton ) {
if(dragging) {
dragging = false;
drag_to(v, mouseEvent->pos());
v->setCursor(cursor_backup);
return true;
}
}
return false;
break;
} // end MouseRelease
default:
return false;
} // end switch
return false;
}
void
GraphicsViewNavigation::scaleView(QGraphicsView* v, qreal scaleFactor)
{
QPointF center = v->mapToScene(v->viewport()->rect().center());
// qreal factor = v->matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
//if (factor < 0.001 || factor > 2000)
// return;
v->scale(scaleFactor, scaleFactor);
QPoint offset = v->mapFromScene(center) - v->viewport()->rect().center();
translateView(v, offset.x(), offset.y());
}
void GraphicsViewNavigation::drag_to(QGraphicsView* v, QPoint new_pos)
{
QPoint dragging_start_in_view = v->mapFromScene(dragging_start);
QPoint offset = new_pos - dragging_start_in_view;
// std::cerr << boost::format("drag_to: origin=(%1%, %2%)\n"
// " offset=(%3%, %4%)\n")
// % dragging_start_in_view.x() % dragging_start_in_view.y()
// % offset.x() % offset.y();
translateView(v, -offset.x(), -offset.y());
dragging_start_in_view = v->mapFromScene(dragging_start);
// std::cerr << boost::format(" after=(%1%, %2%)\n")
// % dragging_start_in_view.x() % dragging_start_in_view.y();
}
void GraphicsViewNavigation::translateView(QGraphicsView* v, int dx, int dy)
{
if( dx == 0 && dy == 0 ) {
return;
}
int horizontalScrollBarValue = v->horizontalScrollBar()->value();
int verticalScrollBarValue = v->verticalScrollBar()->value();
if( (horizontalScrollBarValue + dx <=
v->horizontalScrollBar()->maximum()) &&
(horizontalScrollBarValue + dx >=
v->horizontalScrollBar()->minimum()) &&
(verticalScrollBarValue + dy <=
v->verticalScrollBar()->maximum()) &&
(verticalScrollBarValue + dy >=
v->verticalScrollBar()->minimum()) )
{
v->horizontalScrollBar()->setValue(horizontalScrollBarValue + dx);
v->verticalScrollBar()->setValue(verticalScrollBarValue + dy);
}
else
{
QRect vp_rect = v->viewport()->rect();
QPointF new_center = v->mapToScene(vp_rect.center() + QPoint(dx, dy));
vp_rect |= vp_rect.translated(dx, dy);
QRectF rect = mapToScene(v, vp_rect);
v->setSceneRect(v->sceneRect() | rect);
v->centerOn(new_center);
// QGraphicsView::centerOn makes rounding errors.
// The following two "if" make them unnoticable when dx==0 or dy==0.
if(dx == 0) {
v->horizontalScrollBar()->setValue(horizontalScrollBarValue);
}
if(dy == 0) {
v->verticalScrollBar()->setValue(verticalScrollBarValue);
}
}
// display_parameters();
}
void GraphicsViewNavigation::display_parameters(QGraphicsView* v)
{
std::cerr <<
boost::format("matrix translation=(%1%, %2%)\n"
" rotation=(%3% - %4% )\n"
" (%5% - %6% )\n")
% v->matrix().dx()
% v->matrix().dy()
% v->matrix().m11()
% v->matrix().m12()
% v->matrix().m21()
% v->matrix().m22();
QRect vp_rect = v->viewport()->rect();
QPoint vp_top_left = vp_rect.topLeft();
QPoint vp_bottom_right = vp_rect.bottomRight();
QPointF top_left = v->mapToScene(vp_top_left);
QPointF bottom_right = v->mapToScene(vp_bottom_right);
std::cerr <<
boost::format("view=(%1% - %2%) x (%3% - %4%)\n")
% top_left.x() % bottom_right.x()
% top_left.y() % bottom_right.y();
std::cerr <<
boost::format("viewport=(%1% - %2%) x (%3% - %4%)\n")
% vp_top_left.x() % vp_bottom_right.x()
% vp_top_left.y() % vp_bottom_right.y();
std::cerr <<
boost::format("scrollbars=(%1% <= %2% <= %3%) x (%4% <= %5% <= %6%)\n")
% v->horizontalScrollBar()->minimum()
% v->horizontalScrollBar()->value()
% v->horizontalScrollBar()->maximum()
% v->verticalScrollBar()->minimum()
% v->verticalScrollBar()->value()
% v->verticalScrollBar()->maximum();
}
} // namespace Qt
} // namespace CGAL

View File

@ -1,196 +0,0 @@
// Copyright (c) 2008 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri <Andreas.Fabri@geometryfactory.com>
// Laurent Rineau <Laurent.Rineau@geometryfactory.com>
#include <QGraphicsItem>
#include <QGraphicsPathItem>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <QPolygonF>
#include <QPainterPath>
#include <QEvent>
#include <QKeyEvent>
#include <CGAL/Qt/GraphicsViewPolylineInput.h>
namespace CGAL {
namespace Qt {
GraphicsViewPolylineInput_non_templated_base::
GraphicsViewPolylineInput_non_templated_base(QObject* parent,
QGraphicsScene* s,
int n,
bool closed)
: GraphicsViewInput(parent), closed_(closed), path_item(NULL), b(NULL), e(NULL), n_(n), scene_(s)
{}
bool
GraphicsViewPolylineInput_non_templated_base::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if( event->modifiers() ){
return false;
}
if( event->button() != ::Qt::RightButton
&& event->button() != ::Qt::LeftButton ){
return false;
}
polygon.push_back(event->scenePos());
if(path_item){
scene_->removeItem(path_item);
delete path_item;
path_item = NULL;
}
if( (event->button() == ::Qt::RightButton) || (polygon.size() == n_) ){
// call the virtual function generate_polygon(), that emit a
// CGAL::Object containing a list of points
generate_polygon();
polygon.clear();
if(b){
scene_->removeItem(b);
delete b;
b = NULL;
}
if(e){
scene_->removeItem(e);
delete e;
e = NULL;
}
return true;
}
if(event->button() == ::Qt::LeftButton){
QPainterPath qpp;
qpp.addPolygon(polygon);
path_item = new QGraphicsPathItem(qpp);
path_item->setPen(QPen(::Qt::red, 0, ::Qt::SolidLine, ::Qt::RoundCap, ::Qt::RoundJoin));
scene_->addItem(path_item);
return true;
}
return false;
}
void
GraphicsViewPolylineInput_non_templated_base::rubberbands(const QPointF& p)
{
if(polygon.empty()){
return;
}
if(!b && closed_ ){
b = new QGraphicsLineItem();
b->setPen(QPen(::Qt::red, 0, ::Qt::SolidLine, ::Qt::RoundCap, ::Qt::RoundJoin));
scene_->addItem(b);
}
if( !e){
e = new QGraphicsLineItem();
e->setPen(QPen(::Qt::red, 0, ::Qt::SolidLine, ::Qt::RoundCap, ::Qt::RoundJoin));
scene_->addItem(e);
}
if(closed_){
QLineF bLine(polygon.front(), p);
b->setLine(bLine);
}
QLineF eLine(polygon.back(), p);
e->setLine(eLine);
}
void
GraphicsViewPolylineInput_non_templated_base::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
sp = event->scenePos();
rubberbands(sp);
}
bool
GraphicsViewPolylineInput_non_templated_base::keyPressEvent ( QKeyEvent * event )
{
if( event->modifiers() )
return false;
switch(event->key())
{
case ::Qt::Key_Delete:
case ::Qt::Key_Escape:
case ::Qt::Key_Backspace:
break;
default:
return false;
}
if(polygon.empty()){
return true;
}
polygon.pop_back();
if(polygon.empty()){
if(b){
scene_->removeItem(b);
delete b;
b = NULL;
}
if(e){
scene_->removeItem(e);
delete e;
e = NULL;
}
return true;
}
if(path_item){
scene_->removeItem(path_item);
delete path_item;
path_item = NULL;
}
QPainterPath qpp;
qpp.addPolygon(polygon);
path_item = new QGraphicsPathItem(qpp);
path_item->setPen(QPen(::Qt::red, 0, ::Qt::SolidLine, ::Qt::RoundCap, ::Qt::RoundJoin));
scene_->addItem(path_item);
rubberbands(sp);
return true;
}
bool
GraphicsViewPolylineInput_non_templated_base::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::GraphicsSceneMousePress) {
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
if(!mousePressEvent(mouseEvent)) {
// standard event processing if mousePressEvent has returned false
return QObject::eventFilter(obj, event);
}
} else if (event->type() == QEvent::GraphicsSceneMouseMove) {
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
mouseMoveEvent(mouseEvent);
return QObject::eventFilter(obj, event);
} else if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(!keyPressEvent(keyEvent)) {
return QObject::eventFilter(obj, event);
}
}
// standard event processing if keyPressEvent has returned false
return QObject::eventFilter(obj, event);
}
} // namespace Qt
} // namespace CGAL

View File

@ -1,53 +0,0 @@
// Copyright (c) 2008 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri <Andreas.Fabri@geometryfactory.com>
// Laurent Rineau <Laurent.Rineau@geometryfactory.com>
#include <CGAL/Qt/debug.h>
#include <QDir>
#include <iostream>
namespace CGAL {
namespace Qt {
void traverse_resources(const QString& name, const QString& dirname, int indent)
{
std::cerr << qPrintable(QString(indent, ' '))
<< qPrintable(name);
QString fullname =
dirname.isEmpty() ?
name :
dirname + "/" + name;
QDir dir(fullname);
if(dir.exists()) {
std::cerr << "/\n";
Q_FOREACH(QString path, dir.entryList())
{
traverse_resources(path, fullname, indent + 2);
}
}
else {
std::cerr << "\n";
}
}
} // namesapce Qt
} // namespace CGAL

View File

@ -1,31 +0,0 @@
// Copyright (c) 2011 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Laurent Rineau <Laurent.Rineau@geometryfactory.com>
#include <QDir>
#include <CGAL/Qt/resources.h>
// cannot use namespaces because of the Q_INIT_RESOURCE macro
void CGAL_Qt_init_resources() {
Q_INIT_RESOURCE(File);
Q_INIT_RESOURCE(Triangulation_2);
Q_INIT_RESOURCE(Input);
Q_INIT_RESOURCE(CGAL);
}

View File

@ -1,54 +0,0 @@
// Copyright (c) 2008 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri <Andreas.Fabri@geometryfactory.com>
// Laurent Rineau <Laurent.Rineau@geometryfactory.com>
#include <CGAL/Qt/utility.h>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QList>
#include <QPoint>
#include <QPointF>
namespace CGAL {
namespace Qt {
QRectF mapToScene(const QGraphicsView* v, const QRect rect)
{
QPointF top_left = v->mapToScene(rect.topLeft());
QPointF size = v->mapToScene(rect.bottomRight());
size -= top_left;
return QRectF(top_left.x(),
top_left.y(),
size.x(),
size.y());
}
QRectF viewportsBbox(const QGraphicsScene* scene) {
QRectF rect;
Q_FOREACH(QGraphicsView* view, scene->views())
{
rect |= mapToScene(view, view->viewport()->rect());
}
rect = rect.normalized();
return rect;
}
} // namespace Qt
} // namespace CGAL

View File

@ -39,17 +39,18 @@ set(WITH_CGAL "ON" )
set(WITH_CGAL_Core "@WITH_CGAL_Core@" )
set(WITH_CGAL_ImageIO "@WITH_CGAL_ImageIO@" )
set(WITH_CGAL_Qt3 "@WITH_CGAL_Qt3@" )
set(WITH_CGAL_Qt4 "@WITH_CGAL_Qt4@" )
#New for Qt5 version !
set(WITH_CGAL_Qt5 "@WITH_CGAL_Qt5@" )
set(WITH_CGAL_Qt "@WITH_CGAL_Qt@" )
#New for Qt5 version !
set(CGAL_Qt_version "@CGAL_Qt_version@" )
set(CGAL_LIBRARY "@CGAL_LIBRARY@" )
set(CGAL_Core_LIBRARY "@CGAL_Core_LIBRARY@" )
set(CGAL_ImageIO_LIBRARY "@CGAL_ImageIO_LIBRARY@" )
set(CGAL_Qt3_LIBRARY "@CGAL_Qt3_LIBRARY@" )
set(CGAL_Qt4_LIBRARY "@CGAL_Qt4_LIBRARY@" )
#New for Qt5 version !
set(CGAL_Qt5_LIBRARY "@CGAL_Qt5_LIBRARY@" )
set(CGAL_Qt_LIBRARY "@CGAL_Qt_LIBRARY@" )
set(CGAL_3RD_PARTY_INCLUDE_DIRS "@CGAL_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_3RD_PARTY_DEFINITIONS "@CGAL_3RD_PARTY_DEFINITIONS@" )
@ -72,16 +73,11 @@ set(CGAL_Qt3_3RD_PARTY_DEFINITIONS "@CGAL_Qt3_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt3_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt3_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt3_3RD_PARTY_LIBRARIES "@CGAL_Qt3_3RD_PARTY_LIBRARIES@" )
set(CGAL_Qt4_3RD_PARTY_INCLUDE_DIRS "@CGAL_Qt4_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_Qt4_3RD_PARTY_DEFINITIONS "@CGAL_Qt4_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt4_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt4_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt4_3RD_PARTY_LIBRARIES "@CGAL_Qt4_3RD_PARTY_LIBRARIES@" )
#New for Qt5 version !
set(CGAL_Qt5_3RD_PARTY_INCLUDE_DIRS "@CGAL_Qt5_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_Qt5_3RD_PARTY_DEFINITIONS "@CGAL_Qt5_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt5_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt5_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt5_3RD_PARTY_LIBRARIES "@CGAL_Qt5_3RD_PARTY_LIBRARIES@" )
set(CGAL_Qt_3RD_PARTY_INCLUDE_DIRS "@CGAL_Qt_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_Qt_3RD_PARTY_DEFINITIONS "@CGAL_Qt_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt_3RD_PARTY_LIBRARIES "@CGAL_Qt_3RD_PARTY_LIBRARIES@" )
set(CGAL_VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUILD_VERSION}")

View File

@ -39,17 +39,18 @@ set(WITH_CGAL "ON" )
set(WITH_CGAL_Core "@WITH_CGAL_Core@" )
set(WITH_CGAL_ImageIO "@WITH_CGAL_ImageIO@" )
set(WITH_CGAL_Qt3 "@WITH_CGAL_Qt3@" )
set(WITH_CGAL_Qt4 "@WITH_CGAL_Qt4@" )
#New for Qt5 version !
set(WITH_CGAL_Qt5 "@WITH_CGAL_Qt5@" )
set(WITH_CGAL_Qt "@WITH_CGAL_Qt@" )
#New for Qt5 version !
set(CGAL_Qt_version "@CGAL_Qt_version@" )
set(CGAL_LIBRARY "@CGAL_LIBRARY_INSTALLED@")
set(CGAL_Core_LIBRARY "@CGAL_Core_LIBRARY_INSTALLED@")
set(CGAL_ImageIO_LIBRARY "@CGAL_ImageIO_LIBRARY_INSTALLED@")
set(CGAL_Qt3_LIBRARY "@CGAL_Qt3_LIBRARY_INSTALLED@")
set(CGAL_Qt4_LIBRARY "@CGAL_Qt4_LIBRARY_INSTALLED@")
#New for Qt5 version !
set(CGAL_Qt5_LIBRARY "@CGAL_Qt5_LIBRARY_INSTALLED@")
set(CGAL_Qt_LIBRARY "@CGAL_Qt_LIBRARY_INSTALLED@")
set(CGAL_3RD_PARTY_INCLUDE_DIRS "@CGAL_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_3RD_PARTY_DEFINITIONS "@CGAL_3RD_PARTY_DEFINITIONS@" )
@ -72,16 +73,11 @@ set(CGAL_Qt3_3RD_PARTY_DEFINITIONS "@CGAL_Qt3_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt3_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt3_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt3_3RD_PARTY_LIBRARIES "@CGAL_Qt3_3RD_PARTY_LIBRARIES@" )
set(CGAL_Qt4_3RD_PARTY_INCLUDE_DIRS "@CGAL_Qt4_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_Qt4_3RD_PARTY_DEFINITIONS "@CGAL_Qt4_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt4_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt4_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt4_3RD_PARTY_LIBRARIES "@CGAL_Qt4_3RD_PARTY_LIBRARIES@" )
#New for Qt5 version !
set(CGAL_Qt5_3RD_PARTY_INCLUDE_DIRS "@CGAL_Qt5_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_Qt5_3RD_PARTY_DEFINITIONS "@CGAL_Qt5_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt5_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt5_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt5_3RD_PARTY_LIBRARIES "@CGAL_Qt5_3RD_PARTY_LIBRARIES@" )
set(CGAL_Qt_3RD_PARTY_INCLUDE_DIRS "@CGAL_Qt_3RD_PARTY_INCLUDE_DIRS@" )
set(CGAL_Qt_3RD_PARTY_DEFINITIONS "@CGAL_Qt_3RD_PARTY_DEFINITIONS@" )
set(CGAL_Qt_3RD_PARTY_LIBRARIES_DIRS "@CGAL_Qt_3RD_PARTY_LIBRARIES_DIRS@" )
set(CGAL_Qt_3RD_PARTY_LIBRARIES "@CGAL_Qt_3RD_PARTY_LIBRARIES@" )
set(CGAL_VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUILD_VERSION}")

View File

@ -0,0 +1,19 @@
#This file allows an easy add of Qt library, depending of Qt version used into CGAL compilation.
#New for Qt5 version !
if(${CGAL_Qt_version} )
message("It seem that CGAL is not properly configured with Qt.")
else(${CGAL_Qt_version})
find_package(${CGAL_Qt_version})
if(QT4_FOUND)
include(${QT_USE_FILE})
message("Qt4 found")
set(QT4 TRUE)
endif(QT4_FOUND)
#To the functions differences between Qt4 and Qt5.
include(QtChoice)
endif(${CGAL_Qt_version})

View File

@ -10,7 +10,7 @@ endmacro()
macro(qt_wrap_ui)
if(QT5)
qt5_wrap_ui(${ARGN})
qt5_wrap_ui(${ARGN})
elseif(QT4)
qt4_wrap_ui(${ARGN})
else()

View File

@ -33,34 +33,10 @@ 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)
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(CGAL COMPONENTS Qt)
include(${CGAL_USE_FILE})
find_package(Qt)
find_package(OpenGL)
find_package(QGLViewer)
@ -71,7 +47,7 @@ if ( NOT CGAL_FOUND )
elseif ( NOT (QT4 OR QT5) )
MESSAGE(STATUS "NOTICE: This demo requires "
"Qt4 or Qt5, and will not be compiled.")
"Qt, and will not be compiled.")
elseif ( NOT OPENGL_FOUND )
MESSAGE(STATUS "NOTICE: This demo requires OpenGL "

View File

@ -31,34 +31,11 @@ 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)
find_package(CGAL COMPONENTS Qt ImageIO)
if(USE_QT5)
find_package(CGAL COMPONENTS Qt5 ImageIO)
include(${CGAL_USE_FILE})
include(${CGAL_USE_FILE})
find_package(Qt5)
else (USE_QT5)
find_package(CGAL COMPONENTS Qt4 ImageIO)
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(Qt)
# Find OpenGL
find_package(OpenGL)
@ -391,18 +368,12 @@ else ((QT4 OR QT5) AND OPENGL_FOUND AND QGLVIEWER_FOUND AND Boost_FOUND)
set(MESH_3_MISSING_DEPS "")
if(NOT CGAL_Qt4_FOUND AND NOT USE_QT5)
set(MESH_3_MISSING_DEPS "the CGAL Qt4 library, ${MESH_3_MISSING_DEPS}")
endif()
if(NOT CGAL_Qt5_FOUND AND USE_QT5)
set(MESH_3_MISSING_DEPS "the CGAL Qt5 library, ${MESH_3_MISSING_DEPS}")
if(NOT CGAL_Qt_FOUND)
set(MESH_3_MISSING_DEPS "the CGAL Qt library, ${MESH_3_MISSING_DEPS}")
endif()
if(NOT QT4 AND NOT USE_QT5)
set(MESH_3_MISSING_DEPS "Qt4, ${MESH_3_MISSING_DEPS}")
endif()
if(NOT QT5 AND USE_QT5)
set(MESH_3_MISSING_DEPS "Qt5, ${MESH_3_MISSING_DEPS}")
if(NOT QT4 OR NOT QT5)
set(MESH_3_MISSING_DEPS "Qt, ${MESH_3_MISSING_DEPS}")
endif()
if(NOT OPENGL_FOUND)

View File

@ -21,36 +21,11 @@ set( QT_USE_QTMAIN TRUE )
set( QT_USE_QTSCRIPT TRUE )
set( QT_USE_QTOPENGL TRUE )
#New for Qt5 version !
if(QT4 OR QT5)
option (USE_QT5 "Use Qt5 version instead of Qt4" ON)
endif()
find_package(CGAL COMPONENTS Qt ImageIO)
if(USE_QT5)
find_package(CGAL COMPONENTS Qt5 ImageIO)
include(${CGAL_USE_FILE})
find_package(Qt5)
else (USE_QT5)
find_package(CGAL COMPONENTS Qt4 ImageIO)
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)
include(${CGAL_USE_FILE})
find_package(Qt)
if(QT4 OR QT5)