X-Git-Url: https://cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fsketcher%2Fsketcher.h;h=443e8e9134abc8f25826566236a713233d7735a9;hb=d66d68b9a5228a2f5894ea39e852df19036af800;hp=d0429cb1ffcd0eb7c97f03ff0e6253e7ef3ca636;hpb=83bfb86d01b353bab485d0ccc336e0572bcb63c6;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/sketcher/sketcher.h b/cinelerra-5.1/plugins/sketcher/sketcher.h index d0429cb1..443e8e91 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcher.h +++ b/cinelerra-5.1/plugins/sketcher/sketcher.h @@ -24,27 +24,39 @@ #define __SKETCHERS_H__ #include "pluginvclient.h" +#include "overlayframe.inc" +#include "vframe.h" class Sketcher; -enum { PT_ID, PT_X, PT_Y, PT_SZ }; -enum { CV_ID, CV_TY, CV_RAD, CV_PEN, CV_CLR, CV_SZ }; -enum { TYP_OFF, TYP_SKETCHER, TYP_SMOOTH, TYP_SZ }; -enum { PEN_SQUARE, PEN_PLUS, PEN_SLANT, PEN_XLANT, PEN_SZ }; +#define pt_type SketcherPoint::types +#define cv_pen SketcherCurve::pens +#define CV_COLOR WHITE + +enum { PT_ID, PT_TY, PT_X, PT_Y, PT_SZ }; +enum { CV_ID, CV_RAD, CV_PEN, CV_CLR, CV_SZ }; +enum { PTY_OFF, PTY_LINE, PTY_CURVE, PTY_FILL, PTY_SZ }; +enum { PEN_OFF, PEN_SQUARE, PEN_PLUS, PEN_SLANT, PEN_XLANT, PEN_SZ }; class SketcherVPen : public VFrame { public: + VFrame *vfrm; + int n; + uint8_t *msk; + SketcherVPen(VFrame *vfrm, int n) : VFrame(vfrm->get_data(), -1, vfrm->get_y()-vfrm->get_data(), vfrm->get_u()-vfrm->get_data(), vfrm->get_v()-vfrm->get_data(), vfrm->get_w(), vfrm->get_h(), vfrm->get_color_model(), vfrm->get_bytes_per_line()) { this->vfrm = vfrm; this->n = n; + int sz = vfrm->get_w()*vfrm->get_h(); + this->msk = (uint8_t*)memset(new uint8_t[sz],0,sz); } + ~SketcherVPen() { delete [] msk; } + virtual int draw_pixel(int x, int y) = 0; - VFrame *vfrm; - int n; }; class SketcherPenSquare : public SketcherVPen @@ -76,11 +88,11 @@ public: class SketcherPoint { public: - int id; + int id, pty; int x, y; - void init(int id, int x, int y); - SketcherPoint(int id, int x, int y); + void init(int id, int pty, int x, int y); + SketcherPoint(int id, int pty, int x, int y); SketcherPoint(int id=-1); SketcherPoint(SketcherPoint &pt); ~SketcherPoint(); @@ -88,6 +100,7 @@ public: void copy_from(SketcherPoint &that); void save_data(FileXML &output); void read_data(FileXML &input); + static const char *types[PTY_SZ]; }; class SketcherPoints : public ArrayList { @@ -97,20 +110,17 @@ public: void dump(); }; -#define cv_type SketcherCurve::types -#define cv_pen SketcherCurve::pens class SketcherCurve { public: - int id, ty, radius, pen, color; - static const char *types[TYP_SZ]; + int id, pen, radius, color; static const char *pens[PEN_SZ]; SketcherPoints points; - void init(int id, int ty, int radius, int pen, int color); - SketcherCurve(int id, int ty, int radius, int pen, int color); + void init(int id, int pen, int radius, int color); + SketcherCurve(int id, int pen, int radius, int color); SketcherCurve(int id=-1); ~SketcherCurve(); SketcherCurve(SketcherCurve &cv); @@ -118,9 +128,10 @@ public: void copy_from(SketcherCurve &that); void save_data(FileXML &output); void read_data(FileXML &input); - VFrame *new_vpen(VFrame *out); - void draw_line(VFrame *out); - void draw_smooth(VFrame *out); + double nearest_point(int &pi, float x, float y); + + SketcherVPen *new_vpen(VFrame *out); + void draw(VFrame *img); }; class SketcherCurves : public ArrayList { @@ -141,7 +152,9 @@ public: void copy_from(SketcherConfig &that); void interpolate(SketcherConfig &prev, SketcherConfig &next, long prev_frame, long next_frame, long current_frame); + double nearest_point(int &ci, int &pi, float x, float y); void limits(); + void dump(); int drag; int cv_selected, pt_selected; @@ -152,21 +165,22 @@ class Sketcher : public PluginVClient public: Sketcher(PluginServer *server); ~Sketcher(); -// required for all realtime plugins PLUGIN_CLASS_MEMBERS2(SketcherConfig) int is_realtime(); void update_gui(); void save_data(KeyFrame *keyframe); void read_data(KeyFrame *keyframe); - int new_curve(int ty, int radius, int pen, int color); + int new_curve(int pen, int radius, int color); int new_curve(); - int new_point(SketcherCurve *cv, int x, int y); - int new_point(); + int new_point(SketcherCurve *cv, int pty, int x, int y, int idx=-1); + int new_point(int idx=-1); int process_realtime(VFrame *input, VFrame *output); static void draw_point(VFrame *vfrm, SketcherPoint *pt, int color, int d); void draw_point(VFrame *vfrm, SketcherPoint *pt, int color); VFrame *input, *output; + VFrame *img, *out; + OverlayFrame *overlay_frame; int w, h, color_model, bpp, comp; int is_yuv, is_float; };