X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fscopewindow.C;h=6f34a1555e1267556aae30c98da7ea0d795f7def;hb=26d01a213db5d4f6ee57224cc9a9ea37bd74318c;hp=2b21ff0d34df071e5ee4c3e0d7eec6c5dcf65d35;hpb=6f73adad624d1ca2b397791784d0c778fcce8d39;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/scopewindow.C b/cinelerra-5.1/cinelerra/scopewindow.C index 2b21ff0d..6f34a155 100644 --- a/cinelerra-5.1/cinelerra/scopewindow.C +++ b/cinelerra-5.1/cinelerra/scopewindow.C @@ -26,6 +26,7 @@ #include "file.h" #include "filesystem.h" #include "language.h" +#include "overlayframe.h" #include "scopewindow.h" #include "theme.h" @@ -43,22 +44,23 @@ ScopeUnit::ScopeUnit(ScopeGUI *gui, this->gui = gui; } +#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) { \ +#define incr_points(rows,h, rv,gv,bv, comps) { \ if(iy >= 0 && iy < h) { \ - uint8_t *vp = rows[iy] + ix*3; \ + 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; } \ } -#define decr_points(rows,h, rv,gv,bv) { \ +#define decr_points(rows,h, rv,gv,bv, comps) { \ if(iy >= 0 && iy < h) { \ - uint8_t *vp = rows[iy] + ix*3; \ + 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; } \ @@ -124,7 +126,7 @@ if(iy >= 0 && iy < h) { \ 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); \ } \ } \ } \ @@ -139,7 +141,7 @@ if(iy >= 0 && iy < h) { \ int rv = r + 3; \ int gv = g + 3; \ int bv = b + 3; \ - incr_points(vector_rows,vector_h, rv,gv,bv); \ + incr_points(vector_rows,vector_h, rv,gv,bv, 4); \ } \ else if(use_vector < 0) { \ double t = TO_RAD(-h); \ @@ -147,7 +149,7 @@ if(iy >= 0 && iy < h) { \ 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); \ + decr_points(vector_rows,vector_h, vinc,vinc,vinc, 4); \ } \ } @@ -429,8 +431,8 @@ ScopeGUI::~ScopeGUI() delete temp_frame; delete wave_slider; delete vect_slider; - delete grad_image; - delete grad_pixmap; + delete grat_image; + delete overlay; } void ScopeGUI::reset() @@ -443,16 +445,17 @@ void ScopeGUI::reset() temp_frame = 0; wave_slider = 0; vect_slider = 0; - grad_image = 0; - grad_pixmap = 0; - vector_gradical = 0; - grad_idx = 0; - vect_grads = 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; @@ -460,6 +463,7 @@ void ScopeGUI::reset() use_vector = 1; use_hist_parade = 0; use_wave_parade = 0; + use_graticule = 0; waveform = 0; vectorscope = 0; histogram = 0; @@ -481,17 +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; - add_subwindow(smooth = new ScopeSmooth(this, x, y)); - y += smooth->get_h() + theme->widget_border; + 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, "")); - y += scope_menu->get_h() + theme->widget_border; + int x1 = x + scope_menu->get_w() + 2*margin; + add_subwindow(settings = new ScopeSettings(this, x1, y)); + settings->create_objects(); create_panels(); update_toggles(); @@ -535,31 +539,17 @@ 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) ) { @@ -608,7 +598,7 @@ void ScopeGUI::toggle_event() void ScopeGUI::calculate_sizes(int w, int h) { int margin = theme->widget_border; - int menu_h = smooth->get_h() + scope_menu->get_h() + margin * 3; + 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) + @@ -627,7 +617,7 @@ 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) @@ -673,7 +663,8 @@ 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; } @@ -705,14 +696,12 @@ 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(); clear_points(0); - update_scope(); draw_overlays(1, 1, 1); + update_scope(); return 1; } @@ -727,6 +716,7 @@ int ScopeGUI::translation_event() void ScopeGUI::draw_overlays(int overlays, int borders, int flush) { + int margin = theme->widget_border; if( overlays && borders ) { clear_box(0, 0, get_w(), get_h()); } @@ -756,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); @@ -771,7 +761,6 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) } // Vectorscope overlay if( vectorscope && use_vector ) { - draw_gradical(); set_color(text_color); vectorscope->draw_point(); vectorscope->flash(0); @@ -801,8 +790,25 @@ void ScopeGUI::draw_overlays(int overlays, int borders, int flush) if(flush) this->flush(); } -void ScopeGUI::draw_gradical() +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); @@ -826,44 +832,20 @@ void ScopeGUI::draw_gradical() 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) +void ScopeGUI::update_graticule(int idx) { - grad_idx = idx; + grat_idx = idx; update_scope(); + toggle_event(); } void ScopeGUI::draw_colorwheel(VFrame *dst, int bg_color) { - float cx = vector_cx, cy = vector_cy, rad = radius; +// 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; @@ -886,7 +868,7 @@ void ScopeGUI::draw_colorwheel(VFrame *dst, int bg_color) else { r = bg_r; g = bg_g; b = bg_b; } - row[0] = r; row[1] = g; row[2] = b; + row[0] = r; row[1] = g; row[2] = b; row[3] = 0xff; } } } @@ -909,7 +891,7 @@ void ScopeGUI::process(VFrame *output_frame) frame_w = data_frame->get_w(); bzero(waveform_vframe->get_data(), waveform_vframe->get_data_size()); if( use_vector > 0 ) - bzero(vector_vframe->get_data(), vector_vframe->get_data_size()); + vector_vframe->clear_frame(); else if( use_vector < 0 ) { if( wheel_vframe && ( wheel_vframe->get_w() != vector_w || @@ -917,7 +899,7 @@ void ScopeGUI::process(VFrame *output_frame) delete wheel_vframe; wheel_vframe = 0; } if( !wheel_vframe ) { - wheel_vframe = new VFrame(vector_w, vector_h, BC_RGB888); + wheel_vframe = new VFrame(vector_w, vector_h, BC_RGBA8888); draw_colorwheel(wheel_vframe, BLACK); } vector_vframe->copy_from(wheel_vframe); @@ -929,7 +911,7 @@ void ScopeGUI::process(VFrame *output_frame) if( waveform ) waveform->draw_vframe(waveform_vframe); if( vectorscope ) - vectorscope->draw_vframe(vector_vframe); + draw_scope(); draw_overlays(1, 0, 1); unlock_window(); @@ -938,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) @@ -999,6 +982,7 @@ int ScopePanel::button_release_event() { if( is_dragging ) { is_dragging = 0; + hide_tooltip(); return 1; } return 0; @@ -1032,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); @@ -1088,7 +1072,7 @@ void ScopeVectorscope::update_point(int x, int y) char string[BCTEXTLEN]; sprintf(string, "Hue: %.3f Sat: %.3f", hue, saturation); - gui->value_text->update(string, 0); + show_tooltip(string); // Show it draw_point(); @@ -1163,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); @@ -1260,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; } @@ -1297,22 +1281,67 @@ void ScopeMenu::update_toggles() } -ScopeVectGrads::ScopeVectGrads(ScopeGUI *gui, int x, int y) - : BC_PopupMenu(x, y, xS(40), "", 1, 0, 0) +ScopeSettingOn::ScopeSettingOn(ScopeSettings *settings, const char *text, int id) + : BC_MenuItem(text) { - this->gui = gui; + this->settings = settings; + this->id = id; } -#define SCOPE_SEARCHPATH "/scopes" -void ScopeVectGrads::create_objects() +int ScopeSettingOn::handle_event() { - 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); + 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; +} + +ScopeSettings::ScopeSettings(ScopeGUI *gui, int x, int y) + : BC_PopupMenu(x, y, xS(150), _("Settings")) +{ + this->gui = gui; + refresh_on = 0; + release_on = 0; +} + +void ScopeSettings::create_objects() +{ + 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][*.jpg]"); + fs.set_filter("[*.png]"); char scope_path[BCTEXTLEN]; sprintf(scope_path, "%s%s", File::get_plugin_path(), SCOPE_SEARCHPATH); fs.update(scope_path); @@ -1322,26 +1351,34 @@ void ScopeVectGrads::create_objects() 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())); + 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())); } } -ScopeGradItem::ScopeGradItem(ScopeVectGrads *vect_grads, const char *text, int idx) +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->vect_grads = vect_grads; + this->settings = settings; this->idx = idx; } -int ScopeGradItem::handle_event() +int ScopeGratItem::handle_event() { - for( int i=0,n=vect_grads->total_items(); iget_item(i); - item->set_checked(item == this); + for( int i=0,n=settings->total_items(); iget_item(i); + item->set_checked(item->idx == idx); } - vect_grads->gui->update_gradical(idx); + settings->gui->update_graticule(idx); return 1; } @@ -1429,17 +1466,3 @@ ScopeVectSlider::ScopeVectSlider(ScopeGUI *gui, int x, int y, int w) { } -ScopeSmooth::ScopeSmooth(ScopeGUI *gui, int x, int y) - : BC_CheckBox(x, y, gui->use_smooth, _("Smooth")) -{ - this->gui = gui; -} - -int ScopeSmooth::handle_event() -{ - gui->use_smooth = get_value(); - gui->update_scope(); - gui->toggle_event(); - return 1; -} -