[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57791] trunk/blender/source/blender/ editors: Added checks to vertex Weight editor to respect locked Vertex Groups
Gaia Clary
gaia.clary at machinimatrix.org
Thu Jun 27 00:29:32 CEST 2013
Revision: 57791
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57791
Author: gaiaclary
Date: 2013-06-26 22:29:31 +0000 (Wed, 26 Jun 2013)
Log Message:
-----------
Added checks to vertex Weight editor to respect locked Vertex Groups
Modified Paths:
--------------
trunk/blender/source/blender/editors/object/object_vgroup.c
trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
Modified: trunk/blender/source/blender/editors/object/object_vgroup.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_vgroup.c 2013-06-26 22:12:23 UTC (rev 57790)
+++ trunk/blender/source/blender/editors/object/object_vgroup.c 2013-06-26 22:29:31 UTC (rev 57791)
@@ -4101,12 +4101,34 @@
}
}
+static bool check_vertex_group_accessible(wmOperator *op, Object *ob, int def_nr)
+{
+ bDeformGroup *dg = BLI_findlink(&ob->defbase, def_nr);
+
+ if (!dg) {
+ BKE_report(op->reports, RPT_ERROR, "Invalid Weight Group Index");
+ return true;
+ }
+
+ if (dg->flag & DG_LOCK_WEIGHT) {
+ BKE_report(op->reports, RPT_ERROR, "Weight Group is locked");
+ return true;
+ }
+
+ return false;
+}
+
static int vertex_weight_paste(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- const int wg_index = RNA_int_get(op->ptr, "weight_group");
- vgroup_copy_active_to_sel_single(ob, wg_index);
+ const int def_nr = RNA_int_get(op->ptr, "weight_group");
+ if (!check_vertex_group_accessible(op, ob, def_nr)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ vgroup_copy_active_to_sel_single(ob, def_nr);
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -4119,7 +4141,7 @@
ot->name = "Paste weight to Selected";
ot->idname = "OBJECT_OT_vertex_weight_paste";
- ot->description = "Copy this group's weight to other selected verts";
+ ot->description = "Copy this group's weight to other selected verts (disabled if vertex Group is locked)";
prop = RNA_def_int(ot->srna, "weight_group", -1, -1, INT_MAX, "Weight Index",
"Index of source weight in active Weight Group", -1, INT_MAX);
@@ -4136,9 +4158,13 @@
static int vertex_weight_delete(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- const int wg_index = RNA_int_get(op->ptr, "weight_group");
- vgroup_remove_weight(ob, wg_index);
+ const int def_nr = RNA_int_get(op->ptr, "weight_group");
+ if (check_vertex_group_accessible(op, ob, def_nr)) {
+ return OPERATOR_CANCELLED;
+ }
+ vgroup_remove_weight(ob, def_nr);
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -4151,7 +4177,7 @@
ot->name = "Delete Weight";
ot->idname = "OBJECT_OT_vertex_weight_delete";
- ot->description = "Delete this weight from the vertex";
+ ot->description = "Delete this weight from the vertex (disabled if vertex Group is locked)";
prop = RNA_def_int(ot->srna, "weight_group", -1, -1, INT_MAX, "Weight Index",
"Index of source weight in active Weight Group", -1, INT_MAX);
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c 2013-06-26 22:12:23 UTC (rev 57790)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c 2013-06-26 22:29:31 UTC (rev 57791)
@@ -839,13 +839,13 @@
const bool *vgroup_validmap;
eVGroupSelect subset_type = ts->vgroupsubset;
int yco = 0;
- int locked = 0;
+ int lock_count = 0;
uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL);
bcol = uiLayoutColumn(pa->layout, true);
row = uiLayoutRow(bcol, true); /* The filter button row */
-
+
RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr);
uiItemR(row, &tools_ptr, "vertex_group_subset", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -853,11 +853,14 @@
vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count);
for (i = 0, dg = ob->defbase.first; dg; i++, dg = dg->next) {
+ bool locked = dg->flag & DG_LOCK_WEIGHT;
if (vgroup_validmap[i]) {
MDeformWeight *dw = defvert_find_index(dv, i);
if (dw) {
int x, xco = 0;
- row = uiLayoutRow(col, true);
+ int icon;
+ uiLayout *split = uiLayoutSplit(col, 0.45, true);
+ row = uiLayoutRow(split, true);
/* The Weight Group Name */
@@ -872,15 +875,17 @@
}
xco += x;
+ row = uiLayoutRow(split, true);
+ uiLayoutSetEnabled(row, !locked);
+
/* The weight group value */
/* To be reworked still */
but = uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + i, "",
xco, yco, (x = UI_UNIT_X * 4), UI_UNIT_Y,
&dw->weight, 0.0, 1.0, 1, 3, "");
uiButSetFlag(but, UI_TEXT_LEFT);
- if (dg->flag & DG_LOCK_WEIGHT) {
- uiButSetFlag(but, UI_BUT_DISABLED);
- locked++;
+ if (locked) {
+ lock_count++;
}
xco += x;
@@ -889,14 +894,16 @@
ot = ot_weight_paste;
WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_int_set(&op_ptr, "weight_group", i);
- uiItemFullO_ptr(row, ot, "", ICON_PASTEDOWN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ icon = (locked) ? ICON_BLANK1:ICON_PASTEDOWN;
+ uiItemFullO_ptr(row, ot, "", icon, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
/* The weight entry delete function */
ot = ot_weight_delete;
WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_int_set(&op_ptr, "weight_group", i);
- uiItemFullO_ptr(row, ot, "", ICON_X, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ icon = (locked) ? ICON_LOCKED:ICON_X;
+ uiItemFullO_ptr(row, ot, "", icon, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
yco -= UI_UNIT_Y;
@@ -914,14 +921,17 @@
but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Normalize",
0, yco, UI_UNIT_X * 5, UI_UNIT_Y,
TIP_("Normalize weights of active vertex (if affected groups are unlocked"));
- if (locked) {
+ if (lock_count) {
uiButSetFlag(but, UI_BUT_DISABLED);
}
ot = WM_operatortype_find("OBJECT_OT_vertex_weight_copy", 1);
but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Copy",
UI_UNIT_X * 5, yco, UI_UNIT_X * 5, UI_UNIT_Y,
- TIP_("Copy active vertex to other selected verts"));
+ TIP_("Copy active vertex to other selected verts (if affected groups are unlocked)"));
+ if (lock_count) {
+ uiButSetFlag(but, UI_BUT_DISABLED);
+ }
}
}
More information about the Bf-blender-cvs
mailing list