2008-12-12 18:47:12 +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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-12 18:47:12 +00:00
|
|
|
*
|
2008-12-20 12:36:14 +00:00
|
|
|
* The Original Code is Copyright (C) 2004-2008 Blender Foundation.
|
2008-12-12 18:47:12 +00:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
2008-12-20 12:36:14 +00:00
|
|
|
#include <stdlib.h>
|
2008-12-12 18:47:12 +00:00
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
2009-02-07 03:21:28 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
2008-12-12 18:47:12 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2008-12-20 12:36:14 +00:00
|
|
|
#include "BKE_action.h"
|
2009-02-07 03:21:28 +00:00
|
|
|
#include "BKE_brush.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2008-12-20 12:36:14 +00:00
|
|
|
#include "BKE_curve.h"
|
|
|
|
|
#include "BKE_depsgraph.h"
|
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_image.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_modifier.h"
|
2009-08-15 19:48:50 +00:00
|
|
|
#include "BKE_paint.h"
|
2008-12-20 12:36:14 +00:00
|
|
|
#include "BKE_particle.h"
|
2008-12-12 18:47:12 +00:00
|
|
|
#include "BKE_screen.h"
|
2008-12-20 12:36:14 +00:00
|
|
|
#include "BKE_utildefines.h" /* for VECCOPY */
|
2008-12-12 18:47:12 +00:00
|
|
|
|
2009-01-01 18:05:12 +00:00
|
|
|
#include "ED_mesh.h"
|
2008-12-12 18:47:12 +00:00
|
|
|
#include "ED_util.h"
|
2009-01-05 19:32:04 +00:00
|
|
|
#include "ED_screen.h"
|
2009-07-08 16:17:47 +00:00
|
|
|
#include "ED_transform.h"
|
2008-12-19 12:48:30 +00:00
|
|
|
#include "ED_types.h"
|
2008-12-12 18:47:12 +00:00
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
#include "RNA_define.h"
|
2009-08-16 16:38:32 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2009-02-20 18:01:33 +00:00
|
|
|
|
2008-12-12 18:47:12 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-12-20 12:36:14 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
|
|
2008-12-12 18:47:12 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
|
|
#include "view3d_intern.h"
|
|
|
|
|
|
|
|
|
|
|
2008-12-20 12:36:14 +00:00
|
|
|
/* View3d->modeselect
|
|
|
|
|
* This is a bit of a dodgy hack to enable a 'mode' menu with icons+labels
|
|
|
|
|
* rather than those buttons.
|
|
|
|
|
* I know the implementation's not good - it's an experiment to see if this
|
|
|
|
|
* approach would work well
|
|
|
|
|
*
|
|
|
|
|
* This can be cleaned when I make some new 'mode' icons.
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-31 22:43:29 +00:00
|
|
|
#define TEST_EDITMESH if(obedit==0) return; \
|
|
|
|
|
if( (v3d->lay & obedit->lay)==0 ) return;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-07-03 04:24:19 +00:00
|
|
|
/* XXX port over */
|
2008-12-20 18:43:21 +00:00
|
|
|
extern void borderselect();
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
/* view3d handler codes */
|
|
|
|
|
#define VIEW3D_HANDLER_BACKGROUND 1
|
|
|
|
|
#define VIEW3D_HANDLER_PROPERTIES 2
|
|
|
|
|
#define VIEW3D_HANDLER_OBJECT 3
|
|
|
|
|
#define VIEW3D_HANDLER_PREVIEW 4
|
|
|
|
|
#define VIEW3D_HANDLER_MULTIRES 5
|
|
|
|
|
#define VIEW3D_HANDLER_TRANSFORM 6
|
|
|
|
|
#define VIEW3D_HANDLER_GREASEPENCIL 7
|
2009-03-17 21:44:58 +00:00
|
|
|
#define VIEW3D_HANDLER_BONESKETCH 8
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
/* end XXX ************* */
|
|
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
static void do_view3d_header_buttons(bContext *C, void *arg, int event);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
#define B_SCENELOCK 101
|
|
|
|
|
#define B_FULL 102
|
|
|
|
|
#define B_HOME 103
|
|
|
|
|
#define B_VIEWBUT 104
|
|
|
|
|
#define B_PERSP 105
|
|
|
|
|
#define B_MODESELECT 108
|
|
|
|
|
#define B_SEL_VERT 110
|
|
|
|
|
#define B_SEL_EDGE 111
|
|
|
|
|
#define B_SEL_FACE 112
|
|
|
|
|
#define B_MAN_TRANS 116
|
|
|
|
|
#define B_MAN_ROT 117
|
|
|
|
|
#define B_MAN_SCALE 118
|
|
|
|
|
#define B_NDOF 119
|
|
|
|
|
#define B_MAN_MODE 120
|
|
|
|
|
#define B_REDR 122
|
|
|
|
|
#define B_NOP 123
|
2009-10-26 12:42:25 +00:00
|
|
|
|
2009-07-03 04:24:19 +00:00
|
|
|
// XXX quickly ported across
|
|
|
|
|
static void handle_view3d_lock(bContext *C)
|
|
|
|
|
{
|
2009-10-26 12:42:25 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
2009-07-03 04:24:19 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
2009-07-28 16:33:02 +00:00
|
|
|
View3D *v3d= CTX_wm_view3d(C);
|
2009-07-03 04:24:19 +00:00
|
|
|
|
|
|
|
|
if (v3d != NULL && sa != NULL) {
|
2009-09-22 04:40:16 +00:00
|
|
|
if(v3d->localvd==NULL && v3d->scenelock && sa->spacetype==SPACE_VIEW3D) {
|
2009-07-03 04:24:19 +00:00
|
|
|
/* copy to scene */
|
|
|
|
|
scene->lay= v3d->lay;
|
|
|
|
|
scene->camera= v3d->camera;
|
2009-10-26 12:42:25 +00:00
|
|
|
|
|
|
|
|
/* not through notifiery, listener don't have context
|
|
|
|
|
and non-open screens or spaces need to be updated too */
|
|
|
|
|
ED_view3d_scene_layers_update(bmain, scene);
|
2009-07-03 04:24:19 +00:00
|
|
|
|
2009-10-19 04:56:19 +00:00
|
|
|
/* notifiers for scene update */
|
2009-10-26 12:42:25 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_LAYER, scene);
|
2009-07-03 04:24:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
static int layers_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
|
View3D *v3d= sa->spacedata.first;
|
|
|
|
|
int nr= RNA_int_get(op->ptr, "nr");
|
2010-01-03 04:21:40 +00:00
|
|
|
int toggle= RNA_boolean_get(op->ptr, "toggle");
|
2009-02-20 18:01:33 +00:00
|
|
|
|
2009-09-22 04:40:16 +00:00
|
|
|
if(nr < 0)
|
2009-02-20 18:01:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-09-22 04:40:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if(nr == 0) {
|
|
|
|
|
/* all layers */
|
|
|
|
|
v3d->lay |= (1<<20)-1;
|
|
|
|
|
|
|
|
|
|
if(!v3d->layact)
|
|
|
|
|
v3d->layact= 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2010-01-30 15:23:17 +00:00
|
|
|
int bit;
|
2009-09-22 04:40:16 +00:00
|
|
|
nr--;
|
|
|
|
|
|
2010-01-03 04:21:40 +00:00
|
|
|
if(RNA_boolean_get(op->ptr, "extend")) {
|
|
|
|
|
if(toggle && v3d->lay & (1<<nr) && (v3d->lay & ~(1<<nr)))
|
|
|
|
|
v3d->lay &= ~(1<<nr);
|
|
|
|
|
else
|
|
|
|
|
v3d->lay |= (1<<nr);
|
2010-01-30 15:23:17 +00:00
|
|
|
} else {
|
2009-09-22 04:40:16 +00:00
|
|
|
v3d->lay = (1<<nr);
|
2010-01-30 15:23:17 +00:00
|
|
|
|
|
|
|
|
/* sanity check - when in editmode disallow switching the editmode layer off since its confusing
|
|
|
|
|
* an alternative would be to always draw the editmode object. */
|
|
|
|
|
if(scene->obedit && (scene->obedit->lay & v3d->lay)==0) {
|
|
|
|
|
for(bit=0; bit<32; bit++) {
|
|
|
|
|
if(scene->obedit->lay & (1<<bit)) {
|
|
|
|
|
v3d->lay |= 1<<bit;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-19 16:53:57 +00:00
|
|
|
|
2009-09-22 04:40:16 +00:00
|
|
|
/* set active layer, ensure to always have one */
|
|
|
|
|
if(v3d->lay & (1<<nr))
|
|
|
|
|
v3d->layact= 1<<nr;
|
|
|
|
|
else if((v3d->lay & v3d->layact)==0) {
|
2010-01-30 15:23:17 +00:00
|
|
|
for(bit=0; bit<32; bit++) {
|
2009-09-22 04:40:16 +00:00
|
|
|
if(v3d->lay & (1<<bit)) {
|
|
|
|
|
v3d->layact= 1<<bit;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-07-19 16:53:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-03 04:24:19 +00:00
|
|
|
if(v3d->scenelock) handle_view3d_lock(C);
|
2009-02-20 18:01:33 +00:00
|
|
|
|
|
|
|
|
/* new layers might need unflushed events events */
|
|
|
|
|
DAG_scene_update_flags(scene, v3d->lay); /* tags all that moves and flushes */
|
|
|
|
|
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* applies shift and alt, lazy coding or ok? :) */
|
|
|
|
|
/* the local per-keymap-entry keymap will solve it */
|
|
|
|
|
static int layers_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if(event->ctrl || event->oskey)
|
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
|
|
|
|
if(event->shift)
|
|
|
|
|
RNA_boolean_set(op->ptr, "extend", 1);
|
|
|
|
|
|
|
|
|
|
if(event->alt) {
|
|
|
|
|
int nr= RNA_int_get(op->ptr, "nr") + 10;
|
|
|
|
|
RNA_int_set(op->ptr, "nr", nr);
|
|
|
|
|
}
|
|
|
|
|
layers_exec(C, op);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-03 04:21:40 +00:00
|
|
|
int layers_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd==NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
void VIEW3D_OT_layers(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Layers";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description= "Toggle layer(s) visibility";
|
2009-02-20 18:01:33 +00:00
|
|
|
ot->idname= "VIEW3D_OT_layers";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= layers_invoke;
|
|
|
|
|
ot->exec= layers_exec;
|
2010-01-03 04:21:40 +00:00
|
|
|
ot->poll= layers_poll;
|
2009-02-20 18:01:33 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
2009-09-22 04:40:16 +00:00
|
|
|
RNA_def_int(ot->srna, "nr", 1, 0, 20, "Number", "The layer number to set, zero for all layers", 0, 20);
|
|
|
|
|
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Add this layer to the current view layers");
|
2010-01-03 04:21:40 +00:00
|
|
|
RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
|
2009-02-20 18:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-20 12:36:14 +00:00
|
|
|
static char *view3d_modeselect_pup(Scene *scene)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= OBACT;
|
|
|
|
|
static char string[1024];
|
|
|
|
|
static char formatstr[] = "|%s %%x%d %%i%d";
|
|
|
|
|
char *str = string;
|
|
|
|
|
|
|
|
|
|
str += sprintf(str, "Mode: %%t");
|
|
|
|
|
|
2009-08-16 16:38:32 +00:00
|
|
|
str += sprintf(str, formatstr, "Object Mode", OB_MODE_OBJECT, ICON_OBJECT_DATA);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
if(ob==NULL) return string;
|
|
|
|
|
|
|
|
|
|
/* if active object is editable */
|
2009-09-08 02:09:14 +00:00
|
|
|
if ( ((ob->type == OB_MESH)
|
2008-12-20 12:36:14 +00:00
|
|
|
|| (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
|
|
|
|
|
|| (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
|
|
|
|
|
|
2009-08-16 16:38:32 +00:00
|
|
|
str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
2009-09-08 02:09:14 +00:00
|
|
|
else if (ob->type == OB_ARMATURE) {
|
|
|
|
|
if (ob->mode & OB_MODE_POSE)
|
|
|
|
|
str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
|
|
|
|
|
else
|
|
|
|
|
str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
|
|
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
|
|
2009-08-16 16:38:32 +00:00
|
|
|
str += sprintf(str, formatstr, "Sculpt Mode", OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
|
|
|
|
|
str += sprintf(str, formatstr, "Vertex Paint", OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
|
|
|
|
|
str += sprintf(str, formatstr, "Texture Paint", OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
|
|
|
|
|
str += sprintf(str, formatstr, "Weight Paint", OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* if active object is an armature */
|
|
|
|
|
if (ob->type==OB_ARMATURE) {
|
2009-08-16 16:38:32 +00:00
|
|
|
str += sprintf(str, formatstr, "Pose Mode", OB_MODE_POSE, ICON_POSE_HLT);
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-29 15:20:36 +00:00
|
|
|
if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) {
|
2009-08-16 16:38:32 +00:00
|
|
|
str += sprintf(str, formatstr, "Particle Mode", OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
static void do_view3d_header_buttons(bContext *C, void *arg, int event)
|
2008-12-20 12:36:14 +00:00
|
|
|
{
|
2009-02-20 18:01:33 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
2009-06-23 00:41:55 +00:00
|
|
|
ToolSettings *ts= CTX_data_tool_settings(C);
|
2008-12-20 12:36:14 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
|
View3D *v3d= sa->spacedata.first;
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2009-01-01 18:05:12 +00:00
|
|
|
EditMesh *em= NULL;
|
2009-12-03 09:49:21 +00:00
|
|
|
int ctrl= win->eventstate->ctrl, shift= win->eventstate->shift;
|
2009-08-16 16:38:32 +00:00
|
|
|
PointerRNA props_ptr;
|
2009-01-01 18:05:12 +00:00
|
|
|
|
|
|
|
|
if(obedit && obedit->type==OB_MESH) {
|
2009-04-11 08:26:51 +00:00
|
|
|
em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
|
2009-01-01 18:05:12 +00:00
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
/* watch it: if sa->win does not exist, check that when calling direct drawing routines */
|
|
|
|
|
|
|
|
|
|
switch(event) {
|
2009-01-12 09:04:53 +00:00
|
|
|
case B_REDR:
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
case B_MODESELECT:
|
2009-08-16 16:38:32 +00:00
|
|
|
WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
|
|
|
|
|
RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
|
|
|
|
|
WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr);
|
2009-09-08 02:09:14 +00:00
|
|
|
WM_operator_properties_free(&props_ptr);
|
2009-08-16 16:38:32 +00:00
|
|
|
break;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
case B_SEL_VERT:
|
2009-01-01 18:05:12 +00:00
|
|
|
if(em) {
|
|
|
|
|
if(shift==0 || em->selectmode==0)
|
|
|
|
|
em->selectmode= SCE_SELECT_VERTEX;
|
2009-06-23 00:41:55 +00:00
|
|
|
ts->selectmode= em->selectmode;
|
2009-01-01 18:05:12 +00:00
|
|
|
EM_selectmode_set(em);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
|
2009-01-01 18:05:12 +00:00
|
|
|
ED_undo_push(C, "Selectmode Set: Vertex");
|
|
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
break;
|
|
|
|
|
case B_SEL_EDGE:
|
2009-01-01 18:05:12 +00:00
|
|
|
if(em) {
|
|
|
|
|
if(shift==0 || em->selectmode==0){
|
|
|
|
|
if( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){
|
|
|
|
|
if(ctrl) EM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE);
|
|
|
|
|
}
|
|
|
|
|
em->selectmode = SCE_SELECT_EDGE;
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
2009-06-23 00:41:55 +00:00
|
|
|
ts->selectmode= em->selectmode;
|
2009-01-01 18:05:12 +00:00
|
|
|
EM_selectmode_set(em);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
|
2009-01-01 18:05:12 +00:00
|
|
|
ED_undo_push(C, "Selectmode Set: Edge");
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case B_SEL_FACE:
|
2009-01-01 18:05:12 +00:00
|
|
|
if(em) {
|
|
|
|
|
if( shift==0 || em->selectmode==0){
|
2009-06-23 00:41:55 +00:00
|
|
|
if( ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){
|
|
|
|
|
if(ctrl) EM_convertsel(em, (ts->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE);
|
2009-01-01 18:05:12 +00:00
|
|
|
}
|
|
|
|
|
em->selectmode = SCE_SELECT_FACE;
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
2009-06-23 00:41:55 +00:00
|
|
|
ts->selectmode= em->selectmode;
|
2009-01-01 18:05:12 +00:00
|
|
|
EM_selectmode_set(em);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
|
2009-01-01 18:05:12 +00:00
|
|
|
ED_undo_push(C, "Selectmode Set: Face");
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case B_MAN_TRANS:
|
2009-07-08 15:01:28 +00:00
|
|
|
if( shift==0 || v3d->twtype==0) {
|
2008-12-20 12:36:14 +00:00
|
|
|
v3d->twtype= V3D_MANIP_TRANSLATE;
|
2009-07-08 15:01:28 +00:00
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
2008-12-20 12:36:14 +00:00
|
|
|
case B_MAN_ROT:
|
2009-07-08 15:01:28 +00:00
|
|
|
if( shift==0 || v3d->twtype==0) {
|
2010-03-22 09:30:00 +00:00
|
|
|
v3d->twtype= V3D_MANIP_ROTATE;
|
2009-07-08 15:01:28 +00:00
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2008-12-20 12:36:14 +00:00
|
|
|
break;
|
|
|
|
|
case B_MAN_SCALE:
|
2009-07-08 15:01:28 +00:00
|
|
|
if( shift==0 || v3d->twtype==0) {
|
2010-03-22 09:30:00 +00:00
|
|
|
v3d->twtype= V3D_MANIP_SCALE;
|
2009-07-08 15:01:28 +00:00
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2008-12-20 12:36:14 +00:00
|
|
|
break;
|
|
|
|
|
case B_NDOF:
|
2010-03-22 09:30:00 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2008-12-20 12:36:14 +00:00
|
|
|
break;
|
|
|
|
|
case B_MAN_MODE:
|
2010-03-22 09:30:00 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2008-12-20 12:36:14 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-03-30 07:28:37 +00:00
|
|
|
|
2009-03-30 13:53:48 +00:00
|
|
|
if(obedit && obedit->type==OB_MESH)
|
2009-04-11 08:26:51 +00:00
|
|
|
BKE_mesh_end_editmesh(obedit->data, em);
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-16 16:38:32 +00:00
|
|
|
/* Returns the icon associated with an object mode */
|
|
|
|
|
static int object_mode_icon(int mode)
|
|
|
|
|
{
|
|
|
|
|
EnumPropertyItem *item = object_mode_items;
|
|
|
|
|
|
|
|
|
|
while(item->name != NULL) {
|
|
|
|
|
if(item->value == mode)
|
|
|
|
|
return item->icon;
|
|
|
|
|
++item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ICON_OBJECT_DATAMODE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-11 13:32:20 +00:00
|
|
|
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
|
2008-12-20 12:36:14 +00:00
|
|
|
{
|
2009-11-28 18:19:34 +00:00
|
|
|
bScreen *screen= CTX_wm_screen(C);
|
2008-12-20 12:36:14 +00:00
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
|
View3D *v3d= sa->spacedata.first;
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-06-23 00:41:55 +00:00
|
|
|
ToolSettings *ts= CTX_data_tool_settings(C);
|
2009-11-29 02:42:47 +00:00
|
|
|
PointerRNA v3dptr, toolsptr, sceneptr;
|
2008-12-20 12:36:14 +00:00
|
|
|
Object *ob= OBACT;
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2008-12-20 12:36:14 +00:00
|
|
|
uiBlock *block;
|
2009-11-01 14:04:37 +00:00
|
|
|
uiLayout *row;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 21:27:28 +00:00
|
|
|
RNA_pointer_create(&screen->id, &RNA_Space3DView, v3d, &v3dptr);
|
2009-11-28 19:38:05 +00:00
|
|
|
RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
|
2009-11-29 02:42:47 +00:00
|
|
|
RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);
|
2009-11-28 19:38:05 +00:00
|
|
|
|
2009-11-28 21:52:37 +00:00
|
|
|
block= uiLayoutGetBlock(layout);
|
2009-02-10 15:38:00 +00:00
|
|
|
uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
/* other buttons: */
|
|
|
|
|
uiBlockSetEmboss(block, UI_EMBOSS);
|
|
|
|
|
|
|
|
|
|
/* mode */
|
2009-08-16 16:38:32 +00:00
|
|
|
if(ob)
|
|
|
|
|
v3d->modeselect = ob->mode;
|
|
|
|
|
else
|
|
|
|
|
v3d->modeselect = OB_MODE_OBJECT;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
v3d->flag &= ~V3D_MODE;
|
|
|
|
|
|
|
|
|
|
/* not sure what the v3d->flag is useful for now... modeselect is confusing */
|
2008-12-31 22:43:29 +00:00
|
|
|
if(obedit) v3d->flag |= V3D_EDITMODE;
|
2009-08-16 03:24:23 +00:00
|
|
|
if(ob && (ob->mode & OB_MODE_POSE)) v3d->flag |= V3D_POSEMODE;
|
2009-08-15 20:36:15 +00:00
|
|
|
if(ob && (ob->mode & OB_MODE_VERTEX_PAINT)) v3d->flag |= V3D_VERTEXPAINT;
|
2009-08-15 21:46:25 +00:00
|
|
|
if(ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) v3d->flag |= V3D_WEIGHTPAINT;
|
2009-08-16 01:25:53 +00:00
|
|
|
if(ob && (ob->mode & OB_MODE_TEXTURE_PAINT)) v3d->flag |= V3D_TEXTUREPAINT;
|
2009-08-15 19:48:50 +00:00
|
|
|
if(paint_facesel_test(ob)) v3d->flag |= V3D_FACESELECT;
|
2009-08-16 16:38:32 +00:00
|
|
|
|
2009-11-28 21:52:37 +00:00
|
|
|
uiBlockBeginAlign(block);
|
2009-08-16 16:38:32 +00:00
|
|
|
uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) ,
|
2009-11-29 06:10:26 +00:00
|
|
|
0,0,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode");
|
2009-11-28 21:52:37 +00:00
|
|
|
uiBlockEndAlign(block);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 21:27:28 +00:00
|
|
|
/* Draw type */
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemR(layout, &v3dptr, "viewport_shading", UI_ITEM_R_ICON_ONLY, "", 0);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) {
|
|
|
|
|
/* Manipulators aren't used in weight paint mode */
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 21:27:28 +00:00
|
|
|
PointerRNA meshptr;
|
|
|
|
|
|
|
|
|
|
RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr);
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", 0);
|
2009-11-28 21:27:28 +00:00
|
|
|
} else {
|
|
|
|
|
char *str_menu;
|
|
|
|
|
|
|
|
|
|
row= uiLayoutRow(layout, 1);
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", 0);
|
|
|
|
|
uiItemR(row, &v3dptr, "pivot_point_align", UI_ITEM_R_ICON_ONLY, "", 0);
|
2009-11-28 21:27:28 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
/* NDOF */
|
2009-12-03 09:49:21 +00:00
|
|
|
/* Not implemented yet
|
|
|
|
|
if (G.ndofdevice ==0 ) {
|
2009-11-28 21:52:37 +00:00
|
|
|
uiDefIconTextButC(block, ICONTEXTROW,B_NDOF, ICON_NDOF_TURN, ndof_pup(), 0,0,XIC+10,YIC, &(v3d->ndofmode), 0, 3.0, 0, 0, "Ndof mode");
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
uiDefIconButC(block, TOG, B_NDOF, ICON_NDOF_DOM,
|
2010-03-22 09:30:00 +00:00
|
|
|
0,0,XIC,YIC,
|
|
|
|
|
&v3d->ndoffilter, 0, 1, 0, 0, "dominant axis");
|
2009-11-28 20:02:10 +00:00
|
|
|
}
|
2009-12-03 09:49:21 +00:00
|
|
|
*/
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
/* Transform widget / manipulators */
|
2009-11-28 21:52:37 +00:00
|
|
|
row= uiLayoutRow(layout, 1);
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemR(row, &v3dptr, "manipulator", UI_ITEM_R_ICON_ONLY, "", 0);
|
2009-11-28 21:52:37 +00:00
|
|
|
block= uiLayoutGetBlock(row);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
if(v3d->twflag & V3D_USE_MANIPULATOR) {
|
2009-11-29 06:10:26 +00:00
|
|
|
uiDefIconButBitS(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode");
|
|
|
|
|
uiDefIconButBitS(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode");
|
|
|
|
|
uiDefIconButBitS(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode");
|
2009-11-28 20:02:10 +00:00
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) {
|
|
|
|
|
v3d->twmode = 0;
|
|
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
str_menu = BIF_menustringTransformOrientation(C, "Orientation");
|
2009-11-29 06:10:26 +00:00
|
|
|
uiDefButS(block, MENU, B_MAN_MODE, str_menu,0,0,70,YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation");
|
2009-11-28 20:02:10 +00:00
|
|
|
MEM_freeN(str_menu);
|
|
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 20:02:10 +00:00
|
|
|
if(obedit==NULL && v3d->localvd==NULL) {
|
|
|
|
|
int ob_lay = ob ? ob->lay : 0;
|
2009-12-03 09:49:21 +00:00
|
|
|
|
2009-11-29 06:04:39 +00:00
|
|
|
/* Layers */
|
2009-12-03 09:49:21 +00:00
|
|
|
if (v3d->scenelock)
|
|
|
|
|
uiTemplateLayers(layout, &sceneptr, "visible_layers", &v3dptr, "used_layers", ob_lay);
|
|
|
|
|
else
|
|
|
|
|
uiTemplateLayers(layout, &v3dptr, "visible_layers", &v3dptr, "used_layers", ob_lay);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-11-28 21:27:28 +00:00
|
|
|
/* Scene lock */
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", 0);
|
2009-11-28 20:02:10 +00:00
|
|
|
}
|
2010-01-30 01:25:02 +00:00
|
|
|
|
|
|
|
|
/* selection modus, dont use python for this since it cant do the toggle buttons with shift+click as well as clicking to set one. */
|
|
|
|
|
if(obedit && (obedit->type == OB_MESH)) {
|
|
|
|
|
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
|
|
|
|
|
|
|
|
|
|
row= uiLayoutRow(layout, 1);
|
|
|
|
|
block= uiLayoutGetBlock(row);
|
|
|
|
|
uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
|
|
|
|
|
uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
|
|
|
|
|
uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
|
|
|
|
|
|
|
|
|
|
BKE_mesh_end_editmesh(obedit->data, em);
|
|
|
|
|
}
|
2008-12-12 18:47:12 +00:00
|
|
|
}
|