Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qimpenstroke.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #ifndef QIMPENSTROKE_H_
00022 #define QIMPENSTROKE_H_
00023 
00024 #include <qobject.h>
00025 #include <qarray.h>
00026 #include <qlist.h>
00027 
00028 struct Q_PACKED QIMPenGlyphLink
00029 {
00030     signed char dx;
00031     signed char dy;
00032 };
00033 
00034 class QIMPenStroke
00035 {
00036 public:
00037     QIMPenStroke();
00038     QIMPenStroke( const QIMPenStroke & );
00039 
00040     void clear();
00041     bool isEmpty() const { return links.isEmpty(); }
00042     unsigned int length() const { return links.count(); }
00043     unsigned int match( QIMPenStroke *st );
00044     const QArray<QIMPenGlyphLink> &chain() const { return links; }
00045     QPoint startingPoint() const { return startPoint; }
00046     void setStartingPoint( const QPoint &p ) { startPoint = p; }
00047     QRect boundingRect();
00048 
00049     QIMPenStroke &operator=( const QIMPenStroke &s );
00050 
00051     void beginInput( QPoint p );
00052     bool addPoint( QPoint p );
00053     void endInput();
00054 
00055     QArray<int> sig() { createTanSignature(); return tsig; } // for debugging
00056 
00057 protected:
00058     void createSignatures();
00059     void createTanSignature();
00060     void createAngleSignature();
00061     void createDistSignature();
00062     int calcError( const QArray<int> &base, const QArray<int> &win,
00063                       int off, bool t );
00064     QArray<int> scale( const QArray<int> &s, unsigned count, bool t = FALSE );
00065     void internalAddPoint( QPoint p );
00066     QPoint calcCenter();
00067     int arcTan( int dy, int dx );
00068     QArray<int> createBase( const QArray<int> a, int e );
00069     void smooth( QArray<int> &);
00070 
00071 protected:
00072     QPoint startPoint;
00073     QPoint lastPoint;
00074     QArray<QIMPenGlyphLink> links;
00075     QArray<int> tsig;
00076     QArray<int> asig;
00077     QArray<int> dsig;
00078     QRect bounding;
00079 
00080     friend QDataStream &operator<< (QDataStream &, const QIMPenStroke &);
00081     friend QDataStream &operator>> (QDataStream &, QIMPenStroke &);
00082 };
00083 
00084 typedef QList<QIMPenStroke> QIMPenStrokeList;
00085 typedef QListIterator<QIMPenStroke> QIMPenStrokeIterator;
00086 
00087 QDataStream & operator<< (QDataStream & s, const QIMPenStroke &ws);
00088 QDataStream & operator>> (QDataStream & s, const QIMPenStroke &ws);
00089 
00090 #endif
00091 

Generated on Sat Nov 5 16:16:01 2005 for OPIE by  doxygen 1.4.2