add wheel/gradical to vectorscope, tweak boxblur layout, chromakey booby fix
authorGood Guy <[email protected]>
Mon, 13 Apr 2020 03:13:21 +0000 (21:13 -0600)
committerGood Guy <[email protected]>
Mon, 13 Apr 2020 03:13:21 +0000 (21:13 -0600)
cinelerra-5.1/cinelerra/scopewindow.C
cinelerra-5.1/cinelerra/scopewindow.h
cinelerra-5.1/cinelerra/scopewindow.inc
cinelerra-5.1/guicast/test6.C [new file with mode: 0644]
cinelerra-5.1/plugins/Makefile
cinelerra-5.1/plugins/boxblur/boxblur.C
cinelerra-5.1/plugins/chromakey/chromakey.C
cinelerra-5.1/plugins/scopes/grad.png [new file with mode: 0644]

index b02206ab89d465467ac163e8dbe512a4b193f794..2b21ff0d34df071e5ee4c3e0d7eec6c5dcf65d35 100644 (file)
@@ -23,6 +23,8 @@
 #include "boxblur.h"
 #include "clip.h"
 #include "cursors.h"
+#include "file.h"
+#include "filesystem.h"
 #include "language.h"
 #include "scopewindow.h"
 #include "theme.h"
@@ -54,6 +56,13 @@ if(iy >= 0 && iy < h) { \
   v = *vp+(gv);  *vp++ = v>0xff ? 0xff : v; \
   v = *vp+(bv);  *vp = v>0xff ? 0xff : v; } \
 }
+#define decr_points(rows,h, rv,gv,bv) { \
+if(iy >= 0 && iy < h) { \
+  uint8_t *vp = rows[iy] + ix*3; \
+  int v = *vp-(rv);  *vp++ = v<0 ? 0 : v; \
+  v = *vp-(gv);  *vp++ = v<0 ? 0 : v; \
+  v = *vp-(bv);  *vp = v<0 ? 0 : v; } \
+}
 #define clip_points(rows,h, rv,gv,bv) { \
 if(iy >= 0 && iy < h) { \
   uint8_t *vp = rows[iy] + ix*3; \
@@ -120,23 +129,26 @@ if(iy >= 0 && iy < h) { \
                } \
        } \
 /* Calculate vectorscope */ \
-       if(use_vector) { \
-               float th = 90 - h; \
-               if( th < 0 ) th += 360; \
-               double t = TO_RAD(th); \
-               float adjacent = -cos(t), opposite = sin(t); \
-               int ix = vector_w / 2 + adjacent * (s) / (FLOAT_MAX) * radius; \
-               int iy = vector_h / 2 - opposite * (s) / (FLOAT_MAX) * radius; \
+       if(use_vector > 0) { \
+               double t = TO_RAD(-h); \
+               float adjacent = sin(t), opposite = cos(t); \
+               int ix = vector_cx + adjacent * (s) / (FLOAT_MAX) * radius; \
+               int iy = vector_cy - opposite * (s) / (FLOAT_MAX) * radius; \
                CLAMP(ix, 0, vector_w - 1); \
-       /* Get color with full saturation & value */ \
-               float r_f, g_f, b_f; \
-               if( (h=h-90) < 0 ) h += 360; \
-               HSV::hsv_to_rgb(r_f, g_f, b_f, h, s, 1); \
-               int rv = CLIP(r_f, 0, 1) * vinc + 3; \
-               int gv = CLIP(g_f, 0, 1) * vinc + 3; \
-               int bv = CLIP(b_f, 0, 1) * vinc + 3; \
+               HSV::hsv_to_rgb(r, g, b, h, s, vincf); \
+               int rv = r + 3; \
+               int gv = g + 3; \
+               int bv = b + 3; \
                incr_points(vector_rows,vector_h, rv,gv,bv); \
        } \
+       else if(use_vector < 0) { \
+               double t = TO_RAD(-h); \
+               float adjacent = sin(t), opposite = cos(t); \
+               int ix = vector_cx + adjacent * (s) / (FLOAT_MAX) * radius; \
+               int iy = vector_cy - opposite * (s) / (FLOAT_MAX) * radius; \
+               CLAMP(ix, 0, vector_w - 1); \
+               decr_points(vector_rows,vector_h, vinc,vinc,vinc); \
+       } \
 }
 
 #define PROCESS_RGB_PIXEL(type,max, column) { \
