orca-robotics INTRODUCTION Overview Download and Install Documentation REPOSITORY Interfaces Drivers Libraries Utilities Software Map DEVELOPER Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
zoomwidget.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef HYDROQGUI_ZOOM_WIDGET_H 00012 #define HYDROQGUI_ZOOM_WIDGET_H 00013 00014 #include <QWidget> 00015 #include <QResizeEvent> 00016 #include <QMatrix> 00017 00018 namespace hydroqgui 00019 { 00020 00025 class ZoomWidget : public QWidget 00026 { 00027 Q_OBJECT 00028 public: 00029 ZoomWidget( QWidget* parent=0 ); 00030 00031 QMatrix matrix() const { return wm_; }; 00032 00033 signals: 00034 // Use this signal to broadcast a change in the world matrix. 00035 void matrixChanged( const QMatrix & ); 00036 // Use this signal to broadcast a change in the size of the widget. 00037 void windowSizeChanged( const QSize & ); 00038 00039 public slots: 00040 // view manipulation 00041 void zoomIn( const double & z=4.0/3.0 ) { 00042 zoomView(z); 00043 }; 00044 void zoomOut( const double & z=3.0/4.0 ) { 00045 zoomView(z); 00046 }; 00047 void zoomWorldSize( const QSizeF & worldSize ); 00048 void zoomWorldSize( const QSizeF & worldSize, const QPointF & pcenter ); 00049 00050 void zoomPixelSize( const QSizeF & pixSize ) { 00051 setZoom( 1.0/pixSize.width() ); 00052 }; 00053 00054 void moveUp() { 00055 moveView( QPointF(0.0,25.0) ); 00056 }; 00057 void moveDown() { 00058 moveView( QPointF(0.0,-25.0) ); 00059 }; 00060 void moveLeft() { 00061 moveView( QPointF(25.0,0.0) ); 00062 }; 00063 void moveRight() { 00064 moveView( QPointF(-25.0,0.0) ); 00065 }; 00066 00067 // Responds to an outside request to broadcast the current world matrix. 00068 void transmitMatrix(); 00069 00070 protected: 00071 00072 // world-to-window transformation matrix 00073 QMatrix wm_; 00074 00075 // view manipulation utilities 00076 void setZoom( const double & ); 00077 void zoomView( const double & ); 00078 00079 // Translates the widget view by d(x,y), where d = p2 - p1 00080 // p1 - original coord. of widget center 00081 // p2 - final coord. of widget center 00082 void moveView( const QPointF & ); 00083 00084 // given a point in WORLD CS, position it in the center of the window 00085 void centerView( const QPointF & ); 00086 00087 void resizeEvent( QResizeEvent* ); 00088 00089 }; 00090 00091 } // namespace 00092 00093 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)