Revision: 47234 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47234 Author: campbellbarton Date: 2012-05-30 16:22:33 +0000 (Wed, 30 May 2012) Log Message: ----------- draw options for mask spline matching the UV view
Modified Paths: -------------- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py branches/soc-2011-tomato/source/blender/editors/include/ED_mask.h branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py =================================================================== --- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2012-05-30 15:47:12 UTC (rev 47233) +++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2012-05-30 16:22:33 UTC (rev 47234) @@ -711,6 +711,12 @@ col.label(text="Display Aspect Ratio:") row = col.row() row.prop(clip, "display_aspect", text="") + + if sc.mode == 'MASKEDITING': + col = layout.column() + col.prop(sc, "mask_draw_type", text="") + col.prop(sc, "show_mask_smooth") + class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel): Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_mask.h =================================================================== --- branches/soc-2011-tomato/source/blender/editors/include/ED_mask.h 2012-05-30 15:47:12 UTC (rev 47233) +++ branches/soc-2011-tomato/source/blender/editors/include/ED_mask.h 2012-05-30 16:22:33 UTC (rev 47234) @@ -39,7 +39,7 @@ void ED_operatormacros_mask(void); /* mask_draw.c */ -void ED_mask_draw(const bContext *C); +void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type); /* mask_shapekey.c */ int ED_mask_object_shape_auto_key_all(struct Mask *mask, const int frame); Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c =================================================================== --- branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c 2012-05-30 15:47:12 UTC (rev 47233) +++ branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c 2012-05-30 16:22:33 UTC (rev 47234) @@ -236,41 +236,99 @@ /* #define USE_XOR */ -static void draw_curve_dashed(MaskSpline *spline, float *points, int tot_point, const unsigned char rgb_sel[4]) +static void mask_draw_curve_type(MaskSpline *spline, float *points, int tot_point, + const short is_feather, const short is_smooth, + const unsigned char rgb_spline[4], const char draw_type) { const int draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GL_LINE_LOOP : GL_LINE_STRIP; + unsigned char rgb_tmp[4]; - glEnable(GL_LINE_STIPPLE); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, points); + switch (draw_type) { + + case MASK_DT_OUTLINE: + glLineWidth(3); + cpack(0x0); + + glDrawArrays(draw_method, 0, tot_point); + + glLineWidth(1); + glColor4ubv(rgb_spline); + glDrawArrays(draw_method, 0, tot_point); + + break; + + case MASK_DT_DASH: + default: + glEnable(GL_LINE_STIPPLE); + #ifdef USE_XOR - glEnable(GL_COLOR_LOGIC_OP); - glLogicOp(GL_OR); + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_OR); #endif + glColor4ubv(rgb_spline); + glLineStipple(3, 0xaaaa); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, points); + glDrawArrays(draw_method, 0, tot_point); - glColor4ubv(rgb_sel); - glLineStipple(3, 0xaaaa); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, points); - glDrawArrays(draw_method, 0, tot_point); - #ifdef USE_XOR - glDisable(GL_COLOR_LOGIC_OP); + glDisable(GL_COLOR_LOGIC_OP); #endif + glColor4ub(0, 0, 0, 255); + glLineStipple(3, 0x5555); + glDrawArrays(draw_method, 0, tot_point); - glColor4ub(0, 0, 0, 255); - glLineStipple(3, 0x5555); - glDrawArrays(draw_method, 0, tot_point); + glDisable(GL_LINE_STIPPLE); + break; + + + case MASK_DT_BLACK: + case MASK_DT_WHITE: + if (draw_type == MASK_DT_BLACK) { rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 0; } + else { rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 255; } + /* alpha values seem too low but gl draws many points that compensate for it */ + if (is_feather) { rgb_tmp[3] = 64; } + else { rgb_tmp[3] = 128; } + + if (is_feather) { + rgb_tmp[0] = (unsigned char)(((short)rgb_tmp[0] + (short)rgb_spline[0]) / 2); + rgb_tmp[1] = (unsigned char)(((short)rgb_tmp[1] + (short)rgb_spline[1]) / 2); + rgb_tmp[2] = (unsigned char)(((short)rgb_tmp[2] + (short)rgb_spline[2]) / 2); + } + + if (is_smooth == FALSE && is_feather) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + glColor4ubv(rgb_tmp); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, points); + glDrawArrays(draw_method, 0, tot_point); + + glDrawArrays(draw_method, 0, tot_point); + + if (is_smooth == FALSE && is_feather) { + glDisable(GL_BLEND); + } + + break; + } + glDisableClientState(GL_VERTEX_ARRAY); - glDisable(GL_LINE_STIPPLE); } static void draw_spline_curve(MaskObject *maskobj, MaskSpline *spline, - const char use_smooth, const char draw_type) + const char draw_flag, const char draw_type) { unsigned char rgb_tmp[4]; - const int is_spline_sel = (spline->flag & SELECT) && (maskobj->restrictflag & MASK_RESTRICT_SELECT) == 0; + const short is_spline_sel = (spline->flag & SELECT) && (maskobj->restrictflag & MASK_RESTRICT_SELECT) == 0; + const short is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH); float *diff_points, *feather_points; int tot_diff_point, tot_feather_point; @@ -279,7 +337,7 @@ if (!diff_points) return; - if (use_smooth) { + if (is_smooth) { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -289,15 +347,19 @@ /* draw feather */ mask_spline_feather_color_get(maskobj, spline, is_spline_sel, rgb_tmp); - draw_curve_dashed(spline, feather_points, tot_feather_point, rgb_tmp); + mask_draw_curve_type(spline, feather_points, tot_feather_point, + TRUE, is_smooth, + rgb_tmp, draw_type); MEM_freeN(feather_points); /* draw main curve */ mask_spline_color_get(maskobj, spline, is_spline_sel, rgb_tmp); - draw_curve_dashed(spline, diff_points, tot_diff_point, rgb_tmp); + mask_draw_curve_type(spline, diff_points, tot_diff_point, + FALSE, is_smooth, + rgb_tmp, draw_type); MEM_freeN(diff_points); - if (use_smooth) { + if (draw_flag & MASK_DRAWFLAG_SMOOTH) { glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -306,7 +368,7 @@ } static void draw_maskobjs(Mask *mask, - const char use_smooth, const char draw_type) + const char draw_flag, const char draw_type) { MaskObject *maskobj; @@ -320,7 +382,7 @@ for (spline = maskobj->splines.first; spline; spline = spline->next) { /* draw curve itself first... */ - draw_spline_curve(maskobj, spline, use_smooth, draw_type); + draw_spline_curve(maskobj, spline, draw_flag, draw_type); // draw_spline_parents(maskobj, spline); @@ -334,7 +396,7 @@ void *back = spline->points_deform; spline->points_deform = NULL; - draw_spline_curve(maskobj, spline, use_smooth, draw_type); + draw_spline_curve(maskobj, spline, draw_flag, draw_type); // draw_spline_parents(maskobj, spline); draw_spline_points(maskobj, spline); spline->points_deform = back; @@ -343,12 +405,13 @@ } } -void ED_mask_draw(const bContext *C) +void ED_mask_draw(const bContext *C, + const char draw_flag, const char draw_type) { Mask *mask = CTX_data_edit_mask(C); if (!mask) return; - draw_maskobjs(mask, FALSE, 0); + draw_maskobjs(mask, draw_flag, draw_type); } Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c =================================================================== --- branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c 2012-05-30 15:47:12 UTC (rev 47233) +++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c 2012-05-30 16:22:33 UTC (rev 47234) @@ -1136,7 +1136,7 @@ glScalef(maxdim * zoomx, maxdim * zoomy, 0); glMultMatrixf(sc->stabmat); - ED_mask_draw((bContext *)C); + ED_mask_draw((bContext *)C, sc->mask_draw_flag, sc->mask_draw_type); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h =================================================================== --- branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h 2012-05-30 15:47:12 UTC (rev 47233) +++ branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h 2012-05-30 16:22:33 UTC (rev 47234) @@ -132,4 +132,16 @@ #define MASK_RESTRICT_SELECT 2 #define MASK_RESTRICT_RENDER 4 +/* SpaceClip->mask_draw_flag */ +#define MASK_DRAWFLAG_SMOOTH 1 + +/* copy of eSpaceImage_UVDT */ +/* SpaceClip->mask_draw_type */ +enum { + MASK_DT_OUTLINE = 0, + MASK_DT_DASH, + MASK_DT_BLACK, + MASK_DT_WHITE +}; + #endif // __DNA_MASK_TYPES_H__ Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h =================================================================== --- branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h 2012-05-30 15:47:12 UTC (rev 47233) +++ branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h 2012-05-30 16:22:33 UTC (rev 47234) @@ -1014,6 +1014,10 @@ /* **** mask editing **** */ struct Mask *mask; + /* draw options */ + char mask_draw_flag; + char mask_draw_type; + char pad3[6]; } SpaceClip; /* SpaceClip->flag */ Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c =================================================================== --- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c 2012-05-30 15:47:12 UTC (rev 47233) +++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c 2012-05-30 16:22:33 UTC (rev 47234) @@ -45,6 +45,7 @@ #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_sequence_types.h" +#include "DNA_mask_types.h" #include "DNA_view3d_types.h" #include "WM_api.h" @@ -1068,6 +1069,14 @@ #else +static EnumPropertyItem dt_uv_items[] = { + {SI_UVDT_OUTLINE, "OUTLINE", 0, "Outline", "Draw white edges with black outline"}, + {SI_UVDT_DASH, "DASH", 0, "Dash", "Draw dashed black-white edges"}, + {SI_UVDT_BLACK, "BLACK", 0, "Black", "Draw black edges"}, + {SI_UVDT_WHITE, "WHITE", 0, "White", "Draw white edges"}, + {0, NULL, 0, NULL, NULL} +}; + static void rna_def_space(BlenderRNA *brna) { @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs