Index: release/scripts/ui/space_image.py =================================================================== --- release/scripts/ui/space_image.py (révision 27703) +++ release/scripts/ui/space_image.py (copie de travail) @@ -406,6 +406,39 @@ layout.template_histogram(sima, "histogram") +class IMAGE_PT_view_waveform(bpy.types.Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'PREVIEW' + bl_label = "Waveform" + + def poll(self, context): + sima = context.space_data + return (sima and sima.image) + + def draw(self, context): + layout = self.layout + + sima = context.space_data + + layout.template_waveform(sima, "scope_sample_buffer", color=sima.waveform_color, alpha=sima.scope_alpha) + layout.prop(sima, "waveform_color") + +class IMAGE_PT_view_vectorscope(bpy.types.Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'PREVIEW' + bl_label = "Vectorscope" + + def poll(self, context): + sima = context.space_data + return (sima and sima.image) + + def draw(self, context): + layout = self.layout + + sima = context.space_data + + layout.template_vectorscope(sima, "scope_sample_buffer", alpha=sima.scope_alpha) + class IMAGE_PT_sample_line(bpy.types.Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'PREVIEW' @@ -421,6 +454,26 @@ sima = context.space_data layout.template_histogram(sima, "sample_histogram") +class IMAGE_PT_scope_sample(bpy.types.Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'PREVIEW' + bl_label = "Scope Samples" + + def poll(self, context): + sima = context.space_data + return sima + + def draw(self, context): + layout = self.layout + sima = context.space_data + sbuf = sima.scope_sample_buffer + layout.prop(sima, "scope_alpha", text="Opacity", slider=True) + layout.prop(sbuf, "use_full_resolution") + col = layout.column(align=True) + col.active = not sbuf.use_full_resolution + col.prop(sbuf, "sizex") + col.prop(sbuf, "sizey") + class IMAGE_PT_view_properties(bpy.types.Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' @@ -607,7 +660,10 @@ IMAGE_PT_game_properties, IMAGE_PT_view_properties, IMAGE_PT_view_histogram, - IMAGE_PT_sample_line] + IMAGE_PT_view_waveform, + IMAGE_PT_view_vectorscope, + IMAGE_PT_sample_line, + IMAGE_PT_scope_sample] def register(): Index: source/blender/blenkernel/intern/colortools.c =================================================================== --- source/blender/blenkernel/intern/colortools.c (révision 27734) +++ source/blender/blenkernel/intern/colortools.c (copie de travail) @@ -971,3 +971,57 @@ hist->ok=1; } + +void samplebuf_update(SampleBuf *sb, ImBuf *ibuf) +{ + int x, y, sizex, sizey;; + float xfac, yfac; + unsigned char *dest, *rc; + float *rf; + + if (sb->ok == 1 ) return; + + if (sb->x > ibuf->x) sb->x=ibuf->x; + if (sb->y > ibuf->y) sb->y=ibuf->y; + sizex= sb->x; + sizey= sb->y; + if (sb->fullres) { + sizex = ibuf->x; + sizey = ibuf->y; + } + + xfac= (float)ibuf->x/sizex; + yfac= (float)ibuf->y/sizey; + + if( sb->ibuf) IMB_freeImBuf(sb->ibuf); + sb->ibuf = IMB_allocImBuf(sizex, sizey, 32, IB_rect, 0 ); + + dest= (unsigned char *) sb->ibuf->rect; + + if(ibuf->rect_float) { + + for(y=0; yibuf->y; y++) { + for (x=0; xibuf->x; x++) { + rf= ibuf->rect_float + ibuf->channels *((int)(y*yfac)*ibuf->x + (int)(x*xfac)); + dest[0] = rf[0]; + dest[1] = rf[1]; + dest[2] = rf[2]; + dest +=4; + } + } + + } else if (ibuf->rect) { + + for(y=0; yibuf->y; y++) { + for (x=0; xibuf->x; x++) { + rc= ibuf->rect + (int)(y*yfac)*ibuf->x + (int)(x*xfac); + dest[0] = rc[0]; + dest[1] = rc[1]; + dest[2] = rc[2]; + dest +=4; + } + } + } + + sb->ok = 1; +} Index: source/blender/blenkernel/BKE_colortools.h =================================================================== --- source/blender/blenkernel/BKE_colortools.h (révision 27734) +++ source/blender/blenkernel/BKE_colortools.h (copie de travail) @@ -32,6 +32,7 @@ struct CurveMapping; struct CurveMap; struct Histogram; +struct SampleBuf; struct ImBuf; struct rctf; @@ -75,6 +76,7 @@ void colorcorrection_do_ibuf(struct ImBuf *ibuf, const char *profile); void histogram_update(struct Histogram *hist, struct ImBuf *ibuf); +void samplebuf_update(struct SampleBuf *wfrm, struct ImBuf *ibuf); #endif Index: source/blender/makesdna/DNA_space_types.h =================================================================== --- source/blender/makesdna/DNA_space_types.h (révision 27734) +++ source/blender/makesdna/DNA_space_types.h (copie de travail) @@ -45,6 +45,7 @@ struct ImBuf; struct Image; struct Histogram; +struct SampleBuf; struct SpaceIpo; struct BlendHandle; struct RenderInfo; @@ -259,8 +260,11 @@ struct bGPdata *gpd; /* grease pencil data */ + float scope_alpha, padding; struct Histogram hist; /* viewer histogram */ + struct SampleBuf scopebuf; /* under sampled buffer for scopes */ struct Histogram sample_line_hist; /* sample line histogram */ + } SpaceImage; typedef struct SpaceNla { @@ -731,6 +735,8 @@ #define SI_COLOR_CORRECTION 1<<24 +#define SI_WAVEFORM_COLOR 1<<25 + /* SpaceIpo->flag (Graph Editor Settings) */ /* OLD DEPRECEATED SETTING */ #define SIPO_LOCK_VIEW (1<<0) Index: source/blender/makesdna/DNA_color_types.h =================================================================== --- source/blender/makesdna/DNA_color_types.h (révision 27734) +++ source/blender/makesdna/DNA_color_types.h (copie de travail) @@ -101,5 +101,14 @@ int flag; } Histogram; +struct ImBuf; + +typedef struct SampleBuf { + int ok,fullres; + int x; + int y; + struct ImBuf *ibuf; +} SampleBuf; + #endif Index: source/blender/makesrna/intern/rna_ui_api.c =================================================================== --- source/blender/makesrna/intern/rna_ui_api.c (révision 27734) +++ source/blender/makesrna/intern/rna_ui_api.c (copie de travail) @@ -335,6 +335,17 @@ api_ui_item_rna_common(func); RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); + func= RNA_def_function(srna, "template_waveform", "uiTemplateWaveform"); + api_ui_item_rna_common(func); + RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); + RNA_def_boolean(func, "color", 0, "", "Separate colors."); + RNA_def_float(func, "alpha", 1.0, 0.0, 1.0, "Opacity", "Opacity of the points.", 0.0, 1.0); + + func= RNA_def_function(srna, "template_vectorscope", "uiTemplateVectorscope"); + api_ui_item_rna_common(func); + RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); + RNA_def_float(func, "alpha", 1.0, 0.0, 1.0, "Opacity", "Opacity of the points.", 0.0, 1.0); + func= RNA_def_function(srna, "template_layers", "uiTemplateLayers"); api_ui_item_rna_common(func); parm= RNA_def_pointer(func, "used_layers_data", "AnyType", "", "Data from which to take property."); Index: source/blender/makesrna/intern/rna_color.c =================================================================== --- source/blender/makesrna/intern/rna_color.c (révision 27734) +++ source/blender/makesrna/intern/rna_color.c (copie de travail) @@ -269,7 +269,27 @@ } } +static void rna_SampleBuffer_use_full_resolution_set(PointerRNA *ptr, int value) +{ + SampleBuf *sb= (SampleBuf*)ptr->data; + sb->fullres= value; + sb->ok = 0; +} +static void rna_SampleBuffer_sizex_set(PointerRNA *ptr, int value) +{ + SampleBuf *sb= (SampleBuf*)ptr->data; + sb->x= value; + sb->ok = 0; +} + +static void rna_SampleBuffer_sizey_set(PointerRNA *ptr, int value) +{ + SampleBuf *sb= (SampleBuf*)ptr->data; + sb->y= value; + sb->ok = 0; +} + #else static void rna_def_curvemappoint(BlenderRNA *brna) @@ -449,6 +469,32 @@ } +static void rna_def_samplebuf(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "SampleBuffer", NULL); + RNA_def_struct_ui_text(srna, "Sample Buffer", "Samples of an image"); + + prop= RNA_def_property(srna, "use_full_resolution", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, "SampleBuf", "fullres", 1); + RNA_def_property_ui_text(prop, "Full Resolution", "Sample every pixel of the image"); + RNA_def_property_boolean_funcs(prop, NULL, "rna_SampleBuffer_use_full_resolution_set"); + + prop= RNA_def_property(srna, "sizex", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, "SampleBuf", "x"); + RNA_def_property_range(prop, 64, 1024); + RNA_def_property_ui_text(prop, "X Size", "Number of horizontal samples"); + RNA_def_property_int_funcs(prop, NULL, "rna_SampleBuffer_sizex_set", NULL); + + prop= RNA_def_property(srna, "sizey", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, "SampleBuf", "y"); + RNA_def_property_range(prop, 16, 1024); + RNA_def_property_ui_text(prop, "Y Size", "Number of vertical samples"); + RNA_def_property_int_funcs(prop, NULL, "rna_SampleBuffer_sizey_set", NULL); +} + void RNA_def_color(BlenderRNA *brna) { rna_def_curvemappoint(brna); @@ -457,6 +503,7 @@ rna_def_color_ramp_element(brna); rna_def_color_ramp(brna); rna_def_histogram(brna); + rna_def_samplebuf(brna); } #endif Index: source/blender/makesrna/intern/rna_space.c =================================================================== --- source/blender/makesrna/intern/rna_space.c (révision 27734) +++ source/blender/makesrna/intern/rna_space.c (copie de travail) @@ -442,6 +442,19 @@ ED_space_image_release_buffer(sima, lock); } +static void rna_SpaceImageEditor_scope_sample_buffer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + SpaceImage *sima= (SpaceImage*)ptr->data; + ImBuf *ibuf; + void *lock; + + ibuf= ED_space_image_acquire_buffer(sima, &lock); + if(ibuf) { + samplebuf_update(&sima->scopebuf, ibuf); + WM_main_add_notifier(NC_IMAGE, sima->image); + } + ED_space_image_release_buffer(sima, lock); +} /* Space Text Editor */ @@ -1182,6 +1195,20 @@ RNA_def_property_ui_text(prop, "Histogram", "Histogram for viewing image statistics"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_SpaceImageEditor_histogram_update"); + prop= RNA_def_property(srna, "scope_sample_buffer", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "scopebuf"); + RNA_def_property_struct_type(prop, "SampleBuffer"); + RNA_def_property_ui_text(prop, "Sample Buffer", "Buffer of sample of the image for scopes"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_SpaceImageEditor_scope_sample_buffer_update"); + + prop= RNA_def_property(srna, "scope_alpha", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "scope_alpha"); + RNA_def_property_range(prop, 0, 0.2); + + prop= RNA_def_property(srna, "waveform_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_WAVEFORM_COLOR); + RNA_def_property_ui_text(prop, "Color", "Display statistics for each color intead of luminance"); + prop= RNA_def_property(srna, "image_pin", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pin", 0); RNA_def_property_ui_text(prop, "Image Pin", "Display current image regardless of object selection"); Index: source/blender/makesrna/RNA_access.h =================================================================== --- source/blender/makesrna/RNA_access.h (révision 27734) +++ source/blender/makesrna/RNA_access.h (copie de travail) @@ -378,6 +378,7 @@ extern StructRNA RNA_RenderSettings; extern StructRNA RNA_RGBANodeSocket; extern StructRNA RNA_RigidBodyJointConstraint; +extern StructRNA RNA_SampleBuffer; extern StructRNA RNA_Scene; extern StructRNA RNA_SceneGameData; extern StructRNA RNA_SceneRenderLayer; Index: source/blender/editors/include/UI_interface.h =================================================================== --- source/blender/editors/include/UI_interface.h (révision 27734) +++ source/blender/editors/include/UI_interface.h (copie de travail) @@ -218,6 +218,8 @@ #define HOTKEYEVT (45<<9) #define BUT_IMAGE (46<<9) #define HISTOGRAM (47<<9) +#define WAVEFORM (48<<9) +#define VECTORSCOPE (49<<9) #define BUTTYPE (63<<9) @@ -676,6 +678,8 @@ void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot); void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand); void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand); +void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand, int color, float alpha); +void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand, float alpha); void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, char *propname, int type, int levels, int brush); void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, char *propname, int value_slider, int lock); void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname); Index: source/blender/editors/space_image/space_image.c =================================================================== --- source/blender/editors/space_image/space_image.c (révision 27734) +++ source/blender/editors/space_image/space_image.c (copie de travail) @@ -47,6 +47,7 @@ #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "ED_mesh.h" @@ -304,6 +305,20 @@ sima->hist.ok=0; } +static void image_scope_samplebuf_tag_refresh(ScrArea *sa) +{ + SpaceImage *sima= (SpaceImage *)sa->spacedata.first; + ARegion *ar; + + /* only while histogram is visible */ + for (ar=sa->regionbase.first; ar; ar=ar->next) { + if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN) + return; + } + + sima->scopebuf.ok=0; +} + /* ******************** manage regions ********************* */ ARegion *image_has_buttons_region(ScrArea *sa) @@ -358,6 +373,7 @@ arnew->flag = RGN_FLAG_HIDDEN; image_histogram_tag_refresh(sa); + image_scope_samplebuf_tag_refresh(sa); return arnew; } @@ -400,6 +416,9 @@ ar->regiontype= RGN_TYPE_PREVIEW; ar->alignment= RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; + simage->scopebuf.x=1024; + simage->scopebuf.y=16; + simage->scope_alpha=0.2; /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for image"); @@ -419,7 +438,8 @@ curvemapping_free(simage->cumap); // if(simage->gpd) // XXX free_gpencil_data(simage->gpd); - + if(simage->scopebuf.ibuf) + IMB_freeImBuf(simage->scopebuf.ibuf); } @@ -593,8 +613,10 @@ case ND_MODE: case ND_RENDER_RESULT: case ND_COMPO_RESULT: - if (ED_space_image_show_render(sima)) + if (ED_space_image_show_render(sima)) { image_histogram_tag_refresh(sa); + image_scope_samplebuf_tag_refresh(sa); + } ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); break; @@ -603,6 +625,7 @@ case NC_IMAGE: if (wmn->reference == sima->image || !wmn->reference) { image_histogram_tag_refresh(sa); + image_scope_samplebuf_tag_refresh(sa); ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); } @@ -817,8 +840,10 @@ SpaceImage *sima= CTX_wm_space_image(C); void *lock; ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) + if(ibuf) { histogram_update(&sima->hist, ibuf); + samplebuf_update(&sima->scopebuf, ibuf); + } ED_space_image_release_buffer(sima, lock); ED_region_panels(C, ar, 1, NULL, -1); Index: source/blender/editors/interface/interface_draw.c =================================================================== --- source/blender/editors/interface/interface_draw.c (révision 27734) +++ source/blender/editors/interface/interface_draw.c (copie de travail) @@ -774,7 +774,224 @@ glDisable(GL_BLEND); } +void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *recti) +{ + SampleBuf *sb = (SampleBuf *)but->poin; + rctf rect; + int i, x, y, c; + float w, h, posx, posy, lum, alpha; + unsigned char *rc; + GLint scissor[4]; + float colors[3][3] = {{1.0,0,0},{0,1,0},{0,0,1}}; + + if (sb==NULL) { printf("sb is null \n"); return; } + + rect.xmin = (float)recti->xmin; + rect.xmax = (float)recti->xmax; + rect.ymin = (float)recti->ymin; + rect.ymax = (float)recti->ymax; + + w = rect.xmax - rect.xmin; + h = rect.ymax - rect.ymin; + + alpha = but->a2; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + glColor4f(0.f, 0.f, 0.f, 0.3f); + uiSetRoundBox(15); + gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + + glColor4f(1.f, 1.f, 1.f, 0.08f); + /* draw grid lines here */ + for (i=1; i<4; i++) { + fdrawline(rect.xmin, rect.ymin+(i/4.f)*h, rect.xmax, rect.ymin+(i/4.f)*h); + if (but->a1==0) fdrawline(rect.xmin+(i/4.f)*w, rect.ymin, rect.xmin+(i/4.f)*w, rect.ymax); + else if (i<3) fdrawline(rect.xmin+(i/3.f)*w, rect.ymin, rect.xmin+(i/3.f)*w, rect.ymax); + } + + /* need scissor test, histogram can draw outside of boundary */ + glGetIntegerv(GL_VIEWPORT, scissor); + glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); + + glBegin(GL_POINTS); + + /* luminance */ + if (but->a1==0){ + for (y=0; yibuf->y; y++) { + for (x=0; xibuf->x; x++) { + rc = sb->ibuf->rect + y*sb->ibuf->x + x; + lum= (0.299*rc[0] + 0.587*rc[1] + 0.114*rc[2])/255.0; + posx = rect.xmin + ((float)x/sb->ibuf->x) * w; + posy = rect.ymin + lum * h; + glColor4f(1.0, 1.0, 1.0, alpha); + glVertex2f(posx, posy); + } + } + } + /* separate colors*/ + else { + for (y=0; yibuf->y; y++) { + for (x=0; xibuf->x; x++) { + rc = sb->ibuf->rect + y*sb->ibuf->x + x; + for (c=0; c<3; c++) { + posx = rect.xmin + c*w/3.0 + (((float)x/sb->ibuf->x) * w/3.0); + posy = rect.ymin + rc[c] * h/255.0; + glColor4f(colors[c][0], colors[c][1], colors[c][2], alpha); + glVertex2f(posx, posy); + } + } + } + } + + glEnd(); + + /* restore scissortest */ + glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4f(0.f, 0.f, 0.f, 0.5f); + uiSetRoundBox(15); + gl_round_box(GL_LINE_LOOP, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + + glDisable(GL_BLEND); +} +void vectorscope_normalise_uv(float *u, float *v) { + *u *= 0.5/0.436; + *v *= 0.5/0.615; +} + +void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *recti) +{ + SampleBuf *sb = (SampleBuf *)but->poin; + rctf rect; + int i, x, y; + float w, h, rad, posx, posy, alpha, lum, u, v, r, g, b; + unsigned char *rc; + GLint scissor[4]; + float colors[3][3] = {{1.0,0,0},{0,1,0},{0,0,1}}; + + if (sb==NULL) { printf("sb is null \n"); return; } + + rect.xmin = (float)recti->xmin; + rect.xmax = (float)recti->xmax; + rect.ymin = (float)recti->ymin; + rect.ymax = (float)recti->ymax; + + w = rect.xmax - rect.xmin; + h = rect.ymax - rect.ymin; + rad= h; + if (wa1; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + glColor4f(0.f, 0.f, 0.f, 0.3f); + uiSetRoundBox(15); + gl_round_box(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + + /* draw grid lines here */ + glShadeModel(GL_SMOOTH); + glBegin(GL_LINE_STRIP); + + r=1.0f; g=0.0f; b=0.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v* rad*2; + glColor4f(r, g, b, 0.8f); + glVertex2f(posx, posy); + + b=1.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v* rad*2; + glColor4f(r, g, b, 0.8f); + glVertex2f(posx, posy); + + r=0.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v* rad*2; + glColor4f(r, g, b, 0.8f); + glVertex2f(posx, posy); + + g=1.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v* rad*2; + glColor4f(r, g, b, 0.8f); + glVertex2f(posx, posy); + + b=0.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v* rad*2; + glColor4f(r, g, b, 0.8f); + glVertex2f(posx, posy); + + r=1.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v* rad*2; + glColor4f(r, g, b, 0.8f); + glVertex2f(posx, posy); + + g=0.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v * rad*2; + glColor4f(r, g, b, 0.8f); + glVertex2f(posx, posy); + + glEnd(); + glShadeModel(GL_FLAT); + + /* need scissor test, histogram can draw outside of boundary */ + glGetIntegerv(GL_VIEWPORT, scissor); + glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); + + glBegin(GL_POINTS); + + for (y=0; yibuf->y; y++) { + for (x=0; xibuf->x; x++) { + rc = sb->ibuf->rect + y*sb->ibuf->x + x; + r= rc[0]/255.0f; + g= rc[1]/255.0f; + b= rc[2]/255.0f; + rgb_to_yuv(r, g, b, &lum, &u, &v); + vectorscope_normalise_uv(&u, &v); + posx = rect.xmin + w/2 + u * rad*2; + posy = rect.ymin + h/2 + v* rad*2; + glColor4f(1.0, 1.0, 1.0, alpha); + glVertex2f(posx, posy); + } + } + + glEnd(); + + /* restore scissortest */ + glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4f(0.f, 0.f, 0.f, 0.5f); + uiSetRoundBox(15); + gl_round_box(GL_LINE_LOOP, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + + glDisable(GL_BLEND); +} + void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *wcol, rcti *rect) { ColorBand *coba; Index: source/blender/editors/interface/interface_templates.c =================================================================== --- source/blender/editors/interface/interface_templates.c (révision 27734) +++ source/blender/editors/interface/interface_templates.c (copie de travail) @@ -1595,6 +1595,78 @@ MEM_freeN(cb); } +/********************* Waveform Template ************************/ + +void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, char *propname, int expand, int color, float alpha) +{ + PropertyRNA *prop= RNA_struct_find_property(ptr, propname); + PointerRNA cptr; + RNAUpdateCb *cb; + uiBlock *block; + uiBut *bt; + SampleBuf *sb; + rctf rect; + + if(!prop || RNA_property_type(prop) != PROP_POINTER) + return; + + cptr= RNA_property_pointer_get(ptr, prop); + if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_SampleBuffer)) + return; + + cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); + cb->ptr= *ptr; + cb->prop= prop; + + rect.xmin= 0; rect.xmax= 200; + rect.ymin= 0; rect.ymax= 190; + + block= uiLayoutAbsoluteBlock(layout); + + sb = (SampleBuf *)cptr.data; + + bt= uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, 100.0f, sb, 0, 0, color, alpha, ""); + uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); + + MEM_freeN(cb); +} + +/********************* Vectorscope Template ************************/ + +void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, char *propname, int expand, float alpha) +{ + PropertyRNA *prop= RNA_struct_find_property(ptr, propname); + PointerRNA cptr; + RNAUpdateCb *cb; + uiBlock *block; + uiBut *bt; + SampleBuf *sb; + rctf rect; + + if(!prop || RNA_property_type(prop) != PROP_POINTER) + return; + + cptr= RNA_property_pointer_get(ptr, prop); + if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_SampleBuffer)) + return; + + cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); + cb->ptr= *ptr; + cb->prop= prop; + + rect.xmin= 0; rect.xmax= 200; + rect.ymin= 0; rect.ymax= 190; + + block= uiLayoutAbsoluteBlock(layout); + + sb = (SampleBuf *)cptr.data; + + bt= uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, 100.0f, sb, 0, 0, alpha, 0, ""); + uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); + + MEM_freeN(cb); +} + /********************* CurveMapping Template ************************/ #include "BKE_colortools.h" Index: source/blender/editors/interface/interface_intern.h =================================================================== --- source/blender/editors/interface/interface_intern.h (révision 27734) +++ source/blender/editors/interface/interface_intern.h (copie de travail) @@ -440,6 +440,8 @@ void ui_draw_gradient(rcti *rect, float *rgb, int type, float alpha); void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); +void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); +void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect); void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect); void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); Index: source/blender/editors/interface/interface_widgets.c =================================================================== --- source/blender/editors/interface/interface_widgets.c (révision 27734) +++ source/blender/editors/interface/interface_widgets.c (copie de travail) @@ -2709,6 +2709,14 @@ ui_draw_but_HISTOGRAM(ar, but, &tui->wcol_regular, rect); break; + case WAVEFORM: + ui_draw_but_WAVEFORM(ar, but, &tui->wcol_regular, rect); + break; + + case VECTORSCOPE: + ui_draw_but_VECTORSCOPE(ar, but, &tui->wcol_regular, rect); + break; + case BUT_CURVE: ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect); break;