[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47203] branches/soc-2011-tomato/source/ blender: mask object hide/reveal - access from H/Alt+H/ Shift+H and eye icon in listview.
Campbell Barton
ideasman42 at gmail.com
Wed May 30 08:07:27 CEST 2012
Revision: 47203
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47203
Author: campbellbarton
Date: 2012-05-30 06:07:26 +0000 (Wed, 30 May 2012)
Log Message:
-----------
mask object hide/reveal - access from H/Alt+H/Shift+H and eye icon in listview.
added alpha setting though its not used for rendering yet.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_relationships.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_select.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_shapekey.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/makesrna/RNA_access.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_mask.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-30 04:48:10 UTC (rev 47202)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-30 06:07:26 UTC (rev 47203)
@@ -94,9 +94,12 @@
mask->tot_maskobj++;
+ maskobj->alpha = 1.0f;
+
return maskobj;
}
+/* note: may still be hidden, caller needs to check */
MaskObject *BKE_mask_object_active(Mask *mask)
{
return BLI_findlink(&mask->maskobjs, mask->act_maskobj);
@@ -104,12 +107,7 @@
void BKE_mask_object_active_set(Mask *mask, MaskObject *maskobj)
{
- int index = BLI_findindex(&mask->maskobjs, maskobj);
-
- if (index >= 0)
- mask->act_maskobj = index;
- else
- mask->act_maskobj = 0;
+ mask->act_maskobj = BLI_findindex(&mask->maskobjs, maskobj);
}
void BKE_mask_object_remove(Mask *mask, MaskObject *maskobj)
@@ -1171,7 +1169,7 @@
spline->points_deform = MEM_mallocN(sizeof(*spline->points_deform) * spline->tot_point, __func__);
}
else {
- printf("alloc spline done\n");
+ // printf("alloc spline done\n");
}
}
Modified: branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c 2012-05-30 04:48:10 UTC (rev 47202)
+++ branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c 2012-05-30 06:07:26 UTC (rev 47203)
@@ -2241,7 +2241,19 @@
uiItemL(split, name, ICON_OBJECT_DATA);
}
}
+ else if (itemptr->type == &RNA_MaskObject) {
+ split = uiLayoutSplit(sub, 0.5f, 0);
+ uiItemL(split, name, icon);
+
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+ row = uiLayoutRow(split, 1);
+ uiItemR(row, itemptr, "alpha", 0, "", ICON_NONE);
+ uiItemR(row, itemptr, "hide", 0, "", 0);
+
+ uiBlockSetEmboss(block, UI_EMBOSS);
+ }
+
/* There is a last chance to display custom controls (in addition to the name/label):
* If the given item property group features a string property named as prop_list,
* this tries to add controls for all properties of the item listed in that string property.
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 04:48:10 UTC (rev 47202)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c 2012-05-30 06:07:26 UTC (rev 47203)
@@ -267,10 +267,12 @@
for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
MaskSpline *spline;
+ if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ continue;
+ }
+
for (spline = maskobj->splines.first; spline; spline = spline->next) {
-// BKE_mask_spline_ensure_deform(spline);
-
/* draw curve itself first... */
draw_spline_curve(maskobj, spline);
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c 2012-05-30 04:48:10 UTC (rev 47202)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c 2012-05-30 06:07:26 UTC (rev 47203)
@@ -203,6 +203,10 @@
WM_operatortype_append(MASK_OT_select_border);
WM_operatortype_append(MASK_OT_select_lasso);
+ /* hide/reveal */
+ WM_operatortype_append(MASK_OT_hide_view_clear);
+ WM_operatortype_append(MASK_OT_hide_view_set);
+
/* shape */
WM_operatortype_append(MASK_OT_slide_point);
WM_operatortype_append(MASK_OT_cyclic_toggle);
@@ -255,6 +259,14 @@
kmi = WM_keymap_add_item(keymap, "MASK_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "deselect", TRUE);
+ /* hide/reveal */
+ WM_keymap_add_item(keymap, "MASK_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0);
+ kmi = WM_keymap_add_item(keymap, "MASK_OT_hide_view_set", HKEY, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "unselected", FALSE);
+
+ kmi = WM_keymap_add_item(keymap, "MASK_OT_hide_view_set", HKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "unselected", TRUE);
+
/* select clip while in maker view,
* this matches View3D functionality where you can select an
* object while in editmode to allow vertex parenting */
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h 2012-05-30 04:48:10 UTC (rev 47202)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h 2012-05-30 06:07:26 UTC (rev 47203)
@@ -51,6 +51,9 @@
void MASK_OT_delete(struct wmOperatorType *ot);
+void MASK_OT_hide_view_clear(struct wmOperatorType *ot);
+void MASK_OT_hide_view_set(struct wmOperatorType *ot);
+
void MASK_OT_handle_type_set(struct wmOperatorType *ot);
int ED_mask_feather_find_nearest(
@@ -76,8 +79,10 @@
void MASK_OT_select_circle(struct wmOperatorType *ot);
int ED_mask_spline_select_check(struct MaskSplinePoint *points, int tot_point);
+int ED_mask_object_select_check(struct MaskObject *maskobj);
int ED_mask_select_check(struct Mask *mask);
+void ED_mask_object_select_set(struct MaskObject *maskobj, int select);
void ED_mask_select_toggle_all(struct Mask *mask, int action);
void ED_mask_select_flush_all(struct Mask *mask);
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-30 04:48:10 UTC (rev 47202)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-30 06:07:26 UTC (rev 47203)
@@ -143,6 +143,10 @@
for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
MaskSpline *spline;
+ if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ continue;
+ }
+
for (spline = maskobj->splines.first; spline; spline = spline->next) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
@@ -241,6 +245,10 @@
int i, tot_feather_point;
float *feather_points, *fp;
+ if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ continue;
+ }
+
feather_points = fp = BKE_mask_spline_feather_points(spline, &tot_feather_point);
for (i = 0; i < spline->tot_point; i++) {
@@ -328,6 +336,10 @@
for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
MaskSpline *spline;
+ if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ continue;
+ }
+
for (spline = maskobj->splines.first; spline; spline = spline->next) {
int i;
@@ -1204,6 +1216,10 @@
maskobj = BKE_mask_object_active(mask);
+ if (maskobj && maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ maskobj = NULL;
+ }
+
RNA_float_get_array(op->ptr, "location", co);
if (maskobj && maskobj->act_point && MASKPOINT_ISSEL(maskobj->act_point)) {
@@ -1360,6 +1376,10 @@
for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
MaskSpline *spline;
+ if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ continue;
+ }
+
for (spline = maskobj->splines.first; spline; spline = spline->next) {
if (ED_mask_spline_select_check(spline->points, spline->tot_point)) {
spline->flag ^= MASK_SPLINE_CYCLIC;
@@ -1432,8 +1452,14 @@
int mask_object_shape_ofs = 0;
for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
- MaskSpline *spline = maskobj->splines.first;
+ MaskSpline *spline;
+ if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ continue;
+ }
+
+ spline = maskobj->splines.first;
+
while (spline) {
const int tot_point_orig = spline->tot_point;
int i, count = 0;
@@ -1537,6 +1563,10 @@
MaskSpline *spline;
int i;
+ if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+ continue;
+ }
+
for (spline = maskobj->splines.first; spline; spline = spline->next) {
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -1581,3 +1611,106 @@
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", editcurve_handle_type_items, 1, "Type", "Spline type");
}
+
+
+/* ********* clear/set restrict view *********/
+static int mask_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Mask *mask = CTX_data_edit_mask(C);
+ MaskObject *maskobj;
+ int changed = FALSE;
+
+ for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
+
+ if (maskobj->restrictflag & OB_RESTRICT_VIEW) {
+ ED_mask_object_select_set(maskobj, TRUE);
+ maskobj->restrictflag &= ~OB_RESTRICT_VIEW;
+ changed = 1;
+ }
+ }
+
+ if (changed) {
+ WM_event_add_notifier(C, NC_MASK | ND_DRAW, mask);
+ DAG_id_tag_update(&mask->id, 0);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void MASK_OT_hide_view_clear(wmOperatorType *ot)
+{
+
+ /* identifiers */
+ ot->name = "Clear Restrict View";
+ ot->description = "Reveal the object by setting the hide flag";
+ ot->idname = "MASK_OT_hide_view_clear";
+
+ /* api callbacks */
+ ot->exec = mask_hide_view_clear_exec;
+ ot->poll = ED_maskediting_mask_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int mask_hide_view_set_exec(bContext *C, wmOperator *op)
+{
+ Mask *mask = CTX_data_edit_mask(C);
+ MaskObject *maskobj;
+ const int unselected = RNA_boolean_get(op->ptr, "unselected");
+ int changed = FALSE;
+
+ for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
+ if (!unselected) {
+ if (ED_mask_object_select_check(maskobj)) {
+ ED_mask_object_select_set(maskobj, FALSE);
+
+ maskobj->restrictflag |= OB_RESTRICT_VIEW;
+ changed = 1;
+ if (maskobj == BKE_mask_object_active(mask)) {
+ BKE_mask_object_active_set(mask, NULL);
+ }
+ }
+ }
+ else {
+ if (!ED_mask_object_select_check(maskobj)) {
+ maskobj->restrictflag |= OB_RESTRICT_VIEW;
+ changed = 1;
+ if (maskobj == BKE_mask_object_active(mask)) {
+ BKE_mask_object_active_set(mask, NULL);
+ }
+ }
+ }
+ }
+
+ if (changed) {
+ WM_event_add_notifier(C, NC_MASK | ND_DRAW, mask);
+ DAG_id_tag_update(&mask->id, 0);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void MASK_OT_hide_view_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set Restrict View";
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list