Files
cgal/GraphicsView/include/CGAL/Qt/GraphicsViewNavigation.h
T
Laurent Rineau b731d74096 CGAL::Qt::GraphicsViewNavigation is no longer constructed from a
QGraphicsView*. It is now able to handle several graphics view at the same
time (just install several event filters).

New class CGAL::Qt::DemosMainWindow. That class has several protected
methods:
  void setupStatusBar();
  void addNavigation(QGraphicsView*);
  void setupOptionsMenu(QMenu* menu  = NULL);
  void addAboutCGAL(QMenu* menu  = NULL);
  void addAboutDemo(QString htmlResourceName, QMenu* menu  = NULL);

setupStatusBar() adds a label in the statusBar(), that is connected to the
navigation class, and shows the position of the mouse.

addNavigation(QGraphicsView* v) adds a navigation class to the view v.

setupOptionsMenu(QMenu* m  = NULL) adds two options "Use OpenGL" and
"Use antialiasing" to the menu m. If m==0, a menu named "Options" is searched
for, or created if it does not exists.

addAboutCGAL(QMenu* m  = NULL) adds an entry "About CGAL..." to the menu
m. If m==0, a "Help" menu is searched for or created.

addAboutDemo(QString htmlResourceName, QMenu* m  = NULL) adds an entre
"About the demo...", to the menu m. If m==0, a "Help" menu is searched for
or created. If the entry is clicked, a popup dialog shows the content of
the resource/file whose name is in htmlResourceName.
Example:
  addAboutDemo(":/cgal/help/about_triangulation.html")
2008-06-26 15:19:44 +00:00

51 lines
1019 B
C++

#ifndef CGAL_QT_GRAPHICS_VIEW_NAVIGATION_H
#define CGAL_QT_GRAPHICS_VIEW_NAVIGATION_H
#include <QObject>
#include <QPointF>
#include <QString>
#include <QCursor>
#include <QRect>
#include <QRectF>
class QGraphicsView;
class QGraphicsScene;
class QEvent;
class QGraphicsRectItem;
namespace CGAL {
namespace Qt {
class GraphicsViewNavigation: public QObject {
Q_OBJECT
signals:
void mouseCoordinates(QString);
public:
GraphicsViewNavigation();
~GraphicsViewNavigation();
bool eventFilter(QObject *obj, QEvent *event);
private:
void scaleView(QGraphicsView*, qreal scaleFactor);
void translateView(QGraphicsView*, int dx, int dy);
void drag_to(QGraphicsView*, QPoint new_pos);
QRectF mapToScene(QGraphicsView*, QRect rect) const;
void display_parameters(QGraphicsView*);
QGraphicsRectItem* rectItem;
QPointF rect_first_point;
bool dragging;
QPointF dragging_start;
QCursor cursor_backup;
};
} // namespace Qt
} // namespace CGAL
#endif // CGAL_QT_GRAPHICS_VIEW_NAVIGATION_H