motion51 incr line sz, shortcut tweaks, textbox numeric pad tweaks
authorGood Guy <good1.2guy@gmail.com>
Thu, 13 Sep 2018 22:18:59 +0000 (16:18 -0600)
committerGood Guy <good1.2guy@gmail.com>
Thu, 13 Sep 2018 22:18:59 +0000 (16:18 -0600)
cinelerra-5.1/guicast/bctextbox.C
cinelerra-5.1/guicast/vframe.C
cinelerra-5.1/guicast/vframe.h
cinelerra-5.1/plugins/motion51/motion51.C
cinelerra-5.1/plugins/motion51/motion51.h

index 57a8c5dd31277cfcdaaf708b977c349cf5300500..8de77f4f01d755a50f6404d92b4c485ab526cf0f 100644 (file)
@@ -1128,25 +1128,28 @@ int BC_TextBox::repeat_event(int64_t duration)
 void BC_TextBox::default_keypress(int &dispatch_event, int &result)
 {
        int key = top_level->get_keypress(), len;
-       if( (key == RETURN) || ( key >= 32 && key <= 255 ) ||
-           (key >= KP1 && key <= KP9) || key == KPINS ) {
-               wchar_t *wkeys = top_level->get_wkeystring(&len);
-               switch( key ) {
-               case RETURN: key = '\n';  goto kpchr;
-               case KPINS:  key = '0';   goto kpchr;
-               case KP1: case KP2: case KP3: case KP4: case KP5:
-               case KP6: case KP7: case KP8: case KP9:
-                       key = key - KP1 + '1';
-               kpchr:
-                       wkeys[0] = key;  wkeys[1] = 0;  len = 1;
-                       break;
-               }
-               insert_text(wkeys, len);
-               find_ibeam(1);
-               draw(1);
-               dispatch_event = 1;
-               result = 1;
-       }
+       wchar_t *wkeys = top_level->get_wkeystring(&len);
+       switch( key ) {
+       case KPENTER:   key = '\n';     goto kpchr;
+       case KPMINUS:   key = '-';      goto kpchr;
+       case KPPLUS:    key = '+';      goto kpchr;
+       case KPDEL:     key = '.';      goto kpchr;
+       case RETURN:    key = '\n';     goto kpchr;
+       case KPINS:     key = '0';      goto kpchr;
+       case KP1: case KP2: case KP3: case KP4: case KP5:
+       case KP6: case KP7: case KP8: case KP9:
+               key = key - KP1 + '1';  goto kpchr;
+       default:
+               if( key < 32 || key > 255 ) return;
+       kpchr: {
+               wkeys[0] = key;  wkeys[1] = 0;  len = 1;
+               break; }
+       }
+       insert_text(wkeys, len);
+       find_ibeam(1);
+       draw(1);
+       dispatch_event = 1;
+       result = 1;
 }
 
 int BC_TextBox::keypress_event()
index 041887702435f4028f605bf07ebdfbb1720fb610..3eca676452ca8536fa3f78993e68a24bf35fd9a1 100644 (file)
@@ -279,7 +279,6 @@ int VFrame::reset_parameters(int do_opengl)
        sequence_number = -1;
        timestamp = -1.;
        is_keyframe = 0;
-       draw_point = 0;
        pixel_rgb = 0x000000; // BLACK
        pixel_yuv = 0x008080;
        stipple = 0;
@@ -1360,7 +1359,6 @@ void VFrame::set_stiple(int mask)
 int VFrame::draw_pixel(int x, int y)
 {
        if( x < 0 || y < 0 || x >= get_w() || y >= get_h() ) return 1;
-       if( draw_point ) return (this->*draw_point)(x, y);
 
 #define DRAW_PIXEL(type, r, g, b) { \
        type **rows = (type**)get_rows(); \
index f9a05aefa8f4595d362e7e861af244a0e65f7353..da53bfdda22bdb315613238362c512b1061f2ec6 100644 (file)
@@ -82,7 +82,7 @@ public:
        VFrame(VFrame &vframe);
 // Create new frame for compressed data.
        VFrame();
-       ~VFrame();
+       virtual ~VFrame();
 
 // Return 1 if the colormodel and dimensions are the same
 // Used by FrameCache
@@ -343,12 +343,11 @@ public:
 // This clears the stacks and the param table
        void clear_stacks();
 
-       int (VFrame::*draw_point)(int x, int y);
+       virtual int draw_pixel(int x, int y);
        int pixel_rgb, pixel_yuv, stipple;
 
        void set_pixel_color(int rgb);
        void set_stiple(int mask);
-       int draw_pixel(int x, int y);
        void draw_line(int x1, int y1, int x2, int y2);
        void draw_smooth(int x1, int y1, int x2, int y2, int x3, int y3);
        void smooth_draw(int x1, int y1, int x2, int y2, int x3, int y3);
index 9e4143f45cbe11510fd7077ff50e4deee02d1132..b16cdbc9b60b2bb29316ba7354338e3b6112fbee 100644 (file)
@@ -565,41 +565,64 @@ void Motion51Main::centroid(double *pix[3], double *ctr_v, double *ctr_x, double
        }
 }
 