@@ -178,6 +190,9 @@ void ScopeUnit::process_package(LoadPackage *package)
        int use_vector = gui->use_vector;
        int use_wave = gui->use_wave;
        int use_wave_parade = gui->use_wave_parade;
+       int vector_cx = gui->vector_cx;
+       int vector_cy = gui->vector_cy;
+       int radius = gui->radius;
        VFrame *waveform_vframe = gui->waveform_vframe;
        VFrame *vector_vframe = gui->vector_vframe;
        int wave_h = waveform_vframe->get_h();
@@ -188,10 +203,10 @@ void ScopeUnit::process_package(LoadPackage *package)
        int dat_h = gui->data_frame->get_h();
        int winc = (wave_w * wave_h) / (dat_w * dat_h);
        if( use_wave_parade ) winc *= 3;
-       winc += 2;  winc *= gui->use_wave_gain;
-       int vinc = 3*(vector_w * vector_h) / (dat_w * dat_h) + 2;
-       vinc *= gui->use_vect_gain;
-       float radius = MIN(gui->vector_w / 2, gui->vector_h / 2);
+       winc += 2;  winc = (winc << gui->use_wave_gain) / 4;
+       int vinc = 3*(vector_w * vector_h) / (dat_w * dat_h);
+       vinc += 2;  vinc = (vinc << gui->use_vect_gain) / 4;
+       float vincf = vinc;
        uint8_t **waveform_rows = waveform_vframe->get_rows();
        uint8_t **vector_rows = vector_vframe->get_rows();
        uint8_t **rows = gui->data_frame->get_rows();
@@ -387,7 +402,6 @@ ScopeGUI::ScopeGUI(Theme *theme,
        this->y = y;
        this->w = w;
        this->h = h;
-       this->temp_frame = 0;
        this->theme = theme;
        this->cpus = cpus;
        reset();
@@ -400,11 +414,8 @@ ScopeGUI::ScopeGUI(PluginClient *plugin, int w, int h)
        this->y = get_y();
        this->w = w;
        this->h = h;
-       this->temp_frame = 0;
        this->theme = plugin->get_theme();
        this->cpus = plugin->PluginClient::smp + 1;
-       wave_slider = 0;
-       vect_slider = 0;
        reset();
 }
 
@@ -412,25 +423,38 @@ ScopeGUI::~ScopeGUI()
 {
        delete waveform_vframe;
        delete vector_vframe;
+       delete wheel_vframe;
        delete engine;
        delete box_blur;
        delete temp_frame;
        delete wave_slider;
        delete vect_slider;
+       delete grad_image;
+       delete grad_pixmap;
 }
 
 void ScopeGUI::reset()
 {
+       waveform_vframe = 0;
+       vector_vframe = 0;
+       wheel_vframe = 0;
+       engine = 0;
+       box_blur = 0;
+       temp_frame = 0;
+       wave_slider = 0;
+       vect_slider = 0;
+       grad_image = 0;
+       grad_pixmap = 0;
+       vector_gradical = 0;
+       grad_idx = 0;
+       vect_grads = 0;
+
        output_frame = 0;
        data_frame = 0;
        frame_w = 1;
        use_smooth = 1;
        use_wave_gain = 5;
        use_vect_gain = 5;
-       waveform_vframe = 0;
-       vector_vframe = 0;
-       engine = 0;
-       box_blur = 0;
        use_hist = 0;
        use_wave = 1;
        use_vector = 1;
@@ -441,9 +465,15 @@ void ScopeGUI::reset()
        histogram = 0;
        wave_w = wave_h = 0;
        vector_w = vector_h = 0;
+       vector_cx = vector_cy = 0;
+       radius = 0;
+       text_color = GREEN;
+       dark_color = (text_color>>2) & 0x3f3f3f;
+       BC_Resources *resources = BC_WindowBase::get_resources();
+       if( resources->bg_color == 0xffffff )
+               text_color = dark_color;
 }
 
