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

gest_guards.H

Go to the documentation of this file.
00001 /**********************************************************************
00002  * draw_fsa.H
00003  **********************************************************************/
00004 #ifndef DRAW_FSA_H_HAS_BEEN_INCLUDED
00005 #define DRAW_FSA_H_HAS_BEEN_INCLUDED
00006 
00007 #include "geom/fsa.H"
00008 
00009 #include "gesture.H"
00010 
00011 #ifdef WIN32
00012 #ifdef DrawState
00013 #undef DrawState
00014 #endif
00015 #define DrawState DrawStateWIN
00016 #endif
00017 typedef Guard_t <GESTUREptr>  DrawGuard;
00018 typedef Arc_t   <GESTUREptr>  DrawArc;
00019 typedef State_t <GESTUREptr>  DrawState;
00020 typedef FSAT    <GESTUREptr>  DrawFSA;
00021 
00022 class GarbageGuard : public DrawGuard {
00023  public:
00024    // When the tablet flakes out we get 3000 pixel/sec strokes that
00025    // end 6 feet beyond the edge of the screen. We don't want
00026    // those. Normal gestures are under 500 pixels/sec, with some
00027    // slashes reaching 1000 or so.
00028    virtual int exec(CGESTUREptr& g) { return g && g->speed() > 2000; }
00029 };
00030 
00031 class TapGuard : public DrawGuard {
00032  public:
00033    virtual int exec(CGESTUREptr& g) { return g && g->is_tap(); }
00034 };
00035 
00036 class DslashGuard : public DrawGuard {
00037  public:
00038    virtual int exec(CGESTUREptr& g) { return g && g->is_dslash(); }
00039 };
00040 
00041 class TslashGuard : public DrawGuard {
00042  public:
00043    virtual int exec(CGESTUREptr& g) { return g && g->is_tslash(); }
00044 };
00045 
00046 class SlashTapGuard : public DrawGuard {
00047  public:
00048    virtual int exec(CGESTUREptr& g) { return g && g->is_slash_tap(); }
00049 };
00050 
00051 class DoubleTapGuard : public DrawGuard {
00052  public:
00053    virtual int exec(CGESTUREptr& g) { return g && g->is_double_tap(); }
00054 };
00055 
00056 class ZipZapGuard : public DrawGuard {
00057  public:
00058    virtual int exec(CGESTUREptr& g) { return g && g->is_zip_zap(); }
00059 };
00060 
00061 class ArcGuard : public DrawGuard {
00062  public:
00063    virtual int exec(CGESTUREptr& g) { return g && g->is_arc(); }
00064 };
00065 
00066 class SmallArcGuard : public DrawGuard {
00067  public:
00068    virtual int exec(CGESTUREptr& g) { return g && g->is_small_arc(); }
00069 };
00070 
00071 class DotGuard : public DrawGuard {
00072  public:
00073    virtual int exec(CGESTUREptr& g) { return g && g->is_dot(); }
00074 };
00075 
00076 class ScribbleGuard : public DrawGuard {
00077  public:
00078    virtual int exec(CGESTUREptr& g) { return g && g->is_scribble(); }
00079 };
00080 
00081 class LassoGuard : public DrawGuard {
00082  public:
00083    virtual int exec(CGESTUREptr& g) { return g && g->is_lasso(); }
00084 };
00085 
00086 class CircleGuard : public DrawGuard {
00087  public:
00088    CircleGuard(double r=1.25) : _max_ratio(max(1.0, r)) {}
00089    void set_max_ratio(double r) { _max_ratio = max(1.0, r); }
00090 
00091    virtual int exec(CGESTUREptr& g) { return g && g->is_circle(_max_ratio); }
00092 
00093  protected:
00094    double       _max_ratio;
00095 };
00096 
00097 class SmallCircleGuard : public DrawGuard {
00098  public:
00099    SmallCircleGuard(double r=1.25) : _max_ratio(max(1.0, r)) {}
00100    void set_max_ratio(double r) { _max_ratio = max(1.0, r); }
00101 
00102    virtual int exec(CGESTUREptr& g) { return g && g->is_small_circle(_max_ratio); }
00103 
00104  protected:
00105    double       _max_ratio;
00106 };
00107 
00108 class EllipseGuard : public DrawGuard {
00109  public:
00110    virtual int exec(CGESTUREptr& g) { return g && g->is_ellipse(); }
00111 };
00112 
00113 class LineGuard : public DrawGuard {
00114  public:
00115    virtual int exec(CGESTUREptr& g) {
00116       return (g && g->is_line() && !g->is_slash());
00117    }
00118 };
00119 
00120 class XGuard : public DrawGuard {
00121  public:
00122    virtual int exec(CGESTUREptr& g) { return g && g->is_x(); }
00123 };
00124 
00125 class SlashGuard : public DrawGuard {
00126  public:
00127    virtual int exec(CGESTUREptr& g) { return g && g->is_slash(); }
00128 };
00129 
00130 class ClickHoldGuard : public DrawGuard {
00131  public:
00132    virtual int exec(CGESTUREptr& g) { return g && g->is_click_hold(); }
00133 };
00134 
00135 class StrokeGuard : public DrawGuard {
00136  public:
00137    virtual int exec(CGESTUREptr& g) {
00138       return (g && g->is_stroke() && !g->is_slash() && !g->is_tap());
00139    }
00140 };
00141 
00142 #endif  // DRAW_FSA_H_HAS_BEEN_INCLUDED
00143 
00144 // end of file draw_fsa.H

Generated on Mon Sep 18 11:39:30 2006 for jot by  doxygen 1.4.4