after presentation at Inria

This commit is contained in:
Andreas Fabri 2008-06-25 20:16:44 +00:00
parent 4a92e20e15
commit 00b45e977d
3 changed files with 27 additions and 23 deletions

View File

@ -31,19 +31,19 @@ if(QT4_FOUND)
include(${QT_USE_FILE})
# a moc file that is included in a .cpp file
qt4_generate_moc( ../../include/CGAL/IO/QtNavigation.h QtNavigation.moc )
macro_add_file_dependencies( QtNavigation.cpp QtNavigation.moc )
qt4_generate_moc( ../../include/CGAL/Qt/GtraphicsViewNavigation.h GraphicsViewNavigation.moc )
macro_add_file_dependencies( GraphicsViewNavigation.cpp GraphicsViewNavigation.moc )
# two moc files that are compiled directly as cpp files
qt4_generate_moc( ../../include/CGAL/IO/QtGraphicsItem.h QtGraphicsItem_moc.cpp )
qt4_generate_moc( ../../include/CGAL/IO/QtInput.h QtInput_moc.cpp )
qt4_generate_moc( ../../include/CGAL/Qt/GraphicsItem.h GraphicsItem_moc.cpp )
qt4_generate_moc( ../../include/CGAL/Qt/GraphicsViewInput.h GraphicsViewInput_moc.cpp )
# qrc files (resources files, that contain icons, at least)
qt4_add_resources ( RESOURCE_FILES ../../demo/icons/Input.qrc ../../demo/icons/File.qrc ../../demo/icons/Logos.qrc ../../demo/icons/Triangulation_2.qrc)
set( CGAL_QT4_BASENAME CGAL-Qt4 )
add_library( CGAL_QT4 QtInput_moc.cpp QtNavigation.cpp QtGraphicsItem_moc.cpp QtPolylineInput.cpp ${RESOURCE_FILES} )
add_library( CGAL_QT4 GraphicsViewInput_moc.cpp GraphicsViewNavigation.cpp GraphicsItem_moc.cpp GraphicsViewPolylineInput.cpp ${RESOURCE_FILES} )
target_link_libraries( CGAL_QT4 ${QT_LIBRARIES} )
if ( NOT AUTO_LINK_ENABLED )
# If auto-link is not enabled (on Linux for example), link with libCGAL explicitly.

View File

@ -1,4 +1,4 @@
#include <CGAL/IO/QtNavigation.h>
#include <CGAL/Qt/GraphicsViewNavigation.h>
#include <cmath>
#include <iostream>
#include <boost/format.hpp>
@ -12,8 +12,9 @@
#include <QScrollBar>
namespace CGAL {
namespace Qt {
QtNavigation::QtNavigation(QGraphicsView* v_)
GraphicsViewNavigation::GraphicsViewNavigation(QGraphicsView* v_)
: v(v_),
rectItem(new QGraphicsRectItem),
dragging(false)
@ -27,13 +28,13 @@ namespace CGAL {
rectItem->setZValue(10000);
}
QtNavigation::~QtNavigation()
GraphicsViewNavigation::~GraphicsViewNavigation()
{
delete rectItem;
}
bool
QtNavigation::eventFilter(QObject *obj, QEvent *event)
GraphicsViewNavigation::eventFilter(QObject *obj, QEvent *event)
{
switch(event->type())
{
@ -184,7 +185,7 @@ namespace CGAL {
void
QtNavigation::scaleView(qreal scaleFactor)
GraphicsViewNavigation::scaleView(qreal scaleFactor)
{
QPointF center = v->mapToScene(v->viewport()->rect().center());
// qreal factor = v->matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
@ -196,7 +197,7 @@ namespace CGAL {
translateView(offset.x(), offset.y());
}
void QtNavigation::drag_to(QPoint new_pos)
void GraphicsViewNavigation::drag_to(QPoint new_pos)
{
QPoint dragging_start_in_view = v->mapFromScene(dragging_start);
QPoint offset = new_pos - dragging_start_in_view;
@ -210,14 +211,14 @@ namespace CGAL {
// % dragging_start_in_view.x() % dragging_start_in_view.y();
}
QRectF QtNavigation::mapToScene(QRect rect) const
QRectF GraphicsViewNavigation::mapToScene(QRect rect) const
{
QPointF top_left = v->mapToScene(rect.topLeft());
QPointF bottom_right = v->mapToScene(rect.bottomRight());
return QRectF(top_left, bottom_right);
}
void QtNavigation::translateView(int dx, int dy)
void GraphicsViewNavigation::translateView(int dx, int dy)
{
if( dx == 0 && dy == 0 ) {
return;
@ -259,7 +260,7 @@ namespace CGAL {
// display_parameters();
}
void QtNavigation::display_parameters()
void GraphicsViewNavigation::display_parameters()
{
std::cerr <<
boost::format("matrix translation=(%1%, %2%)\n"
@ -296,7 +297,8 @@ namespace CGAL {
% v->verticalScrollBar()->maximum();
}
#include "QtNavigation.moc"
#include "GraphicsViewNavigation.moc"
} // namespace Qt
} // namespace CGAL

View File

@ -8,12 +8,13 @@
#include <QEvent>
#include <QKeyEvent>
#include <CGAL/IO/QtPolylineInput.h>
#include <CGAL/Qt/GraphicsViewPolylineInput.h>
namespace CGAL {
namespace Qt {
QtPolylineInput_non_templated_base::
QtPolylineInput_non_templated_base(QObject* parent,
GraphicsViewPolylineInput_non_templated_base::
GraphicsViewPolylineInput_non_templated_base(QObject* parent,
QGraphicsScene* s,
int n,
bool closed)
@ -22,7 +23,7 @@ QtPolylineInput_non_templated_base(QObject* parent,
bool
QtPolylineInput_non_templated_base::mousePressEvent(QGraphicsSceneMouseEvent *event)
GraphicsViewPolylineInput_non_templated_base::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if( event->modifiers() ){
return false;
@ -67,7 +68,7 @@ QtPolylineInput_non_templated_base::mousePressEvent(QGraphicsSceneMouseEvent *ev
void
QtPolylineInput_non_templated_base::rubberbands(const QPointF& p)
GraphicsViewPolylineInput_non_templated_base::rubberbands(const QPointF& p)
{
if(polygon.empty()){
return;
@ -92,7 +93,7 @@ QtPolylineInput_non_templated_base::rubberbands(const QPointF& p)
void
QtPolylineInput_non_templated_base::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
GraphicsViewPolylineInput_non_templated_base::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
sp = event->scenePos();
rubberbands(sp);
@ -100,7 +101,7 @@ QtPolylineInput_non_templated_base::mouseMoveEvent(QGraphicsSceneMouseEvent *eve
bool
QtPolylineInput_non_templated_base::keyPressEvent ( QKeyEvent * event )
GraphicsViewPolylineInput_non_templated_base::keyPressEvent ( QKeyEvent * event )
{
if( event->modifiers() )
return false;
@ -148,7 +149,7 @@ QtPolylineInput_non_templated_base::keyPressEvent ( QKeyEvent * event )
bool
QtPolylineInput_non_templated_base::eventFilter(QObject *obj, QEvent *event)
GraphicsViewPolylineInput_non_templated_base::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::GraphicsSceneMousePress) {
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
@ -171,4 +172,5 @@ QtPolylineInput_non_templated_base::eventFilter(QObject *obj, QEvent *event)
}
}
} // namespace Qt
} // namespace CGAL