-
 void ScopeGUI::create_objects()
 {
        if( use_hist && use_hist_parade )
@@ -505,17 +535,31 @@ void ScopeGUI::create_panels()
                        vectorscope->create_objects();
                        vect_slider = new ScopeVectSlider(this, vx, vy, slider_w);
                        vect_slider->create_objects();
+                       if( use_vector < 0 ) {
+                               add_subwindow(vect_grads = new ScopeVectGrads(this, vector_x, vy));
+                               vect_grads->create_objects();
+                       }
                }
                else {
                        vectorscope->reposition_window(
                                vector_x, vector_y, vector_w, vector_h);
                        vectorscope->clear_box(0, 0, vector_w, vector_h);
                        vect_slider->reposition_window(vx, vy);
+                       if( use_vector > 0 ) {
+                               delete vect_grads;  vect_grads = 0;
+                       }
+                       else if( !vect_grads ) {
+                               add_subwindow(vect_grads = new ScopeVectGrads(this, vector_x, vy));
+                               vect_grads->create_objects();
+                       }
+                       else
+                               vect_grads->reposition_window(vector_x, vy);
                }
        }
        else if( !use_vector && vectorscope ) {
                delete vectorscope;  vectorscope = 0;
                delete vect_slider;  vect_slider = 0;
+               delete vect_grads;   vect_grads = 0;
        }
 
        if( (use_hist || use_hist_parade) ) {
@@ -589,6 +633,9 @@ void ScopeGUI::calculate_sizes(int w, int h)
                if(total_panels > 0)
                        panel_w = (vector_x - text_w - margin) / total_panels;
        }
+       vector_cx = vector_w / 2;
+       vector_cy = vector_h / 2;
+       radius = bmin(vector_cx, vector_cy);
 
 // Histogram is always 1st panel
        if( use_hist || use_hist_parade ) {
@@ -615,6 +662,7 @@ void ScopeGUI::allocate_vframes()
 {
        if(waveform_vframe) delete waveform_vframe;
        if(vector_vframe) delete vector_vframe;
+       if(wheel_vframe) delete wheel_vframe;
 
        int w, h;
 //printf("ScopeGUI::allocate_vframes %d %d %d %d %d\n", __LINE__,
@@ -626,6 +674,7 @@ void ScopeGUI::allocate_vframes()
        w = MAX(vector_w, xs16);
        h = MAX(vector_h, ys16);
        vector_vframe = new VFrame(w, h, BC_RGB888);
+       wheel_vframe = 0;
 }
 
 
@@ -656,6 +705,8 @@ int ScopeGUI::resize_event(int w, int h)
                int vx = vector_x + vector_w - vect_slider->get_w() - margin;
                int vy = vector_y - vect_slider->get_h() - margin;
                vect_slider->reposition_window(vx, vy);
+               if( vect_grads )
+                       vect_grads->reposition_window(vector_x, vy);
        }
 
        allocate_vframes();
@@ -676,13 +727,6 @@ int ScopeGUI::translation_event()
 
 void ScopeGUI::draw_overlays(int overlays, int borders, int flush)
 {
-       BC_Resources *resources = BC_WindowBase::get_resources();
-       int text_color = GREEN;
-       int dark_color = (text_color>>2) & 0x3f3f3f;
-       if( resources->bg_color == 0xffffff ) {
-               text_color = dark_color;
-       }
-
        if( overlays && borders ) {
                clear_box(0, 0, get_w(), get_h());
        }
@@ -727,29 +771,11 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush)
                }
 // Vectorscope overlay
                if( vectorscope && use_vector ) {
-                       set_line_dashes(1);
-                       int radius = MIN(vector_w / 2, vector_h / 2);
-                       for( int i=1; i<=VECTORSCOPE_DIVISIONS; i+=2 ) {
-                               int y = vector_h / 2 - radius * i / VECTORSCOPE_DIVISIONS;
-                               int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2;
-                               set_color(text_color);
-                               char string[BCTEXTLEN];
-                               sprintf(string, "%d",
-                                       (int)((FLOAT_MAX / VECTORSCOPE_DIVISIONS * i) * 100));
-                               int text_x = vector_x - get_text_width(SMALLFONT, string) - theme->widget_border;
-                               draw_text(text_x, text_y, string);
-                               int x = vector_w / 2 - radius * i / VECTORSCOPE_DIVISIONS;
-                               int w = radius * i / VECTORSCOPE_DIVISIONS * 2;
-                               int h = radius * i / VECTORSCOPE_DIVISIONS * 2;
-                               if( i+2 > VECTORSCOPE_DIVISIONS )
-                                       set_line_dashes(0);
-                               set_color(dark_color);
-                               vectorscope->draw_circle(x, y, w, h);
-                       }
+                       draw_gradical();
                        set_color(text_color);
                        vectorscope->draw_point();
-                       set_line_dashes(1);
                        vectorscope->flash(0);
+                       set_line_dashes(1);
                }
 
                set_font(MEDIUMFONT);
