00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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; }
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