summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenstroke.cpp
Unidiff
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
@@ -21,12 +21,13 @@
21#include <qfile.h> 21#include <qfile.h>
22#include <qtl.h> 22#include <qtl.h>
23#include <math.h> 23#include <math.h>
24#include <limits.h> 24#include <limits.h>
25#include <qdatastream.h> 25#include <qdatastream.h>
26#include "qimpenstroke.h" 26#include "qimpenstroke.h"
27#include "opie2/odebug.h"
27 28
28#define QIMPEN_CORRELATION_POINTS 25 29#define QIMPEN_CORRELATION_POINTS 25
29//#define DEBUG_QIMPEN 30//#define DEBUG_QIMPEN
30 31
31/*! 32/*!
32 \class QIMPenStroke qimpenstroke.h 33 \class QIMPenStroke qimpenstroke.h
@@ -46,13 +47,13 @@ QIMPenStroke::QIMPenStroke( const QIMPenStroke &st )
46 links = st.links.copy(); 47 links = st.links.copy();
47} 48}
48 49
49QIMPenStroke &QIMPenStroke::operator=( const QIMPenStroke &s ) 50QIMPenStroke &QIMPenStroke::operator=( const QIMPenStroke &s )
50{ 51{
51 clear(); 52 clear();
52 //qDebug( "copy strokes %d", s.links.count() ); 53 //odebug << "copy strokes " << s.links.count() << oendl;
53 startPoint = s.startPoint; 54 startPoint = s.startPoint;
54 lastPoint = s.lastPoint; 55 lastPoint = s.lastPoint;
55 links = s.links.copy(); 56 links = s.links.copy();
56 57
57 return *this; 58 return *this;
58} 59}
@@ -146,13 +147,13 @@ void QIMPenStroke::endInput()
146 links.resize(1); 147 links.resize(1);
147 gl.dx = 1; 148 gl.dx = 1;
148 gl.dy = 0; 149 gl.dy = 0;
149 links[0] = gl; 150 links[0] = gl;
150 } 151 }
151 152
152 //qDebug("Points: %d", links.count() ); 153 //odebug << "Points: " << links.count() << oendl;
153} 154}
154 155
155/*! 156/*!
156 Return an indicator of the closeness of this stroke to \a pen. 157 Return an indicator of the closeness of this stroke to \a pen.
157 Lower value is better. 158 Lower value is better.
158*/ 159*/
@@ -166,13 +167,13 @@ unsigned int QIMPenStroke::match( QIMPenStroke *pen )
166 lratio = (pen->links.count()+2) / (links.count()+2); 167 lratio = (pen->links.count()+2) / (links.count()+2);
167 168
168 lratio -= 1.0; 169 lratio -= 1.0;
169 170
170 if ( lratio > 2.0 ) { 171 if ( lratio > 2.0 ) {
171#ifdef DEBUG_QIMPEN 172#ifdef DEBUG_QIMPEN
172 qDebug( "stroke length too different" ); 173 odebug << "stroke length too different" << oendl;
173#endif 174#endif
174 return 400000; 175 return 400000;
175 } 176 }
176 177
177 createSignatures(); 178 createSignatures();
178 pen->createSignatures(); 179 pen->createSignatures();
@@ -212,30 +213,30 @@ unsigned int QIMPenStroke::match( QIMPenStroke *pen )
212 int e = calcError( base, pen->tsig, i, TRUE ); 213 int e = calcError( base, pen->tsig, i, TRUE );
213 if ( e < err1 ) 214 if ( e < err1 )
214 err1 = e; 215 err1 = e;
215 } 216 }
216 if ( err1 > 40 ) { // no need for more matching 217 if ( err1 > 40 ) { // no need for more matching
217#ifdef DEBUG_QIMPEN 218#ifdef DEBUG_QIMPEN
218 qDebug( "tsig too great: %d", err1 ); 219 odebug << "tsig too great: " << err1 << oendl;
219#endif 220#endif
220 return 400000; 221 return 400000;
221 } 222 }
222 223
223 // maybe a sliding window is worthwhile for these too. 224 // maybe a sliding window is worthwhile for these too.
224 err2 = calcError( dsig, pen->dsig, 0, FALSE ); 225 err2 = calcError( dsig, pen->dsig, 0, FALSE );
225 if ( err2 > 100 ) { 226 if ( err2 > 100 ) {
226#ifdef DEBUG_QIMPEN 227#ifdef DEBUG_QIMPEN
227 qDebug( "dsig too great: %d", err2 ); 228 odebug << "dsig too great: " << err2 << oendl;
228#endif 229#endif
229 return 400000; 230 return 400000;
230 } 231 }
231 232
232 err3 = calcError( asig, pen->asig, 0, TRUE ); 233 err3 = calcError( asig, pen->asig, 0, TRUE );
233 if ( err3 > 60 ) { 234 if ( err3 > 60 ) {
234#ifdef DEBUG_QIMPEN 235#ifdef DEBUG_QIMPEN
235 qDebug( "asig too great: %d", err3 ); 236 odebug << "asig too great: " << err3 << oendl;
236#endif 237#endif
237 return 400000; 238 return 400000;
238 } 239 }
239 240
240 // Some magic numbers here - the addition reduces the weighting of 241 // Some magic numbers here - the addition reduces the weighting of
241 // the error and compensates for the different error scales. I 242 // the error and compensates for the different error scales. I
@@ -244,13 +245,13 @@ unsigned int QIMPenStroke::match( QIMPenStroke *pen )
244 // Basically, these numbers are the tuning factors. 245 // Basically, these numbers are the tuning factors.
245 unsigned int err = (err1+1) * ( err2 + 60 ) * ( err3 + 20 ) + 246 unsigned int err = (err1+1) * ( err2 + 60 ) * ( err3 + 20 ) +
246 vdiff * 1000 + evdiff * 500 + 247 vdiff * 1000 + evdiff * 500 +
247 (unsigned int)(lratio * 5000.0); 248 (unsigned int)(lratio * 5000.0);
248 249
249#ifdef DEBUG_QIMPEN 250#ifdef DEBUG_QIMPEN
250 qDebug( "err %d ( %d, %d, %d, %d)", err, err1, err2, err3, vdiff ); 251 odebug << "err " << err << "( " << err1 << ", " << err2 << ", " << err3 << ", " << vdiff << oendl;
251#endif 252#endif
252 253
253 return err; 254 return err;
254} 255}
255 256
256/*! 257/*!