00001
00012 #ifndef STROKE_H
00013 #define STROKE_H
00014
00015 #include <basic.h>
00016 #include <vector>
00017 #include <btron/dp.h>
00018 #include <tad.h>
00019 #include <btron/taddata.h>
00020 #include <limits.h>
00021
00023
00026 class AbstractStroke {
00027
00028 protected:
00029
00031 std::vector<PNT> poly;
00032
00034 static const int sz_header = 1;
00035
00037 AbstractStroke() {
00038 PNT p;
00039 reinterpret_cast<POLY*>(&p)->round = 0;
00040 reinterpret_cast<POLY*>(&p)->size = 0;
00041 poly.push_back(p);
00042 }
00043
00044 public:
00045
00047
00050 virtual void clear() = 0;
00051
00053
00057 const POLY* getPoly() const {
00058 return reinterpret_cast<const POLY*>(&(poly[0]));
00059 }
00060
00062
00066 PNT getPoint(int index) const {
00067 return poly.at(index + sz_header);
00068 }
00069
00071
00075 int getSize() const {
00076 return poly.size() - sz_header;
00077 }
00078
00080
00084 void addPoint(const PNT& p);
00085
00087
00092 void moveOffset(int dh, int dv);
00093
00094 };
00095
00096
00098
00101 class DrawingStroke : public AbstractStroke {
00102
00103 static int lwidth;
00104 static LATTR lattr;
00105 static PAT pat;
00106 static DCM dcm;
00107
00108 public:
00109
00111 DrawingStroke() : AbstractStroke() {}
00112
00114
00118 DrawingStroke(const TF_SPLINE *p) : AbstractStroke() {
00119 for (int i = 0; i < p->np; i++){
00120 addPoint(p->pt[i]);
00121 }
00122 }
00123
00125
00130 W draw(W gid) const;
00131
00133
00138 W drawLatest(W gid) const {
00139 int sz = getSize();
00140 if (sz >= 2){
00141 return gdra_lin(gid, getPoint(sz-2), getPoint(sz-1), lattr, &pat, dcm);
00142 }
00143 return 0;
00144 }
00145
00146 virtual void clear();
00147
00148 };
00149
00150 #endif // STROKE_H