@@ -775,6 +801,95 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush)
        if(flush) this->flush();
 }
 
+void ScopeGUI::draw_gradical()
+{
+       if( use_vector > 0 ) {
+               int margin = theme->widget_border;
+               set_line_dashes(1);
+               for( int i=1; i<=VECTORSCOPE_DIVISIONS; i+=2 ) {
+                       int y = vector_cy - radius * i / VECTORSCOPE_DIVISIONS;
+                       int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2;
+                       set_color(text_color);
+                       char string[BCTEXTLEN];
+                       sprintf(string, "%d",
+                               (int)((FLOAT_MAX / VECTORSCOPE_DIVISIONS * i) * 100));
+                       int text_x = vector_x - get_text_width(SMALLFONT, string) - margin;
+                       draw_text(text_x, text_y, string);
+                       int x = vector_cx - radius * i / VECTORSCOPE_DIVISIONS;
+                       int w = radius * i / VECTORSCOPE_DIVISIONS * 2;
+                       int h = radius * i / VECTORSCOPE_DIVISIONS * 2;
+                       if( i+2 > VECTORSCOPE_DIVISIONS )
+                               set_line_dashes(0);
+                       set_color(dark_color);
+                       vectorscope->draw_circle(x, y, w, h);
+               }
+               float th = TO_RAD(90 + 32.875);
+               vectorscope->draw_radient(th, 0.1f, .75f, dark_color);
+       }
+       else if( use_vector < 0 ) {
+               if( grad_image && grad_idx != vector_gradical ) {
+                       delete grad_image;   grad_image = 0;
+                       vector_gradical = 0;
+               }
+               if( !grad_image && grad_idx > 0 ) {
+                       grad_image = VFramePng::vframe_png(grad_paths[grad_idx]);
+               }
+               int rr = 2*radius;
+               if( grad_pixmap && (!vector_gradical ||
+                     rr != grad_pixmap->get_w() || rr != grad_pixmap->get_h()) ) {
+                       delete grad_pixmap;  grad_pixmap = 0;
+                       vector_gradical = 0;
+               }
+               if( !grad_pixmap && grad_image ) {
+                       VFrame grad(rr, rr, BC_RGBA8888);
+                       grad.transfer_from(grad_image);
+                       grad_pixmap = new BC_Pixmap(this, &grad, PIXMAP_ALPHA);
+                       vector_gradical = grad_idx;
+               }
+               if( grad_pixmap ) {
+                       int px = vector_cx - radius, py = vector_cy - radius;
+                       vectorscope->draw_pixmap(grad_pixmap, px, py);
+//                     vectorscope->flash(0);
+               }
+       }
+}
+
+
+void ScopeGUI::update_gradical(int idx)
+{
+       grad_idx = idx;
+       update_scope();
+}
+
+void ScopeGUI::draw_colorwheel(VFrame *dst, int bg_color)
+{
+       float cx = vector_cx, cy = vector_cy, rad = radius;
+        int color_model = dst->get_color_model();
+        int bpp = BC_CModels::calculate_pixelsize(color_model);
+       int bg_r = (bg_color>>16) & 0xff;
+       int bg_g = (bg_color>> 8) & 0xff;
+       int bg_b = (bg_color>> 0) & 0xff;
+       int w = dst->get_w(), h = dst->get_h();
+       unsigned char **rows = dst->get_rows();
+       for( int y=0; y<h; ++y ) {
+               unsigned char *row = rows[y];
+               for( int x=0; x<w; ++x,row+=bpp ) {
+                       int dx = cx-x, dy = cy-y;
+                       float d = sqrt(dx*dx + dy*dy);
+                       float r, g, b;
+                       if( d < rad ) {
+                               float h = TO_DEG(atan2(cx-x, cy-y));
+                               if( h < 0 ) h += 360;
+                               float s = d / rad, v = 255;
+                               HSV::hsv_to_rgb(r, g, b, h, s, v);
+                       }
+                       else {
+                                r = bg_r; g = bg_g; b = bg_b;
+                       }
+                       row[0] = r; row[1] = g; row[2] = b;
+               }
+       }
+}
 
 
 void ScopeGUI::process(VFrame *output_frame)
@@ -792,9 +907,21 @@ void ScopeGUI::process(VFrame *output_frame)
        else
                data_frame = output_frame;
        frame_w = data_frame->get_w();
-       //float radius = MIN(vector_w / 2, vector_h / 2);
        bzero(waveform_vframe->get_data(), waveform_vframe->get_data_size());