+Motion51VVFrame::Motion51VVFrame(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->n = n;
+}
+
+int Motion51VVFrame::draw_pixel(int x, int y)
+{
+       VFrame::draw_pixel(x+0, y+0);
+       for( int i=1; i<n; ++i ) {
+               VFrame::draw_pixel(x-i, y+0);
+               VFrame::draw_pixel(x+0, y+i);
+               VFrame::draw_pixel(x+i, y+0);
+               VFrame::draw_pixel(x+0, y-i);
+       }
+       return 0;
+}
 
 void Motion51Main::draw_vectors(VFrame *img)
 {
-       img->draw_arrow(rx, ry, rx+current_dx, ry+current_dy);
+       int iw = img->get_w(), ih = img->get_h();
+       int mx = iw > ih ? iw : ih;
+       Motion51VVFrame vfrm(img, mx/800+1);
 
-//     img->draw_smooth(rx-rr,ry, rx-rr,ry+rr, rx,ry+rr);
-//     img->draw_smooth(rx,ry+rr, rx+rr,ry+rr, rx+rr,ry);
-//     img->draw_smooth(rx+rr,ry, rx+rr,ry-rr, rx,ry-rr);
-//     img->draw_smooth(rx,ry-rr, rx-rr,ry-rr, rx-rr,ry);
+       vfrm.draw_arrow(rx, ry, rx+current_dx, ry+current_dy);
+//     vfrm.draw_smooth(rx-rr,ry, rx-rr,ry+rr, rx,ry+rr);
+//     vfrm.draw_smooth(rx,ry+rr, rx+rr,ry+rr, rx+rr,ry);
+//     vfrm.draw_smooth(rx+rr,ry, rx+rr,ry-rr, rx,ry-rr);
+//     vfrm.draw_smooth(rx,ry-rr, rx-rr,ry-rr, rx-rr,ry);
 
        float rx1 = rx - 0.5*rw;
        float ry1 = ry - 0.5*rh;
        float rx2 = rx1 + rw;
        float ry2 = ry1 + rh;
 
-       img->draw_line(rx1, ry1, rx2, ry1);
-       img->draw_line(rx2, ry1, rx2, ry2);
-       img->draw_line(rx2, ry2, rx1, ry2);
-       img->draw_line(rx1, ry2, rx1, ry1);
+       vfrm.draw_line(rx1, ry1, rx2, ry1);
+       vfrm.draw_line(rx2, ry1, rx2, ry2);
+       vfrm.draw_line(rx2, ry2, rx1, ry2);
+       vfrm.draw_line(rx1, ry2, rx1, ry1);
 
        float sx1 = rx1 - rr, sy1 = ry1 - rr;
        float sx2 = rx2 + rr, sy2 = ry2 + rr;
 
-       img->draw_smooth(sx1, ry1, sx1, sy1, rx1, sy1);
-       img->draw_line(rx1, sy1, rx2, sy1);
-       img->draw_smooth(rx2, sy1, sx2, sy1, sx2, ry1);
-       img->draw_line(sx2, ry1, sx2, ry2);
-       img->draw_smooth(sx2, ry2, sx2, sy2, rx2, sy2);
-       img->draw_line(rx2, sy2, rx1, sy2);
-       img->draw_smooth(rx1, sy2, sx1, sy2, sx1, ry2);
-       img->draw_line(sx1, ry2, sx1, ry1);
+       vfrm.draw_smooth(sx1, ry1, sx1, sy1, rx1, sy1);
+       vfrm.draw_line(rx1, sy1, rx2, sy1);
+       vfrm.draw_smooth(rx2, sy1, sx2, sy1, sx2, ry1);
+       vfrm.draw_line(sx2, ry1, sx2, ry2);
+       vfrm.draw_smooth(sx2, ry2, sx2, sy2, rx2, sy2);
+       vfrm.draw_line(rx2, sy2, rx1, sy2);
+       vfrm.draw_smooth(rx1, sy2, sx1, sy2, sx1, ry2);
+       vfrm.draw_line(sx1, ry2, sx1, ry1);
 
        double *xp = xpts, *yp = ypts;
        for( int i=cir_sz; --i>=0; ++xp, ++yp )
-               img->draw_pixel(rx+*xp, ry+*yp);
+               vfrm.draw_pixel(rx+*xp, ry+*yp);
 }
 
 int Motion51Main::open_cache_file()
index bb93ef1502ff7925cc72322b3b410811a9aeaed6..afd8bbade3d4483ec8ca0751179e8c9e70a54d8a 100644 (file)
@@ -42,6 +42,7 @@ class Motion51Main;
 class Motion51ScanUnit;
 class Motion51ScanPackage;
 class Motion51Scan;
+class Motion51VVFrame;
 
 class Motion51Config
 {
@@ -178,4 +179,12 @@ public:
        double compare(double cx, double cy, double ct);
 };
 
+class Motion51VVFrame : public VFrame
+{
+public:
+       Motion51VVFrame(VFrame *vfrm, int n);
+       int draw_pixel(int x, int y);
+       int n;
+};
+
 #endif