StrokeList Class Reference

#include <strokelist.h>

List of all members.

Public Member Functions

 StrokeList ()
 StrokeList (const StrokeList &other)
 StrokeList (const QList< Stroke > &other)
void translate (StrokeCoordT dx, StrokeCoordT dy)
void translate (const StrokePointBase &p)
StrokeList translated (StrokeCoordT dx, StrokeCoordT dy) const
StrokeList translated (const StrokePointBase &p) const
QString toString () const

Static Public Member Functions

static StrokeList fromString (const QString &str)


Constructor & Destructor Documentation

StrokeList::StrokeList (  ) 

StrokeList::StrokeList ( const StrokeList other  ) 

StrokeList::StrokeList ( const QList< Stroke > &  other  ) 


Member Function Documentation

void StrokeList::translate ( StrokeCoordT  dx,
StrokeCoordT  dy 
) [inline]

void StrokeList::translate ( const StrokePointBase p  )  [inline]

StrokeList StrokeList::translated ( StrokeCoordT  dx,
StrokeCoordT  dy 
) const [inline]

StrokeList StrokeList::translated ( const StrokePointBase p  )  const [inline]

QString StrokeList::toString (  )  const

Returns the strokes as a QString.

This method is required to store the strokes in a record of the Gesture table (in a QSqlDatabase). Hence, the QString returned is be compact while also easy enough for fromString() to parse (or by some external parser).

The format of the string also allows for extensibility, as each field is explicitly stated as a "tag" (like XML element attributes). However, as compactness is important for storage, the fields values are not grouped by StrokePoint. Instead they are stored as a vector for each field type for each stroke. This format makes it easy to fetch data from specific fields without having to parse all of the data (e.g. parse only "x" and "y", not "pressure").

Also of note: field values, field vectors and strokes are separated using single characters, not brackets (they being ",", ";" and "$", respectively). The decision to not use bracketing wasn't driven by compactness (although that is a nice side-effect), but instead by the ease of parsing, given the availability of a "split-on" function.

Lastly, a textual string has been used instead of binary data, as this code is designed to be cross platform, where the database could reside on a machine of any architecture, communicating with a client of also any architecture. It also makes the data (mildly) human-readable.

Example of 3 strokes, with 12 points in total:

   "x=0,1,2,1,2;y=3,1,2,4,5;pressure=.1,.5,1,.4,.01
    |x=2,4,1;y=3,0,2;pressure=.2,.9,.1
    |x=7,3,5,2;y=8,7,6,4;pressure=.4,.9,.9,.3"

StrokeList StrokeList::fromString ( const QString &  str  )  [static]

Returns a StrokeList object with the data contained in the given string. The order of the elements in the StrokeList is the same as in string.

This method is required to load strokes from a record of the Gesture table (in a QSqlDatabase). This method parses data that has been generated using toString().


The documentation for this class was generated from the following files:
Generated on Mon Jul 30 09:46:53 2007 for Digest by  doxygen 1.5.2