[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10817] trunk/blender/source/blender: Patch #6759: this speeds up the vertex group editing workflow a bit.

Joshua Leung aligorith at gmail.com
Wed May 30 12:36:19 CEST 2007


Revision: 10817
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10817
Author:   aligorith
Date:     2007-05-30 12:36:17 +0200 (Wed, 30 May 2007)

Log Message:
-----------
Patch #6759: this speeds up the vertex group editing workflow a bit. 

The hotkey Ctrl-G in EditMode for Meshes and Lattices, brings up a menu giving the user options to assign/remove selected vertices to a new/the active Vertex Group.

The hotkey Ctrl-Shift-G in EditMode for Meshes and Lattices, brings up a menu giving the user options to change the active Vertex Group and delete the current Vertex Group.

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_editdeform.h
    trunk/blender/source/blender/src/editdeform.c
    trunk/blender/source/blender/src/space.c

Modified: trunk/blender/source/blender/include/BIF_editdeform.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editdeform.h	2007-05-30 06:11:25 UTC (rev 10816)
+++ trunk/blender/source/blender/include/BIF_editdeform.h	2007-05-30 10:36:17 UTC (rev 10817)
@@ -67,5 +67,8 @@
 
 extern void object_apply_deform(struct Object *ob);
 
+void vgroup_assign_with_menu(void);
+void vgroup_operation_with_menu(void);
+
 #endif
 

Modified: trunk/blender/source/blender/src/editdeform.c
===================================================================
--- trunk/blender/source/blender/src/editdeform.c	2007-05-30 06:11:25 UTC (rev 10816)
+++ trunk/blender/source/blender/src/editdeform.c	2007-05-30 10:36:17 UTC (rev 10817)
@@ -55,12 +55,16 @@
 #include "BKE_mesh.h"
 #include "BKE_utildefines.h"
 
+#include "BIF_interface.h"
 #include "BIF_editdeform.h"
 #include "BIF_editmesh.h"
+#include "BIF_space.h"
 #include "BIF_toolbox.h"
 
 #include "BSE_edit.h"
 
+#include "butspace.h"
+#include "mydevice.h"
 #include "editmesh.h"
 #include "multires.h"
 
@@ -788,7 +792,100 @@
 	ob->actdef=0;	// this signals on painting to create a new one, if a bone in posemode is selected */
 }
 
+/* This function provides a shortcut for adding/removing verts from 
+ * vertex groups. It is called by the Ctrl-G hotkey in EditMode for Meshes
+ * and Lattices. (currently only restricted to those two)
+ * It is only responsible for 
+ */
+void vgroup_assign_with_menu(void)
+{
+	Object *ob= G.obedit;
+	int defCount;
+	int mode;
+	
+	/* prevent crashes */
+	if (ob==NULL) return;
+	
+	defCount= BLI_countlist(&ob->defbase);
+	
+	/* give user choices of adding to current/new or removing from current */
+	if (defCount && ob->actdef)
+		mode = pupmenu("Vertex Groups %t|Add Selected to New Group %x1|Add Selected to Active Group %x2|Remove Selected from Active Group %x3");
+	else
+		mode= pupmenu("Vertex Groups %t|Add Selected to New Group %x1");
+	
+	/* handle choices */
+	switch (mode) {
+		case 1: /* add to new group */
+			add_defgroup(ob);
+			assign_verts_defgroup();
+			allqueue(REDRAWVIEW3D, 1);
+			BIF_undo_push("Assign to vertex group");
+			break;
+		case 2: /* add to current group */
+			assign_verts_defgroup();
+			allqueue(REDRAWVIEW3D, 1);
+			BIF_undo_push("Assign to vertex group");
+			break;
+		case 3:	/* remove from current group */
+			remove_verts_defgroup(0);
+			allqueue(REDRAWVIEW3D, 1);
+			BIF_undo_push("Remove from vertex group");
+			break;
+	}
+}
 
+/* This function provides a shortcut for commonly used vertex group 
+ * functions - change weight (not implemented), change active group, delete active group,
+ * when Ctrl-Shift-G is used in EditMode, for Meshes and Lattices (only for now).
+ */
+void vgroup_operation_with_menu(void)
+{
+	Object *ob= G.obedit;
+	int defCount;
+	int mode;
+	
+	/* prevent crashes and useless cases */
+	if (ob==NULL) return;
+	
+	defCount= BLI_countlist(&ob->defbase);
+	if (defCount == 0) return;
+	
+	/* give user choices of adding to current/new or removing from current */
+	if (ob->actdef)
+		mode = pupmenu("Vertex Groups %t|Change Active Group%x1|Delete Active Group%x2");
+	else
+		mode= pupmenu("Vertex Groups %t|Change Active Group%x1");
+	
+	/* handle choices */
+	switch (mode) {
+		case 1: /* change active group*/
+			{
+				char *menustr= get_vertexgroup_menustr(ob);
+				short nr;
+				
+				if (menustr) {
+					nr= pupmenu(menustr);
+					
+					if ((nr >= 1) && (nr <= defCount)) 
+						ob->actdef= nr;
+						
+					MEM_freeN(menustr);
+				}
+				allqueue(REDRAWBUTSALL, 0);
+			}
+			break;
+		case 2: /* delete active group  */
+			{
+				del_defgroup(ob);
+				allqueue (REDRAWVIEW3D, 1);
+				allqueue(REDRAWOOPS, 0);
+				BIF_undo_push("Delete vertex group");
+			}
+			break;
+	}
+}
+
 /* ******************* other deform edit stuff ********** */
 
 void object_apply_deform(Object *ob)

Modified: trunk/blender/source/blender/src/space.c
===================================================================
--- trunk/blender/source/blender/src/space.c	2007-05-30 06:11:25 UTC (rev 10816)
+++ trunk/blender/source/blender/src/space.c	2007-05-30 10:36:17 UTC (rev 10817)
@@ -97,6 +97,7 @@
 #include "BIF_drawscript.h"
 #include "BIF_editarmature.h"
 #include "BIF_editconstraint.h"
+#include "BIF_editdeform.h"
 #include "BIF_editfont.h"
 #include "BIF_editgroup.h"
 #include "BIF_editkey.h"
@@ -1835,8 +1836,20 @@
 				
 				break;
 			case GKEY:
-				if(G.qual == LR_CTRLKEY) 
-					group_operation_with_menu();
+				if((G.qual == LR_CTRLKEY)) {
+					if(G.obedit) {
+						if(ELEM(G.obedit->type, OB_MESH, OB_LATTICE))
+							vgroup_assign_with_menu();
+					}
+					else
+						group_operation_with_menu();
+				}
+				else if((G.qual == (LR_CTRLKEY|LR_SHIFTKEY))) {
+					if(G.obedit) {
+						if(ELEM(G.obedit->type, OB_MESH, OB_LATTICE))
+							vgroup_operation_with_menu();
+					}
+				}
 				else if((G.qual==LR_SHIFTKEY))
 					if(G.obedit) {
 						if(G.obedit->type==OB_MESH)





More information about the Bf-blender-cvs mailing list