| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) Blender Foundation | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): none yet. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 20:29:51 +00:00
										 |  |  | /** \file blender/editors/object/object_group.c
 | 
					
						
							|  |  |  |  *  \ingroup edobj | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_blenlib.h"
 | 
					
						
							| 
									
										
										
										
											2011-01-07 18:36:47 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_group_types.h"
 | 
					
						
							|  |  |  | #include "DNA_object_types.h"
 | 
					
						
							|  |  |  | #include "DNA_scene_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include "BKE_context.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | #include "BKE_depsgraph.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include "BKE_group.h"
 | 
					
						
							| 
									
										
										
										
											2013-06-11 11:21:16 +00:00
										 |  |  | #include "BKE_library.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | #include "BKE_main.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-20 11:03:53 +00:00
										 |  |  | #include "BKE_report.h"
 | 
					
						
							| 
									
										
										
										
											2012-07-18 09:45:50 +00:00
										 |  |  | #include "BKE_object.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | #include "ED_screen.h"
 | 
					
						
							| 
									
										
										
										
											2012-01-02 17:15:24 +00:00
										 |  |  | #include "ED_object.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "WM_api.h"
 | 
					
						
							|  |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "RNA_access.h"
 | 
					
						
							|  |  |  | #include "RNA_define.h"
 | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | #include "RNA_enum_types.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | #include "object_intern.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | /********************* 3d view operators ***********************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | /* can be called with C == NULL */ | 
					
						
							| 
									
										
										
										
											2014-01-04 18:08:43 +11:00
										 |  |  | static EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	Object *ob; | 
					
						
							|  |  |  | 	EnumPropertyItem *item = NULL, item_tmp = {0}; | 
					
						
							|  |  |  | 	int totitem = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (C == NULL) { | 
					
						
							|  |  |  | 		return DummyRNA_NULL_items; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ob = ED_object_context(C); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	/* check that the object exists */ | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 	if (ob) { | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 		Group *group; | 
					
						
							|  |  |  | 		int i = 0, count = 0; | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 		/* if 2 or more groups, add option to add to all groups */ | 
					
						
							|  |  |  | 		group = NULL; | 
					
						
							|  |  |  | 		while ((group = BKE_group_object_find(group, ob))) | 
					
						
							|  |  |  | 			count++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (count >= 2) { | 
					
						
							|  |  |  | 			item_tmp.identifier = item_tmp.name = "All Groups"; | 
					
						
							|  |  |  | 			item_tmp.value = INT_MAX; /* this will give NULL on lookup */ | 
					
						
							|  |  |  | 			RNA_enum_item_add(&item, &totitem, &item_tmp); | 
					
						
							|  |  |  | 			RNA_enum_item_add_separator(&item, &totitem); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* add groups */ | 
					
						
							|  |  |  | 		group = NULL; | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 		while ((group = BKE_group_object_find(group, ob))) { | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 			item_tmp.identifier = item_tmp.name = group->id.name + 2; | 
					
						
							|  |  |  | 			/* item_tmp.icon = ICON_ARMATURE_DATA; */ | 
					
						
							|  |  |  | 			item_tmp.value = i; | 
					
						
							|  |  |  | 			RNA_enum_item_add(&item, &totitem, &item_tmp); | 
					
						
							|  |  |  | 			i++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	RNA_enum_item_end(&item, &totitem); | 
					
						
							| 
									
										
										
										
											2014-01-04 18:08:43 +11:00
										 |  |  | 	*r_free = true; | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return item; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* get the group back from the enum index, quite awkward and UI specific */ | 
					
						
							|  |  |  | static Group *group_object_active_find_index(Object *ob, const int group_object_index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Group *group = NULL; | 
					
						
							|  |  |  | 	int i = 0; | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 	while ((group = BKE_group_object_find(group, ob))) { | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 		if (i == group_object_index) { | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		i++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return group; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | static int objects_add_active_exec(bContext *C, wmOperator *op) | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 	Object *ob = ED_object_context(C); | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	int single_group_index = RNA_enum_get(op->ptr, "group"); | 
					
						
							|  |  |  | 	Group *single_group = group_object_active_find_index(ob, single_group_index); | 
					
						
							|  |  |  | 	Group *group; | 
					
						
							|  |  |  | 	bool is_cycle = false; | 
					
						
							|  |  |  | 	bool updated = false; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	if (ob == NULL) | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							| 
									
										
										
										
											2013-08-07 20:16:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	/* now add all selected objects to the group(s) */ | 
					
						
							|  |  |  | 	for (group = bmain->group.first; group; group = group->id.next) { | 
					
						
							|  |  |  | 		if (single_group && group != single_group) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		if (!BKE_group_object_exists(group, ob)) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2015-02-06 18:10:46 +11:00
										 |  |  | 			if (BKE_group_object_exists(group, base->object)) | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-06 18:10:46 +11:00
										 |  |  | 			if (!BKE_group_object_cyclic_check(bmain, base->object, group)) { | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 				BKE_group_object_add(group, base->object, scene, base); | 
					
						
							|  |  |  | 				updated = true; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 			else { | 
					
						
							|  |  |  | 				is_cycle = true; | 
					
						
							| 
									
										
										
										
											2012-07-18 20:32:31 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 		CTX_DATA_END; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	if (is_cycle) | 
					
						
							|  |  |  | 		BKE_report(op->reports, RPT_WARNING, "Skipped some groups because of cycle detected"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!updated) | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DAG_relations_tag_update(bmain); | 
					
						
							|  |  |  | 	WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | void GROUP_OT_objects_add_active(wmOperatorType *ot) | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->name = "Add Selected To Active Group"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description = "Add the object to an object group that contains the active object"; | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->idname = "GROUP_OT_objects_add_active"; | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 	ot->exec = objects_add_active_exec; | 
					
						
							|  |  |  | 	ot->invoke = WM_menu_invoke; | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							| 
									
										
										
										
											2009-01-31 19:40:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							|  |  |  | 	prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to add other selected objects to"); | 
					
						
							|  |  |  | 	RNA_def_enum_funcs(prop, group_object_active_itemf); | 
					
						
							| 
									
										
										
										
											2014-05-05 15:22:36 +10:00
										 |  |  | 	RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 	ot->prop = prop; | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | static int objects_remove_active_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							|  |  |  | 	Object *ob = OBACT; | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	int single_group_index = RNA_enum_get(op->ptr, "group"); | 
					
						
							|  |  |  | 	Group *single_group = group_object_active_find_index(ob, single_group_index); | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 	Group *group; | 
					
						
							| 
									
										
										
										
											2014-04-11 11:25:41 +10:00
										 |  |  | 	bool ok = false; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	if (ob == NULL) | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 	/* linking to same group requires its own loop so we can avoid
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 	 * looking up the active objects groups each time */ | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	for (group = bmain->group.first; group; group = group->id.next) { | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 		if (single_group && group != single_group) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 		if (BKE_group_object_exists(group, ob)) { | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 			/* Remove groups from selected objects */ | 
					
						
							| 
									
										
										
										
											2012-04-30 16:22:40 +00:00
										 |  |  | 			CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 				BKE_group_object_unlink(group, base->object, scene, base); | 
					
						
							| 
									
										
										
										
											2009-01-20 11:03:53 +00:00
										 |  |  | 				ok = 1; | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 			CTX_DATA_END; | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-01-20 11:03:53 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	if (!ok) | 
					
						
							|  |  |  | 		BKE_report(op->reports, RPT_ERROR, "Active object contains no groups"); | 
					
						
							| 
									
										
										
										
											2009-01-20 11:03:53 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-02-21 19:33:04 +00:00
										 |  |  | 	DAG_relations_tag_update(bmain); | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void GROUP_OT_objects_remove_active(wmOperatorType *ot) | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->name = "Remove Selected From Active Group"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description = "Remove the object from an object group that contains the active object"; | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->idname = "GROUP_OT_objects_remove_active"; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 	/* api callbacks */ | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 	ot->exec = objects_remove_active_exec; | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	ot->invoke = WM_menu_invoke; | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							| 
									
										
										
										
											2009-01-31 19:40:40 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							|  |  |  | 	prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to remove other selected objects from"); | 
					
						
							|  |  |  | 	RNA_def_enum_funcs(prop, group_object_active_itemf); | 
					
						
							| 
									
										
										
										
											2014-05-05 15:22:36 +10:00
										 |  |  | 	RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	ot->prop = prop; | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | static int group_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-30 16:22:40 +00:00
										 |  |  | 	CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2012-07-18 09:45:50 +00:00
										 |  |  | 		BKE_object_groups_clear(scene, base, base->object); | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	CTX_DATA_END; | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-21 19:33:04 +00:00
										 |  |  | 	DAG_relations_tag_update(bmain); | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 	return OPERATOR_FINISHED; | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | void GROUP_OT_objects_remove_all(wmOperatorType *ot) | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 	ot->name = "Remove From All Groups"; | 
					
						
							| 
									
										
										
										
											2013-09-30 05:50:41 +00:00
										 |  |  | 	ot->description = "Remove selected objects from all groups"; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 	ot->idname = "GROUP_OT_objects_remove_all"; | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 	ot->exec = group_objects_remove_all_exec; | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							| 
									
										
										
										
											2009-01-31 19:40:40 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | static int group_objects_remove_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Object *ob = ED_object_context(C); | 
					
						
							|  |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	int single_group_index = RNA_enum_get(op->ptr, "group"); | 
					
						
							|  |  |  | 	Group *single_group = group_object_active_find_index(ob, single_group_index); | 
					
						
							|  |  |  | 	Group *group; | 
					
						
							|  |  |  | 	bool updated = false; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	if (ob == NULL) | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	for (group = bmain->group.first; group; group = group->id.next) { | 
					
						
							|  |  |  | 		if (single_group && group != single_group) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		if (!BKE_group_object_exists(group, ob)) | 
					
						
							|  |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 		/* now remove all selected objects from the group */ | 
					
						
							|  |  |  | 		CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			BKE_group_object_unlink(group, base->object, scene, base); | 
					
						
							|  |  |  | 			updated = true; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 		CTX_DATA_END; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 06:07:10 +01:00
										 |  |  | 	if (!updated) | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DAG_relations_tag_update(bmain); | 
					
						
							|  |  |  | 	WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GROUP_OT_objects_remove(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							|  |  |  | 	ot->name = "Remove From Group"; | 
					
						
							| 
									
										
										
										
											2013-09-30 05:50:41 +00:00
										 |  |  | 	ot->description = "Remove selected objects from a group"; | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 	ot->idname = "GROUP_OT_objects_remove"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							|  |  |  | 	ot->exec = group_objects_remove_exec; | 
					
						
							|  |  |  | 	ot->invoke = WM_menu_invoke; | 
					
						
							|  |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							|  |  |  | 	prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to remove this object from"); | 
					
						
							| 
									
										
										
										
											2012-07-18 08:13:30 +00:00
										 |  |  | 	RNA_def_enum_funcs(prop, group_object_active_itemf); | 
					
						
							| 
									
										
										
										
											2014-05-05 15:22:36 +10:00
										 |  |  | 	RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | 
					
						
							| 
									
										
										
										
											2012-06-20 14:13:22 +00:00
										 |  |  | 	ot->prop = prop; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | static int group_create_exec(bContext *C, wmOperator *op) | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							|  |  |  | 	Group *group = NULL; | 
					
						
							|  |  |  | 	char name[MAX_ID_NAME - 2]; /* id name */ | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-02 11:14:22 +00:00
										 |  |  | 	RNA_string_get(op->ptr, "name", name); | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 	group = BKE_group_add(bmain, name); | 
					
						
							| 
									
										
										
										
											2009-01-20 10:50:36 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2012-12-27 15:55:37 +00:00
										 |  |  | 	CTX_DATA_BEGIN (C, Base *, base, selected_bases) | 
					
						
							| 
									
										
										
										
											2012-04-30 16:22:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 		BKE_group_object_add(group, base->object, scene, base); | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	CTX_DATA_END; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-21 19:33:04 +00:00
										 |  |  | 	DAG_relations_tag_update(bmain); | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-02 11:14:22 +00:00
										 |  |  | void GROUP_OT_create(wmOperatorType *ot) | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->name = "Create New Group"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description = "Create an object group from selected objects"; | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->idname = "GROUP_OT_create"; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-01-20 03:41:23 +00:00
										 |  |  | 	/* api callbacks */ | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 	ot->exec = group_create_exec; | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-01-31 19:40:40 +00:00
										 |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							| 
									
										
										
										
											2009-01-31 19:40:40 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME - 2, "Name", "Name of the new group"); | 
					
						
							| 
									
										
										
										
											2009-01-13 15:18:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | /****************** properties window operators *********************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-15 01:36:14 +00:00
										 |  |  | static int group_add_exec(bContext *C, wmOperator *UNUSED(op)) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							|  |  |  | 	Object *ob = ED_object_context(C); | 
					
						
							| 
									
										
										
										
											2013-02-05 12:46:15 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	Group *group; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (ob == NULL) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 	group = BKE_group_add(bmain, "Group"); | 
					
						
							|  |  |  | 	BKE_group_object_add(group, ob, scene, NULL); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | void OBJECT_OT_group_add(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->name = "Add to Group"; | 
					
						
							|  |  |  | 	ot->idname = "OBJECT_OT_group_add"; | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 	ot->description = "Add an object to a new group"; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 	/* api callbacks */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->exec = group_add_exec; | 
					
						
							| 
									
										
										
										
											2012-08-26 08:03:31 +00:00
										 |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | static int group_link_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-06-11 11:21:16 +00:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							|  |  |  | 	Object *ob = ED_object_context(C); | 
					
						
							| 
									
										
										
										
											2014-04-30 07:48:54 +10:00
										 |  |  | 	Group *group = BLI_findlink(&bmain->group, RNA_enum_get(op->ptr, "group")); | 
					
						
							| 
									
										
										
										
											2010-01-27 21:19:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (ELEM(NULL, ob, group)) | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-11 11:21:16 +00:00
										 |  |  | 	/* Early return check, if the object is already in group
 | 
					
						
							|  |  |  | 	 * we could sckip all the dependency check and just consider | 
					
						
							|  |  |  | 	 * operator is finished. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2015-02-06 18:10:46 +11:00
										 |  |  | 	if (BKE_group_object_exists(group, ob)) { | 
					
						
							| 
									
										
										
										
											2013-06-11 11:21:16 +00:00
										 |  |  | 		return OPERATOR_FINISHED; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Adding object to group which is used as dupligroup for self is bad idea.
 | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * It is also  bad idea to add object to group which is in group which | 
					
						
							|  |  |  | 	 * contains our current object. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2015-02-06 18:10:46 +11:00
										 |  |  | 	if (BKE_group_object_cyclic_check(bmain, ob, group)) { | 
					
						
							| 
									
										
										
										
											2013-06-11 11:21:16 +00:00
										 |  |  | 		BKE_report(op->reports, RPT_ERROR, "Could not add the group because of dependency cycle detected"); | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 	BKE_group_object_add(group, ob, scene, NULL); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 	return OPERATOR_FINISHED; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | void OBJECT_OT_group_link(wmOperatorType *ot) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->name = "Link to Group"; | 
					
						
							|  |  |  | 	ot->idname = "OBJECT_OT_group_link"; | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 	ot->description = "Add an object to an existing group"; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->exec = group_link_exec; | 
					
						
							|  |  |  | 	ot->invoke = WM_enum_search_invoke; | 
					
						
							| 
									
										
										
										
											2012-08-26 08:03:31 +00:00
										 |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); | 
					
						
							| 
									
										
										
										
											2010-05-05 15:41:38 +00:00
										 |  |  | 	RNA_def_enum_funcs(prop, RNA_group_local_itemf); | 
					
						
							| 
									
										
										
										
											2014-05-05 15:09:29 +10:00
										 |  |  | 	RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->prop = prop; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-15 01:36:14 +00:00
										 |  |  | static int group_remove_exec(bContext *C, wmOperator *UNUSED(op)) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							|  |  |  | 	Object *ob = ED_object_context(C); | 
					
						
							|  |  |  | 	Group *group = CTX_data_pointer_get_type(C, "group", &RNA_Group).data; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!ob || !group) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-03 11:28:42 +00:00
										 |  |  | 	BKE_group_object_unlink(group, ob, scene, NULL); /* base will be used if found */ | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void OBJECT_OT_group_remove(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->name = "Remove Group"; | 
					
						
							|  |  |  | 	ot->idname = "OBJECT_OT_group_remove"; | 
					
						
							| 
									
										
										
										
											2012-05-05 17:10:51 +00:00
										 |  |  | 	ot->description = "Remove the active object from this group"; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							| 
									
										
										
										
											2012-03-22 07:26:09 +00:00
										 |  |  | 	ot->exec = group_remove_exec; | 
					
						
							| 
									
										
										
										
											2012-08-26 08:03:31 +00:00
										 |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2012-04-28 15:42:27 +00:00
										 |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-06 20:03:16 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int group_unlink_exec(bContext *C, wmOperator *UNUSED(op)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-11-02 21:20:03 +11:00
										 |  |  | 	Main *bmain = CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2014-08-06 20:03:16 +02:00
										 |  |  | 	Group *group = CTX_data_pointer_get_type(C, "group", &RNA_Group).data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!group) | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-02 21:20:03 +11:00
										 |  |  | 	BKE_group_unlink(bmain, group); | 
					
						
							| 
									
										
										
										
											2014-08-06 20:03:16 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void OBJECT_OT_group_unlink(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							|  |  |  | 	ot->name = "Unlink Group"; | 
					
						
							|  |  |  | 	ot->idname = "OBJECT_OT_group_unlink"; | 
					
						
							|  |  |  | 	ot->description = "Unlink the group from all objects"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							|  |  |  | 	ot->exec = group_unlink_exec; | 
					
						
							|  |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op))  /* Select objects in the same group as the active */ | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Group *group = CTX_data_pointer_get_type(C, "group", &RNA_Group).data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!group) | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	CTX_DATA_BEGIN (C, Base *, base, visible_bases) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (!(base->flag & SELECT) && BKE_group_object_exists(group, base->object)) { | 
					
						
							|  |  |  | 			ED_base_object_select(base, BA_SELECT); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	CTX_DATA_END; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void OBJECT_OT_grouped_select(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							|  |  |  | 	ot->name = "Select Grouped"; | 
					
						
							|  |  |  | 	ot->idname = "OBJECT_OT_grouped_select"; | 
					
						
							|  |  |  | 	ot->description = "Select all objects in group"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							|  |  |  | 	ot->exec = select_grouped_exec; | 
					
						
							|  |  |  | 	ot->poll = ED_operator_objectmode; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | 
					
						
							|  |  |  | } |