2009-01-13 15:18:41 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** 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,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* 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 *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
#include "BKE_global.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"
|
2009-01-13 15:18:41 +00:00
|
|
|
#include "BKE_main.h"
|
2009-01-20 11:03:53 +00:00
|
|
|
#include "BKE_report.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_scene.h"
|
2009-01-13 15:18:41 +00:00
|
|
|
|
2009-01-20 03:41:23 +00:00
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
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 ***********************/
|
|
|
|
|
|
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
|
|
|
{
|
2009-01-20 10:50:36 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-01-13 15:18:41 +00:00
|
|
|
Object *ob= OBACT, *obt;
|
|
|
|
|
Group *group;
|
2009-01-20 11:03:53 +00:00
|
|
|
int ok = 0;
|
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
|
|
|
if(!ob) return OPERATOR_CANCELLED;
|
2009-01-13 15:18:41 +00:00
|
|
|
|
|
|
|
|
/* linking to same group requires its own loop so we can avoid
|
|
|
|
|
looking up the active objects groups each time */
|
|
|
|
|
|
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
|
|
|
for(group= G.main->group.first; group; group=group->id.next) {
|
2009-01-13 15:18:41 +00:00
|
|
|
if(object_in_group(ob, group)) {
|
|
|
|
|
/* Assign groups to selected objects */
|
2009-01-20 10:50:36 +00:00
|
|
|
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
|
|
|
|
obt= base->object;
|
|
|
|
|
add_to_group(group, obt);
|
|
|
|
|
obt->flag |= OB_FROMGROUP;
|
|
|
|
|
base->flag |= OB_FROMGROUP;
|
|
|
|
|
base->object->recalc= OB_RECALC_OB;
|
2009-01-20 11:03:53 +00:00
|
|
|
ok = 1;
|
2009-01-13 15:18:41 +00:00
|
|
|
}
|
2009-01-20 10:50:36 +00:00
|
|
|
CTX_DATA_END;
|
2009-01-13 15:18:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-01-20 11:03:53 +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
|
|
|
if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
|
2009-01-20 11:03:53 +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
|
|
|
DAG_scene_sort(scene);
|
2009-01-20 11:09:26 +00:00
|
|
|
WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);
|
2009-01-20 10:50:36 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2009-01-20 10:50:36 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Add Selected To Active Group";
|
2009-03-22 22:07:52 +00:00
|
|
|
ot->description = "Add the object to an object group that contains the active object.";
|
2009-01-20 10:50:36 +00:00
|
|
|
ot->idname= "GROUP_OT_objects_add_active";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= objects_add_active_exec;
|
|
|
|
|
ot->poll= ED_operator_scene_editable;
|
2009-01-31 19:40:40 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
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)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= OBACT, *obt;
|
|
|
|
|
Group *group;
|
2009-01-20 11:03:53 +00:00
|
|
|
int ok = 0;
|
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
|
|
|
if(!ob) 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
|
|
|
|
|
looking up the active objects groups each time */
|
|
|
|
|
|
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
|
|
|
for(group= G.main->group.first; group; group=group->id.next) {
|
2009-01-20 10:50:36 +00:00
|
|
|
if(object_in_group(ob, group)) {
|
|
|
|
|
/* Assign groups to selected objects */
|
|
|
|
|
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
|
|
|
|
obt= base->object;
|
|
|
|
|
rem_from_group(group, obt);
|
|
|
|
|
obt->flag &= ~OB_FROMGROUP;
|
2009-01-20 03:41:23 +00:00
|
|
|
base->flag &= ~OB_FROMGROUP;
|
2009-01-20 10:50:36 +00:00
|
|
|
base->object->recalc= OB_RECALC_OB;
|
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
|
|
|
|
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
|
|
|
if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
|
2009-01-20 11:03:53 +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
|
|
|
DAG_scene_sort(scene);
|
2009-01-20 11:09:26 +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
|
|
|
{
|
2009-01-20 10:50:36 +00:00
|
|
|
/* identifiers */
|
2009-07-10 13:56:29 +00:00
|
|
|
ot->name= "Remove Selected From Active Group";
|
2009-03-22 22:07:52 +00:00
|
|
|
ot->description = "Remove the object from an object group that contains the active object.";
|
2009-01-20 10:50:36 +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 */
|
|
|
|
|
ot->exec= objects_remove_active_exec;
|
|
|
|
|
ot->poll= ED_operator_scene_editable;
|
2009-01-31 19:40:40 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-01-20 10:50:36 +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
|
|
|
static int group_objects_remove_exec(bContext *C, wmOperator *op)
|
2009-01-20 10:50:36 +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
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-01-20 10:50:36 +00:00
|
|
|
Group *group= NULL;
|
|
|
|
|
|
2009-01-20 03:41:23 +00:00
|
|
|
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
2009-01-20 10:50:36 +00:00
|
|
|
group = 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
|
|
|
while((group = find_group(base->object, group)))
|
2009-01-20 10:50:36 +00:00
|
|
|
rem_from_group(group, base->object);
|
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
|
|
|
|
2009-01-20 10:50:36 +00:00
|
|
|
base->object->flag &= ~OB_FROMGROUP;
|
|
|
|
|
base->flag &= ~OB_FROMGROUP;
|
|
|
|
|
base->object->recalc= OB_RECALC_OB;
|
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
|
|
|
|
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
|
|
|
DAG_scene_sort(scene);
|
2009-01-20 11:09:26 +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
|
|
|
|
2009-03-29 02:15:13 +00:00
|
|
|
void GROUP_OT_objects_remove(wmOperatorType *ot)
|
2009-01-20 03:41:23 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2009-07-14 20:27:28 +00:00
|
|
|
ot->name= "Remove From Groups";
|
2009-03-29 02:15:13 +00:00
|
|
|
ot->description = "Remove selected objects from all groups.";
|
|
|
|
|
ot->idname= "GROUP_OT_objects_remove";
|
2009-01-20 03:41:23 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
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
|
|
|
ot->exec= group_objects_remove_exec;
|
2009-01-20 03:41:23 +00:00
|
|
|
ot->poll= ED_operator_scene_editable;
|
2009-01-31 19:40:40 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-01-13 15:18:41 +00:00
|
|
|
}
|
2009-01-20 10:50:36 +00:00
|
|
|
|
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
|
|
|
{
|
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
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-01-13 15:18:41 +00:00
|
|
|
Group *group= NULL;
|
2009-01-20 10:50:36 +00:00
|
|
|
char gid[32]; //group id
|
2009-01-20 03:41:23 +00:00
|
|
|
|
2009-01-20 10:50:36 +00:00
|
|
|
RNA_string_get(op->ptr, "GID", gid);
|
2009-01-20 03:41:23 +00:00
|
|
|
|
2009-01-20 10:50:36 +00:00
|
|
|
group= add_group(gid);
|
|
|
|
|
|
2009-01-20 03:41:23 +00:00
|
|
|
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
|
|
|
|
|
add_to_group(group, base->object);
|
|
|
|
|
base->object->flag |= OB_FROMGROUP;
|
|
|
|
|
base->flag |= OB_FROMGROUP;
|
|
|
|
|
base->object->recalc= OB_RECALC_OB;
|
|
|
|
|
}
|
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
|
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
|
|
|
DAG_scene_sort(scene);
|
2009-01-20 11:09:26 +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-01-20 03:41:23 +00:00
|
|
|
void GROUP_OT_group_create(wmOperatorType *ot)
|
2009-01-13 15:18:41 +00:00
|
|
|
{
|
2009-01-20 03:41:23 +00:00
|
|
|
/* identifiers */
|
2009-01-20 10:50:36 +00:00
|
|
|
ot->name= "Create New Group";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Create an object group.";
|
2009-01-20 03:41:23 +00:00
|
|
|
ot->idname= "GROUP_OT_group_create";
|
2009-01-13 15:18:41 +00:00
|
|
|
|
2009-01-20 03:41:23 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= group_create_exec;
|
|
|
|
|
ot->poll= ED_operator_scene_editable;
|
2009-01-13 15:18:41 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
2009-01-20 10:50:36 +00:00
|
|
|
RNA_def_string(ot->srna, "GID", "Group", 32, "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 *********************/
|
|
|
|
|
|
|
|
|
|
static int group_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
Base *base;
|
|
|
|
|
Group *group;
|
|
|
|
|
int value= RNA_enum_get(op->ptr, "group");
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
base= object_in_scene(ob, scene);
|
|
|
|
|
if(!base)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
if(value == -1)
|
|
|
|
|
group= add_group( "Group" );
|
|
|
|
|
else
|
|
|
|
|
group= BLI_findlink(&bmain->group, value);
|
|
|
|
|
|
|
|
|
|
if(group) {
|
|
|
|
|
add_to_group(group, ob);
|
|
|
|
|
ob->flag |= OB_FROMGROUP;
|
|
|
|
|
base->flag |= OB_FROMGROUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem group_items[]= {
|
|
|
|
|
{-1, "ADD_NEW", 0, "Add New Group", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free)
|
|
|
|
|
{
|
2009-10-14 19:19:43 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
|
Group *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
|
|
|
EnumPropertyItem tmp = {0, "", 0, "", ""};
|
|
|
|
|
EnumPropertyItem *item= NULL;
|
|
|
|
|
int a, totitem= 0;
|
|
|
|
|
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, group_items, -1);
|
|
|
|
|
|
|
|
|
|
if(bmain->group.first)
|
|
|
|
|
RNA_enum_item_add_separator(&item, &totitem);
|
|
|
|
|
|
|
|
|
|
for(a=0, group=bmain->group.first; group; group=group->id.next, a++) {
|
|
|
|
|
tmp.value= a;
|
|
|
|
|
tmp.identifier= group->id.name+2;
|
|
|
|
|
tmp.name= group->id.name+2;
|
|
|
|
|
RNA_enum_item_add(&item, &totitem, &tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
*free= 1;
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_group_add(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Add Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_group_add";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= group_add_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
prop= RNA_def_enum(ot->srna, "group", group_items, -1, "Group", "Group to add object to.");
|
|
|
|
|
RNA_def_enum_funcs(prop, group_itemf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int group_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data;
|
|
|
|
|
Base *base;
|
|
|
|
|
|
|
|
|
|
if(!ob || !group)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
base= object_in_scene(ob, scene);
|
|
|
|
|
if(!base)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
rem_from_group(group, ob);
|
|
|
|
|
|
|
|
|
|
if(find_group(ob, NULL) == NULL) {
|
|
|
|
|
ob->flag &= ~OB_FROMGROUP;
|
|
|
|
|
base->flag &= ~OB_FROMGROUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_group_remove(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Remove Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_group_remove";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= group_remove_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|