demos/deform/pathdeform.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2005-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the demonstration applications of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 #ifndef PATHDEFORM_H
00025 #define PATHDEFORM_H
00026 
00027 #include "arthurwidgets.h"
00028 
00029 #include <QPainterPath>
00030 #include <QBasicTimer>
00031 #include <QDateTime>
00032 
00033 class PathDeformRenderer : public ArthurFrame
00034 {
00035     Q_OBJECT
00036     Q_PROPERTY(bool animated READ animated WRITE setAnimated)
00037     Q_PROPERTY(int radius READ radius WRITE setRadius)
00038     Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize)
00039     Q_PROPERTY(int intensity READ intensity WRITE setIntensity)
00040     Q_PROPERTY(QString text READ text WRITE setText)
00041 
00042 public:
00043     PathDeformRenderer(QWidget *widget);
00044 
00045     void paint(QPainter *painter);
00046 
00047     void mousePressEvent(QMouseEvent *e);
00048     void mouseReleaseEvent(QMouseEvent *e);
00049     void mouseMoveEvent(QMouseEvent *e);
00050     void timerEvent(QTimerEvent *e);
00051 
00052     QSize sizeHint() const { return QSize(600, 500); }
00053 
00054     bool animated() const { return m_animated; }
00055     int radius() const { return int(m_radius); }
00056     int fontSize() const { return m_fontSize; }
00057     int intensity() const { return int(m_intensity); }
00058     QString text() const { return m_text; }
00059 
00060 public slots:
00061     void setRadius(int radius);
00062     void setFontSize(int fontSize) { m_fontSize = fontSize; setText(m_text); }
00063     void setText(const QString &text);
00064     void setIntensity(int intensity);
00065 
00066     void setAnimated(bool animated);
00067 
00068 // signals:
00069 //     void frameRate(double fps);
00070 
00071 private:
00072     void generateLensPixmap();
00073     QPainterPath lensDeform(const QPainterPath &source, const QPointF &offset);
00074 
00075     QBasicTimer m_repaintTimer;
00076 //     QBasicTimer m_fpsTimer;
00077 //     int m_fpsCounter;
00078     QTime m_repaintTracker;
00079 
00080     QVector<QPainterPath> m_paths;
00081     QVector<QPointF> m_advances;
00082     QRectF m_pathBounds;
00083     QString m_text;
00084 
00085     QPixmap m_lens_pixmap;
00086     QImage m_lens_image;
00087 
00088     int m_fontSize;
00089     bool m_animated;
00090 
00091     double m_intensity;
00092     double m_radius;
00093     QPointF m_pos;
00094     QPointF m_offset;
00095     QPointF m_direction;
00096 };
00097 
00098 class PathDeformWidget : public QWidget
00099 {
00100 public:
00101     PathDeformWidget(QWidget *parent);
00102 
00103 private:
00104     PathDeformRenderer *m_renderer;
00105 };
00106 
00107 #endif // PATHDEFORM_H

Generated on Thu Mar 15 11:52:32 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1