-       bzero(vector_vframe->get_data(), vector_vframe->get_data_size());
+       if( use_vector > 0 )
+               bzero(vector_vframe->get_data(), vector_vframe->get_data_size());
+       else if( use_vector < 0 ) {
+               if( wheel_vframe && (
+                    wheel_vframe->get_w() != vector_w ||
+                    wheel_vframe->get_h() != vector_h ) ) {
+                       delete wheel_vframe;  wheel_vframe = 0;
+               }
+               if( !wheel_vframe ) {
+                       wheel_vframe = new VFrame(vector_w, vector_h, BC_RGB888);
+                       draw_colorwheel(wheel_vframe, BLACK);
+               }
+               vector_vframe->copy_from(wheel_vframe);
+       }
        engine->process();
 
        if( histogram )
@@ -951,15 +1078,12 @@ void ScopeVectorscope::update_point(int x, int y)
 {
 // Hide it
        draw_point();
-
-       int radius = MIN(get_w() / 2, get_h() / 2);
-       drag_radius = sqrt(SQR(x - get_w() / 2) + SQR(y - get_h() / 2));
-       drag_angle = atan2(y - get_h() / 2, x - get_w() / 2);
-
-       drag_radius = MIN(drag_radius, radius);
-
-       float saturation = (float)drag_radius / radius * FLOAT_MAX;
-       float hue = -drag_angle * 360 / 2 / M_PI - 90;
+       int dx = x - gui->vector_cx, dy = y - gui->vector_cy;
+       drag_radius = sqrt(dx*dx + dy*dy);
+       if( drag_radius > gui->radius ) drag_radius = gui->radius;
+       float saturation = (float)drag_radius / gui->radius * FLOAT_MAX;
+       drag_angle = atan2(-dy, dx);
+       float hue = TO_DEG(drag_angle) - 90;
        if( hue < 0 ) hue += 360;
 
        char string[BCTEXTLEN];
@@ -973,21 +1097,36 @@ void ScopeVectorscope::update_point(int x, int y)
 
 void ScopeVectorscope::draw_point()
 {
-       if( drag_radius > 0 ) {
-               int radius = MIN(get_w() / 2, get_h() / 2);
-               set_inverse();
-               set_color(0xff0000);
+       set_inverse();
+       draw_point(drag_angle, drag_radius, RED);
+       set_opaque();
+}
+
+void ScopeVectorscope::draw_point(float th, float r, int color)
+{
+       if( r > 0 ) {
+               set_color(color);
                set_line_width(2);
-               draw_circle(get_w() / 2 - drag_radius, get_h() / 2 - drag_radius,
-                       drag_radius * 2, drag_radius * 2);
-               draw_line(get_w() / 2, get_h() / 2,
-                       get_w() / 2 + radius * cos(drag_angle),
-                       get_h() / 2 + radius * sin(drag_angle));
+               int cx = gui->vector_cx, cy = gui->vector_cy;
+               draw_circle(cx-r, cy-r, r*2, r*2);
                set_line_width(1);
-               set_opaque();
+               float radius = gui->radius;
+               draw_radient(th, 0.f, drag_radius/radius, color);
        }
 }
 
+void ScopeVectorscope::draw_radient(float th, float r1, float r2, int color)
+{
+       if( r2 > 0 && r2 >= r1 ) {
+               set_color(color);
+               set_line_width(2);
+               int r = gui->radius;
+               double cth = r*cos(th), sth = -r*sin(th);
+               int cx = gui->vector_cx, cy = gui->vector_cy;
+               draw_line(cx+r1*cth, cy+r1*sth, cx+r2*cth, cy+r2*sth);
+               set_line_width(1);
+       }
+}
 
 
 ScopeHistogram::ScopeHistogram(ScopeGUI *gui,
@@ -1108,6 +1247,9 @@ int ScopeScopesOn::handle_event()
        case SCOPE_VECTORSCOPE:
                gui->use_vector = v;
                break;
+       case SCOPE_VECTORWHEEL:
+               gui->use_vector = -v;
+               break;
        }
        gui->toggle_event();
        gui->update_toggles();
@@ -1139,6 +1281,8 @@ void ScopeMenu::create_objects()
        add_item(new BC_MenuItem("-"));
        add_item(vect_on =
                new ScopeScopesOn(this, _("Vectorscope"), SCOPE_VECTORSCOPE));
+       add_item(vect_wheel =
+               new ScopeScopesOn(this, _("VectorWheel"), SCOPE_VECTORWHEEL));
 }
 
 void ScopeMenu::update_toggles()
@@ -1148,7 +1292,57 @@ void ScopeMenu::update_toggles()
        wave_on->set_checked(gui->use_wave);
        wave_rgb_on->set_checked(gui->use_wave_parade>0);
        wave_ply_on->set_checked(gui->use_wave_parade<0);
-       vect_on->set_checked(gui->use_vector);
+       vect_on->set_checked(gui->use_vector>0);
+       vect_wheel->set_checked(gui->use_vector<0);
+}
+
+
+ScopeVectGrads::ScopeVectGrads(ScopeGUI *gui, int x, int y)
+ : BC_PopupMenu(x, y, xS(40), "", 1, 0, 0)
+{
+       this->gui = gui;
+}
+
+#define SCOPE_SEARCHPATH "/scopes"
+void ScopeVectGrads::create_objects()
+{
+       gui->grad_paths.remove_all_objects();
+       ScopeGradItem *item;
+       add_item(item = new ScopeGradItem(this, _("none"), 0));
+       if( item->idx == gui->vector_gradical ) item->set_checked(1);
+       gui->grad_paths.append(0);
+       FileSystem fs;
+       fs.set_filter("[*.png][*.jpg]");
+       char scope_path[BCTEXTLEN];
+       sprintf(scope_path, "%s%s", File::get_plugin_path(), SCOPE_SEARCHPATH);
+       fs.update(scope_path);
+       for( int i=0; i<fs.total_files(); ++i ) {
+               FileItem *file_item = fs.get_entry(i);
+               if( file_item->get_is_dir() ) continue;
+               strcpy(scope_path, file_item->get_name());
+               char *cp = strrchr(scope_path, '.');
+               if( cp ) *cp = 0;
+               add_item(item = new ScopeGradItem(this, scope_path, gui->grad_paths.size()));
+               if( item->idx == gui->vector_gradical ) item->set_checked(1);
+               gui->grad_paths.append(cstrdup(file_item->get_path()));
+       }
+}
+
+ScopeGradItem::ScopeGradItem(ScopeVectGrads *vect_grads, const char *text, int idx)
+ : BC_MenuItem(text)
+{
+       this->vect_grads = vect_grads;
+       this->idx = idx;
+}
+
+int ScopeGradItem::handle_event()
+{
+       for( int i=0,n=vect_grads->total_items(); i<n; ++i ) {
+               ScopeGradItem *item = (ScopeGradItem *)vect_grads->get_item(i);
+               item->set_checked(item == this);
+       }       
+       vect_grads->gui->update_gradical(idx);
+       return 1;
 }
 
 
