INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide 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-2009 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 00041 // view manipulation 00042 00043 // z is a ratio 00044 void zoomIn( const double & z=4.0/3.0 ) { 00045 zoomView(z); 00046 }; 00047 void zoomOut( const double & z=3.0/4.0 ) { 00048 zoomView(z); 00049 }; 00050 00051 // in world coordinates [m] 00052 void zoomWorldSize( const QSizeF & worldSize ); 00053 void zoomWorldSize( const QSizeF & worldSize, const QPointF & pcenter ); 00054 00055 // in pixel 00056 void zoomPixelSize( const QSizeF & pixSize ) { 00057 setZoom( 1.0/pixSize.width() ); 00058 }; 00059 00060 void moveUp() { 00061 moveView( QPointF(0.0,25.0) ); 00062 }; 00063 void moveDown() { 00064 moveView( QPointF(0.0,-25.0) ); 00065 }; 00066 void moveLeft() { 00067 moveView( QPointF(25.0,0.0) ); 00068 }; 00069 void moveRight() { 00070 moveView( QPointF(-25.0,0.0) ); 00071 }; 00072 00073 // Responds to an outside request to broadcast the current world matrix. 00074 void transmitMatrix(); 00075 00076 protected: 00077 00078 // world-to-window transformation matrix 00079 QMatrix wm_; 00080 00081 // view manipulation utilities 00082 void setZoom( const double & ); 00083 void zoomView( const double & ); 00084 00085 // Translates the widget view by d(x,y), where d = p2 - p1 00086 // d is in pixels 00087 // p1 - original coord. of widget center 00088 // p2 - final coord. of widget center 00089 void moveView( const QPointF & ); 00090 00091 // As above but in world coordinates [m] 00092 void moveViewWorldCs( const QPointF & ); 00093 00094 // given a point in WORLD CS [m], position it in the center of the window 00095 void centerView( const QPointF & ); 00096 00097 void resizeEvent( QResizeEvent* ); 00098 00099 }; 00100 00101 } // namespace 00102 00103 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)