summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenstroke.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/handwriting/qimpenstroke.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenstroke.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/inputmethods/handwriting/qimpenstroke.cpp b/inputmethods/handwriting/qimpenstroke.cpp
index 3567d6d..14e435a 100644
--- a/inputmethods/handwriting/qimpenstroke.cpp
+++ b/inputmethods/handwriting/qimpenstroke.cpp
@@ -15,24 +15,25 @@
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qfile.h>
#include <qtl.h>
#include <math.h>
#include <limits.h>
#include <qdatastream.h>
#include "qimpenstroke.h"
+#include "opie2/odebug.h"
#define QIMPEN_CORRELATION_POINTS 25
//#define DEBUG_QIMPEN
/*!
\class QIMPenStroke qimpenstroke.h
Handles a single stroke. Can calculate closeness of match to
another stroke.
*/
QIMPenStroke::QIMPenStroke()
@@ -40,25 +41,25 @@ QIMPenStroke::QIMPenStroke()
}
QIMPenStroke::QIMPenStroke( const QIMPenStroke &st )
{
startPoint = st.startPoint;
lastPoint = st.lastPoint;
links = st.links.copy();
}
QIMPenStroke &QIMPenStroke::operator=( const QIMPenStroke &s )
{
clear();
- //qDebug( "copy strokes %d", s.links.count() );
+ //odebug << "copy strokes " << s.links.count() << oendl;
startPoint = s.startPoint;
lastPoint = s.lastPoint;
links = s.links.copy();
return *this;
}
void QIMPenStroke::clear()
{
startPoint = QPoint(0,0);
lastPoint = QPoint( 0, 0 );
links.resize( 0 );
@@ -140,45 +141,45 @@ bool QIMPenStroke::addPoint( QPoint p )
Finish inputting a stroke.
*/
void QIMPenStroke::endInput()
{
if ( links.count() < 3 ) {
QIMPenGlyphLink gl;
links.resize(1);
gl.dx = 1;
gl.dy = 0;
links[0] = gl;
}
- //qDebug("Points: %d", links.count() );
+ //odebug << "Points: " << links.count() << oendl;
}
/*!
Return an indicator of the closeness of this stroke to \a pen.
Lower value is better.
*/
unsigned int QIMPenStroke::match( QIMPenStroke *pen )
{
double lratio;
if ( links.count() > pen->links.count() )
lratio = (links.count()+2) / (pen->links.count()+2);
else
lratio = (pen->links.count()+2) / (links.count()+2);
lratio -= 1.0;
if ( lratio > 2.0 ) {
#ifdef DEBUG_QIMPEN
- qDebug( "stroke length too different" );
+ odebug << "stroke length too different" << oendl;
#endif
return 400000;
}
createSignatures();
pen->createSignatures();
// Starting point offset
int vdiff = QABS(startPoint.y() - pen->startPoint.y());
// Insanely offset?
if ( vdiff > 18 ) {
@@ -206,57 +207,57 @@ unsigned int QIMPenStroke::match( QIMPenStroke *pen )
int err3 = INT_MAX;
// base has extra points at the start and end to enable
// correlation of a sliding window with the pen supplied.
QArray<int> base = createBase( tsig, 2 );
for ( int i = 0; i < 4; i++ ) {
int e = calcError( base, pen->tsig, i, TRUE );
if ( e < err1 )
err1 = e;
}
if ( err1 > 40 ) { // no need for more matching
#ifdef DEBUG_QIMPEN
- qDebug( "tsig too great: %d", err1 );
+ odebug << "tsig too great: " << err1 << oendl;
#endif
return 400000;
}
// maybe a sliding window is worthwhile for these too.
err2 = calcError( dsig, pen->dsig, 0, FALSE );
if ( err2 > 100 ) {
#ifdef DEBUG_QIMPEN
- qDebug( "dsig too great: %d", err2 );
+ odebug << "dsig too great: " << err2 << oendl;
#endif
return 400000;
}
err3 = calcError( asig, pen->asig, 0, TRUE );
if ( err3 > 60 ) {
#ifdef DEBUG_QIMPEN
- qDebug( "asig too great: %d", err3 );
+ odebug << "asig too great: " << err3 << oendl;
#endif
return 400000;
}
// Some magic numbers here - the addition reduces the weighting of
// the error and compensates for the different error scales. I
// consider the tangent signature to be the best indicator, so it
// has the most weight. This ain't rocket science.
// Basically, these numbers are the tuning factors.
unsigned int err = (err1+1) * ( err2 + 60 ) * ( err3 + 20 ) +
vdiff * 1000 + evdiff * 500 +
(unsigned int)(lratio * 5000.0);
#ifdef DEBUG_QIMPEN
- qDebug( "err %d ( %d, %d, %d, %d)", err, err1, err2, err3, vdiff );
+ odebug << "err " << err << "( " << err1 << ", " << err2 << ", " << err3 << ", " << vdiff << oendl;
#endif
return err;
}
/*!
Return the bounding rect of this stroke.
*/
QRect QIMPenStroke::boundingRect()
{
if ( !bounding.isValid() ) {
int x = startPoint.x();