index 86f9efa91155147d2c94fc6988057ace0dd9d21a..44b2f8fd80503b803480384d3cc7ceb014a15638 100644 (file)
@@ -34,7 +34,7 @@
 enum {
        SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
        SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
-       SCOPE_VECTORSCOPE,
+       SCOPE_VECTORSCOPE, SCOPE_VECTORWHEEL,
 };
 
 // Number of divisions in histogram.
@@ -119,6 +119,9 @@ public:
        virtual void update_point(int x, int y);
        virtual void draw_point();
        virtual void clear_point();
+       void draw_point(float th, float r, int color);
+       void draw_radient(float th, float r1, float r2, int color);
+
        int drag_radius;
        float drag_angle;
 };
@@ -160,6 +163,34 @@ public:
        ScopeScopesOn *wave_rgb_on;
        ScopeScopesOn *wave_ply_on;
        ScopeScopesOn *vect_on;
+       ScopeScopesOn *vect_wheel;
+};
+
+
+class ScopeGradPaths : public ArrayList<const char *>
+{
+public:
+       ScopeGradPaths() { set_array_delete(); }
+       ~ScopeGradPaths() { remove_all_objects(); }
+};
+
+class ScopeGradItem : public BC_MenuItem
+{
+public:
+       ScopeGradItem(ScopeVectGrads *vect_grads, const char *text, int idx);
+       int handle_event();
+
+       ScopeVectGrads *vect_grads;
+       int idx;
+};
+
+class ScopeVectGrads : public BC_PopupMenu
+{
+public:
+       ScopeVectGrads(ScopeGUI *gui, int x, int y);
+       void create_objects();
+
+       ScopeGUI *gui;
 };
 
 
