X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fscopewindow.C;h=6f34a1555e1267556aae30c98da7ea0d795f7def;hb=22c6251d37911a11e322bf7518e6a992ea0bb6c7;hp=36883b68d5da6355c0db01966913435a48838d5e;hpb=e1e5dee5935f9f416a31014906a7e0dfacb10c02;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/scopewindow.C b/cinelerra-5.1/cinelerra/scopewindow.C index 36883b68..6f34a155 100644 --- a/cinelerra-5.1/cinelerra/scopewindow.C +++ b/cinelerra-5.1/cinelerra/scopewindow.C @@ -20,9 +20,13 @@ #include "bcsignals.h" #include "bccolors.h" +#include "boxblur.h" #include "clip.h" #include "cursors.h" +#include "file.h" +#include "filesystem.h" #include "language.h" +#include "overlayframe.h" #include "scopewindow.h" #include "theme.h" @@ -40,25 +44,33 @@ ScopeUnit::ScopeUnit(ScopeGUI *gui, this->gui = gui; } -#define BPP 3 -#define incr_point(rows,h, n, comp) \ -if(iy >= 0 && iy < h) { int v; \ - uint8_t *vp = rows[iy] + ix*BPP + (comp); \ - v = *vp+(n); *vp = v>0xff ? 0xff : v; \ +#define SCOPE_SEARCHPATH "/scopes" + +#define incr_point(rows,h, iv,comp) { \ +if(iy >= 0 && iy < h) { \ + uint8_t *vp = rows[iy] + ix*3 + (comp); \ + int v = *vp+(iv); *vp = v>0xff ? 0xff : v; } \ } -#define incr_points(rows,h, rv, gv, bv) \ -if(iy >= 0 && iy < h) { int v; \ - uint8_t *vp = rows[iy] + ix*BPP; \ - v = *vp+(rv); *vp++ = v>0xff ? 0xff : v; \ +#define incr_points(rows,h, rv,gv,bv, comps) { \ +if(iy >= 0 && iy < h) { \ + uint8_t *vp = rows[iy] + ix*comps; \ + int v = *vp+(rv); *vp++ = v>0xff ? 0xff : v; \ v = *vp+(gv); *vp++ = v>0xff ? 0xff : v; \ - v = *vp+(bv); *vp = v>0xff ? 0xff : v; \ + v = *vp+(bv); *vp = v>0xff ? 0xff : v; } \ +} +#define decr_points(rows,h, rv,gv,bv, comps) { \ +if(iy >= 0 && iy < h) { \ + uint8_t *vp = rows[iy] + ix*comps; \ + 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) { int v; \ - uint8_t *vp = rows[iy] + ix*BPP; \ - v = *vp+(rv); *vp++ = v>0xff ? 0xff : v<0 ? 0 : v; \ +#define clip_points(rows,h, rv,gv,bv) { \ +if(iy >= 0 && iy < h) { \ + uint8_t *vp = rows[iy] + ix*3; \ + int v = *vp+(rv); *vp++ = v>0xff ? 0xff : v<0 ? 0 : v; \ v = *vp+(gv); *vp++ = v>0xff ? 0xff : v<0 ? 0 : v; \ - v = *vp+(bv); *vp = v>0xff ? 0xff : v<0 ? 0 : v; \ + v = *vp+(bv); *vp = v>0xff ? 0xff : v<0 ? 0 : v; } \ } #define PROCESS_PIXEL(column) { \ @@ -81,76 +93,81 @@ if(iy >= 0 && iy < h) { int v; \ } \ /* Calculate waveform */ \ if(use_wave || use_wave_parade) { \ - int ix = (column) * wave_w / out_w; \ - if(ix >= 0 && ix < wave_w) { \ + int ix = column * wave_w / dat_w; \ + if(ix >= 0 && ix < wave_w-1) { \ if(use_wave_parade > 0) { \ ix /= 3; \ - int iy = wave_h - (int)((r - FLOAT_MIN) / \ + int iy = wave_h - ((r - FLOAT_MIN) / \ (FLOAT_MAX - FLOAT_MIN) * wave_h); \ - incr_point(waveform_rows,wave_h, winc, 0); \ + incr_point(waveform_rows,wave_h, winc,0); \ ix += wave_w/3; \ - iy = wave_h - (int)((g - FLOAT_MIN) / \ + iy = wave_h - ((g - FLOAT_MIN) / \ (FLOAT_MAX - FLOAT_MIN) * wave_h); \ - incr_point(waveform_rows,wave_h, winc, 1); \ + incr_point(waveform_rows,wave_h, winc,1); \ ix += wave_w/3; \ - iy = wave_h - (int)((b - FLOAT_MIN) / \ + iy = wave_h - ((b - FLOAT_MIN) / \ (FLOAT_MAX - FLOAT_MIN) * wave_h); \ - incr_point(waveform_rows,wave_h, winc, 2); \ + incr_point(waveform_rows,wave_h, winc,2); \ } \ else if(use_wave_parade < 0) { \ - int iy = wave_h - (int)((r - FLOAT_MIN) / \ + int iy = wave_h - ((r - FLOAT_MIN) / \ (FLOAT_MAX - FLOAT_MIN) * wave_h); \ - clip_points(waveform_rows,wave_h, winc, -winc, -winc); \ - iy = wave_h - (int)((g - FLOAT_MIN) / \ + clip_points(waveform_rows,wave_h, winc,-winc,-winc); \ + iy = wave_h - ((g - FLOAT_MIN) / \ (FLOAT_MAX - FLOAT_MIN) * wave_h); \ - clip_points(waveform_rows,wave_h, -winc, winc, -winc); \ - iy = wave_h - (int)((b - FLOAT_MIN) / \ + clip_points(waveform_rows,wave_h, -winc,winc,-winc); \ + iy = wave_h - ((b - FLOAT_MIN) / \ (FLOAT_MAX - FLOAT_MIN) * wave_h); \ - clip_points(waveform_rows,wave_h, -winc, -winc, winc); \ + clip_points(waveform_rows,wave_h, -winc,-winc,winc); \ } \ - else { int yinc = 3*winc; \ - int rinc = yinc*(r-FLOAT_MIN) / (FLOAT_MAX-FLOAT_MIN) + 3; \ - int ginc = yinc*(g-FLOAT_MIN) / (FLOAT_MAX-FLOAT_MIN) + 3; \ - int binc = yinc*(b-FLOAT_MIN) / (FLOAT_MAX-FLOAT_MIN) + 3; \ + else { float yinc = 3*winc; \ + float rinc = yinc*(r-FLOAT_MIN) / (FLOAT_MAX-FLOAT_MIN) + 3; \ + float ginc = yinc*(g-FLOAT_MIN) / (FLOAT_MAX-FLOAT_MIN) + 3; \ + float binc = yinc*(b-FLOAT_MIN) / (FLOAT_MAX-FLOAT_MIN) + 3; \ int iy = wave_h - ((intensity - FLOAT_MIN) / \ (FLOAT_MAX - FLOAT_MIN) * wave_h); \ - incr_points(waveform_rows,wave_h, rinc, ginc, binc); \ + incr_points(waveform_rows,wave_h, rinc, ginc, binc, 3); \ } \ } \ } \ /* 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; \ - incr_points(vector_rows,vector_h, rv, gv, bv); \ + 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, 4); \ + } \ + 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, 4); \ } \ } -#define PROCESS_RGB_PIXEL(column, max) { \ - r = (float)*row++ / max; \ - g = (float)*row++ / max; \ - b = (float)*row++ / max; \ +#define PROCESS_RGB_PIXEL(type,max, column) { \ + type *rp = (type *)row; \ + r = (float)rp[0] / max; \ + g = (float)rp[1] / max; \ + b = (float)rp[2] / max; \ HSV::rgb_to_hsv(r, g, b, h, s, v); \ intensity = v; \ PROCESS_PIXEL(column) \ } -#define PROCESS_BGR_PIXEL(column, max) { \ - b = (float)*row++ / max; \ - g = (float)*row++ / max; \ - r = (float)*row++ / max; \ +#define PROCESS_BGR_PIXEL(type,max, column) { \ + type *rp = (type *)row; \ + b = (float)rp[0] / max; \ + g = (float)rp[1] / max; \ + r = (float)rp[2] / max; \ HSV::rgb_to_hsv(r, g, b, h, s, v); \ intensity = v; \ PROCESS_PIXEL(column) \ @@ -175,126 +192,149 @@ 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(); int wave_w = waveform_vframe->get_w(); int vector_h = vector_vframe->get_h(); int vector_w = vector_vframe->get_w(); - int out_w = gui->output_frame->get_w(); - int out_h = gui->output_frame->get_h(); - int winc = (wave_w * wave_h) / (out_w * out_h); + int dat_w = gui->data_frame->get_w(); + 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->wdial; - int vinc = 3*(vector_w * vector_h) / (out_w * out_h) + 2; - vinc *= gui->vdial; - float radius = MIN(gui->vector_w / 2, gui->vector_h / 2); - unsigned char **waveform_rows = waveform_vframe->get_rows(); - unsigned char **vector_rows = vector_vframe->get_rows(); - unsigned char **rows = gui->output_frame->get_rows(); - - switch( gui->output_frame->get_color_model() ) { + 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(); + + switch( gui->data_frame->get_color_model() ) { case BC_RGB888: for( int y=pkg->row1; yrow2; ++y ) { - unsigned char *row = rows[y]; - for( int x=0; xrow1; yrow2; ++y ) { - unsigned char *row = rows[y]; - for( int x=0; xrow1; yrow2; ++y ) { + uint8_t *row = rows[y]; + for( int x=0; xrow1; yrow2; ++y ) { + uint8_t *row = rows[y]; + for( int x=0; xrow1; yrow2; ++y ) { - unsigned char *row = rows[y]; - for( int x=0; xrow1; yrow2; ++y ) { - unsigned char *row = rows[y]; - for( int x=0; xrow1; yrow2; ++y ) { - float *row = (float*)rows[y]; - for( int x=0; xrow1; yrow2; ++y ) { - float *row = (float*)rows[y]; - for( int x=0; xrow1; yrow2; ++y ) { - unsigned char *row = rows[y]; - for( int x=0; xrow1; yrow2; ++y ) { - unsigned char *row = rows[y]; - for( int x=0; xoutput_frame->get_y(); - unsigned char *up = gui->output_frame->get_u(); - unsigned char *vp = gui->output_frame->get_v(); + uint8_t *yp = gui->data_frame->get_y(); + uint8_t *up = gui->data_frame->get_u(); + uint8_t *vp = gui->data_frame->get_v(); for( int y=pkg->row1; yrow2; ++y ) { - unsigned char *y_row = yp + y * out_w; - unsigned char *u_row = up + (y / 2) * (out_w / 2); - unsigned char *v_row = vp + (y / 2) * (out_w / 2); - for( int x=0; xrow1; yrow2; ++y ) { - unsigned char *row = rows[y]; - for( int x=0; xoutput_frame->get_color_model()); + __LINE__, gui->data_frame->get_color_model()); break; } } @@ -313,7 +353,7 @@ ScopeEngine::~ScopeEngine() void ScopeEngine::init_packages() { - int y = 0, h = gui->output_frame->get_h(); + int y = 0, h = gui->data_frame->get_h(); for( int i=0,n=LoadServer::get_total_packages(); irow1 = y; @@ -385,28 +425,59 @@ 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 grat_image; + delete overlay; } void ScopeGUI::reset() { - frame_w = 1; waveform_vframe = 0; vector_vframe = 0; + wheel_vframe = 0; engine = 0; + box_blur = 0; + temp_frame = 0; + wave_slider = 0; + vect_slider = 0; + grat_image = 0; + overlay = 0; + grat_idx = 0; + settings = 0; + + output_frame = 0; + data_frame = 0; + frame_w = 1; + use_smooth = 1; + use_refresh = 0; + use_release = 0; + use_wave_gain = 5; + use_vect_gain = 5; use_hist = 0; use_wave = 1; use_vector = 1; use_hist_parade = 0; use_wave_parade = 0; + use_graticule = 0; waveform = 0; vectorscope = 0; histogram = 0; - wave_w = wave_h = vector_w = vector_h = 0; - wdial = vdial = 5.f; + 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 ) @@ -414,15 +485,17 @@ void ScopeGUI::create_objects() if( use_wave && use_wave_parade ) use_wave = 0; if( !engine ) engine = new ScopeEngine(this, cpus); + grat_idx = use_graticule; // last graticule + use_graticule = 0; lock_window("ScopeGUI::create_objects"); - int x = theme->widget_border; - int y = theme->widget_border + - ScopeWaveDial::calculate_h() - ScopeMenu::calculate_h(); + int margin = theme->widget_border; + int x = margin, y = margin; add_subwindow(scope_menu = new ScopeMenu(this, x, y)); scope_menu->create_objects(); - x += scope_menu->get_w() + theme->widget_border; - add_subwindow(value_text = new BC_Title(x, y, "")); + int x1 = x + scope_menu->get_w() + 2*margin; + add_subwindow(settings = new ScopeSettings(this, x1, y)); + settings->create_objects(); create_panels(); update_toggles(); @@ -434,46 +507,49 @@ void ScopeGUI::create_objects() void ScopeGUI::create_panels() { calculate_sizes(get_w(), get_h()); + int slider_w = xS(100); if( (use_wave || use_wave_parade) ) { - int px = wave_x + wave_w - ScopeWaveDial::calculate_w() - xS(5); - int py = wave_y - ScopeWaveDial::calculate_h() - yS(5); + int px = wave_x + wave_w - slider_w - xS(5); + int py = wave_y - ScopeGain::calculate_h() - yS(5); if( !waveform ) { add_subwindow(waveform = new ScopeWaveform(this, wave_x, wave_y, wave_w, wave_h)); waveform->create_objects(); - add_subwindow(wave_dial = new ScopeWaveDial(this, px, py)); + wave_slider = new ScopeWaveSlider(this, px, py, slider_w); + wave_slider->create_objects(); } else { waveform->reposition_window( wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); - wave_dial->reposition_window(px, py); + wave_slider->reposition_window(px, py); } } else if( !(use_wave || use_wave_parade) && waveform ) { - delete waveform; waveform = 0; - delete wave_dial; wave_dial = 0; + delete waveform; waveform = 0; + delete wave_slider; wave_slider = 0; } if( use_vector ) { - int vx = vector_x + vector_w - ScopeVectDial::calculate_w() - xS(5); - int vy = vector_y - ScopeVectDial::calculate_h() - yS(5); + int vx = vector_x + vector_w - slider_w - xS(5); + int vy = vector_y - ScopeGain::calculate_h() - yS(5); if( !vectorscope ) { add_subwindow(vectorscope = new ScopeVectorscope(this, vector_x, vector_y, vector_w, vector_h)); vectorscope->create_objects(); - add_subwindow(vect_dial = new ScopeVectDial(this, vx, vy)); + vect_slider = new ScopeVectSlider(this, vx, vy, slider_w); + vect_slider->create_objects(); } else { vectorscope->reposition_window( vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); - vect_dial->reposition_window(vx, vy); + vect_slider->reposition_window(vx, vy); } } else if( !use_vector && vectorscope ) { delete vectorscope; vectorscope = 0; - delete vect_dial; vect_dial = 0; + delete vect_slider; vect_slider = 0; } if( (use_hist || use_hist_parade) ) { @@ -522,7 +598,7 @@ void ScopeGUI::toggle_event() void ScopeGUI::calculate_sizes(int w, int h) { int margin = theme->widget_border; - int menu_h = ScopeWaveDial::calculate_h() + margin * 2; + int menu_h = scope_menu->get_h() + ScopeGain::calculate_h() + margin * 3; int text_w = get_text_width(SMALLFONT, "000") + margin * 2; int total_panels = ((use_hist || use_hist_parade) ? 1 : 0) + ((use_wave || use_wave_parade) ? 1 : 0) + @@ -541,12 +617,15 @@ void ScopeGUI::calculate_sizes(int w, int h) if( vector_w > vector_h ) { vector_w = vector_h; - vector_x = w - theme->widget_border - vector_w; + vector_x = w - margin - vector_w; } --total_panels; 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 ) { @@ -573,6 +652,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__, @@ -583,7 +663,9 @@ void ScopeGUI::allocate_vframes() waveform_vframe = new VFrame(w, h, BC_RGB888); w = MAX(vector_w, xs16); h = MAX(vector_h, ys16); - vector_vframe = new VFrame(w, h, BC_RGB888); + vector_vframe = new VFrame(w, h, BC_RGBA8888); + vector_vframe->set_clear_color(BLACK, 0xff); + wheel_vframe = 0; } @@ -593,13 +675,14 @@ int ScopeGUI::resize_event(int w, int h) this->w = w; this->h = h; calculate_sizes(w, h); + int margin = theme->widget_border; if( waveform ) { waveform->reposition_window(wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); - int px = wave_x + wave_w - ScopeWaveDial::calculate_w() - xS(5); - int py = wave_y - ScopeWaveDial::calculate_h() - yS(5); - wave_dial->reposition_window(px, py); + int px = wave_x + wave_w - wave_slider->get_w() - margin; + int py = wave_y - wave_slider->get_h() - margin; + wave_slider->reposition_window(px, py); } if( histogram ) { @@ -610,15 +693,15 @@ int ScopeGUI::resize_event(int w, int h) if( vectorscope ) { vectorscope->reposition_window(vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); - int vx = vector_x + vector_w - ScopeVectDial::calculate_w() - xS(5); - int vy = vector_y - ScopeVectDial::calculate_h() - yS(5); - vect_dial->reposition_window(vx, vy); + 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); } allocate_vframes(); clear_points(0); - update_scope(); draw_overlays(1, 1, 1); + update_scope(); return 1; } @@ -633,13 +716,7 @@ 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; - } - + int margin = theme->widget_border; if( overlays && borders ) { clear_box(0, 0, get_w(), get_h()); } @@ -669,7 +746,7 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) char string[BCTEXTLEN]; sprintf(string, "%d", (int)lround((FLOAT_MAX - i * (FLOAT_MAX - FLOAT_MIN) / WAVEFORM_DIVISIONS) * 100)); - int text_x = wave_x - get_text_width(SMALLFONT, string) - theme->widget_border; + int text_x = wave_x - get_text_width(SMALLFONT, string) - margin; set_color(text_color); draw_text(text_x, text_y, string); CLAMP(y, 0, waveform->get_h() - 1); @@ -684,29 +761,10 @@ 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); - } set_color(text_color); vectorscope->draw_point(); - set_line_dashes(1); vectorscope->flash(0); + set_line_dashes(1); } set_font(MEDIUMFONT); @@ -732,24 +790,128 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) if(flush) this->flush(); } +void ScopeGUI::draw_scope() +{ + int graticule = use_vector < 0 ? grat_idx : 0; + if( grat_image && use_graticule != graticule ) { + delete grat_image; grat_image = 0; + } + if( !grat_image && graticule > 0 ) + grat_image = VFramePng::vframe_png(grat_paths[graticule]); + if( grat_image ) { + if( !overlay ) + overlay = new OverlayFrame(1); + int cx = vector_cx, cy = vector_cy, r = radius; + int iw = grat_image->get_w(), ih = grat_image->get_h(); + overlay->overlay(vector_vframe, grat_image, + 0,0, iw, ih, cx-r,cy-r, cx+r, cy+r, + 1, TRANSFER_NORMAL, CUBIC_CUBIC); + } + use_graticule = graticule; + vectorscope->draw_vframe(vector_vframe); + 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); + } +} + + +void ScopeGUI::update_graticule(int idx) +{ + grat_idx = idx; + update_scope(); + toggle_event(); +} + +void ScopeGUI::draw_colorwheel(VFrame *dst, int bg_color) +{ +// downfactor radius to prevent extreme edge from showing behind graticule + float cx = vector_cx, cy = vector_cy, rad = radius * 0.99; + 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; youtput_frame = output_frame; - frame_w = output_frame->get_w(); - //float radius = MIN(vector_w / 2, vector_h / 2); + int ow = output_frame->get_w(), oh = output_frame->get_h(); + if( use_smooth ) { + VFrame::get_temp(temp_frame, ow, oh, BC_RGB161616); + temp_frame->transfer_from(output_frame); + if( !box_blur ) box_blur = new BoxBlur(cpus); + box_blur->blur(temp_frame, temp_frame, 2, 2); + data_frame = temp_frame; + } + else + data_frame = output_frame; + frame_w = data_frame->get_w(); bzero(waveform_vframe->get_data(), waveform_vframe->get_data_size()); - bzero(vector_vframe->get_data(), vector_vframe->get_data_size()); + if( use_vector > 0 ) + vector_vframe->clear_frame(); + 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_RGBA8888); + draw_colorwheel(wheel_vframe, BLACK); + } + vector_vframe->copy_from(wheel_vframe); + } engine->process(); if( histogram ) histogram->draw(0, 0); if( waveform ) - waveform->draw_vframe(waveform_vframe, 1, 0, 0); + waveform->draw_vframe(waveform_vframe); if( vectorscope ) - vectorscope->draw_vframe(vector_vframe, 1, 0, 0); + draw_scope(); draw_overlays(1, 0, 1); unlock_window(); @@ -758,6 +920,7 @@ void ScopeGUI::process(VFrame *output_frame) void ScopeGUI::update_toggles() { scope_menu->update_toggles(); + settings->update_toggles(); } ScopePanel::ScopePanel(ScopeGUI *gui, int x, int y, int w, int h) @@ -819,6 +982,7 @@ int ScopePanel::button_release_event() { if( is_dragging ) { is_dragging = 0; + hide_tooltip(); return 1; } return 0; @@ -852,7 +1016,7 @@ void ScopeWaveform::update_point(int x, int y) float value = ((float)get_h() - y) / get_h() * (FLOAT_MAX - FLOAT_MIN) + FLOAT_MIN; char string[BCTEXTLEN]; sprintf(string, "X: %d Value: %.3f", frame_x, value); - gui->value_text->update(string, 0); + show_tooltip(string); draw_point(); flash(1); @@ -898,20 +1062,17 @@ 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]; sprintf(string, "Hue: %.3f Sat: %.3f", hue, saturation); - gui->value_text->update(string, 0); + show_tooltip(string); // Show it draw_point(); @@ -920,21 +1081,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, @@ -971,7 +1147,7 @@ void ScopeHistogram::update_point(int x, int y) char string[BCTEXTLEN]; sprintf(string, "Value: %.3f", value); - gui->value_text->update(string, 0); + show_tooltip(string); draw_point(); flash(1); @@ -1055,6 +1231,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(); @@ -1065,7 +1244,7 @@ int ScopeScopesOn::handle_event() } ScopeMenu::ScopeMenu(ScopeGUI *gui, int x, int y) - : BC_PopupMenu(x, y, xS(100), _("Scopes")) + : BC_PopupMenu(x, y, xS(110), _("Scopes")) { this->gui = gui; } @@ -1076,14 +1255,18 @@ void ScopeMenu::create_objects() new ScopeScopesOn(this, _("Histogram"), SCOPE_HISTOGRAM)); add_item(hist_rgb_on = new ScopeScopesOn(this, _("Histogram RGB"), SCOPE_HISTOGRAM_RGB)); + add_item(new BC_MenuItem("-")); add_item(wave_on = new ScopeScopesOn(this, _("Waveform"), SCOPE_WAVEFORM)); add_item(wave_rgb_on = new ScopeScopesOn(this, _("Waveform RGB"), SCOPE_WAVEFORM_RGB)); add_item(wave_ply_on = new ScopeScopesOn(this, _("Waveform ply"), SCOPE_WAVEFORM_PLY)); + 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() @@ -1093,30 +1276,193 @@ 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); } -ScopeWaveDial::ScopeWaveDial(ScopeGUI *gui, int x, int y) - : BC_FPot(x, y, gui->wdial, 1.f, 9.f) + +ScopeSettingOn::ScopeSettingOn(ScopeSettings *settings, const char *text, int id) + : BC_MenuItem(text) { - this->gui = gui; + this->settings = settings; + this->id = id; } -int ScopeWaveDial::handle_event() + +int ScopeSettingOn::handle_event() { - gui->wdial = get_value(); + int v = get_checked() ? 0 : 1; + set_checked(v); + ScopeGUI *gui = settings->gui; + switch( id ) { + case SCOPE_SMOOTH: + gui->use_smooth = v; + break; + case SCOPE_REFRESH: + gui->use_refresh = v; + gui->use_release = 0; + break; + case SCOPE_RELEASE: + gui->use_release = v; + gui->use_refresh = 0; + } + gui->toggle_event(); + gui->update_toggles(); gui->update_scope(); + gui->show_window(); return 1; } -ScopeVectDial::ScopeVectDial(ScopeGUI *gui, int x, int y) - : BC_FPot(x, y, gui->vdial, 1.f, 9.f) +ScopeSettings::ScopeSettings(ScopeGUI *gui, int x, int y) + : BC_PopupMenu(x, y, xS(150), _("Settings")) { this->gui = gui; + refresh_on = 0; + release_on = 0; } -int ScopeVectDial::handle_event() + +void ScopeSettings::create_objects() { - gui->vdial = get_value(); + add_item(smooth_on = + new ScopeSettingOn(this, _("Smooth"), SCOPE_SMOOTH)); + smooth_on->set_checked(gui->use_smooth); + if( gui->use_refresh >= 0 ) { + add_item(refresh_on = + new ScopeSettingOn(this, _("Refresh on Stop"), SCOPE_REFRESH)); + add_item(release_on = + new ScopeSettingOn(this, _("Refresh on Release"), SCOPE_RELEASE)); + refresh_on->set_checked(gui->use_refresh); + release_on->set_checked(gui->use_release); + } + add_item(new BC_MenuItem(_("-VectorWheel Grids-"))); + + gui->grat_paths.remove_all_objects(); + ScopeGratItem *item; + add_item(item = new ScopeGratItem(this, _("None"), 0)); + if( item->idx == gui->grat_idx ) item->set_checked(1); + gui->grat_paths.append(0); + FileSystem fs; + fs.set_filter("[*.png]"); + char scope_path[BCTEXTLEN]; + sprintf(scope_path, "%s%s", File::get_plugin_path(), SCOPE_SEARCHPATH); + fs.update(scope_path); + for( int i=0; iget_is_dir() ) continue; + strcpy(scope_path, file_item->get_name()); + char *cp = strrchr(scope_path, '.'); + if( cp ) *cp = 0; + add_item(item = new ScopeGratItem(this, scope_path, gui->grat_paths.size())); + if( item->idx == gui->grat_idx ) item->set_checked(1); + gui->grat_paths.append(cstrdup(file_item->get_path())); + } +} + +void ScopeSettings::update_toggles() +{ + if( refresh_on ) + refresh_on->set_checked(gui->use_refresh); + if( release_on ) + release_on->set_checked(gui->use_release); +} + +ScopeGratItem::ScopeGratItem(ScopeSettings *settings, const char *text, int idx) + : BC_MenuItem(text) +{ + this->settings = settings; + this->idx = idx; +} + +int ScopeGratItem::handle_event() +{ + for( int i=0,n=settings->total_items(); iget_item(i); + item->set_checked(item->idx == idx); + } + settings->gui->update_graticule(idx); + return 1; +} + + +ScopeGainReset::ScopeGainReset(ScopeGain *gain, int x, int y) + : BC_Button(x, y, gain->gui->theme->get_image_set("reset_button")) +{ + this->gain = gain; +} + +int ScopeGainReset::calculate_w(BC_Theme *theme) +{ + VFrame *vfrm = *theme->get_image_set("reset_button"); + return vfrm->get_w(); +} + +int ScopeGainReset::handle_event() +{ + gain->slider->update(5); + return gain->handle_event(); +} + +ScopeGainSlider::ScopeGainSlider(ScopeGain *gain, int x, int y, int w) + : BC_ISlider(x, y, 0, w, w, 1, 9, *gain->value) +{ + this->gain = gain; +} + +int ScopeGainSlider::handle_event() +{ + return gain->handle_event(); +} + +ScopeGain::ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value) +{ + this->gui = gui; + this->x = x; + this->y = y; + this->w = w; + this->value = value; + + slider = 0; + reset = 0; +} +ScopeGain::~ScopeGain() +{ + delete reset; + delete slider; +} + +int ScopeGain::calculate_h() +{ + return BC_ISlider::get_span(0); +} + +void ScopeGain::create_objects() +{ + reset_w = ScopeGainReset::calculate_w(gui->theme); + gui->add_subwindow(slider = new ScopeGainSlider(this, x, y, w-reset_w-xS(5))); + gui->add_subwindow(reset = new ScopeGainReset(this, x+w-reset_w, y)); +} + +int ScopeGain::handle_event() +{ + *value = slider->get_value(); gui->update_scope(); + gui->toggle_event(); return 1; } +void ScopeGain::reposition_window(int x, int y) +{ + this->x = x; this->y = y; + slider->reposition_window(x, y); + reset->reposition_window(x+w-reset_w, y); +} + +ScopeWaveSlider::ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w) + : ScopeGain(gui, x, y, w, &gui->use_wave_gain) +{ +} + +ScopeVectSlider::ScopeVectSlider(ScopeGUI *gui, int x, int y, int w) + : ScopeGain(gui, x, y, w, &gui->use_vect_gain) +{ +} +