4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2009 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
35 #include "DNA_action_types.h"
36 #include "DNA_armature_types.h"
37 #include "DNA_curve_types.h"
38 #include "DNA_camera_types.h"
39 #include "DNA_lamp_types.h"
40 #include "DNA_lattice_types.h"
41 #include "DNA_meta_types.h"
42 #include "DNA_mesh_types.h"
43 #include "DNA_meshdata_types.h"
44 #include "DNA_object_types.h"
45 #include "DNA_space_types.h"
46 #include "DNA_scene_types.h"
47 #include "DNA_screen_types.h"
48 #include "DNA_userdef_types.h"
49 #include "DNA_view3d_types.h"
50 #include "DNA_world_types.h"
52 #include "MEM_guardedalloc.h"
54 #include "BLI_arithb.h"
55 #include "BLI_blenlib.h"
56 #include "BLI_editVert.h"
59 #include "BKE_action.h"
60 #include "BKE_brush.h"
61 #include "BKE_context.h"
62 #include "BKE_curve.h"
63 #include "BKE_customdata.h"
64 #include "BKE_depsgraph.h"
65 #include "BKE_idprop.h"
67 #include "BKE_object.h"
68 #include "BKE_global.h"
69 #include "BKE_scene.h"
70 #include "BKE_screen.h"
71 #include "BKE_utildefines.h"
74 #include "BIF_transform.h"
79 #include "RNA_access.h"
80 #include "RNA_define.h"
82 #include "ED_armature.h"
85 #include "ED_keyframing.h"
87 #include "ED_object.h"
88 #include "ED_particle.h"
89 #include "ED_screen.h"
93 #include "UI_interface.h"
94 #include "UI_resources.h"
95 #include "UI_view2d.h"
97 #include "view3d_intern.h" // own include
100 /* ******************* view3d space & buttons ************** */
103 #define B_OBJECTPANELROT 1007
104 #define B_OBJECTPANELMEDIAN 1008
105 #define B_ARMATUREPANEL1 1009
106 #define B_ARMATUREPANEL2 1010
107 #define B_OBJECTPANELPARENT 1011
108 #define B_OBJECTPANEL 1012
109 #define B_ARMATUREPANEL3 1013
110 #define B_OBJECTPANELSCALE 1014
111 #define B_OBJECTPANELDIMS 1015
112 #define B_TRANSFORMSPACEADD 1016
113 #define B_TRANSFORMSPACECLEAR 1017
114 #define B_SETPT_AUTO 2125
115 #define B_SETPT_VECTOR 2126
116 #define B_SETPT_ALIGN 2127
117 #define B_SETPT_FREE 2128
118 #define B_RECALCMBALL 2501
120 #define B_WEIGHT0_0 2840
121 #define B_WEIGHT1_4 2841
122 #define B_WEIGHT1_2 2842
123 #define B_WEIGHT3_4 2843
124 #define B_WEIGHT1_0 2844
126 #define B_OPA1_8 2845
127 #define B_OPA1_4 2846
128 #define B_OPA1_2 2847
129 #define B_OPA3_4 2848
130 #define B_OPA1_0 2849
132 #define B_CLR_WPAINT 2850
134 #define B_RV3D_LOCKED 2900
135 #define B_RV3D_BOXVIEW 2901
136 #define B_RV3D_BOXCLIP 2902
138 #define B_IDNAME 3000
140 /* temporary struct for storing transform properties */
142 float ob_eul[4]; // used for quat too....
143 float ob_scale[3]; // need temp space due to linked values
149 } TransformProperties;
152 /* is used for both read and write... */
153 static void v3d_editvertex_buts(const bContext *C, uiBlock *block, View3D *v3d, Object *ob, float lim)
155 MDeformVert *dvert=NULL;
156 TransformProperties *tfp= v3d->properties_storage;
157 float median[5], ve_median[5];
158 int tot, totw, totweight, totedge;
161 median[0]= median[1]= median[2]= median[3]= median[4]= 0.0;
162 tot= totw= totweight= totedge= 0;
165 if(ob->type==OB_MESH) {
167 EditMesh *em = BKE_mesh_get_editmesh(me);
168 EditVert *eve, *evedef=NULL;
171 eve= em->verts.first;
173 if(eve->f & SELECT) {
176 VecAddf(median, median, eve->co);
180 eed= em->edges.first;
182 if((eed->f & SELECT)) {
184 median[3]+= eed->crease;
189 /* check for defgroups */
191 dvert= CustomData_em_get(&em->vdata, evedef->data, CD_MDEFORMVERT);
192 if(tot==1 && dvert && dvert->totweight) {
194 int i, max=1, init=1;
197 for (i=0; i<dvert->totweight; i++){
198 dg = BLI_findlink (&ob->defbase, dvert->dw[i].def_nr);
200 max+= BLI_snprintf(str, sizeof(str), "%s %%x%d|", dg->name, dvert->dw[i].def_nr);
201 if(max<320) strcat(defstr, str);
203 else printf("oh no!\n");
204 if(tfp->curdef==dvert->dw[i].def_nr) {
206 tfp->defweightp= &dvert->dw[i].weight;
210 if(init) { // needs new initialized
211 tfp->curdef= dvert->dw[0].def_nr;
212 tfp->defweightp= &dvert->dw[0].weight;
216 BKE_mesh_end_editmesh(me, em);
218 else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
225 nu= cu->editnurb->first;
227 if((nu->type & 7)==CU_BEZIER) {
231 if(bezt->f2 & SELECT) {
232 VecAddf(median, median, bezt->vec[1]);
234 median[4]+= bezt->weight;
238 if(bezt->f1 & SELECT) {
239 VecAddf(median, median, bezt->vec[0]);
242 if(bezt->f3 & SELECT) {
243 VecAddf(median, median, bezt->vec[2]);
252 a= nu->pntsu*nu->pntsv;
254 if(bp->f1 & SELECT) {
255 VecAddf(median, median, bp->vec);
256 median[3]+= bp->vec[3];
259 median[4]+= bp->weight;
268 else if(ob->type==OB_LATTICE) {
269 Lattice *lt= ob->data;
273 a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
274 bp= lt->editlatt->def;
276 if(bp->f1 & SELECT) {
277 VecAddf(median, median, bp->vec);
279 median[4]+= bp->weight;
288 median[0] /= (float)tot;
289 median[1] /= (float)tot;
290 median[2] /= (float)tot;
291 if(totedge) median[3] /= (float)totedge;
292 else if(totw) median[3] /= (float)totw;
293 if(totweight) median[4] /= (float)totweight;
295 if(v3d->flag & V3D_GLOBAL_STATS)
296 Mat4MulVecfl(ob->obmat, median);
298 if(block) { // buttons
300 if((ob->parent) && (ob->partype == PARBONE)) but_y = 135;
303 uiBlockBeginAlign(block);
304 uiDefButBitS(block, TOG, V3D_GLOBAL_STATS, B_REDR, "Global", 160, but_y, 70, 19, &v3d->flag, 0, 0, 0, 0, "Displays global values");
305 uiDefButBitS(block, TOGN, V3D_GLOBAL_STATS, B_REDR, "Local", 230, but_y, 70, 19, &v3d->flag, 0, 0, 0, 0, "Displays local values");
306 uiBlockEndAlign(block);
308 memcpy(tfp->ve_median, median, sizeof(tfp->ve_median));
310 uiBlockBeginAlign(block);
312 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex X:", 10, 110, 290, 19, &(tfp->ve_median[0]), -lim, lim, 10, 3, "");
313 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Y:", 10, 90, 290, 19, &(tfp->ve_median[1]), -lim, lim, 10, 3, "");
314 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex Z:", 10, 70, 290, 19, &(tfp->ve_median[2]), -lim, lim, 10, 3, "");
316 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Vertex W:", 10, 50, 290, 19, &(tfp->ve_median[3]), 0.01, 100.0, 10, 3, "");
317 uiBlockEndAlign(block);
320 uiDefBut(block, LABEL, 1, "Vertex Deform Groups", 10, 40, 290, 20, NULL, 0.0, 0.0, 0, 0, "");
322 uiBlockBeginAlign(block);
323 uiDefButF(block, NUM, B_NOP, "Weight:", 10, 20, 150, 19, tfp->defweightp, 0.0f, 1.0f, 10, 3, "Weight value");
324 uiDefButI(block, MENU, B_REDR, defstr, 160, 20, 140, 19, &tfp->curdef, 0.0, 0.0, 0, 0, "Current Vertex Group");
325 uiBlockEndAlign(block);
328 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Weight:", 10, 20, 290, 19, &(tfp->ve_median[4]), 0.0, 1.0, 10, 3, "");
332 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median X:", 10, 110, 290, 19, &(tfp->ve_median[0]), -lim, lim, 10, 3, "");
333 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Y:", 10, 90, 290, 19, &(tfp->ve_median[1]), -lim, lim, 10, 3, "");
334 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Z:", 10, 70, 290, 19, &(tfp->ve_median[2]), -lim, lim, 10, 3, "");
336 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median W:", 10, 50, 290, 19, &(tfp->ve_median[3]), 0.01, 100.0, 10, 3, "");
337 uiBlockEndAlign(block);
339 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Weight:", 10, 20, 290, 19, &(tfp->ve_median[4]), 0.0, 1.0, 10, 3, "Weight is used for SoftBody Goal");
342 if(ob->type==OB_CURVE && (totw==0)) { /* bez curves have no w */
343 uiBlockBeginAlign(block);
344 uiDefBut(block, BUT,B_SETPT_AUTO,"Auto", 10, 44, 72, 19, 0, 0, 0, 0, 0, "Auto handles (Shift H)");
345 uiDefBut(block, BUT,B_SETPT_VECTOR,"Vector",82, 44, 73, 19, 0, 0, 0, 0, 0, "Vector handles (V)");
346 uiDefBut(block, BUT,B_SETPT_ALIGN,"Align",155, 44, 73, 19, 0, 0, 0, 0, 0, "Align handles (H Toggles)");
347 uiDefBut(block, BUT,B_SETPT_FREE,"Free", 227, 44, 72, 19, 0, 0, 0, 0, 0, "Align handles (H Toggles)");
348 uiBlockEndAlign(block);
352 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Crease W:", 10, 30, 290, 19, &(tfp->ve_median[3]), 0.0, 1.0, 10, 3, "");
354 uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Median Crease W:", 10, 30, 290, 19, &(tfp->ve_median[3]), 0.0, 1.0, 10, 3, "");
358 memcpy(ve_median, tfp->ve_median, sizeof(tfp->ve_median));
360 if(v3d->flag & V3D_GLOBAL_STATS) {
361 Mat4Invert(ob->imat, ob->obmat);
362 Mat4MulVecfl(ob->imat, median);
363 Mat4MulVecfl(ob->imat, ve_median);
365 VecSubf(median, ve_median, median);
366 median[3]= ve_median[3]-median[3];
367 median[4]= ve_median[4]-median[4];
369 if(ob->type==OB_MESH) {
371 EditMesh *em = BKE_mesh_get_editmesh(me);
375 eve= em->verts.first;
377 if(eve->f & SELECT) {
378 VecAddf(eve->co, eve->co, median);
383 for(eed= em->edges.first; eed; eed= eed->next) {
384 if(eed->f & SELECT) {
385 /* ensure the median can be set to zero or one */
386 if(ve_median[3]==0.0f) eed->crease= 0.0f;
387 else if(ve_median[3]==1.0f) eed->crease= 1.0f;
389 eed->crease+= median[3];
390 CLAMP(eed->crease, 0.0, 1.0);
395 recalc_editnormals(em);
397 BKE_mesh_end_editmesh(me, em);
399 else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
406 nu= cu->editnurb->first;
408 if((nu->type & 7)==CU_BEZIER) {
412 if(bezt->f2 & SELECT) {
413 VecAddf(bezt->vec[0], bezt->vec[0], median);
414 VecAddf(bezt->vec[1], bezt->vec[1], median);
415 VecAddf(bezt->vec[2], bezt->vec[2], median);
416 bezt->weight+= median[4];
419 if(bezt->f1 & SELECT) {
420 VecAddf(bezt->vec[0], bezt->vec[0], median);
422 if(bezt->f3 & SELECT) {
423 VecAddf(bezt->vec[2], bezt->vec[2], median);
431 a= nu->pntsu*nu->pntsv;
433 if(bp->f1 & SELECT) {
434 VecAddf(bp->vec, bp->vec, median);
435 bp->vec[3]+= median[3];
436 bp->weight+= median[4];
442 testhandlesNurb(nu); /* test for bezier too */
447 else if(ob->type==OB_LATTICE) {
448 Lattice *lt= ob->data;
452 a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
453 bp= lt->editlatt->def;
455 if(bp->f1 & SELECT) {
456 VecAddf(bp->vec, bp->vec, median);
457 bp->weight+= median[4];
463 // ED_undo_push(C, "Transform properties");
467 /* assumes armature active */
468 static void validate_bonebutton_cb(bContext *C, void *bonev, void *namev)
470 Object *ob= CTX_data_active_object(C);
472 if(ob && ob->type==OB_ARMATURE) {
474 char oldname[32], newname[32];
476 /* need to be on the stack */
477 BLI_strncpy(newname, bone->name, 32);
478 BLI_strncpy(oldname, (char *)namev, 32);
480 BLI_strncpy(bone->name, oldname, 32);
482 armature_bone_rename(ob, oldname, newname); // editarmature.c
486 static void v3d_posearmature_buts(uiBlock *block, View3D *v3d, Object *ob, float lim)
492 TransformProperties *tfp= v3d->properties_storage;
495 if (!arm || !ob->pose) return;
497 for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
499 if(bone && (bone->flag & BONE_ACTIVE) && (bone->layer & arm->layer))
502 if (!pchan || !bone) return;
504 if((ob->parent) && (ob->partype == PARBONE))
505 but= uiDefBut (block, TEX, B_NOP, "Bone:", 160, 130, 140, 19, bone->name, 1, 31, 0, 0, "");
507 but= uiDefBut(block, TEX, B_NOP, "Bone:", 160, 140, 140, 19, bone->name, 1, 31, 0, 0, "");
508 uiButSetFunc(but, validate_bonebutton_cb, bone, NULL);
509 uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob);
511 QuatToEul(pchan->quat, tfp->ob_eul);
512 tfp->ob_eul[0]*= 180.0/M_PI;
513 tfp->ob_eul[1]*= 180.0/M_PI;
514 tfp->ob_eul[2]*= 180.0/M_PI;
516 uiBlockBeginAlign(block);
517 uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCX, B_REDR, ICON_UNLOCKED, 10,140,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
518 uiDefButF(block, NUM, B_ARMATUREPANEL2, "LocX:", 30, 140, 120, 19, pchan->loc, -lim, lim, 100, 3, "");
519 uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCY, B_REDR, ICON_UNLOCKED, 10,120,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
520 uiDefButF(block, NUM, B_ARMATUREPANEL2, "LocY:", 30, 120, 120, 19, pchan->loc+1, -lim, lim, 100, 3, "");
521 uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCZ, B_REDR, ICON_UNLOCKED, 10,100,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
522 uiDefButF(block, NUM, B_ARMATUREPANEL2, "LocZ:", 30, 100, 120, 19, pchan->loc+2, -lim, lim, 100, 3, "");
524 uiBlockBeginAlign(block);
525 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTX, B_REDR, ICON_UNLOCKED, 10,70,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
526 uiDefButF(block, NUM, B_ARMATUREPANEL3, "RotX:", 30, 70, 120, 19, tfp->ob_eul, -1000.0, 1000.0, 100, 3, "");
527 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTY, B_REDR, ICON_UNLOCKED, 10,50,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
528 uiDefButF(block, NUM, B_ARMATUREPANEL3, "RotY:", 30, 50, 120, 19, tfp->ob_eul+1, -1000.0, 1000.0, 100, 3, "");
529 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTZ, B_REDR, ICON_UNLOCKED, 10,30,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
530 uiDefButF(block, NUM, B_ARMATUREPANEL3, "RotZ:", 30, 30, 120, 19, tfp->ob_eul+2, -1000.0, 1000.0, 100, 3, "");
532 uiBlockBeginAlign(block);
533 uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEX, B_REDR, ICON_UNLOCKED, 160,70,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
534 uiDefButF(block, NUM, B_ARMATUREPANEL2, "ScaleX:", 180, 70, 120, 19, pchan->size, -lim, lim, 10, 3, "");
535 uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEY, B_REDR, ICON_UNLOCKED, 160,50,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
536 uiDefButF(block, NUM, B_ARMATUREPANEL2, "ScaleY:", 180, 50, 120, 19, pchan->size+1, -lim, lim, 10, 3, "");
537 uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEZ, B_REDR, ICON_UNLOCKED, 160,30,20,19, &(pchan->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
538 uiDefButF(block, NUM, B_ARMATUREPANEL2, "ScaleZ:", 180, 30, 120, 19, pchan->size+2, -lim, lim, 10, 3, "");
539 uiBlockEndAlign(block);
542 /* assumes armature editmode */
543 void validate_editbonebutton_cb(bContext *C, void *bonev, void *namev)
545 EditBone *eBone= bonev;
546 char oldname[32], newname[32];
548 /* need to be on the stack */
549 BLI_strncpy(newname, eBone->name, 32);
550 BLI_strncpy(oldname, (char *)namev, 32);
552 BLI_strncpy(eBone->name, oldname, 32);
554 armature_bone_rename(CTX_data_edit_object(C), oldname, newname); // editarmature.c
555 WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, CTX_data_edit_object(C)); // XXX fix
558 static void v3d_editarmature_buts(uiBlock *block, View3D *v3d, Object *ob, float lim)
560 bArmature *arm= ob->data;
563 TransformProperties *tfp= v3d->properties_storage;
565 ebone= arm->edbo->first;
567 for (ebone = arm->edbo->first; ebone; ebone=ebone->next){
568 if ((ebone->flag & BONE_ACTIVE) && (ebone->layer & arm->layer))
575 if((ob->parent) && (ob->partype == PARBONE))
576 but= uiDefBut(block, TEX, B_NOP, "Bone:", 160, 130, 140, 19, ebone->name, 1, 31, 0, 0, "");
578 but= uiDefBut(block, TEX, B_NOP, "Bone:", 160, 150, 140, 19, ebone->name, 1, 31, 0, 0, "");
579 uiButSetFunc(but, validate_editbonebutton_cb, ebone, NULL);
581 uiBlockBeginAlign(block);
582 uiDefButF(block, NUM, B_ARMATUREPANEL1, "HeadX:", 10, 70, 140, 19, ebone->head, -lim, lim, 10, 3, "");
583 uiDefButF(block, NUM, B_ARMATUREPANEL1, "HeadY:", 10, 50, 140, 19, ebone->head+1, -lim, lim, 10, 3, "");
584 uiDefButF(block, NUM, B_ARMATUREPANEL1, "HeadZ:", 10, 30, 140, 19, ebone->head+2, -lim, lim, 10, 3, "");
585 uiBlockBeginAlign(block);
586 uiDefButF(block, NUM, B_ARMATUREPANEL1, "TailX:", 160, 70, 140, 19, ebone->tail, -lim, lim, 10, 3, "");
587 uiDefButF(block, NUM, B_ARMATUREPANEL1, "TailY:", 160, 50, 140, 19, ebone->tail+1, -lim, lim, 10, 3, "");
588 uiDefButF(block, NUM, B_ARMATUREPANEL1, "TailZ:", 160, 30, 140, 19, ebone->tail+2, -lim, lim, 10, 3, "");
589 uiBlockEndAlign(block);
591 tfp->ob_eul[0]= 180.0*ebone->roll/M_PI;
592 uiDefButF(block, NUM, B_ARMATUREPANEL1, "Roll:", 10, 100, 140, 19, tfp->ob_eul, -lim, lim, 1000, 3, "");
594 uiDefButBitI(block, TOG, BONE_EDITMODE_LOCKED, B_REDR, "Lock", 160, 100, 140, 19, &(ebone->flag), 0, 0, 0, 0, "Prevents bone from being transformed in edit mode");
596 uiBlockBeginAlign(block);
597 uiDefButF(block, NUM, B_ARMATUREPANEL1, "TailRadius:", 10, 150, 140, 19, &ebone->rad_tail, 0, lim, 10, 3, "");
598 if (ebone->parent && ebone->flag & BONE_CONNECTED )
599 uiDefButF(block, NUM, B_ARMATUREPANEL1, "HeadRadius:", 10, 130, 140, 19, &ebone->parent->rad_tail, 0, lim, 10, 3, "");
601 uiDefButF(block, NUM, B_ARMATUREPANEL1, "HeadRadius:", 10, 130, 140, 19, &ebone->rad_head, 0, lim, 10, 3, "");
602 uiBlockEndAlign(block);
605 static void v3d_editmetaball_buts(uiBlock *block, Object *ob, float lim)
607 MetaElem *lastelem= NULL; // XXX
610 uiBlockBeginAlign(block);
611 uiDefButF(block, NUM, B_RECALCMBALL, "LocX:", 10, 70, 140, 19, &lastelem->x, -lim, lim, 100, 3, "");
612 uiDefButF(block, NUM, B_RECALCMBALL, "LocY:", 10, 50, 140, 19, &lastelem->y, -lim, lim, 100, 3, "");
613 uiDefButF(block, NUM, B_RECALCMBALL, "LocZ:", 10, 30, 140, 19, &lastelem->z, -lim, lim, 100, 3, "");
615 uiBlockBeginAlign(block);
616 if(lastelem->type!=MB_BALL)
617 uiDefButF(block, NUM, B_RECALCMBALL, "dx:", 160, 70, 140, 19, &lastelem->expx, 0, lim, 100, 3, "");
618 if((lastelem->type!=MB_BALL) && (lastelem->type!=MB_TUBE))
619 uiDefButF(block, NUM, B_RECALCMBALL, "dy:", 160, 50, 140, 19, &lastelem->expy, 0, lim, 100, 3, "");
620 if((lastelem->type==MB_ELIPSOID) || (lastelem->type==MB_CUBE))
621 uiDefButF(block, NUM, B_RECALCMBALL, "dz:", 160, 30, 140, 19, &lastelem->expz, 0, lim, 100, 3, "");
623 uiBlockEndAlign(block);
625 uiBlockBeginAlign(block);
626 uiDefButF(block, NUM, B_RECALCMBALL, "Radius:", 10, 120, 140, 19, &lastelem->rad, 0, lim, 100, 3, "Size of the active metaball");
627 uiDefButF(block, NUM, B_RECALCMBALL, "Stiffness:", 10, 100, 140, 19, &lastelem->s, 0, 10, 100, 3, "Stiffness of the active metaball");
628 uiBlockEndAlign(block);
630 uiDefButS(block, MENU, B_RECALCMBALL, "Type%t|Ball%x0|Tube%x4|Plane%x5|Elipsoid%x6|Cube%x7", 160, 120, 140, 19, &lastelem->type, 0.0, 0.0, 0, 0, "Set active element type");
635 /* test if 'ob' is a parent somewhere in par's parents */
636 static int test_parent_loop(Object *par, Object *ob)
638 if(par == NULL) return 0;
639 if(ob == par) return 1;
640 return test_parent_loop(par->parent, ob);
643 static void do_view3d_region_buttons(bContext *C, void *arg, int event)
645 Scene *scene= CTX_data_scene(C);
646 Object *obedit= CTX_data_edit_object(C);
647 View3D *v3d= CTX_wm_view3d(C);
650 TransformProperties *tfp= v3d->properties_storage;
655 ED_area_tag_redraw(CTX_wm_area(C));
656 return; /* no notifier! */
659 DAG_object_flush_update(scene, ob, OB_RECALC_OB);
662 case B_OBJECTPANELROT:
664 ob->rot[0]= M_PI*tfp->ob_eul[0]/180.0;
665 ob->rot[1]= M_PI*tfp->ob_eul[1]/180.0;
666 ob->rot[2]= M_PI*tfp->ob_eul[2]/180.0;
667 DAG_object_flush_update(scene, ob, OB_RECALC_OB);
671 case B_OBJECTPANELSCALE:
674 /* link scale; figure out which axis changed */
675 if (tfp->link_scale) {
676 float ratio, tmp, max = 0.0;
680 max = fabs(tfp->ob_scale[0] - ob->size[0]);
681 tmp = fabs(tfp->ob_scale[1] - ob->size[1]);
686 tmp = fabs(tfp->ob_scale[2] - ob->size[2]);
692 if (ob->size[axis] != tfp->ob_scale[axis]) {
693 if (fabs(ob->size[axis]) > FLT_EPSILON) {
694 ratio = tfp->ob_scale[axis] / ob->size[axis];
695 ob->size[0] *= ratio;
696 ob->size[1] *= ratio;
697 ob->size[2] *= ratio;
702 VECCOPY(ob->size, tfp->ob_scale);
705 DAG_object_flush_update(scene, ob, OB_RECALC_OB);
709 case B_OBJECTPANELDIMS:
710 bb= object_get_boundbox(ob);
712 float old_dims[3], scale[3], ratio, len[3];
715 Mat4ToSize(ob->obmat, scale);
717 len[0] = bb->vec[4][0] - bb->vec[0][0];
718 len[1] = bb->vec[2][1] - bb->vec[0][1];
719 len[2] = bb->vec[1][2] - bb->vec[0][2];
721 old_dims[0] = fabs(scale[0]) * len[0];
722 old_dims[1] = fabs(scale[1]) * len[1];
723 old_dims[2] = fabs(scale[2]) * len[2];
725 /* for each axis changed */
726 for (axis = 0; axis<3; axis++) {
727 if (fabs(old_dims[axis] - tfp->ob_dims[axis]) > 0.0001) {
728 if (old_dims[axis] > 0.0) {
729 ratio = tfp->ob_dims[axis] / old_dims[axis];
730 if (tfp->link_scale) {
731 ob->size[0] *= ratio;
732 ob->size[1] *= ratio;
733 ob->size[2] *= ratio;
737 ob->size[axis] *= ratio;
742 ob->size[axis] = tfp->ob_dims[axis] / len[axis];
748 /* prevent multiple B_OBJECTPANELDIMS events to keep scaling, cycling with TAB on buttons can cause that */
749 VECCOPY(tfp->ob_dims, old_dims);
751 DAG_object_flush_update(scene, ob, OB_RECALC_OB);
755 case B_OBJECTPANELMEDIAN:
757 v3d_editvertex_buts(C, NULL, v3d, ob, 1.0);
758 DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
762 /* note; this case also used for parbone */
763 case B_OBJECTPANELPARENT:
765 if(ob->id.lib || test_parent_loop(ob->parent, ob) )
768 DAG_scene_sort(scene);
769 DAG_object_flush_update(scene, ob, OB_RECALC_OB);
774 case B_ARMATUREPANEL1:
776 bArmature *arm= obedit->data;
777 EditBone *ebone, *child;
779 for (ebone = arm->edbo->first; ebone; ebone=ebone->next){
780 if ((ebone->flag & BONE_ACTIVE) && (ebone->layer & arm->layer))
784 ebone->roll= M_PI*tfp->ob_eul[0]/180.0;
786 if (ebone->parent && ebone->flag & BONE_CONNECTED){
787 VECCOPY (ebone->parent->tail, ebone->head);
790 // Update our children if necessary
791 for (child = arm->edbo->first; child; child=child->next){
792 if (child->parent == ebone && (child->flag & BONE_CONNECTED)){
793 VECCOPY (child->head, ebone->tail);
796 if(arm->flag & ARM_MIRROR_EDIT) {
797 EditBone *eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebone);
799 eboflip->roll= -ebone->roll;
800 eboflip->head[0]= -ebone->head[0];
801 eboflip->tail[0]= -ebone->tail[0];
804 if (eboflip->parent && eboflip->flag & BONE_CONNECTED){
805 VECCOPY (eboflip->parent->tail, eboflip->head);
808 // Update our children if necessary
809 for (child = arm->edbo->first; child; child=child->next){
810 if (child->parent == eboflip && (child->flag & BONE_CONNECTED)){
811 VECCOPY (child->head, eboflip->tail);
819 case B_ARMATUREPANEL3: // rotate button on channel
827 if (!arm || !ob->pose) return;
829 for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
831 if(bone && (bone->flag & BONE_ACTIVE) && (bone->layer & arm->layer))
836 /* make a copy to eul[3], to allow TAB on buttons to work */
837 eul[0]= M_PI*tfp->ob_eul[0]/180.0;
838 eul[1]= M_PI*tfp->ob_eul[1]/180.0;
839 eul[2]= M_PI*tfp->ob_eul[2]/180.0;
840 EulToQuat(eul, pchan->quat);
842 /* no break, pass on */
843 case B_ARMATUREPANEL2:
845 ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
846 DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
849 case B_TRANSFORMSPACEADD:
850 BIF_manageTransformOrientation(C, 1, 0);
852 case B_TRANSFORMSPACECLEAR:
853 BIF_clearTransformOrientation(C);
858 wpaint->weight = 0.0f;
862 wpaint->weight = 0.25f;
865 wpaint->weight = 0.5f;
868 wpaint->weight = 0.75f;
871 wpaint->weight = 1.0f;
891 // if(!multires_level1_test()) {
893 bDeformGroup *defGroup = BLI_findlink(&ob->defbase, ob->actdef-1);
897 for(a=0; a<me->totvert; a++)
898 remove_vert_defgroup (ob, defGroup, a);
899 DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
907 ScrArea *sa= CTX_wm_area(C);
908 ARegion *ar= sa->regionbase.last;
913 rv3d= ar->regiondata;
914 viewlock= rv3d->viewlock;
916 if((viewlock & RV3D_LOCKED)==0)
918 else if((viewlock & RV3D_BOXVIEW)==0)
919 viewlock &= ~RV3D_BOXCLIP;
921 for(; ar; ar= ar->prev) {
922 if(ar->alignment==RGN_ALIGN_QSPLIT) {
923 rv3d= ar->regiondata;
924 rv3d->viewlock= viewlock;
928 if(rv3d->viewlock & RV3D_BOXVIEW)
929 view3d_boxview_copy(sa, sa->regionbase.last);
931 ED_area_tag_redraw(sa);
936 /* default for now */
937 WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
940 void removeTransformOrientation_func(bContext *C, void *target, void *unused)
942 BIF_removeTransformOrientation(C, (TransformOrientation *) target);
945 void selectTransformOrientation_func(bContext *C, void *target, void *unused)
947 BIF_selectTransformOrientation(C, (TransformOrientation *) target);
950 static void view3d_panel_transform_spaces(const bContext *C, Panel *pa)
952 Scene *scene= CTX_data_scene(C);
953 Object *obedit= CTX_data_edit_object(C);
954 View3D *v3d= CTX_wm_view3d(C);
955 ListBase *transform_spaces = &scene->transform_spaces;
956 TransformOrientation *ts = transform_spaces->first;
959 int xco = 20, yco = 70;
962 block= uiLayoutFreeBlock(pa->layout);
964 uiBlockBeginAlign(block);
967 uiDefBut(block, BUT, B_TRANSFORMSPACEADD, "Add", xco,120,80,20, 0, 0, 0, 0, 0, "Add the selected element as a Transform Orientation");
969 uiDefBut(block, BUT, B_TRANSFORMSPACEADD, "Add", xco,120,80,20, 0, 0, 0, 0, 0, "Add the active object as a Transform Orientation");
971 uiDefBut(block, BUT, B_TRANSFORMSPACECLEAR, "Clear", xco + 80,120,80,20, 0, 0, 0, 0, 0, "Removal all Transform Orientations");
973 uiBlockEndAlign(block);
975 uiBlockBeginAlign(block);
977 uiDefButS(block, ROW, B_REDR, "Global", xco, 90, 40,20, &v3d->twmode, 5.0, (float)V3D_MANIP_GLOBAL,0, 0, "Global Transform Orientation");
978 uiDefButS(block, ROW, B_REDR, "Local", xco + 40, 90, 40,20, &v3d->twmode, 5.0, (float)V3D_MANIP_LOCAL, 0, 0, "Local Transform Orientation");
979 uiDefButS(block, ROW, B_REDR, "Normal", xco + 80, 90, 40,20, &v3d->twmode, 5.0, (float)V3D_MANIP_NORMAL,0, 0, "Normal Transform Orientation");
980 uiDefButS(block, ROW, B_REDR, "View", xco + 120, 90, 40,20, &v3d->twmode, 5.0, (float)V3D_MANIP_VIEW, 0, 0, "View Transform Orientation");
982 for (index = V3D_MANIP_CUSTOM, ts = transform_spaces->first ; ts ; ts = ts->next, index++) {
984 if (v3d->twmode == index) {
985 but = uiDefIconButS(block,ROW, B_REDR, ICON_CHECKBOX_HLT, xco,yco,XIC,YIC, &v3d->twmode, 5.0, (float)index, 0, 0, "Use this Custom Transform Orientation");
988 but = uiDefIconButS(block,ROW, B_REDR, ICON_CHECKBOX_DEHLT, xco,yco,XIC,YIC, &v3d->twmode, 5.0, (float)index, 0, 0, "Use this Custom Transform Orientation");
990 uiButSetFunc(but, selectTransformOrientation_func, ts, NULL);
991 uiDefBut(block, TEX, 0, "", xco+=XIC, yco,100+XIC,20, &ts->name, 0, 30, 0, 0, "Edits the name of this Transform Orientation");
992 but = uiDefIconBut(block, BUT, B_REDR, ICON_X, xco+=100+XIC,yco,XIC,YIC, 0, 0, 0, 0, 0, "Deletes this Transform Orientation");
993 uiButSetFunc(but, removeTransformOrientation_func, ts, NULL);
998 uiBlockEndAlign(block);
1001 static void weight_paint_buttons(Scene *scene, uiBlock *block)
1003 VPaint *wpaint= scene->toolsettings->wpaint;
1007 if(ob==NULL || ob->type!=OB_MESH) return;
1010 uiBlockBeginAlign(block);
1011 uiDefButF(block, NUMSLI, B_REDR, "Weight:",10,170,225,19, &wpaint->weight, 0, 1, 10, 0, "Sets the current vertex group's bone deformation strength");
1013 uiDefBut(block, BUT, B_WEIGHT0_0 , "0", 10,150,45,19, 0, 0, 0, 0, 0, "");
1014 uiDefBut(block, BUT, B_WEIGHT1_4 , "1/4", 55,150,45,19, 0, 0, 0, 0, 0, "");
1015 uiDefBut(block, BUT, B_WEIGHT1_2 , "1/2", 100,150,45,19, 0, 0, 0, 0, 0, "");
1016 uiDefBut(block, BUT, B_WEIGHT3_4 , "3/4", 145,150,45,19, 0, 0, 0, 0, 0, "");
1017 uiDefBut(block, BUT, B_WEIGHT1_0 , "1", 190,150,45,19, 0, 0, 0, 0, 0, "");
1019 uiDefButF(block, NUMSLI, B_NOP, "Opacity ", 10,130,225,19, &wpaint->a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
1021 uiDefBut(block, BUT, B_OPA1_8 , "1/8", 10,110,45,19, 0, 0, 0, 0, 0, "");
1022 uiDefBut(block, BUT, B_OPA1_4 , "1/4", 55,110,45,19, 0, 0, 0, 0, 0, "");
1023 uiDefBut(block, BUT, B_OPA1_2 , "1/2", 100,110,45,19, 0, 0, 0, 0, 0, "");
1024 uiDefBut(block, BUT, B_OPA3_4 , "3/4", 145,110,45,19, 0, 0, 0, 0, 0, "");
1025 uiDefBut(block, BUT, B_OPA1_0 , "1", 190,110,45,19, 0, 0, 0, 0, 0, "");
1027 uiDefButF(block, NUMSLI, B_NOP, "Size ", 10,90,225,19, &wpaint->size, 2.0, 64.0, 0, 0, "The size of the brush");
1029 uiBlockBeginAlign(block);
1030 uiDefButS(block, ROW, B_NOP, "Mix", 250,170,60,17, &wpaint->mode, 1.0, 0.0, 0, 0, "Mix the vertex colors");
1031 uiDefButS(block, ROW, B_NOP, "Add", 250,152,60,17, &wpaint->mode, 1.0, 1.0, 0, 0, "Add the vertex colors");
1032 uiDefButS(block, ROW, B_NOP, "Sub", 250,134,60,17, &wpaint->mode, 1.0, 2.0, 0, 0, "Subtract from the vertex color");
1033 uiDefButS(block, ROW, B_NOP, "Mul", 250,116,60,17, &wpaint->mode, 1.0, 3.0, 0, 0, "Multiply the vertex color");
1034 uiDefButS(block, ROW, B_NOP, "Blur", 250, 98,60,17, &wpaint->mode, 1.0, 4.0, 0, 0, "Blur the weight with surrounding values");
1035 uiDefButS(block, ROW, B_NOP, "Lighter", 250, 80,60,17, &wpaint->mode, 1.0, 5.0, 0, 0, "Paint over darker areas only");
1036 uiDefButS(block, ROW, B_NOP, "Darker", 250, 62,60,17, &wpaint->mode, 1.0, 6.0, 0, 0, "Paint over lighter areas only");
1037 uiBlockEndAlign(block);
1040 /* draw options same as below */
1041 uiBlockBeginAlign(block);
1042 if (FACESEL_PAINT_TEST) {
1044 uiDefButBitI(block, TOG, ME_DRAWFACES, B_REDR, "Faces", 10,45,60,19, &me->drawflag, 0, 0, 0, 0, "Displays all faces as shades");
1045 uiDefButBitI(block,TOG, ME_DRAWEDGES, B_REDR,"Edges",70,45,60,19, &me->drawflag, 2.0, 0, 0, 0, "Displays edges of visible faces");
1046 uiDefButBitI(block,TOG, ME_HIDDENEDGES, B_REDR,"Hidden Edges",130,45,100,19, &me->drawflag, 2.0, 1.0, 0, 0, "Displays edges of hidden faces");
1048 uiDefButBitC(block, TOG, OB_DRAWWIRE, B_REDR, "Wire", 10,45,75,19, &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes");
1050 uiBlockEndAlign(block);
1052 uiBlockBeginAlign(block);
1053 uiDefButBitS(block, TOG, VP_AREA, 0, "All Faces", 10,20,60,19, &wpaint->flag, 0, 0, 0, 0, "Paint on all faces inside brush (otherwise only on face under mouse cursor)");
1054 uiDefButBitS(block, TOG, VP_SOFT, 0, "Vert Dist", 70,20,60,19, &wpaint->flag, 0, 0, 0, 0, "Use distances to vertices (instead of all vertices of face)");
1055 uiDefButBitS(block, TOGN, VP_HARD, 0, "Soft", 130,20,60,19, &wpaint->flag, 0, 0, 0, 0, "Use a soft brush");
1056 uiDefButBitS(block, TOG, VP_NORMALS, 0, "Normals", 190,20,60,19, &wpaint->flag, 0, 0, 0, 0, "Applies the vertex normal before painting");
1057 uiDefButBitS(block, TOG, VP_SPRAY, 0, "Spray", 250,20,55,19, &wpaint->flag, 0, 0, 0, 0, "Keep applying paint effect while holding mouse");
1058 uiBlockEndAlign(block);
1061 uiBlockBeginAlign(block);
1062 uiDefButBitS(block, TOG, VP_ONLYVGROUP, B_REDR, "Vgroup", 10,0,100,19, &wpaint->flag, 0, 0, 0, 0, "Only paint on vertices in the selected vertex group.");
1063 uiDefButBitS(block, TOG, VP_MIRROR_X, B_REDR, "X-Mirror", 110,0,100,19, &wpaint->flag, 0, 0, 0, 0, "Mirrored Paint, applying on mirrored Weight Group name");
1064 uiDefBut(block, BUT, B_CLR_WPAINT, "Clear", 210,0,100,19, NULL, 0, 0, 0, 0, "Removes reference to this deform group from all vertices");
1065 uiBlockEndAlign(block);
1069 static void brush_idpoin_handle(bContext *C, ID *id, int event)
1071 Brush **br = current_brush_source(CTX_data_scene(C));
1088 (*br) = copy_brush((Brush*)id);
1092 (*br) = add_brush("Brush");
1095 /* XXX not implemented */
1100 static int view3d_panel_brush_poll(const bContext *C, PanelType *pt)
1102 Brush **brp = current_brush_source(CTX_data_scene(C));
1104 return ((G.f & (G_SCULPTMODE|G_TEXTUREPAINT|G_VERTEXPAINT|G_WEIGHTPAINT)) && brp);
1107 static void view3d_panel_brush(const bContext *C, Panel *pa)
1110 Brush **brp = current_brush_source(CTX_data_scene(C)), *br;
1111 short w = 268, h = 400, cx = 10, cy = h;
1116 block= uiLayoutFreeBlock(pa->layout);
1117 uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
1119 uiBlockBeginAlign(block);
1120 uiDefIDPoinButs(block, CTX_data_main(C), NULL, &br->id, ID_BR, NULL, cx, cy,
1121 brush_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE);
1123 uiBlockEndAlign(block);
1128 if(G.f & G_SCULPTMODE) {
1129 uiBlockBeginAlign(block);
1130 uiDefButC(block,ROW,B_REDR,"Draw",cx,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_DRAW,0,0,"Draw lines on the model");
1131 uiDefButC(block,ROW,B_REDR,"Smooth",cx+67,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_SMOOTH,0,0,"Interactively smooth areas of the model");
1132 uiDefButC(block,ROW,B_REDR,"Pinch",cx+134,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_PINCH,0,0,"Interactively pinch areas of the model");
1133 uiDefButC(block,ROW,B_REDR,"Inflate",cx+201,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_INFLATE,0,0,"Push vertices along the direction of their normals");
1135 uiDefButC(block,ROW,B_REDR,"Grab", cx,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_GRAB,0,0,"Grabs a group of vertices and moves them with the mouse");
1136 uiDefButC(block,ROW,B_REDR,"Layer", cx+67,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_LAYER,0,0,"Adds a layer of depth");
1137 uiDefButC(block,ROW,B_REDR,"Flatten", cx+134,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_FLATTEN,0,0,"Interactively flatten areas of the model");
1138 uiDefButC(block,ROW,B_REDR,"Clay", cx+201,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_CLAY,0,0,"Build up depth quickly");
1140 uiBlockEndAlign(block);
1143 uiBlockBeginAlign(block);
1144 uiDefButI(block,NUMSLI,B_NOP,"Size: ",cx,cy,w,19,&br->size,1.0,200.0,0,0,"Set brush radius in pixels");
1146 uiDefButF(block,NUMSLI,B_NOP,"Strength: ",cx,cy,w,19,&br->alpha,0,1.0,0,0,"Set brush strength");
1148 uiBlockEndAlign(block);
1150 uiBlockBeginAlign(block);
1152 uiDefButBitS(block, TOG, BRUSH_AIRBRUSH, B_NOP, "Airbrush", cx,cy,w/3,19, &br->flag,0,0,0,0, "Brush makes changes without waiting for the mouse to move");
1153 uiDefButBitS(block, TOG, BRUSH_RAKE, B_NOP, "Rake", cx+w/3,cy,w/3,19, &br->flag,0,0,0,0, "");
1154 uiDefButBitS(block, TOG, BRUSH_ANCHORED, B_NOP, "Anchored", cx+w*2.0/3,cy,w/3,19, &br->flag,0,0,0,0, "");
1156 uiDefButBitS(block, TOG, BRUSH_SPACE, B_NOP, "Space", cx,cy,w/3,19, &br->flag,0,0,0,0, "");
1157 uiDefButF(block,NUMSLI,B_NOP,"Spacing: ",cx+w/3,cy,w*2.0/3,19,&br->spacing,1.0,500,0,0,"");
1159 uiBlockEndAlign(block);
1162 rect.xmin= cx; rect.xmax= cx + w;
1163 rect.ymin= cy - 200; rect.ymax= cy;
1164 uiBlockBeginAlign(block);
1165 curvemap_buttons(block, br->curve, (char)0, B_NOP, 0, &rect);
1166 uiBlockEndAlign(block);
1170 static void sculptmode_draw_interface_tools(Scene *scene, uiBlock *block, unsigned short cx, unsigned short cy)
1172 Sculpt *s = scene->toolsettings->sculpt;
1174 //XXX if(sd->brush_type != SMOOTH_BRUSH && sd->brush_type != GRAB_BRUSH && sd->brush_type != FLATTEN_BRUSH) {
1176 /*uiDefButBitS(block,ROW,B_NOP,"Add",cx,cy,89,19,&br->dir,15.0,1.0,0, 0,"Add depth to model [Shift]");
1177 uiDefButBitS(block,ROW,B_NOP,"Sub",cx+89,cy,89,19,&br->dir,15.0,2.0,0, 0,"Subtract depth from model [Shift]");
1179 //XXX if(sd->brush_type!=GRAB_BRUSH)
1181 uiBlockBeginAlign(block);
1182 uiDefBut( block,LABEL,B_NOP,"Symmetry",cx,cy,90,19,NULL,0,0,0,0,"");
1184 uiBlockBeginAlign(block);
1185 uiDefButBitI(block, TOG, SCULPT_SYMM_X, B_NOP, "X", cx,cy,40,19, &s->flags, 0,0,0,0, "Mirror brush across X axis");
1186 uiDefButBitI(block, TOG, SCULPT_SYMM_Y, B_NOP, "Y", cx+40,cy,40,19, &s->flags, 0,0,0,0, "Mirror brush across Y axis");
1187 uiDefButBitI(block, TOG, SCULPT_SYMM_Z, B_NOP, "Z", cx+80,cy,40,19, &s->flags, 0,0,0,0, "Mirror brush across Z axis");
1188 uiBlockEndAlign(block);
1192 uiBlockBeginAlign(block);
1193 uiDefBut( block,LABEL,B_NOP,"LockAxis",cx+140,cy,90,19,NULL,0,0,0,0,"");
1195 uiBlockBeginAlign(block);
1196 uiDefButBitI(block, TOG, SCULPT_LOCK_X, B_NOP, "X", cx+140,cy,40,19, &s->flags, 0,0,0,0, "Constrain X axis");
1197 uiDefButBitI(block, TOG, SCULPT_LOCK_Y, B_NOP, "Y", cx+180,cy,40,19, &s->flags, 0,0,0,0, "Constrain Y axis");
1198 uiDefButBitI(block, TOG, SCULPT_LOCK_Z, B_NOP, "Z", cx+220,cy,40,19, &s->flags, 0,0,0,0, "Constrain Z axis");
1199 uiBlockEndAlign(block);
1205 static void view3d_panel_object(const bContext *C, Panel *pa)
1208 Scene *scene= CTX_data_scene(C);
1209 Object *obedit= CTX_data_edit_object(C);
1210 View3D *v3d= CTX_wm_view3d(C);
1213 TransformProperties *tfp;
1215 static char hexcol[128];
1217 if(ob==NULL) return;
1219 /* make sure we got storage */
1220 if(v3d->properties_storage==NULL)
1221 v3d->properties_storage= MEM_callocN(sizeof(TransformProperties), "TransformProperties");
1222 tfp= v3d->properties_storage;
1224 block= uiLayoutFreeBlock(pa->layout);
1225 uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
1227 // XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
1229 if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) {
1232 bt= uiDefBut(block, TEX, B_IDNAME, "OB: ", 10,180,140,20, ob->id.name+2, 0.0, 21.0, 0, 0, "");
1233 uiButSetFunc(bt, test_idbutton_cb, ob->id.name, NULL);
1235 if((G.f & G_PARTICLEEDIT)==0) {
1236 uiBlockBeginAlign(block);
1237 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", 160, 180, 140, 20, &ob->parent, "Parent Object");
1238 if((ob->parent) && (ob->partype == PARBONE)) {
1239 bt= uiDefBut(block, TEX, B_OBJECTPANELPARENT, "ParBone:", 160, 160, 140, 20, ob->parsubstr, 0, 30, 0, 0, "");
1240 uiButSetCompleteFunc(bt, autocomplete_bone, (void *)ob->parent);
1243 strcpy(ob->parsubstr, "");
1245 uiBlockEndAlign(block);
1249 lim= 10000.0f*MAX2(1.0, v3d->grid);
1252 if(ob->type==OB_ARMATURE) v3d_editarmature_buts(block, v3d, ob, lim);
1253 if(ob->type==OB_MBALL) v3d_editmetaball_buts(block, ob, lim);
1254 else v3d_editvertex_buts(C, block, v3d, ob, lim);
1256 else if(ob->flag & OB_POSEMODE) {
1257 v3d_posearmature_buts(block, v3d, ob, lim);
1259 else if(G.f & G_WEIGHTPAINT) {
1260 BLI_strncpy(pa->drawname, "Weight Paint Properties", sizeof(pa->drawname));
1261 weight_paint_buttons(scene, block);
1263 else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT)) {
1264 static float hsv[3], old[3]; // used as temp mem for picker
1265 Brush **br = current_brush_source(scene);
1267 BLI_strncpy(pa->drawname, "Paint Properties", sizeof(pa->drawname));
1269 /* 'f' is for floating panel */
1270 uiBlockPickerButtons(block, (*br)->rgb, hsv, old, hexcol, 'f', B_REDR);
1272 else if(G.f & G_SCULPTMODE) {
1273 BLI_strncpy(pa->drawname, "Sculpt Properties", sizeof(pa->drawname));
1274 sculptmode_draw_interface_tools(scene, block, 10, 150);
1276 else if(G.f & G_PARTICLEEDIT){
1277 BLI_strncpy(pa->drawname, "Particle Edit Properties", sizeof(pa->drawname));
1278 // XXX particle_edit_buttons(block);
1281 BoundBox *bb = NULL;
1283 uiBlockBeginAlign(block);
1284 uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCX, B_REDR, ICON_UNLOCKED, 10,150,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1285 uiDefButF(block, NUM, B_OBJECTPANEL, "LocX:", 30, 150, 120, 19, &(ob->loc[0]), -lim, lim, 100, 3, "");
1286 uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCY, B_REDR, ICON_UNLOCKED, 10,130,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1287 uiDefButF(block, NUM, B_OBJECTPANEL, "LocY:", 30, 130, 120, 19, &(ob->loc[1]), -lim, lim, 100, 3, "");
1288 uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCZ, B_REDR, ICON_UNLOCKED, 10,110,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1289 uiDefButF(block, NUM, B_OBJECTPANEL, "LocZ:", 30, 110, 120, 19, &(ob->loc[2]), -lim, lim, 100, 3, "");
1291 tfp->ob_eul[0]= 180.0*ob->rot[0]/M_PI;
1292 tfp->ob_eul[1]= 180.0*ob->rot[1]/M_PI;
1293 tfp->ob_eul[2]= 180.0*ob->rot[2]/M_PI;
1295 uiBlockBeginAlign(block);
1296 if ((ob->parent) && (ob->partype == PARBONE)) {
1297 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTX, B_REDR, ICON_UNLOCKED, 160,130,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1298 uiDefButF(block, NUM, B_OBJECTPANELROT, "RotX:", 180, 130, 120, 19, &(tfp->ob_eul[0]), -lim, lim, 1000, 3, "");
1299 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTY, B_REDR, ICON_UNLOCKED, 160,110,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1300 uiDefButF(block, NUM, B_OBJECTPANELROT, "RotY:", 180, 110, 120, 19, &(tfp->ob_eul[1]), -lim, lim, 1000, 3, "");
1301 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTZ, B_REDR, ICON_UNLOCKED, 160,90,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1302 uiDefButF(block, NUM, B_OBJECTPANELROT, "RotZ:", 180, 90, 120, 19, &(tfp->ob_eul[2]), -lim, lim, 1000, 3, "");
1306 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTX, B_REDR, ICON_UNLOCKED, 160,150,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1307 uiDefButF(block, NUM, B_OBJECTPANELROT, "RotX:", 180, 150, 120, 19, &(tfp->ob_eul[0]), -lim, lim, 1000, 3, "");
1308 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTY, B_REDR, ICON_UNLOCKED, 160,130,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1309 uiDefButF(block, NUM, B_OBJECTPANELROT, "RotY:", 180, 130, 120, 19, &(tfp->ob_eul[1]), -lim, lim, 1000, 3, "");
1310 uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTZ, B_REDR, ICON_UNLOCKED, 160,110,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1311 uiDefButF(block, NUM, B_OBJECTPANELROT, "RotZ:", 180, 110, 120, 19, &(tfp->ob_eul[2]), -lim, lim, 1000, 3, "");
1314 tfp->ob_scale[0]= ob->size[0];
1315 tfp->ob_scale[1]= ob->size[1];
1316 tfp->ob_scale[2]= ob->size[2];
1318 uiBlockBeginAlign(block);
1319 uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEX, B_REDR, ICON_UNLOCKED, 10,80,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1320 uiDefButF(block, NUM, B_OBJECTPANELSCALE, "ScaleX:", 30, 80, 120, 19, &(tfp->ob_scale[0]), -lim, lim, 10, 3, "");
1321 uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEY, B_REDR, ICON_UNLOCKED, 10,60,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1322 uiDefButF(block, NUM, B_OBJECTPANELSCALE, "ScaleY:", 30, 60, 120, 19, &(tfp->ob_scale[1]), -lim, lim, 10, 3, "");
1323 uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEZ, B_REDR, ICON_UNLOCKED, 10,40,20,19, &(ob->protectflag), 0, 0, 0, 0, "Protects this value from being Transformed");
1324 uiDefButF(block, NUM, B_OBJECTPANELSCALE, "ScaleZ:", 30, 40, 120, 19, &(tfp->ob_scale[2]), -lim, lim, 10, 3, "");
1325 uiBlockEndAlign(block);
1327 uiDefButS(block, TOG, B_REDR, "Link Scale", 10, 10, 140, 19, &(tfp->link_scale), 0, 1, 0, 0, "Scale values vary proportionally in all directions");
1329 bb= object_get_boundbox(ob);
1333 Mat4ToSize(ob->obmat, scale);
1335 tfp->ob_dims[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
1336 tfp->ob_dims[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
1337 tfp->ob_dims[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
1339 uiBlockBeginAlign(block);
1340 if ((ob->parent) && (ob->partype == PARBONE)) {
1341 uiDefButF(block, NUM, B_OBJECTPANELDIMS, "DimX:", 160, 60, 140, 19, &(tfp->ob_dims[0]), 0.0, lim, 10, 3, "Manipulate bounding box size");
1342 uiDefButF(block, NUM, B_OBJECTPANELDIMS, "DimY:", 160, 40, 140, 19, &(tfp->ob_dims[1]), 0.0, lim, 10, 3, "Manipulate bounding box size");
1343 uiDefButF(block, NUM, B_OBJECTPANELDIMS, "DimZ:", 160, 20, 140, 19, &(tfp->ob_dims[2]), 0.0, lim, 10, 3, "Manipulate bounding box size");
1347 uiDefButF(block, NUM, B_OBJECTPANELDIMS, "DimX:", 160, 80, 140, 19, &(tfp->ob_dims[0]), 0.0, lim, 10, 3, "Manipulate bounding box size");
1348 uiDefButF(block, NUM, B_OBJECTPANELDIMS, "DimY:", 160, 60, 140, 19, &(tfp->ob_dims[1]), 0.0, lim, 10, 3, "Manipulate bounding box size");
1349 uiDefButF(block, NUM, B_OBJECTPANELDIMS, "DimZ:", 160, 40, 140, 19, &(tfp->ob_dims[2]), 0.0, lim, 10, 3, "Manipulate bounding box size");
1352 uiBlockEndAlign(block);
1357 static void view3d_panel_background(const bContext *C, Panel *pa)
1359 View3D *v3d= CTX_wm_view3d(C);
1362 block= uiLayoutFreeBlock(pa->layout);
1363 uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
1365 if(v3d->flag & V3D_DISPBGPIC) {
1366 if(v3d->bgpic==NULL) {
1367 v3d->bgpic= MEM_callocN(sizeof(BGpic), "bgpic");
1368 v3d->bgpic->size= 5.0;
1369 v3d->bgpic->blend= 0.5;
1370 v3d->bgpic->iuser.fie_ima= 2;
1371 v3d->bgpic->iuser.ok= 1;
1375 if(!(v3d->flag & V3D_DISPBGPIC)) {
1376 uiDefButBitS(block, TOG, V3D_DISPBGPIC, B_REDR, "Use Background Image", 10, 180, 150, 20, &v3d->flag, 0, 0, 0, 0, "Display an image in the background of this 3D View");
1377 uiDefBut(block, LABEL, 1, " ", 160, 180, 150, 20, NULL, 0.0, 0.0, 0, 0, "");
1380 uiBlockBeginAlign(block);
1381 uiDefButBitS(block, TOG, V3D_DISPBGPIC, B_REDR, "Use", 10, 225, 50, 20, &v3d->flag, 0, 0, 0, 0, "Display an image in the background of this 3D View");
1382 uiDefButF(block, NUMSLI, B_REDR, "Blend:", 60, 225, 150, 20, &v3d->bgpic->blend, 0.0,1.0, 0, 0, "Set the transparency of the background image");
1383 uiDefButF(block, NUM, B_REDR, "Size:", 210, 225, 100, 20, &v3d->bgpic->size, 0.1, 250.0*v3d->grid, 100, 0, "Set the size (width) of the background image");
1385 uiDefButF(block, NUM, B_REDR, "X Offset:", 10, 205, 150, 20, &v3d->bgpic->xof, -250.0*v3d->grid,250.0*v3d->grid, 10, 2, "Set the horizontal offset of the background image");
1386 uiDefButF(block, NUM, B_REDR, "Y Offset:", 160, 205, 150, 20, &v3d->bgpic->yof, -250.0*v3d->grid,250.0*v3d->grid, 10, 2, "Set the vertical offset of the background image");
1388 ED_image_uiblock_panel(C, block, &v3d->bgpic->ima, &v3d->bgpic->iuser, B_REDR, B_REDR);
1389 uiBlockEndAlign(block);
1394 static void view3d_panel_properties(const bContext *C, Panel *pa)
1396 ScrArea *sa= CTX_wm_area(C);
1398 Scene *scene= CTX_data_scene(C);
1399 View3D *v3d= CTX_wm_view3d(C);
1404 block= uiLayoutFreeBlock(pa->layout);
1405 uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
1407 uiDefBut(block, LABEL, 1, "Grid:", 10, 220, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
1408 uiBlockBeginAlign(block);
1409 uiDefButF(block, NUM, B_REDR, "Spacing:", 10, 200, 140, 19, &v3d->grid, 0.001, 100.0, 10, 0, "Set the distance between grid lines");
1410 uiDefButS(block, NUM, B_REDR, "Lines:", 10, 180, 140, 19, &v3d->gridlines, 0.0, 100.0, 100, 0, "Set the number of grid lines in perspective view");
1411 uiDefButS(block, NUM, B_REDR, "Divisions:", 10, 160, 140, 19, &v3d->gridsubdiv, 1.0, 100.0, 100, 0, "Set the number of grid lines");
1412 uiBlockEndAlign(block);
1414 uiDefBut(block, LABEL, 1, "3D Display:", 160, 220, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
1415 uiDefButBitS(block, TOG, V3D_SHOW_FLOOR, B_REDR, "Grid Floor",160, 200, 150, 19, &v3d->gridflag, 0, 0, 0, 0, "Show the grid floor in free camera mode");
1416 uiDefButBitS(block, TOG, V3D_SHOW_X, B_REDR, "X Axis", 160, 176, 48, 19, &v3d->gridflag, 0, 0, 0, 0, "Show the X Axis line");
1417 uiDefButBitS(block, TOG, V3D_SHOW_Y, B_REDR, "Y Axis", 212, 176, 48, 19, &v3d->gridflag, 0, 0, 0, 0, "Show the Y Axis line");
1418 uiDefButBitS(block, TOG, V3D_SHOW_Z, B_REDR, "Z Axis", 262, 176, 48, 19, &v3d->gridflag, 0, 0, 0, 0, "Show the Z Axis line");
1420 uiDefBut(block, LABEL, 1, "View Camera:", 10, 140, 140, 19, NULL, 0.0, 0.0, 0, 0, "");
1422 uiDefButF(block, NUM, B_REDR, "Lens:", 10, 120, 140, 19, &v3d->lens, 10.0, 120.0, 100, 0, "The lens angle in perspective view");
1423 uiBlockBeginAlign(block);
1424 uiDefButF(block, NUM, B_REDR, "Clip Start:", 10, 96, 140, 19, &v3d->near, v3d->grid/100.0, 100.0, 10, 0, "Set the beginning of the range in which 3D objects are displayed (perspective view)");
1425 uiDefButF(block, NUM, B_REDR, "Clip End:", 10, 76, 140, 19, &v3d->far, 1.0, 10000.0*v3d->grid, 100, 0, "Set the end of the range in which 3D objects are displayed (perspective view)");
1426 uiBlockEndAlign(block);
1428 uiDefBut(block, LABEL, 1, "3D Cursor:", 160, 150, 140, 19, NULL, 0.0, 0.0, 0, 0, "");
1430 uiBlockBeginAlign(block);
1431 curs= give_cursor(scene, v3d);
1432 uiDefButF(block, NUM, B_REDR, "X:", 160, 130, 150, 22, curs, -10000.0*v3d->grid, 10000.0*v3d->grid, 10, 0, "X co-ordinate of the 3D cursor");
1433 uiDefButF(block, NUM, B_REDR, "Y:", 160, 108, 150, 22, curs+1, -10000.0*v3d->grid, 10000.0*v3d->grid, 10, 0, "Y co-ordinate of the 3D cursor");
1434 uiDefButF(block, NUM, B_REDR, "Z:", 160, 86, 150, 22, curs+2, -10000.0*v3d->grid, 10000.0*v3d->grid, 10, 0, "Z co-ordinate of the 3D cursor");
1435 uiBlockEndAlign(block);
1437 uiDefBut(block, LABEL, 1, "Display:", 10, 50, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
1438 uiBlockBeginAlign(block);
1439 uiDefButBitS(block, TOG, V3D_SELECT_OUTLINE, B_REDR, "Outline Selected", 10, 30, 140, 19, &v3d->flag, 0, 0, 0, 0, "Highlight selected objects with an outline, in Solid, Shaded or Textured viewport shading modes");
1440 uiDefButBitS(block, TOG, V3D_DRAW_CENTERS, B_REDR, "All Object Centers", 10, 10, 140, 19, &v3d->flag, 0, 0, 0, 0, "Draw the center points on all objects");
1441 uiDefButBitS(block, TOGN, V3D_HIDE_HELPLINES, B_REDR, "Relationship Lines", 10, -10, 140, 19, &v3d->flag, 0, 0, 0, 0, "Draw dashed lines indicating Parent, Constraint, or Hook relationships");
1442 uiDefButBitS(block, TOG, V3D_SOLID_TEX, B_REDR, "Solid Tex", 10, -30, 140, 19, &v3d->flag2, 0, 0, 0, 0, "Display textures in Solid draw type (Shift T)");
1443 uiBlockEndAlign(block);
1445 uiDefBut(block, LABEL, 1, "View Locking:", 160, 60, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
1446 uiBlockBeginAlign(block);
1447 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_REDR, "Object:", 160, 40, 150, 19, &v3d->ob_centre, "Lock view to center to this Object");
1448 uiDefBut(block, TEX, B_REDR, "Bone:", 160, 20, 150, 19, v3d->ob_centre_bone, 1, 31, 0, 0, "If view locked to Object, use this Bone to lock to view to");
1449 uiBlockEndAlign(block);
1451 /* last region is always 3d... a bit weak */
1452 arlast= sa->regionbase.last;
1453 uiBlockBeginAlign(block);
1454 if(arlast->alignment==RGN_ALIGN_QSPLIT) {
1455 arlast= arlast->prev;
1456 rv3d= arlast->regiondata;
1458 uiDefButO(block, BUT, "SCREEN_OT_region_foursplit", WM_OP_EXEC_REGION_WIN, "End 4-Split View", 160, -10, 150, 19, "Join the 3D View");
1459 uiDefButBitS(block, TOG, RV3D_LOCKED, B_RV3D_LOCKED, "Lock", 160, -30, 50, 19, &rv3d->viewlock, 0, 0, 0, 0, "");
1460 uiDefButBitS(block, TOG, RV3D_BOXVIEW, B_RV3D_BOXVIEW, "Box", 210, -30, 50, 19, &rv3d->viewlock, 0, 0, 0, 0, "");
1461 uiDefButBitS(block, TOG, RV3D_BOXCLIP, B_RV3D_BOXCLIP, "Clip", 260, -30, 50, 19, &rv3d->viewlock, 0, 0, 0, 0, "");
1464 uiDefButO(block, BUT, "SCREEN_OT_region_foursplit", WM_OP_EXEC_REGION_WIN, "4-Split View", 160, -10, 150, 19, "Split 3D View in 4 parts");
1466 uiBlockEndAlign(block);
1470 // uiDefBut(block, LABEL, 1, "Keyframe Display:", 160, -2, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
1471 // uiBlockBeginAlign(block);
1472 // uiDefButBitS(block, TOG, ANIMFILTER_ACTIVE, B_REDR, "Active",160, -22, 50, 19, &v3d->keyflags, 0, 0, 0, 0, "Show keyframes for active element only (i.e. active bone or active material)");
1473 // uiDefButBitS(block, TOG, ANIMFILTER_MUTED, B_REDR, "Muted",210, -22, 50, 19, &v3d->keyflags, 0, 0, 0, 0, "Show keyframes in muted channels");
1474 // uiDefButBitS(block, TOG, ANIMFILTER_LOCAL, B_REDR, "Local",260, -22, 50, 19, &v3d->keyflags, 0, 0, 0, 0, "Show keyframes directly connected to datablock");
1475 // if ((v3d->keyflags & ANIMFILTER_LOCAL)==0) {
1476 // uiDefButBitS(block, TOGN, ANIMFILTER_NOMAT, B_REDR, "Material",160, -42, 75, 19, &v3d->keyflags, 0, 0, 0, 0, "Show keyframes for any available Materials");
1477 // uiDefButBitS(block, TOGN, ANIMFILTER_NOSKEY, B_REDR, "ShapeKey",235, -42, 75, 19, &v3d->keyflags, 0, 0, 0, 0, "Show keyframes for any available Shape Keys");
1479 uiBlockEndAlign(block);
1483 static void view3d_panel_preview(bContext *C, ARegion *ar, short cntrl) // VIEW3D_HANDLER_PREVIEW
1486 View3D *v3d= sa->spacedata.first;
1489 block= uiBeginBlock(C, ar, "view3d_panel_preview", UI_EMBOSS);
1490 uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl);
1491 uiSetPanelHandler(VIEW3D_HANDLER_PREVIEW); // for close and esc
1493 ofsx= -150+(sa->winx/2)/v3d->blockscale;
1494 ofsy= -100+(sa->winy/2)/v3d->blockscale;
1495 if(uiNewPanel(C, ar, block, "Preview", "View3d", ofsx, ofsy, 300, 200)==0) return;
1497 uiBlockSetDrawExtraFunc(block, BIF_view3d_previewdraw);
1499 if(scene->recalc & SCE_PRV_CHANGED) {
1500 scene->recalc &= ~SCE_PRV_CHANGED;
1501 //printf("found recalc\n");
1502 BIF_view3d_previewrender_free(sa->spacedata.first);
1503 BIF_preview_changed(0);
1509 static void view3d_panel_gpencil(const bContext *C, Panel *pa)
1511 View3D *v3d= CTX_wm_view3d(C);
1514 block= uiLayoutFreeBlock(pa->layout);
1516 /* allocate memory for gpd if drawing enabled (this must be done first or else we crash) */
1517 if (v3d->flag2 & V3D_DISPGP) {
1518 // if (v3d->gpd == NULL)
1519 // XXX gpencil_data_setactive(ar, gpencil_data_addnew());
1522 if (v3d->flag2 & V3D_DISPGP) {
1523 // XXX bGPdata *gpd= v3d->gpd;
1525 /* draw button for showing gpencil settings and drawings */
1526 uiDefButBitS(block, TOG, V3D_DISPGP, B_REDR, "Use Grease Pencil", 10, 225, 150, 20, &v3d->flag2, 0, 0, 0, 0, "Display freehand annotations overlay over this 3D View (draw using Shift-LMB)");
1529 uiDefButBitS(block, TOG, V3D_DISPGP, B_REDR, "Use Grease Pencil", 10, 225, 150, 20, &v3d->flag2, 0, 0, 0, 0, "Display freehand annotations overlay over this 3D View");
1530 uiDefBut(block, LABEL, 1, " ", 160, 180, 150, 20, NULL, 0.0, 0.0, 0, 0, "");
1535 static void delete_sketch_armature(bContext *C, void *arg1, void *arg2)
1537 BIF_deleteSketch(C);
1540 static void convert_sketch_armature(bContext *C, void *arg1, void *arg2)
1542 BIF_convertSketch(C);
1545 static void assign_template_sketch_armature(bContext *C, void *arg1, void *arg2)
1547 int index = *(int*)arg1;
1548 BIF_setTemplate(C, index);
1551 static int view3d_panel_bonesketch_spaces_poll(const bContext *C, PanelType *pt)
1553 Object *obedit = CTX_data_edit_object(C);
1555 /* replace with check call to sketching lib */
1556 return (obedit && obedit->type == OB_ARMATURE);
1558 static void view3d_panel_bonesketch_spaces(const bContext *C, Panel *pa)
1560 Scene *scene = CTX_data_scene(C);
1561 static int template_index;
1562 static char joint_label[128];
1568 static char subdiv_tooltip[4][64] = {
1569 "Subdivide arcs based on a fixed number of bones",
1570 "Subdivide arcs in bones of equal length",
1571 "Subdivide arcs based on correlation",
1572 "Retarget template to stroke"
1576 block= uiLayoutFreeBlock(pa->layout);
1577 uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
1579 uiBlockBeginAlign(block);
1581 /* use real flag instead of 1 */
1582 uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 160, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones, (Ctrl snaps to mesh volume)");
1583 uiDefButBitC(block, TOG, BONE_SKETCHING_ADJUST, B_REDR, "A", 170, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Adjust strokes by drawing near them");
1584 uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 190, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
1587 but = uiDefBut(block, BUT, B_REDR, "Convert", 10,yco,100,20, 0, 0, 0, 0, 0, "Convert sketch to armature");
1588 uiButSetFunc(but, convert_sketch_armature, NULL, NULL);
1590 but = uiDefBut(block, BUT, B_REDR, "Delete", 110,yco,100,20, 0, 0, 0, 0, 0, "Delete sketch");
1591 uiButSetFunc(but, delete_sketch_armature, NULL, NULL);
1594 uiBlockEndAlign(block);
1596 uiBlockBeginAlign(block);
1598 uiDefButC(block, MENU, B_REDR, "Subdivision Method%t|Length%x1|Adaptative%x2|Fixed%x0|Template%x3", 10,yco,60,19, &scene->toolsettings->bone_sketching_convert, 0, 0, 0, 0, subdiv_tooltip[(unsigned char)scene->toolsettings->bone_sketching_convert]);
1600 switch(scene->toolsettings->bone_sketching_convert)
1602 case SK_CONVERT_CUT_LENGTH:
1603 uiDefButF(block, NUM, B_REDR, "Lim:", 70, yco, 140, 19, &scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0, "Maximum length of the subdivided bones");
1606 case SK_CONVERT_CUT_ADAPTATIVE:
1607 uiDefButF(block, NUM, B_REDR, "Thres:", 70, yco, 140, 19, &scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0, "Correlation threshold for subdivision");
1611 case SK_CONVERT_CUT_FIXED:
1612 uiDefButC(block, NUM, B_REDR, "Num:", 70, yco, 140, 19, &scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Number of subdivided bones");
1615 case SK_CONVERT_RETARGET:
1616 uiDefButC(block, ROW, B_NOP, "No", 70, yco, 40,19, &scene->toolsettings->skgen_retarget_roll, 0, 0, 0, 0, "No special roll treatment");
1617 uiDefButC(block, ROW, B_NOP, "View", 110, yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_VIEW, 0, 0, "Roll bones perpendicular to view");
1618 uiDefButC(block, ROW, B_NOP, "Joint", 160, yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_JOINT, 0, 0, "Roll bones relative to joint bend");
1621 uiBlockEndAlign(block);
1623 uiBlockBeginAlign(block);
1624 /* button here to select what to do (copy or not), template, ...*/
1626 BIF_makeListTemplates(C);
1627 template_index = BIF_currentTemplate(C);
1629 but = uiDefButI(block, MENU, B_REDR, BIF_listTemplates(C), 10,yco,200,19, &template_index, 0, 0, 0, 0, "Template");
1630 uiButSetFunc(but, assign_template_sketch_armature, &template_index, NULL);
1634 uiDefButF(block, NUM, B_NOP, "A:", 10, yco, 66,19, &scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0, "Angle Weight");
1635 uiDefButF(block, NUM, B_NOP, "L:", 76, yco, 67,19, &scene->toolsettings->skgen_retarget_length_weight, 0, 10, 1, 0, "Length Weight");
1636 uiDefButF(block, NUM, B_NOP, "D:", 143,yco, 67,19, &scene->toolsettings->skgen_retarget_distance_weight, 0, 10, 1, 0, "Distance Weight");
1639 uiDefBut(block, TEX,B_REDR,"S:", 10, yco, 90, 20, scene->toolsettings->skgen_side_string, 0.0, 8.0, 0, 0, "Text to replace &S with");
1640 uiDefBut(block, TEX,B_REDR,"N:", 100, yco, 90, 20, scene->toolsettings->skgen_num_string, 0.0, 8.0, 0, 0, "Text to replace &N with");
1641 uiDefIconButBitC(block, TOG, SK_RETARGET_AUTONAME, B_NOP, ICON_AUTO,190,yco,20,20, &scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0, "Use Auto Naming");
1644 /* auto renaming magic */
1645 uiBlockEndAlign(block);
1647 nb_joints = BIF_nbJointsTemplate(C);
1649 if (nb_joints == -1)
1652 //nb_joints = G.totvertsel;
1655 bone_name = BIF_nameBoneTemplate(C);
1657 BLI_snprintf(joint_label, 32, "%i joints: %s", nb_joints, bone_name);
1659 uiDefBut(block, LABEL, 1, joint_label, 10, yco, 200, 20, NULL, 0.0, 0.0, 0, 0, "");
1664 uiBlockEndAlign(block);
1666 uiDefButBitS(block, TOG, SCE_SNAP_PEEL_OBJECT, B_NOP, "Peel Objects", 10, yco, 200, 20, &scene->toolsettings->snap_flag, 0, 0, 0, 0, "Peel whole objects as one");
1671 static void redo_cb(bContext *C, void *arg_op, void *arg2)
1673 wmOperator *lastop= arg_op;
1678 printf("operator redo %s\n", lastop->type->name);
1680 retval= WM_operator_repeat(C, lastop);
1681 if((retval & OPERATOR_FINISHED)==0) {
1682 printf("operator redo failed %s\n", lastop->type->name);
1688 static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
1690 wmWindowManager *wm= CTX_wm_manager(C);
1695 block= uiLayoutGetBlock(pa->layout);
1697 /* only for operators that are registered and did an undo push */
1698 for(op= wm->operators.last; op; op= op->prev)
1699 if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO))
1705 uiBlockSetFunc(block, redo_cb, op, NULL);
1707 if(!op->properties) {
1708 IDPropertyTemplate val = {0};
1709 op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
1712 RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
1713 uiDefAutoButsRNA(C, pa->layout, &ptr, 2);
1716 void view3d_buttons_register(ARegionType *art)
1720 pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel object");
1721 strcpy(pt->idname, "VIEW3D_PT_object");
1722 strcpy(pt->label, "Transform Properties");
1723 pt->draw= view3d_panel_object;
1724 BLI_addtail(&art->paneltypes, pt);
1726 pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel properties");
1727 strcpy(pt->idname, "VIEW3D_PT_properties");
1728 strcpy(pt->label, "View Properties");
1729 pt->draw= view3d_panel_properties;
1730 BLI_addtail(&art->paneltypes, pt);
1732 pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel background");
1733 strcpy(pt->idname, "VIEW3D_PT_background");
1734 strcpy(pt->label, "Background Image");
1735 pt->draw= view3d_panel_background;
1736 BLI_addtail(&art->paneltypes, pt);
1738 pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel brush");
1739 strcpy(pt->idname, "VIEW3D_PT_brush");
1740 strcpy(pt->label, "Brush");
1741 pt->draw= view3d_panel_brush;
1742 pt->poll= view3d_panel_brush_poll;
1743 BLI_addtail(&art->paneltypes, pt);
1745 pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel transform spaces");
1746 strcpy(pt->idname, "VIEW3D_PT_transform spaces");
1747 strcpy(pt->label, "Transform Orientations");
1748 pt->draw= view3d_panel_transform_spaces;
1749 BLI_addtail(&art->paneltypes, pt);
1751 /*pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel gpencil");
1752 strcpy(pt->idname, "VIEW3D_PT_gpencil");
1753 strcpy(pt->label, "Greas Pencil");
1754 pt->draw= view3d_panel_gpencil;
1755 BLI_addtail(&art->paneltypes, pt);*/
1757 pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel bonesketch spaces");
1758 strcpy(pt->idname, "VIEW3D_PT_bonesketch_spaces");
1759 strcpy(pt->label, "Bone Sketching");
1760 pt->draw= view3d_panel_bonesketch_spaces;
1761 pt->poll= view3d_panel_bonesketch_spaces_poll;
1762 BLI_addtail(&art->paneltypes, pt);
1764 pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel redo");
1765 strcpy(pt->idname, "VIEW3D_PT_redo");
1766 strcpy(pt->label, "Last Operator");
1767 pt->draw= view3d_panel_operator_redo;
1768 BLI_addtail(&art->paneltypes, pt);
1770 // XXX view3d_panel_preview(C, ar, 0);
1773 static int view3d_properties(bContext *C, wmOperator *op)
1775 ScrArea *sa= CTX_wm_area(C);
1776 ARegion *ar= view3d_has_buttons_region(sa);
1779 ar->flag ^= RGN_FLAG_HIDDEN;
1780 ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */
1782 ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
1783 ED_area_tag_redraw(sa);
1785 return OPERATOR_FINISHED;
1788 void VIEW3D_OT_properties(wmOperatorType *ot)
1790 ot->name= "Properties";
1791 ot->idname= "VIEW3D_OT_properties";
1793 ot->exec= view3d_properties;
1794 ot->poll= ED_operator_view3d_active;