@@ -248,6 +279,9 @@ public:
        void calculate_sizes(int w, int h);
        void allocate_vframes();
        void draw_overlays(int overlays, int borders, int flush);
+       void update_gradical(int idx);
+       void draw_colorwheel(VFrame *dst, int bg_color);
+       void draw_gradical();
        void process(VFrame *output_frame);
        void draw(int flash, int flush);
        void clear_points(int flash);
@@ -259,19 +293,28 @@ public:
        BoxBlur *box_blur;
        VFrame *waveform_vframe;
        VFrame *vector_vframe;
+       VFrame *wheel_vframe;
        ScopeHistogram *histogram;
        ScopeWaveform *waveform;
        ScopeVectorscope *vectorscope;
        ScopeMenu *scope_menu;
        ScopeWaveSlider *wave_slider;
        ScopeVectSlider *vect_slider;
+       ScopeVectGrads *vect_grads;
        ScopeSmooth *smooth;
        BC_Title *value_text;
+       VFrame *grad_image;
+       BC_Pixmap *grad_pixmap;
 
        int x, y, w, h;
        int vector_x, vector_y, vector_w, vector_h;
+       int vector_cx, vector_cy, radius;
        int wave_x, wave_y, wave_w, wave_h;
        int hist_x, hist_y, hist_w, hist_h;
+       int text_color, dark_color;
+
+       ScopeGradPaths grad_paths;
+       int grad_idx, vector_gradical;
 
        int cpus;
        int use_hist, use_wave, use_vector;
index a59475a12357a1bcfa893abc4fa847b888ff07bf..931685070da4b2031fd9f869dd0ced6ae1416e24 100644 (file)
@@ -10,6 +10,9 @@ class ScopeVectorscope;
 class ScopeHistogram;
 class ScopeScopesOn;
 class ScopeMenu;
+class ScopeGradPaths;
+class ScopeGradItem;
+class ScopeVectGrads;
 class ScopeGainReset;
 class ScopeGainSlider;
 class ScopeGain;
diff --git a/cinelerra-5.1/guicast/test6.C b/cinelerra-5.1/guicast/test6.C
new file mode 100644 (file)
index 0000000..4ac6bae
--- /dev/null
@@ -0,0 +1,123 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <math.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "bcwindowbase.h"
+#include "bcwindow.h"
+#include "bcsignals.h"
+#include "bccolors.h"
+#include "clip.h"
+#include "fonts.h"
+#include "thread.h"
+#include "vframe.h"
+
+/*c++ -g -I/mnt1/build5/cinelerra-5.1/guicast x.C \
+  /mnt1/build5/cinelerra-5.1/guicast/x86_64/libguicast.a \
+  -DHAVE_GL -DHAVE_XFT -I/usr/include/freetype2 -lGL -lX11 -lXext \
+  -lXinerama -lXv -lpng  -lfontconfig -lfreetype -lXft -pthread */
+
+void wheel(VFrame *dst, float cx, float cy, float rad, int bg_color)
+{
+        int color_model = dst->get_color_model();
+        int bpp = BC_CModels::calculate_pixelsize(color_model);
+       int bg_r = (bg_color>>16) & 0xff;
+       int bg_g = (bg_color>> 8) & 0xff;
+       int bg_b = (bg_color>> 0) & 0xff;
+       int w = dst->get_w(), h = dst->get_h();
+       unsigned char **rows = dst->get_rows();
+       for( int y=0; y<h; ++y ) {
+               unsigned char *row = rows[y];
+               for( int x=0; x<w; ++x,row+=bpp ) {
+                       int dx = cx-x, dy = cy-y;
+                       float d = sqrt(dx*dx + dy*dy);
+                       float r, g, b;
+                       if( d < rad ) {
+                               float h = TO_DEG(atan2(cx-x, cy-y));
+                               if( h < 0 ) h += 360;
+                               float s = d / rad, v = 255;
+                               HSV::hsv_to_rgb(r, g, b, h, s, v);
+                       }
+                       else {
+                                r = bg_r; g = bg_g; b = bg_b;
+                       }
+                       row[0] = r; row[1] = g; row[2] = b;
+               }
+       }
+}
+
+class TestWindowGUI : public BC_Window
+{
+public:
+       VFrame *wfrm;
+       int bg;
+
+       TestWindowGUI(int x, int y, int w, int h);
+       ~TestWindowGUI();
+
+       void draw(int ww, int wh) {
+               delete wfrm;
+               wfrm = new VFrame(ww,wh,BC_RGB888);
+               float wr = bmin(ww, wh)/2.25;
+               int bg = get_bg_color();
+               wheel(wfrm, ww/2,wh/2, wr, bg);
+               draw_vframe(wfrm);
+               flash();
+       }
+       int resize_event(int w, int h) {
+               BC_WindowBase::resize_event(w, h);
+               draw(w, h);
+               return 0;
+       }
+};
+
+TestWindowGUI::
+TestWindowGUI(int x, int y, int w, int h)
+ : BC_Window("test", x,y, w,h, 100,100)
+{
+       wfrm = 0;
+       set_bg_color(0x885533);
+       lock_window("init");
+       clear_box(0,0,w,h);
+       flash();
+       unlock_window();
+}
+
+TestWindowGUI::
+~TestWindowGUI()
+{
+}
+
+
+class TestWindow : public Thread
+{
+       TestWindowGUI *gui;
+public:
+       TestWindow(int x, int y, int w, int h)
+        : Thread(1,0,0) {
+               gui = new TestWindowGUI(x,y, w,h);
+               gui->lock_window("init");
+               gui->resize_event(w, h);
+               gui->unlock_window();
+               start();
+       }
+       ~TestWindow() { delete gui; }
+       void run() { gui->run_window(); }
+       void close_window() { gui->close(0); }
+};
+
+
+int main(int ac, char **av)
+{
+       BC_Signals signals;
+       signals.initialize();
+       BC_WindowBase::init_resources(1.);
+       TestWindow test_window(100, 100, 256, 256);
+       test_window.join();
+       return 0;
+}
+
index 0777e924bda5fec9df036e9c360119064c846698..05323bb86c1fea75ec73a91ef63a24e9363f74ef 100644 (file)
@@ -180,7 +180,7 @@ DIRS = $(OPENCV_OBJS) \
 #      vocoder \
 
 PLUGIN_DIR = $(BINDIR)/plugins
-DATA = $(PLUGIN_DIR)/fonts $(PLUGIN_DIR)/shapes
+DATA = $(PLUGIN_DIR)/fonts $(PLUGIN_DIR)/shapes $(PLUGIN_DIR)/scopes
 LADSPA_DIR = $(BINDIR)/ladspa
 
 all:   $(PLUGIN_DIR) $(DIRS) $(DATA) $(LADSPA_DIR)
index 8408bc3396494bd9c923a33287915b37d841ef16..4c9affc621c338aef0c6d61ab75af0023d2e5d44 100644 (file)
@@ -419,7 +419,7 @@ BoxBlurPower::BoxBlurPower(BoxBlurWindow *gui, int x, int y, int w,
 }
 
 BoxBlurWindow::BoxBlurWindow(BoxBlurEffect *plugin)
- : PluginClientWindow(plugin, xS(360), yS(240), xS(360), yS(240), 0)
+ : PluginClientWindow(plugin, xS(360), yS(246), xS(360), yS(246), 0)
 {
        this->plugin = plugin;
        blur_horz = 0;
@@ -485,7 +485,7 @@ void BoxBlurWindow::create_objects()
        blur_power = new BoxBlurPower(this, x, y, ww, _("Power:"),
                        &plugin->config.power);
        blur_power->create_objects();
-       y += blur_power->get_h() + margin;
+       y += blur_power->get_h() + margin + yS(8);
        BC_Bar *bar;
        add_subwindow(bar = new BC_Bar(x, y, ww));
        y += bar->get_h() + 2*margin;
index c627200d2d0ea52a339aa13922bfb7c28f91d4fd..832a1d45cfe32e4035820002099de57b69173dce 100644 (file)
@@ -318,7 +318,9 @@ int ChromaKeyColorThread::handle_new_color(int output, int alpha)
        plugin->config.red = (float)(output & 0xff0000) / 0xff0000;
        plugin->config.green = (float)(output & 0xff00) / 0xff00;
        plugin->config.blue = (float)(output & 0xff) / 0xff;
+       gui->lock_window("ChromaKeyColorThread::handle_new_color");
        gui->update_sample();
+       gui->unlock_window();
        plugin->send_configure_change();
        return 1;
 }
diff --git a/cinelerra-5.1/plugins/scopes/grad.png b/cinelerra-5.1/plugins/scopes/grad.png
new file mode 100644 (file)
index 0000000..20ba9e6
Binary files /dev/null and b/cinelerra-5.1/plugins/scopes/grad.png differ