Continuing OBJ exporter conversion.
[blender.git] / source / blender / editors / interface / interface_templates.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
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.
10  *
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.
15  *
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.
19  *
20  * Contributor(s): Blender Foundation 2009.
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 #include <stdlib.h>
26
27 #include "MEM_guardedalloc.h"
28
29 #include "BLI_string.h"
30
31 #include "BKE_context.h"
32 #include "BKE_library.h"
33 #include "BKE_utildefines.h"
34
35 #include "ED_screen.h"
36
37 #include "RNA_access.h"
38
39 #include "WM_api.h"
40 #include "WM_types.h"
41
42 #include "UI_interface.h"
43 #include "UI_resources.h"
44
45 void ui_template_fix_linking()
46 {
47 }
48
49 /********************** Header Template *************************/
50
51 void uiTemplateHeader(uiLayout *layout, bContext *C)
52 {
53         uiBlock *block;
54         
55         block= uiLayoutFreeBlock(layout);
56         ED_area_header_standardbuttons(C, block, 0);
57 }
58
59 /******************* Header ID Template ************************/
60
61 typedef struct TemplateHeaderID {
62         PointerRNA ptr;
63         PropertyRNA *prop;
64
65         int flag;
66         short browse;
67
68         char newop[256];
69         char openop[256];
70         char unlinkop[256];
71 } TemplateHeaderID;
72
73 static void template_header_id_cb(bContext *C, void *arg_litem, void *arg_event)
74 {
75         TemplateHeaderID *template= (TemplateHeaderID*)arg_litem;
76         PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop);
77         ID *idtest, *id= idptr.data;
78         ListBase *lb= wich_libbase(CTX_data_main(C), ID_TXT);
79         int nr, event= GET_INT_FROM_POINTER(arg_event);
80         
81         if(event == UI_ID_BROWSE && template->browse == 32767)
82                 event= UI_ID_ADD_NEW;
83         else if(event == UI_ID_BROWSE && template->browse == 32766)
84                 event= UI_ID_OPEN;
85
86         switch(event) {
87                 case UI_ID_BROWSE: {
88                         if(template->browse== -2) {
89                                 /* XXX implement or find a replacement
90                                  * activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &template->browse, do_global_buttons); */
91                                 return;
92                         }
93                         if(template->browse < 0)
94                                 return;
95
96                         for(idtest=lb->first, nr=1; idtest; idtest=idtest->next, nr++) {
97                                 if(nr==template->browse) {
98                                         if(id == idtest)
99                                                 return;
100
101                                         id= idtest;
102                                         RNA_id_pointer_create(id, &idptr);
103                                         RNA_property_pointer_set(&template->ptr, template->prop, idptr);
104                                         RNA_property_update(C, &template->ptr, template->prop);
105                                         /* XXX */
106
107                                         break;
108                                 }
109                         }
110                         break;
111                 }
112 #if 0
113                 case UI_ID_DELETE:
114                         id= NULL;
115                         break;
116                 case UI_ID_FAKE_USER:
117                         if(id) {
118                                 if(id->flag & LIB_FAKEUSER) id->us++;
119                                 else id->us--;
120                         }
121                         else return;
122                         break;
123 #endif
124                 case UI_ID_PIN:
125                         break;
126                 case UI_ID_ADD_NEW:
127                         WM_operator_name_call(C, template->newop, WM_OP_INVOKE_REGION_WIN, NULL);
128                         break;
129                 case UI_ID_OPEN:
130                         WM_operator_name_call(C, template->openop, WM_OP_INVOKE_REGION_WIN, NULL);
131                         break;
132 #if 0
133                 case UI_ID_ALONE:
134                         if(!id || id->us < 1)
135                                 return;
136                         break;
137                 case UI_ID_LOCAL:
138                         if(!id || id->us < 1)
139                                 return;
140                         break;
141                 case UI_ID_AUTO_NAME:
142                         break;
143 #endif
144         }
145 }
146
147 static void template_header_ID(bContext *C, uiBlock *block, TemplateHeaderID *template)
148 {
149         uiBut *but;
150         TemplateHeaderID *duptemplate;
151         PointerRNA idptr;
152         ListBase *lb;
153         int x= 0, y= 0;
154
155         idptr= RNA_property_pointer_get(&template->ptr, template->prop);
156         lb= wich_libbase(CTX_data_main(C), ID_TXT);
157
158         uiBlockBeginAlign(block);
159         if(template->flag & UI_ID_BROWSE) {
160                 char *extrastr, *str;
161                 
162                 if((template->flag & UI_ID_ADD_NEW) && (template->flag && UI_ID_OPEN))
163                         extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
164                 else if(template->flag & UI_ID_ADD_NEW)
165                         extrastr= "ADD NEW %x 32767";
166                 else if(template->flag & UI_ID_OPEN)
167                         extrastr= "OPEN NEW %x 32766";
168                 else
169                         extrastr= NULL;
170
171                 duptemplate= MEM_dupallocN(template);
172                 IDnames_to_pupstring(&str, NULL, extrastr, lb, idptr.data, &duptemplate->browse);
173
174                 but= uiDefButS(block, MENU, 0, str, x, y, UI_UNIT_X, UI_UNIT_Y, &duptemplate->browse, 0, 0, 0, 0, "Browse existing choices, or add new");
175                 uiButSetNFunc(but, template_header_id_cb, duptemplate, SET_INT_IN_POINTER(UI_ID_BROWSE));
176                 x+= UI_UNIT_X;
177         
178                 MEM_freeN(str);
179         }
180
181         /* text button with name */
182         if(idptr.data) {
183                 char name[64];
184
185                 text_idbutton(idptr.data, name);
186                 but= uiDefButR(block, TEX, 0, name, x, y, UI_UNIT_X*6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
187                 uiButSetNFunc(but, template_header_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME));
188                 x += UI_UNIT_X*6;
189
190                 /* delete button */
191                 if(template->flag & UI_ID_DELETE) {
192                         but= uiDefIconButO(block, BUT, template->unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, x, y, UI_UNIT_X, UI_UNIT_Y, NULL);
193                         x += UI_UNIT_X;
194                 }
195         }
196         uiBlockEndAlign(block);
197 }
198
199 void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop)
200 {
201         TemplateHeaderID *template;
202         uiBlock *block;
203         PropertyRNA *prop;
204
205         if(!ptr->data)
206                 return;
207
208         prop= RNA_struct_find_property(ptr, propname);
209
210         if(!prop) {
211                 printf("uiTemplateHeaderID: property not found: %s\n", propname);
212                 return;
213         }
214
215         template= MEM_callocN(sizeof(TemplateHeaderID), "TemplateHeaderID");
216         template->ptr= *ptr;
217         template->prop= prop;
218         template->flag= UI_ID_BROWSE|UI_ID_RENAME;
219
220         if(newop) {
221                 template->flag |= UI_ID_ADD_NEW;
222                 BLI_strncpy(template->newop, newop, sizeof(template->newop));
223         }
224         if(openop) {
225                 template->flag |= UI_ID_OPEN;
226                 BLI_strncpy(template->openop, openop, sizeof(template->openop));
227         }
228         if(unlinkop) {
229                 template->flag |= UI_ID_DELETE;
230                 BLI_strncpy(template->unlinkop, unlinkop, sizeof(template->unlinkop));
231         }
232
233         block= uiLayoutFreeBlock(layout);
234         template_header_ID(C, block, template);
235
236         MEM_freeN(template);
237 }
238
239 /************************ Modifier Template *************************/
240
241 #define ERROR_LIBDATA_MESSAGE "Can't edit external libdata"
242
243 #define B_NOP                           0
244 #define B_MODIFIER_RECALC       1
245 #define B_MODIFIER_REDRAW       2
246 #define B_CHANGEDEP                     3
247 #define B_ARM_RECALCDATA        4
248
249 #include <string.h>
250
251 #include "DNA_armature_types.h"
252 #include "DNA_curve_types.h"
253 #include "DNA_object_force.h"
254 #include "DNA_object_types.h"
255 #include "DNA_mesh_types.h"
256 #include "DNA_meshdata_types.h"
257 #include "DNA_modifier_types.h"
258 #include "DNA_particle_types.h"
259 #include "DNA_scene_types.h"
260
261 #include "BKE_bmesh.h"
262 #include "BKE_curve.h"
263 #include "BKE_depsgraph.h"
264 #include "BKE_DerivedMesh.h"
265 #include "BKE_displist.h"
266 #include "BKE_global.h"
267 #include "BKE_lattice.h"
268 #include "BKE_main.h"
269 #include "BKE_mesh.h"
270 #include "BKE_modifier.h"
271 #include "BKE_object.h"
272 #include "BKE_particle.h"
273 #include "BKE_report.h"
274
275 #include "UI_resources.h"
276 #include "ED_util.h"
277
278 #include "BLI_arithb.h"
279 #include "BLI_listbase.h"
280
281 #include "ED_object.h"
282
283 void do_modifier_panels(bContext *C, void *arg, int event)
284 {
285         Scene *scene= CTX_data_scene(C);
286         Object *ob = CTX_data_active_object(C);
287
288         switch(event) {
289         case B_MODIFIER_REDRAW:
290                 WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
291                 break;
292
293         case B_MODIFIER_RECALC:
294                 WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
295                 DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
296                 object_handle_update(scene, ob);
297                 // XXX countall();
298                 break;
299         }
300 }
301
302 static void modifiers_del(bContext *C, void *ob_v, void *md_v)
303 {
304         ReportList reports;
305
306         BKE_reports_init(&reports, RPT_STORE);
307
308         if(ED_object_modifier_delete(&reports, ob_v, md_v))
309                 ED_undo_push(C, "Delete modifier");
310         else
311                 uiPupMenuReports(C, &reports);
312
313         BKE_reports_clear(&reports);
314 }
315
316 static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
317 {
318         ReportList reports;
319
320         BKE_reports_init(&reports, RPT_STORE);
321
322         if(ED_object_modifier_move_up(&reports, ob_v, md_v))
323                 ED_undo_push(C, "Move modifier");
324         else
325                 uiPupMenuReports(C, &reports);
326
327         BKE_reports_clear(&reports);
328 }
329
330 static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
331 {
332         ReportList reports;
333
334         BKE_reports_init(&reports, RPT_STORE);
335
336         if(ED_object_modifier_move_down(&reports, ob_v, md_v))
337                 ED_undo_push(C, "Move modifier");
338         else
339                 uiPupMenuReports(C, &reports);
340
341         BKE_reports_clear(&reports);
342 }
343
344 static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
345 {
346         Scene *scene= CTX_data_scene(C);
347         ReportList reports;
348
349         BKE_reports_init(&reports, RPT_STORE);
350
351         if(ED_object_modifier_convert(&reports, scene, obv, mdv))
352                 ED_undo_push(C, "Convert particles to mesh object(s).");
353         else
354                 uiPupMenuReports(C, &reports);
355
356         BKE_reports_clear(&reports);
357 }
358
359 static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
360 {
361         Scene *scene= CTX_data_scene(C);
362         ReportList reports;
363
364         BKE_reports_init(&reports, RPT_STORE);
365
366         if(ED_object_modifier_apply(&reports, scene, obv, mdv))
367                 ED_undo_push(C, "Apply modifier");
368         else
369                 uiPupMenuReports(C, &reports);
370
371         BKE_reports_clear(&reports);
372 }
373
374 static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
375 {
376         ReportList reports;
377
378         BKE_reports_init(&reports, RPT_STORE);
379
380         if(ED_object_modifier_copy(&reports, ob_v, md_v))
381                 ED_undo_push(C, "Copy modifier");
382         else
383                 uiPupMenuReports(C, &reports);
384
385         BKE_reports_clear(&reports);
386 }
387
388 static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
389 {
390         Object *ob = ob_v;
391         ModifierData *md;
392         
393         int i, cageIndex = modifiers_getCageIndex(ob, NULL );
394
395         for( i = 0, md=ob->modifiers.first; md; ++i, md=md->next )
396                 if( md == md_v ) {
397                         if( i >= cageIndex )
398                                 md->mode ^= eModifierMode_OnCage;
399                         break;
400                 }
401 }
402
403 static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
404 {
405         Object *ob = ob_v;
406         ModifierData *md = md_v;
407         ModifierData *nmd = modifier_new(md->type);
408
409         modifier_copyData(md, nmd);
410         nmd->mode &= ~eModifierMode_Virtual;
411
412         BLI_addhead(&ob->modifiers, nmd);
413
414         ob->partype = PAROBJECT;
415
416         ED_undo_push(C, "Modifier convert to real");
417 }
418
419 #if 0
420 static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v)
421 {
422         Object *ob = ob_v;
423         ModifierData *md = md_v;
424         HookModifierData *hmd = (HookModifierData*) md;
425         
426         if (hmd->object) {
427                 Mat4Invert(hmd->object->imat, hmd->object->obmat);
428                 Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
429                 ED_undo_push(C, "Clear hook offset");
430         }
431 }
432
433 static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v)
434 {
435         /* XXX 
436         Object *ob = ob_v;
437         ModifierData *md = md_v;
438         HookModifierData *hmd = (HookModifierData*) md;
439
440         if(G.vd) {
441                 float *curs = give_cursor();
442                 float bmat[3][3], imat[3][3];
443
444                 where_is_object(ob);
445         
446                 Mat3CpyMat4(bmat, ob->obmat);
447                 Mat3Inv(imat, bmat);
448
449                 curs= give_cursor();
450                 hmd->cent[0]= curs[0]-ob->obmat[3][0];
451                 hmd->cent[1]= curs[1]-ob->obmat[3][1];
452                 hmd->cent[2]= curs[2]-ob->obmat[3][2];
453                 Mat3MulVecfl(imat, hmd->cent);
454
455                 ED_undo_push(C, "Hook cursor center");
456         }*/
457 }
458
459 static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v)
460 {
461         /* XXX ModifierData *md = md_v;
462         HookModifierData *hmd = (HookModifierData*) md;
463
464         hook_select(hmd);*/
465 }
466
467 static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v)
468 {
469         /* XXX ModifierData *md = md_v;
470         HookModifierData *hmd = (HookModifierData*) md;
471         float cent[3];
472         int *indexar, tot, ok;
473         char name[32];
474                 
475         ok= hook_getIndexArray(&tot, &indexar, name, cent);
476
477         if (!ok) {
478                 uiPupMenuError(C, "Requires selected vertices or active Vertex Group");
479         } else {
480                 if (hmd->indexar) {
481                         MEM_freeN(hmd->indexar);
482                 }
483
484                 VECCOPY(hmd->cent, cent);
485                 hmd->indexar = indexar;
486                 hmd->totindex = tot;
487         }*/
488 }
489
490 static void modifiers_bindMeshDeform(bContext *C, void *ob_v, void *md_v)
491 {
492         Scene *scene= CTX_data_scene(C);
493         MeshDeformModifierData *mmd = (MeshDeformModifierData*) md_v;
494         Object *ob = (Object*)ob_v;
495
496         if(mmd->bindcos) {
497                 if(mmd->bindweights) MEM_freeN(mmd->bindweights);
498                 if(mmd->bindcos) MEM_freeN(mmd->bindcos);
499                 if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
500                 if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
501                 if(mmd->dynverts) MEM_freeN(mmd->dynverts);
502                 mmd->bindweights= NULL;
503                 mmd->bindcos= NULL;
504                 mmd->dyngrid= NULL;
505                 mmd->dyninfluences= NULL;
506                 mmd->dynverts= NULL;
507                 mmd->totvert= 0;
508                 mmd->totcagevert= 0;
509                 mmd->totinfluence= 0;
510         }
511         else {
512                 DerivedMesh *dm;
513                 int mode= mmd->modifier.mode;
514
515                 /* force modifier to run, it will call binding routine */
516                 mmd->needbind= 1;
517                 mmd->modifier.mode |= eModifierMode_Realtime;
518
519                 if(ob->type == OB_MESH) {
520                         dm= mesh_create_derived_view(scene, ob, 0);
521                         dm->release(dm);
522                 }
523                 else if(ob->type == OB_LATTICE) {
524                         lattice_calc_modifiers(scene, ob);
525                 }
526                 else if(ob->type==OB_MBALL) {
527                         makeDispListMBall(scene, ob);
528                 }
529                 else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
530                         makeDispListCurveTypes(scene, ob, 0);
531                 }
532
533                 mmd->needbind= 0;
534                 mmd->modifier.mode= mode;
535         }
536 }
537
538 void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2)
539 {
540         ExplodeModifierData *emd=arg1;
541
542         emd->flag |= eExplodeFlag_CalcFaces;
543 }
544
545 void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2)
546 {
547         ExplodeModifierData *emd=arg1;
548         emd->vgroup = 0;
549 }
550 #endif
551
552 static int modifier_is_fluid_particles(ModifierData *md)
553 {
554         if(md->type == eModifierType_ParticleSystem) {
555                 if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
556                         return 1;
557         }
558         return 0;
559 }
560
561 static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex)
562 {
563         ModifierTypeInfo *mti = modifierType_getInfo(md->type);
564         uiBut *but;
565         uiBlock *block;
566         uiLayout *column, *row, *result= NULL;
567         int isVirtual = md->mode&eModifierMode_Virtual;
568         int x = 0, y = 0; // XXX , color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
569         short width = 295, buttonWidth = width-120-10;
570         char str[128];
571
572         column= uiLayoutColumn(layout, 1);
573
574         /* rounded header */
575         /* XXX uiBlockSetCol(block, color); */
576                 /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
577         block= uiLayoutFreeBlock(uiLayoutBox(column));
578         uiBlockSetHandleFunc(block, do_modifier_panels, NULL);
579
580         //uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0, 
581         //               (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, ""); 
582         /* XXX uiBlockSetCol(block, TH_AUTO); */
583         
584         /* open/close icon */
585         if (!isVirtual) {
586                 uiBlockSetEmboss(block, UI_EMBOSSN);
587                 uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, B_MODIFIER_REDRAW, ICON_TRIA_RIGHT, x-10, y-2, 20, 20, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
588         }
589
590         uiBlockSetEmboss(block, UI_EMBOSS);
591         
592         if (isVirtual) {
593                 sprintf(str, "%s parent deform", md->name);
594                 uiDefBut(block, LABEL, 0, str, x+10, y-1, width-110, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); 
595
596                 but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Make Real", x+width-100, y, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
597                 uiButSetFunc(but, modifiers_convertToReal, ob, md);
598         } else {
599                 uiBlockBeginAlign(block);
600                 uiDefBut(block, TEX, B_MODIFIER_REDRAW, "", x+10, y-1, buttonWidth-60, 19, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); 
601
602                 /* Softbody not allowed in this situation, enforce! */
603                 if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
604                         uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
605                         but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, ICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
606                         if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
607                                 uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, ICON_EDITMODE_HLT, x+10+buttonWidth-20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
608                         }
609                 }
610                 uiBlockEndAlign(block);
611
612                 /* XXX uiBlockSetEmboss(block, UI_EMBOSSR); */
613
614                 if (ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
615                         int icon; //, color;
616
617                         if (index==cageIndex) {
618                                 // XXX color = TH_BUT_SETTING;
619                                 icon = VICON_EDITMODE_HLT;
620                         } else if (index<cageIndex) {
621                                 // XXX color = TH_BUT_NEUTRAL;
622                                 icon = VICON_EDITMODE_DEHLT;
623                         } else {
624                                 // XXX color = TH_BUT_NEUTRAL;
625                                 icon = ICON_BLANK1;
626                         }
627                         /* XXX uiBlockSetCol(block, color); */
628                         but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, icon, x+width-105, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode");
629                         uiButSetFunc(but, modifiers_setOnCage, ob, md);
630                         /* XXX uiBlockSetCol(block, TH_AUTO); */
631                 }
632
633                 /* XXX uiBlockSetCol(block, TH_BUT_ACTION); */
634
635                 but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_UP, x+width-75, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
636                 uiButSetFunc(but, modifiers_moveUp, ob, md);
637
638                 but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_DOWN, x+width-75+20, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
639                 uiButSetFunc(but, modifiers_moveDown, ob, md);
640                 
641                 uiBlockSetEmboss(block, UI_EMBOSSN);
642                 
643                 // deletion over the deflection panel
644                 // fluid particle modifier can't be deleted here
645                 if(md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Collision && md->type!=eModifierType_Surface && !modifier_is_fluid_particles(md))
646                 {
647                         but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_X, x+width-70+40, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
648                         uiButSetFunc(but, modifiers_del, ob, md);
649                 }
650                 /* XXX uiBlockSetCol(block, TH_AUTO); */
651         }
652
653         uiBlockSetEmboss(block, UI_EMBOSS);
654
655         if(!isVirtual && (md->mode&eModifierMode_Expanded)) {
656                 int cy = y - 8;
657                 int lx = x + width - 60 - 15;
658                 uiLayout *box;
659
660                 box= uiLayoutBox(column);
661                 row= uiLayoutRow(box, 1);
662
663                 y -= 18;
664
665                 if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
666                         uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */
667
668                                                 if (md->type==eModifierType_ParticleSystem) {
669                         ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys;
670
671                         if(!(G.f & G_PARTICLEEDIT)) {
672                                         if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) {
673                                                 but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Convert",        lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
674                                                 uiButSetFunc(but, modifiers_convertParticles, ob, md);
675                                         }
676                                 }
677                         }
678                         else{
679                                 but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Apply",  lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
680                                 uiButSetFunc(but, modifiers_applyModifier, ob, md);
681                         }
682                         
683                         uiBlockClearButLock(block);
684                         uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
685
686                         if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) {
687                                 but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Copy",   lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
688                                 uiButSetFunc(but, modifiers_copyModifier, ob, md);
689                         }
690                 }
691
692                 result= uiLayoutColumn(box, 0);
693                 block= uiLayoutFreeBlock(box);
694
695                 lx = x + 10;
696                 cy = y + 10 - 1;
697                 // else if (md->type==eModifierType_Surface) {
698                 //      uiDefBut(block, LABEL, 1, "See Fields panel.",  lx, (cy-=19), buttonWidth,19, NULL, 0.0, 0.0, 0, 0, "");
699         }
700
701         if (md->error) {
702                 row = uiLayoutRow(uiLayoutBox(column), 0);
703
704                 /* XXX uiBlockSetCol(block, color); */
705                 uiItemL(row, md->error, ICON_ERROR);
706                 /* XXX uiBlockSetCol(block, TH_AUTO); */
707         }
708
709         return result;
710 }
711
712 uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr)
713 {
714         Object *ob;
715         ModifierData *md, *vmd;
716         int i, lastCageIndex, cageIndex;
717
718         /* verify we have valid data */
719         if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
720                 printf("uiTemplateModifier: expected modifier on object.\n");
721                 return NULL;
722         }
723
724         ob= ptr->id.data;
725         md= ptr->data;
726
727         if(!ob || !(GS(ob->id.name) == ID_OB)) {
728                 printf("uiTemplateModifier: expected modifier on object.\n");
729                 return NULL;
730         }
731         
732         uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE);
733         
734         /* find modifier and draw it */
735         cageIndex = modifiers_getCageIndex(ob, &lastCageIndex);
736
737         // XXX virtual modifiers are not accesible for python
738         vmd = modifiers_getVirtualModifierList(ob);
739
740         for(i=0; vmd; i++, vmd=vmd->next) {
741                 if(md == vmd)
742                         return draw_modifier(layout, ob, md, i, cageIndex, lastCageIndex);
743                 else if(vmd->mode&eModifierMode_Virtual)
744                         i--;
745         }
746
747         return NULL;
748 }
749
750 /************************ Constraint Template *************************/
751
752 #include "DNA_action_types.h"
753 #include "DNA_constraint_types.h"
754
755 #include "BKE_action.h"
756 #include "BKE_constraint.h"
757
758 #define REDRAWIPO                                       1
759 #define REDRAWNLA                                       2
760 #define REDRAWBUTSOBJECT                        3               
761 #define REDRAWACTION                            4
762 #define B_CONSTRAINT_TEST                       5
763 #define B_CONSTRAINT_CHANGETARGET       6
764 #define B_CONSTRAINT_INF                        7
765 #define REMAKEIPO                                       8
766 #define B_DIFF                                          9
767
768 void do_constraint_panels(bContext *C, void *arg, int event)
769 {
770         Scene *scene= CTX_data_scene(C);
771         Object *ob= CTX_data_active_object(C);
772         
773         switch(event) {
774         case B_CONSTRAINT_TEST:
775                 // XXX allqueue(REDRAWVIEW3D, 0);
776                 // XXX allqueue(REDRAWBUTSOBJECT, 0);
777                 // XXX allqueue(REDRAWBUTSEDIT, 0);
778                 break;  // no handling
779         case B_CONSTRAINT_INF:
780                 /* influence; do not execute actions for 1 dag_flush */
781                 if (ob->pose)
782                         ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
783                 break;
784         case B_CONSTRAINT_CHANGETARGET:
785                 if (ob->pose) ob->pose->flag |= POSE_RECALC;    // checks & sorts pose channels
786                 DAG_scene_sort(scene);
787                 break;
788         default:
789                 break;
790         }
791
792         object_test_constraints(ob);
793         
794         if(ob->pose) update_pose_constraint_flags(ob->pose);
795         
796         if(ob->type==OB_ARMATURE) DAG_object_flush_update(scene, ob, OB_RECALC_DATA|OB_RECALC_OB);
797         else DAG_object_flush_update(scene, ob, OB_RECALC_OB);
798         
799         // XXX allqueue(REDRAWVIEW3D, 0);
800         // XXX allqueue(REDRAWBUTSOBJECT, 0);
801         // XXX allqueue(REDRAWBUTSEDIT, 0);
802 }
803
804 static void constraint_active_func(bContext *C, void *ob_v, void *con_v)
805 {
806         ED_object_constraint_set_active(ob_v, con_v);
807 }
808
809 static void del_constraint_func (bContext *C, void *ob_v, void *con_v)
810 {
811         if(ED_object_constraint_delete(NULL, ob_v, con_v))
812                 ED_undo_push(C, "Delete Constraint");
813 }
814
815 static void verify_constraint_name_func (bContext *C, void *con_v, void *name_v)
816 {
817         Object *ob= CTX_data_active_object(C);
818         bConstraint *con= con_v;
819         char oldname[32];       
820         
821         if (!con)
822                 return;
823         
824         /* put on the stack */
825         BLI_strncpy(oldname, (char *)name_v, 32);
826         
827         ED_object_constraint_rename(ob, con, oldname);
828         ED_object_constraint_set_active(ob, con);
829         // XXX allqueue(REDRAWACTION, 0); 
830 }
831
832 static void constraint_moveUp(bContext *C, void *ob_v, void *con_v)
833 {
834         if(ED_object_constraint_move_up(NULL, ob_v, con_v))
835                 ED_undo_push(C, "Move Constraint");
836 }
837
838 static void constraint_moveDown(bContext *C, void *ob_v, void *con_v)
839 {
840         if(ED_object_constraint_move_down(NULL, ob_v, con_v))
841                 ED_undo_push(C, "Move Constraint");
842 }
843
844 /* some commonly used macros in the constraints drawing code */
845 #define is_armature_target(target) (target && target->type==OB_ARMATURE)
846 #define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->flag & OB_POSEMODE))
847 #define is_geom_target(target) (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) )
848
849 /* Helper function for draw constraint - draws constraint space stuff 
850  * This function should not be called if no menus are required 
851  * owner/target: -1 = don't draw menu; 0= not posemode, 1 = posemode 
852  */
853 static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short xco, short yco, short owner, short target)
854 {
855         short tarx, ownx, iconx;
856         short bwidth;
857         short iconwidth = 20;
858         
859         /* calculate sizes and placement of menus */
860         if (owner == -1) {
861                 bwidth = 125;
862                 tarx = 120;
863                 ownx = 0;
864         }
865         else if (target == -1) {
866                 bwidth = 125;
867                 tarx = 0;
868                 ownx = 120;
869         }
870         else {
871                 bwidth = 100;
872                 tarx = 85;
873                 iconx = tarx + bwidth + 5;
874                 ownx = tarx + bwidth + iconwidth + 10;
875         }
876         
877         
878         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Convert:", xco, yco, 80,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
879
880         /* Target-Space */
881         if (target == 1) {
882                 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1", 
883                                                                                                 tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in"); 
884         }
885         else if (target == 0) {
886                 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1", 
887                                                                                 tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in"); 
888         }
889         
890         if ((target != -1) && (owner != -1))
891                 uiDefIconBut(block, LABEL, B_NOP, ICON_ARROW_LEFTRIGHT,
892                         iconx, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
893         
894         /* Owner-Space */
895         if (owner == 1) {
896                 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1", 
897                                                                                                 ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in");  
898         }
899         else if (owner == 0) {
900                 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Local (Without Parent) Space %x1", 
901                                                                                 ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in");  
902         }
903 }
904
905 /* draw panel showing settings for a constraint */
906 static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
907 {
908         bPoseChannel *pchan= get_active_posechannel(ob);
909         bConstraintTypeInfo *cti;
910         uiBlock *block;
911         uiLayout *result= NULL, *col, *box;
912         uiBut *but;
913         char typestr[32];
914         short width = 265;
915         short proxy_protected, xco=0, yco=0;
916         int rb_col;
917
918         /* get constraint typeinfo */
919         cti= constraint_get_typeinfo(con);
920         if (cti == NULL) {
921                 /* exception for 'Null' constraint - it doesn't have constraint typeinfo! */
922                 if (con->type == CONSTRAINT_TYPE_NULL)
923                         strcpy(typestr, "Null");
924                 else
925                         strcpy(typestr, "Unknown");
926         }
927         else
928                 strcpy(typestr, cti->name);
929                 
930         /* determine whether constraint is proxy protected or not */
931         if (proxylocked_constraints_owner(ob, pchan))
932                 proxy_protected= (con->flag & CONSTRAINT_PROXY_LOCAL)==0;
933         else
934                 proxy_protected= 0;
935
936         /* unless button has own callback, it adds this callback to button */
937         block= uiLayoutGetBlock(layout);
938         uiBlockSetHandleFunc(block, do_constraint_panels, NULL);
939         uiBlockSetFunc(block, constraint_active_func, ob, con);
940
941         col= uiLayoutColumn(layout, 1);
942         box= uiLayoutBox(col);
943
944         block= uiLayoutFreeBlock(box);
945                 
946         /* Draw constraint header */
947         uiBlockSetEmboss(block, UI_EMBOSSN);
948         
949         /* rounded header */
950         rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20;
951         
952         /* open/close */
953         uiDefIconButBitS(block, ICONTOG, CONSTRAINT_EXPAND, B_CONSTRAINT_TEST, ICON_TRIA_RIGHT, xco-10, yco, 20, 20, &con->flag, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Constraint");
954         
955         /* name */      
956         if ((con->flag & CONSTRAINT_EXPAND) && (proxy_protected==0)) {
957                 /* XXX if (con->flag & CONSTRAINT_DISABLE)
958                         uiBlockSetCol(block, TH_REDALERT);*/
959                 
960                 uiBlockSetEmboss(block, UI_EMBOSS);
961                 
962                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco+10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
963                 
964                 but = uiDefBut(block, TEX, B_CONSTRAINT_TEST, "", xco+120, yco, 85, 18, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name"); 
965                 uiButSetFunc(but, verify_constraint_name_func, con, NULL);
966         }       
967         else {
968                 uiBlockSetEmboss(block, UI_EMBOSSN);
969                 
970                 /* XXX if (con->flag & CONSTRAINT_DISABLE)
971                         uiBlockSetCol(block, TH_REDALERT);*/
972                 
973                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco+10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
974                 
975                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, xco+120, yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
976         }
977
978         // XXX uiBlockSetCol(block, TH_AUTO);   
979         
980         /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
981         if (proxy_protected) {
982                 uiBlockSetEmboss(block, UI_EMBOSSN);
983                 
984                 /* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
985                 uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco+244, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Proxy Protected");
986                 uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco+262, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Proxy Protected");
987                 
988                 uiBlockSetEmboss(block, UI_EMBOSS);
989         }
990         else {
991                 short prev_proxylock, show_upbut, show_downbut;
992                 
993                 /* Up/Down buttons: 
994                  *      Proxy-constraints are not allowed to occur after local (non-proxy) constraints
995                  *      as that poses problems when restoring them, so disable the "up" button where
996                  *      it may cause this situation. 
997                  *
998                  *      Up/Down buttons should only be shown (or not greyed - todo) if they serve some purpose. 
999                  */
1000                 if (proxylocked_constraints_owner(ob, pchan)) {
1001                         if (con->prev) {
1002                                 prev_proxylock= (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1;
1003                         }
1004                         else
1005                                 prev_proxylock= 0;
1006                 }
1007                 else
1008                         prev_proxylock= 0;
1009                         
1010                 show_upbut= ((prev_proxylock == 0) && (con->prev));
1011                 show_downbut= (con->next) ? 1 : 0;
1012                 
1013                 if (show_upbut || show_downbut) {
1014                         uiBlockBeginAlign(block);
1015                                 uiBlockSetEmboss(block, UI_EMBOSS);
1016                                 
1017                                 if (show_upbut) {
1018                                         but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_UP, xco+width-50, yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint up in constraint stack");
1019                                         uiButSetFunc(but, constraint_moveUp, ob, con);
1020                                 }
1021                                 
1022                                 if (show_downbut) {
1023                                         but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_DOWN, xco+width-50+18, yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint down in constraint stack");
1024                                         uiButSetFunc(but, constraint_moveDown, ob, con);
1025                                 }
1026                         uiBlockEndAlign(block);
1027                 }
1028                 
1029                 
1030                 /* Close 'button' - emboss calls here disable drawing of 'button' behind X */
1031                 uiBlockSetEmboss(block, UI_EMBOSSN);
1032                 
1033                 but = uiDefIconBut(block, BUT, B_CONSTRAINT_CHANGETARGET, ICON_X, xco+262, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Delete constraint");
1034                 uiButSetFunc(but, del_constraint_func, ob, con);
1035                 
1036                 uiBlockSetEmboss(block, UI_EMBOSS);
1037         }
1038         
1039         /* Set but-locks for protected settings (magic numbers are used here!) */
1040         if (proxy_protected)
1041                 uiBlockSetButLock(block, 1, "Cannot edit Proxy-Protected Constraint");
1042         
1043         /* Draw constraint data */
1044         if ((con->flag & CONSTRAINT_EXPAND) == 0) {
1045                 (yco) -= 21;
1046         }
1047         else {
1048                 box= uiLayoutBox(col);
1049                 block= uiLayoutFreeBlock(box);
1050
1051                 switch (con->type) {
1052 #ifndef DISABLE_PYTHON
1053                 case CONSTRAINT_TYPE_PYTHON:
1054                         {
1055                                 bPythonConstraint *data = con->data;
1056                                 bConstraintTarget *ct;
1057                                 // uiBut *but2;
1058                                 int tarnum, theight;
1059                                 // static int pyconindex=0;
1060                                 // char *menustr;
1061                                 
1062                                 theight = (data->tarnum)? (data->tarnum * 38) : (38);
1063                                 
1064                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Script:", xco+60, yco-24, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1065                                 
1066                                 /* do the scripts menu */
1067                                 /* XXX menustr = buildmenu_pyconstraints(data->text, &pyconindex);
1068                                 but2 = uiDefButI(block, MENU, B_CONSTRAINT_TEST, menustr,
1069                                       xco+120, yco-24, 150, 20, &pyconindex,
1070                                       0, 0, 0, 0, "Set the Script Constraint to use");
1071                                 uiButSetFunc(but2, validate_pyconstraint_cb, data, &pyconindex);
1072                                 MEM_freeN(menustr);      */
1073                                 
1074                                 /* draw target(s) */
1075                                 if (data->flag & PYCON_USETARGETS) {
1076                                         /* Draw target parameters */ 
1077                                         for (ct=data->targets.first, tarnum=1; ct; ct=ct->next, tarnum++) {
1078                                                 char tarstr[32];
1079                                                 short yoffset= ((tarnum-1) * 38);
1080         
1081                                                 /* target label */
1082                                                 sprintf(tarstr, "Target %d:", tarnum);
1083                                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, tarstr, xco+45, yco-(48+yoffset), 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1084                                                 
1085                                                 /* target space-selector - per target */
1086                                                 if (is_armature_target(ct->tar)) {
1087                                                         uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x3|Local with Parent %x4|Local Space %x1", 
1088                                                                                                                         xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in"); 
1089                                                 }
1090                                                 else {
1091                                                         uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1", 
1092                                                                                                                         xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in"); 
1093                                                 }
1094                                                 
1095                                                 uiBlockBeginAlign(block);
1096                                                         /* target object */
1097                                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-(48+yoffset), 150, 18, &ct->tar, "Target Object"); 
1098                                                         
1099                                                         /* subtarget */
1100                                                         if (is_armature_target(ct->tar)) {
1101                                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1102                                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)ct->tar);
1103                                                         }
1104                                                         else if (is_geom_target(ct->tar)) {
1105                                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1106                                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ct->tar);
1107                                                         }
1108                                                         else {
1109                                                                 strcpy(ct->subtarget, "");
1110                                                         }
1111                                                 uiBlockEndAlign(block);
1112                                         }
1113                                 }
1114                                 else {
1115                                         /* Draw indication that no target needed */
1116                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+60, yco-48, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1117                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Not Applicable", xco+120, yco-48, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1118                                 }
1119                                 
1120                                 /* settings */
1121                                 uiBlockBeginAlign(block);
1122                                         but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Options", xco, yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Change some of the constraint's settings.");
1123                                         // XXX uiButSetFunc(but, BPY_pyconstraint_settings, data, NULL);
1124                                         
1125                                         but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Refresh", xco+((width/2)+10), yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Force constraint to refresh it's settings");
1126                                 uiBlockEndAlign(block);
1127                                 
1128                                 /* constraint space settings */
1129                                 draw_constraint_spaceselect(block, con, xco, yco-(73+theight), is_armature_owner(ob), -1);
1130                         }
1131                         break;
1132 #endif /* DISABLE_PYTHON */
1133                 case CONSTRAINT_TYPE_ACTION:
1134                         {
1135                                 bActionConstraint *data = con->data;
1136                                 float minval, maxval;
1137                                 
1138                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1139                                 
1140                                 /* Draw target parameters */
1141                                 uiBlockBeginAlign(block);
1142                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1143                                         
1144                                         if (is_armature_target(data->tar)) {
1145                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1146                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1147                                         }
1148                                         else {
1149                                                 strcpy(data->subtarget, "");
1150                                         }
1151                                 
1152                                 uiBlockEndAlign(block);
1153                                 
1154                                 /* Draw action/type buttons */
1155                                 uiBlockBeginAlign(block);
1156                                         uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, B_CONSTRAINT_TEST, "AC:",     xco+((width/2)-117), yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone"); 
1157                                         uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Key on%t|Loc X%x20|Loc Y%x21|Loc Z%x22|Rot X%x0|Rot Y%x1|Rot Z%x2|Size X%x10|Size Y%x11|Size Z%x12", xco+((width/2)-117), yco-84, 78, 18, &data->type, 0, 24, 0, 0, "Specify which transformation channel from the target is used to key the action");
1158                                 uiBlockEndAlign(block);
1159                                 
1160                                 /* Draw start/end frame buttons */
1161                                 uiBlockBeginAlign(block);
1162                                         uiDefButI(block, NUM, B_CONSTRAINT_TEST, "Start:", xco+((width/2)-36), yco-64, 78, 18, &data->start, 1, MAXFRAME, 0.0, 0.0, "Starting frame of the keyed motion"); 
1163                                         uiDefButI(block, NUM, B_CONSTRAINT_TEST, "End:", xco+((width/2)-36), yco-84, 78, 18, &data->end, 1, MAXFRAME, 0.0, 0.0, "Ending frame of the keyed motion"); 
1164                                 uiBlockEndAlign(block);
1165                                 
1166                                 /* Draw minimum/maximum transform range buttons */
1167                                 uiBlockBeginAlign(block);
1168                                         if (data->type < 10) { /* rotation */
1169                                                 minval = -180.0f;
1170                                                 maxval = 180.0f;
1171                                         }
1172                                         else if (data->type < 20) { /* scaling */
1173                                                 minval = 0.0001f;
1174                                                 maxval = 1000.0f;
1175                                         }
1176                                         else { /* location */
1177                                                 minval = -1000.0f;
1178                                                 maxval = 1000.0f;
1179                                         }
1180                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Min:", xco+((width/2)+45), yco-64, 78, 18, &data->min, minval, maxval, 0, 0, "Minimum value for target channel range");
1181                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Max:", xco+((width/2)+45), yco-84, 78, 18, &data->max, minval, maxval, 0, 0, "Maximum value for target channel range");
1182                                 uiBlockEndAlign(block);
1183                                 
1184                                 /* constraint space settings */
1185                                 draw_constraint_spaceselect(block, con, xco, yco-104, -1, is_armature_target(data->tar));
1186                         }
1187                         break;
1188                 case CONSTRAINT_TYPE_CHILDOF:
1189                         {
1190                                 bChildOfConstraint *data = con->data;
1191                                 short normButWidth = (width/3);
1192                                 
1193                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Parent:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1194                                 
1195                                 /* Draw target parameters */
1196                                 uiBlockBeginAlign(block);
1197                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object to use as Parent"); 
1198                                         
1199                                         if (is_armature_target(data->tar)) {
1200                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone to use as Parent");
1201                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1202                                         }
1203                                         else if (is_geom_target(data->tar)) {
1204                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1205                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1206                                         }
1207                                         else {
1208                                                 strcpy(data->subtarget, "");
1209                                         }
1210                                 uiBlockEndAlign(block);
1211                                 
1212                                 /* Draw triples of channel toggles */
1213                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Use Channel(s):", xco+65, yco-64, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1214                                 uiBlockBeginAlign(block); 
1215                                         uiDefButBitI(block, TOG, CHILDOF_LOCX, B_CONSTRAINT_TEST, "Loc X", xco, yco-84, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects x-location"); 
1216                                         uiDefButBitI(block, TOG, CHILDOF_LOCY, B_CONSTRAINT_TEST, "Loc Y", xco+normButWidth, yco-84, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects y-location"); 
1217                                         uiDefButBitI(block, TOG, CHILDOF_LOCZ, B_CONSTRAINT_TEST, "Loc Z", xco+(normButWidth * 2), yco-84, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects z-location"); 
1218                                 uiBlockEndAlign(block); 
1219                                 
1220                                 uiBlockBeginAlign(block); 
1221                                         uiDefButBitI(block, TOG, CHILDOF_ROTX, B_CONSTRAINT_TEST, "Rot X", xco, yco-105, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects x-rotation"); 
1222                                         uiDefButBitI(block, TOG, CHILDOF_ROTY, B_CONSTRAINT_TEST, "Rot Y", xco+normButWidth, yco-105, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects y-rotation"); 
1223                                         uiDefButBitI(block, TOG, CHILDOF_ROTZ, B_CONSTRAINT_TEST, "Rot Z", xco+(normButWidth * 2), yco-105, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects z-rotation"); 
1224                                 uiBlockEndAlign(block); 
1225                                 
1226                                 uiBlockBeginAlign(block); 
1227                                         uiDefButBitI(block, TOG, CHILDOF_SIZEX, B_CONSTRAINT_TEST, "Scale X", xco, yco-126, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects x-scaling"); 
1228                                         uiDefButBitI(block, TOG, CHILDOF_SIZEY, B_CONSTRAINT_TEST, "Scale Y", xco+normButWidth, yco-126, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects y-scaling"); 
1229                                         uiDefButBitI(block, TOG, CHILDOF_SIZEZ, B_CONSTRAINT_TEST, "Scale Z", xco+(normButWidth * 2), yco-126, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects z-scaling"); 
1230                                 uiBlockEndAlign(block);
1231                                 
1232                                 
1233                                 /* Inverse options */
1234                                 uiBlockBeginAlign(block);
1235                                         but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Set Offset", xco, yco-151, (width/2),18, NULL, 0, 24, 0, 0, "Calculate current Parent-Inverse Matrix (i.e. restore offset from parent)");
1236                                         // XXX uiButSetFunc(but, childof_const_setinv, con, NULL);
1237                                         
1238                                         but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Clear Offset", xco+((width/2)+10), yco-151, (width/2),18, NULL, 0, 24, 0, 0, "Clear Parent-Inverse Matrix (i.e. clear offset from parent)");
1239                                         // XXX uiButSetFunc(but, childof_const_clearinv, con, NULL);
1240                                 uiBlockEndAlign(block);
1241                         }
1242                         break;
1243                 case CONSTRAINT_TYPE_ROTLIKE:
1244                         {
1245                                 bRotateLikeConstraint *data = con->data;
1246                                 
1247                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1248                                 
1249                                 /* Draw target parameters */
1250                                 uiBlockBeginAlign(block);
1251                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1252                                         
1253                                         if (is_armature_target(data->tar)) {
1254                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1255                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1256                                         }
1257                                         else if (is_geom_target(data->tar)) { 
1258                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1259                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1260                                         }
1261                                         else {
1262                                                 strcpy(data->subtarget, "");
1263                                         }
1264                                 uiBlockEndAlign(block);
1265                                 
1266                                 /* Draw XYZ toggles */
1267                                 uiBlockBeginAlign(block);
1268                                         uiDefButBitI(block, TOG, ROTLIKE_X, B_CONSTRAINT_TEST, "X", xco+((width/2)-48), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
1269                                         uiDefButBitI(block, TOG, ROTLIKE_X_INVERT, B_CONSTRAINT_TEST, "-", xco+((width/2)-16), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert X component");
1270                                         uiDefButBitI(block, TOG, ROTLIKE_Y, B_CONSTRAINT_TEST, "Y", xco+((width/2)+16), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
1271                                         uiDefButBitI(block, TOG, ROTLIKE_Y_INVERT, B_CONSTRAINT_TEST, "-", xco+((width/2)+48), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert Y component");
1272                                         uiDefButBitI(block, TOG, ROTLIKE_Z, B_CONSTRAINT_TEST, "Z", xco+((width/2)+96), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
1273                                         uiDefButBitI(block, TOG, ROTLIKE_Z_INVERT, B_CONSTRAINT_TEST, "-", xco+((width/2)+128), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert Z component");
1274                                 uiBlockEndAlign(block);
1275                                 
1276                                 /* draw offset toggle */
1277                                 uiDefButBitI(block, TOG, ROTLIKE_OFFSET, B_CONSTRAINT_TEST, "Offset", xco, yco-64, 80, 18, &data->flag, 0, 24, 0, 0, "Add original rotation onto copied rotation");
1278                                 
1279                                 /* constraint space settings */
1280                                 draw_constraint_spaceselect(block, con, xco, yco-94, is_armature_owner(ob), is_armature_target(data->tar));
1281                         }
1282                         break;
1283                 case CONSTRAINT_TYPE_SIZELIKE:
1284                         {
1285                                 bSizeLikeConstraint *data = con->data;
1286                                 
1287                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1288                                 
1289                                 /* Draw target parameters */
1290                                 uiBlockBeginAlign(block);
1291                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1292                                         
1293                                         if (is_armature_target(data->tar)) {
1294                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1295                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1296                                         }
1297                                         else if (is_geom_target(data->tar)) {
1298                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1299                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1300                                         }
1301                                         else {
1302                                                 strcpy(data->subtarget, "");
1303                                         }
1304                                 uiBlockEndAlign(block);
1305                                 
1306                                 /* Draw XYZ toggles */
1307                                 uiBlockBeginAlign(block);
1308                                         uiDefButBitI(block, TOG, SIZELIKE_X, B_CONSTRAINT_TEST, "X", xco+((width/2)-48), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
1309                                         uiDefButBitI(block, TOG, SIZELIKE_Y, B_CONSTRAINT_TEST, "Y", xco+((width/2)-16), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
1310                                         uiDefButBitI(block, TOG, SIZELIKE_Z, B_CONSTRAINT_TEST, "Z", xco+((width/2)+16), yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
1311                                 uiBlockEndAlign(block);
1312                                 
1313                                 /* draw offset toggle */
1314                                 uiDefButBitI(block, TOG, SIZELIKE_OFFSET, B_CONSTRAINT_TEST, "Offset", xco, yco-64, 80, 18, &data->flag, 0, 24, 0, 0, "Add original scaling onto copied scaling");
1315                                 
1316                                 /* constraint space settings */
1317                                 draw_constraint_spaceselect(block, con, xco, yco-94, is_armature_owner(ob), is_armature_target(data->tar));
1318                         }
1319                         break;
1320                 case CONSTRAINT_TYPE_KINEMATIC:
1321                         {
1322                                 bKinematicConstraint *data = con->data;
1323
1324                                 /* IK Target */
1325                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco, yco-24, 80, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1326                                 
1327                                 /* Draw target parameters */
1328                                 uiBlockBeginAlign(block);
1329                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco, yco-44, 137, 19, &data->tar, "Target Object"); 
1330
1331                                 if (is_armature_target(data->tar)) {
1332                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco, yco-62,137,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1333                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1334                                 }
1335                                 else if (is_geom_target(data->tar)) {
1336                                         but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco, yco-62,137,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1337                                         uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1338                                 }
1339                                 else {
1340                                         strcpy (data->subtarget, "");
1341                                 }
1342                                 
1343                                 uiBlockEndAlign(block);
1344                                 
1345                                 /* Settings */
1346                                 uiBlockBeginAlign(block);
1347                                 uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tail", xco, yco-92, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tail also last element in Chain");
1348                                 uiDefButS(block, NUM, B_CONSTRAINT_TEST, "ChainLen:", xco, yco-112,137,19, &data->rootbone, 0, 255, 0, 0, "If not zero, the amount of bones in this chain");
1349                                 
1350                                 uiBlockBeginAlign(block);
1351                                 uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "PosW ", xco+147, yco-92, 137, 19, &data->weight, 0.01, 1.0, 2, 2, "For Tree-IK: weight of position control for this target");
1352                                 uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", xco+147, yco-112, 40,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target");
1353                                 uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "W ", xco+187, yco-112, 97, 19, &data->orientweight, 0.01, 1.0, 2, 2, "For Tree-IK: Weight of orientation control for this target");
1354                                 
1355                                 uiBlockBeginAlign(block);
1356                                 
1357                                 uiDefButBitS(block, TOG, CONSTRAINT_IK_STRETCH, B_CONSTRAINT_TEST, "Stretch", xco, yco-137,137,19, &data->flag, 0, 0, 0, 0, "Enable IK stretching");
1358                                 uiBlockBeginAlign(block);
1359                                 uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", xco+147, yco-137, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations"); 
1360                                 uiBlockEndAlign(block);
1361                                 
1362                                 /* Pole Vector */
1363                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Pole Target:", xco+147, yco-24, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1364                                 
1365                                 uiBlockBeginAlign(block);
1366                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+147, yco-44, 137, 19, &data->poletar, "Pole Target Object"); 
1367                                 if (is_armature_target(data->poletar)) {
1368                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+147, yco-62,137,19, &data->polesubtarget, 0, 24, 0, 0, "Pole Subtarget Bone");
1369                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->poletar);
1370                                 }
1371                                 else if (is_geom_target(data->poletar)) {
1372                                         but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+147, yco-62,137,18, &data->polesubtarget, 0, 24, 0, 0, "Name of Vertex Group defining pole 'target' points");
1373                                         uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->poletar);
1374                                 }
1375                                 else {
1376                                         strcpy(data->polesubtarget, "");
1377                                 }
1378                                 
1379                                 if (data->poletar) {
1380                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pole Offset ", xco, yco-167, 137, 19, &data->poleangle, -180.0, 180.0, 0, 0, "Pole rotation offset");
1381                                 }
1382                         }
1383                         break;
1384                 case CONSTRAINT_TYPE_TRACKTO:
1385                         {
1386                                 bTrackToConstraint *data = con->data;
1387                                         
1388                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1389                                 
1390                                 /* Draw target parameters */
1391                                 uiBlockBeginAlign(block);
1392                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1393                                         
1394                                         if (is_armature_target(data->tar)) {
1395                                                 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1396                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1397                                         }
1398                                         else if (is_geom_target(data->tar)) {
1399                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1400                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1401                                         }
1402                                         else {
1403                                                 strcpy(data->subtarget, "");
1404                                         }
1405                                 uiBlockEndAlign(block);
1406                                 
1407                                 uiBlockBeginAlign(block);
1408                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Align:", xco+5, yco-42, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1409                                         
1410                                         uiDefButBitI(block, TOG, 1, B_CONSTRAINT_TEST, "TargetZ", xco+60, yco-42, 50, 18, &data->flags, 0, 1, 0, 0, "Target Z axis, not world Z axis, will constrain up direction");
1411                                 uiBlockEndAlign(block);
1412                                 
1413                                 uiBlockBeginAlign(block);
1414                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", xco+12, yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1415                                         
1416                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     xco+39, yco-64,17,18, &data->reserved1, 12.0, 0.0, 0, 0, "X axis points to the target object");
1417                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     xco+56, yco-64,17,18, &data->reserved1, 12.0, 1.0, 0, 0, "Y axis points to the target object");
1418                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     xco+73, yco-64,17,18, &data->reserved1, 12.0, 2.0, 0, 0, "Z axis points to the target object");
1419                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X",    xco+90, yco-64,24,18, &data->reserved1, 12.0, 3.0, 0, 0, "-X axis points to the target object");
1420                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y",    xco+114, yco-64,24,18, &data->reserved1, 12.0, 4.0, 0, 0, "-Y axis points to the target object");
1421                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z",    xco+138, yco-64,24,18, &data->reserved1, 12.0, 5.0, 0, 0, "-Z axis points to the target object");
1422                                 uiBlockEndAlign(block);
1423                                 
1424                                 uiBlockBeginAlign(block);
1425                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", xco+174, yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1426                                         
1427                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     xco+204, yco-64,17,18, &data->reserved2, 13.0, 0.0, 0, 0, "X axis points upward");
1428                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     xco+221, yco-64,17,18, &data->reserved2, 13.0, 1.0, 0, 0, "Y axis points upward");
1429                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     xco+238, yco-64,17,18, &data->reserved2, 13.0, 2.0, 0, 0, "Z axis points upward");
1430                                 uiBlockEndAlign(block);
1431                                 
1432                                 if (is_armature_target(data->tar)) {
1433                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco, yco-94, 241, 18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1");
1434                                         
1435                                         /* constraint space settings */
1436                                         draw_constraint_spaceselect(block, con, xco, yco-116, is_armature_owner(ob), is_armature_target(data->tar));
1437                                 }
1438                                 else {
1439                                         /* constraint space settings */
1440                                         draw_constraint_spaceselect(block, con, xco, yco-94, is_armature_owner(ob), is_armature_target(data->tar));
1441                                 }
1442                         }
1443                         break;
1444                 case CONSTRAINT_TYPE_MINMAX:
1445                         {
1446                                 bMinMaxConstraint *data = con->data;
1447                                         
1448                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1449                                 
1450                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Offset:", xco, yco-44, 100, 18, &data->offset, -100, 100, 100.0, 0.0, "Offset from the position of the object center"); 
1451                                 
1452                                 /* Draw target parameters */
1453                                 uiBlockBeginAlign(block);
1454                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1455                                         
1456                                         if (is_armature_target(data->tar)) {
1457                                                 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1458                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1459                                         }
1460                                         else if (is_geom_target(data->tar)) {
1461                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1462                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1463                                         }
1464                                         else {
1465                                                 strcpy(data->subtarget, "");
1466                                         }
1467                                 uiBlockEndAlign(block);
1468                                 
1469                                 uiDefButBitI(block, TOG, MINMAX_STICKY, B_CONSTRAINT_TEST, "Sticky", xco, yco-24, 44, 18, &data->flag, 0, 24, 0, 0, "Immobilize object while constrained");
1470                                 uiDefButBitI(block, TOG, MINMAX_USEROT, B_CONSTRAINT_TEST, "Use Rot", xco+44, yco-24, 64, 18, &data->flag, 0, 24, 0, 0, "Use target object rotation");
1471                                 
1472                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Max/Min:", xco-8, yco-64, 54, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1473                                 
1474                                 uiBlockBeginAlign(block);                       
1475                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"X",    xco+51, yco-64,17,18, &data->minmaxflag, 12.0, 0.0, 0, 0, "Will not pass below X of target");
1476                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Y",    xco+67, yco-64,17,18, &data->minmaxflag, 12.0, 1.0, 0, 0, "Will not pass below Y of target");
1477                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Z",    xco+85, yco-64,17,18, &data->minmaxflag, 12.0, 2.0, 0, 0, "Will not pass below Z of target");
1478                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-X",   xco+102, yco-64,24,18, &data->minmaxflag, 12.0, 3.0, 0, 0, "Will not pass above X of target");
1479                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-Y",   xco+126, yco-64,24,18, &data->minmaxflag, 12.0, 4.0, 0, 0, "Will not pass above Y of target");
1480                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-Z",   xco+150, yco-64,24,18, &data->minmaxflag, 12.0, 5.0, 0, 0, "Will not pass above Z of target");
1481                                 uiBlockEndAlign(block);
1482                                 
1483                                 if (is_armature_target(data->tar)) {
1484                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco, yco-86, 241, 18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1");
1485                                 }
1486                                 
1487                         }
1488                         break;
1489                 case CONSTRAINT_TYPE_LOCKTRACK:
1490                         {
1491                                 bLockTrackConstraint *data = con->data;
1492                                 
1493                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1494                                 
1495                                 /* Draw target parameters */
1496                                 uiBlockBeginAlign(block);
1497                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1498                                         
1499                                         if (is_armature_target(data->tar)) {
1500                                                 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1501                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1502                                         }
1503                                         else if (is_geom_target(data->tar)) {
1504                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1505                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1506                                         }
1507                                         else {
1508                                                 strcpy(data->subtarget, "");
1509                                         }
1510                                 uiBlockEndAlign(block);
1511                                 
1512                                 uiBlockBeginAlign(block);
1513                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", xco+12, yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1514                                         
1515                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"X",    xco+39, yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "X axis points to the target object");
1516                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Y",    xco+56, yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "Y axis points to the target object");
1517                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Z",    xco+73, yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "Z axis points to the target object");
1518                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-X",   xco+90, yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "-X axis points to the target object");
1519                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-Y",   xco+114, yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "-Y axis points to the target object");
1520                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-Z",   xco+138, yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "-Z axis points to the target object");
1521                                 uiBlockEndAlign(block);
1522                                 
1523                                 uiBlockBeginAlign(block);
1524                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Lock:", xco+166, yco-64, 38, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1525                                         
1526                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"X",    xco+204, yco-64,17,18, &data->lockflag, 13.0, 0.0, 0, 0, "X axis is locked");
1527                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Y",    xco+221, yco-64,17,18, &data->lockflag, 13.0, 1.0, 0, 0, "Y axis is locked");
1528                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Z",    xco+238, yco-64,17,18, &data->lockflag, 13.0, 2.0, 0, 0, "Z axis is locked");
1529                                 uiBlockEndAlign(block);
1530                         }
1531                         break;
1532                 case CONSTRAINT_TYPE_FOLLOWPATH:
1533                         {
1534                                 bFollowPathConstraint *data = con->data;
1535                                 
1536                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1537                                 
1538                                 /* Draw target parameters */
1539                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1540                                 
1541                                 /* Draw Curve Follow toggle */
1542                                 uiDefButBitI(block, TOG, 1, B_CONSTRAINT_TEST, "CurveFollow", xco+39, yco-44, 100, 18, &data->followflag, 0, 24, 0, 0, "Object will follow the heading and banking of the curve");
1543                                 
1544                                 /* Draw Offset number button */
1545                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Offset:", xco+155, yco-44, 100, 18, &data->offset, -MAXFRAMEF, MAXFRAMEF, 100.0, 0.0, "Offset from the position corresponding to the time frame"); 
1546                                 
1547                                 uiBlockBeginAlign(block);
1548                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Fw:", xco+12, yco-64, 27, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1549                                         
1550                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"X",    xco+39, yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "The axis that points forward along the path");
1551                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Y",    xco+56, yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "The axis that points forward along the path");
1552                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Z",    xco+73, yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "The axis that points forward along the path");
1553                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-X",   xco+90, yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "The axis that points forward along the path");
1554                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-Y",   xco+114, yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "The axis that points forward along the path");
1555                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"-Z",   xco+138, yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "The axis that points forward along the path");
1556                                 uiBlockEndAlign(block);
1557                                 
1558                                 uiBlockBeginAlign(block);
1559                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", xco+174, yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1560                                         
1561                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"X",    xco+204, yco-64,17,18, &data->upflag, 13.0, 0.0, 0, 0, "The axis that points upward");
1562                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Y",    xco+221, yco-64,17,18, &data->upflag, 13.0, 1.0, 0, 0, "The axis that points upward");
1563                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST,"Z",    xco+238, yco-64,17,18, &data->upflag, 13.0, 2.0, 0, 0, "The axis that points upward");
1564                                 uiBlockEndAlign(block);
1565                         }
1566                         break;
1567                 case CONSTRAINT_TYPE_STRETCHTO:
1568                         {
1569                                 bStretchToConstraint *data = con->data;
1570                                 
1571                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1572                                 
1573                                 /* Draw target parameters */
1574                                 uiBlockBeginAlign(block);
1575                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1576                                         
1577                                         if (is_armature_target(data->tar)) {
1578                                                 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1579                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1580                                         }
1581                                         else if (is_geom_target(data->tar)) {
1582                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1583                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1584                                         }
1585                                         else {
1586                                                 strcpy(data->subtarget, "");
1587                                         }
1588                                 uiBlockEndAlign(block);
1589                                 
1590                                 uiBlockBeginAlign(block);
1591                                         if (is_armature_target(data->tar)) {
1592                                                 uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->orglength, 0.0, 0, 0, 0, "Recalculate RLength");
1593                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Rest Length:", xco+18, yco-60,139,18, &data->orglength, 0.0, 100, 0.5, 0.5, "Length at Rest Position");
1594                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco+155, yco-60,98,18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1");
1595                                         }
1596                                         else {
1597                                                 uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->orglength, 0.0, 0, 0, 0, "Recalculate RLength");
1598                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Rest Length:", xco+18, yco-60, 237, 18, &data->orglength, 0.0, 100, 0.5, 0.5, "Length at Rest Position");
1599                                         }
1600                                 uiBlockEndAlign(block);
1601                                 
1602                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Volume Variation:", xco+18, yco-82, 237, 18, &data->bulge, 0.0, 100, 0.5, 0.5, "Factor between volume variation and stretching");
1603                                 
1604                                 uiBlockBeginAlign(block);
1605                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Vol:",xco+14, yco-104,30,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1606                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"XZ",     xco+44, yco-104,30,18, &data->volmode, 12.0, 0.0, 0, 0, "Keep Volume: Scaling X & Z");
1607                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",      xco+74, yco-104,20,18, &data->volmode, 12.0, 1.0, 0, 0, "Keep Volume: Scaling X");
1608                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",      xco+94, yco-104,20,18, &data->volmode, 12.0, 2.0, 0, 0, "Keep Volume: Scaling Z");
1609                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"NONE", xco+114, yco-104,50,18, &data->volmode, 12.0, 3.0, 0, 0, "Ignore Volume");
1610                                 uiBlockEndAlign(block);
1611                                 
1612                                 uiBlockBeginAlign(block);
1613                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Plane:",xco+175, yco-104,40,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1614                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",       xco+215, yco-104,20,18, &data->plane, 12.0, 0.0, 0, 0, "Keep X axis");
1615                                         uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",       xco+235, yco-104,20,18, &data->plane, 12.0, 2.0, 0, 0, "Keep Z axis");
1616                                 uiBlockEndAlign(block);
1617                                 }
1618                         break;
1619                 case CONSTRAINT_TYPE_LOCLIMIT:
1620                         {
1621                                 bLocLimitConstraint *data = con->data;
1622                                 
1623                                 int togButWidth = 50;
1624                                 int textButWidth = ((width/2)-togButWidth);
1625                                 
1626                                 /* Draw Pairs of LimitToggle+LimitValue */
1627                                 uiBlockBeginAlign(block); 
1628                                         uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", xco, yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value"); 
1629                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-28, (textButWidth-5), 18, &(data->xmin), -1000, 1000, 0.1,0.5,"Lowest x value to allow"); 
1630                                 uiBlockEndAlign(block); 
1631                                 
1632                                 uiBlockBeginAlign(block); 
1633                                         uiDefButBitS(block, TOG, LIMIT_XMAX, B_CONSTRAINT_TEST, "maxX", xco+(width-(textButWidth-5)-togButWidth), yco-28, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum x value"); 
1634                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-28, (textButWidth-5), 18, &(data->xmax), -1000, 1000, 0.1,0.5,"Highest x value to allow"); 
1635                                 uiBlockEndAlign(block); 
1636                                 
1637                                 uiBlockBeginAlign(block); 
1638                                         uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", xco, yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value"); 
1639                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-50, (textButWidth-5), 18, &(data->ymin), -1000, 1000, 0.1,0.5,"Lowest y value to allow"); 
1640                                 uiBlockEndAlign(block);
1641                                 
1642                                 uiBlockBeginAlign(block); 
1643                                         uiDefButBitS(block, TOG, LIMIT_YMAX, B_CONSTRAINT_TEST, "maxY", xco+(width-(textButWidth-5)-togButWidth), yco-50, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum y value"); 
1644                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-50, (textButWidth-5), 18, &(data->ymax), -1000, 1000, 0.1,0.5,"Highest y value to allow"); 
1645                                 uiBlockEndAlign(block); 
1646                                 
1647                                 uiBlockBeginAlign(block); 
1648                                         uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", xco, yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value"); 
1649                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-72, (textButWidth-5), 18, &(data->zmin), -1000, 1000, 0.1,0.5,"Lowest z value to allow"); 
1650                                 uiBlockEndAlign(block);
1651                                 
1652                                 uiBlockBeginAlign(block); 
1653                                         uiDefButBitS(block, TOG, LIMIT_ZMAX, B_CONSTRAINT_TEST, "maxZ", xco+(width-(textButWidth-5)-togButWidth), yco-72, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum z value"); 
1654                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-72, (textButWidth-5), 18, &(data->zmax), -1000, 1000, 0.1,0.5,"Highest z value to allow"); 
1655                                 uiBlockEndAlign(block);
1656                                 
1657                                 /* special option(s) */
1658                                 uiDefButBitS(block, TOG, LIMIT_TRANSFORM, B_CONSTRAINT_TEST, "For Transform", xco+(width/4), yco-100, (width/2), 18, &data->flag2, 0, 24, 0, 0, "Transforms are affected by this constraint as well"); 
1659                                 
1660                                 /* constraint space settings */
1661                                 draw_constraint_spaceselect(block, con, xco, yco-130, is_armature_owner(ob), -1);
1662                         }
1663                         break;
1664                 case CONSTRAINT_TYPE_ROTLIMIT:
1665                         {
1666                                 bRotLimitConstraint *data = con->data;
1667                                 int normButWidth = (width/3);
1668                                 
1669                                 /* Draw Pairs of LimitToggle+LimitValue */
1670                                 uiBlockBeginAlign(block); 
1671                                         uiDefButBitS(block, TOG, LIMIT_XROT, B_CONSTRAINT_TEST, "LimitX", xco, yco-28, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on x-axis"); 
1672                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", xco+normButWidth, yco-28, normButWidth, 18, &(data->xmin), -360, 360, 0.1,0.5,"Lowest x value to allow"); 
1673                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", xco+(normButWidth * 2), yco-28, normButWidth, 18, &(data->xmax), -360, 360, 0.1,0.5,"Highest x value to allow"); 
1674                                 uiBlockEndAlign(block); 
1675                                 
1676                                 uiBlockBeginAlign(block); 
1677                                         uiDefButBitS(block, TOG, LIMIT_YROT, B_CONSTRAINT_TEST, "LimitY", xco, yco-50, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on y-axis"); 
1678                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", xco+normButWidth, yco-50, normButWidth, 18, &(data->ymin), -360, 360, 0.1,0.5,"Lowest y value to allow"); 
1679                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", xco+(normButWidth * 2), yco-50, normButWidth, 18, &(data->ymax), -360, 360, 0.1,0.5,"Highest y value to allow"); 
1680                                 uiBlockEndAlign(block); 
1681                                 
1682                                 uiBlockBeginAlign(block); 
1683                                         uiDefButBitS(block, TOG, LIMIT_ZROT, B_CONSTRAINT_TEST, "LimitZ", xco, yco-72, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on z-axis"); 
1684                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", xco+normButWidth, yco-72, normButWidth, 18, &(data->zmin), -360, 360, 0.1,0.5,"Lowest z value to allow"); 
1685                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", xco+(normButWidth * 2), yco-72, normButWidth, 18, &(data->zmax), -360, 360, 0.1,0.5,"Highest z value to allow"); 
1686                                 uiBlockEndAlign(block); 
1687                                 
1688                                 /* special option(s) */
1689                                 uiDefButBitS(block, TOG, LIMIT_TRANSFORM, B_CONSTRAINT_TEST, "For Transform", xco+(width/4), yco-100, (width/2), 18, &data->flag2, 0, 24, 0, 0, "Transforms are affected by this constraint as well"); 
1690                                 
1691                                 /* constraint space settings */
1692                                 draw_constraint_spaceselect(block, con, xco, yco-130, is_armature_owner(ob), -1);
1693                         }
1694                         break;
1695                 case CONSTRAINT_TYPE_SIZELIMIT:
1696                         {
1697                                 bSizeLimitConstraint *data = con->data;
1698                                 
1699                                 int togButWidth = 50;
1700                                 int textButWidth = ((width/2)-togButWidth);
1701                                         
1702                                 /* Draw Pairs of LimitToggle+LimitValue */
1703                                 uiBlockBeginAlign(block); 
1704                                         uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", xco, yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value"); 
1705                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-28, (textButWidth-5), 18, &(data->xmin), 0.0001, 1000, 0.1,0.5,"Lowest x value to allow"); 
1706                                 uiBlockEndAlign(block); 
1707                                 
1708                                 uiBlockBeginAlign(block); 
1709                                         uiDefButBitS(block, TOG, LIMIT_XMAX, B_CONSTRAINT_TEST, "maxX", xco+(width-(textButWidth-5)-togButWidth), yco-28, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum x value"); 
1710                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-28, (textButWidth-5), 18, &(data->xmax), 0.0001, 1000, 0.1,0.5,"Highest x value to allow"); 
1711                                 uiBlockEndAlign(block); 
1712                                 
1713                                 
1714                                 uiBlockBeginAlign(block); 
1715                                         uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", xco, yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value"); 
1716                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-50, (textButWidth-5), 18, &(data->ymin), 0.0001, 1000, 0.1,0.5,"Lowest y value to allow"); 
1717                                 uiBlockEndAlign(block); 
1718                                 
1719                                 uiBlockBeginAlign(block); 
1720                                         uiDefButBitS(block, TOG, LIMIT_YMAX, B_CONSTRAINT_TEST, "maxY", xco+(width-(textButWidth-5)-togButWidth), yco-50, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum y value"); 
1721                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-50, (textButWidth-5), 18, &(data->ymax), 0.0001, 1000, 0.1,0.5,"Highest y value to allow"); 
1722                                 uiBlockEndAlign(block); 
1723                                 
1724                                 
1725                                 uiBlockBeginAlign(block); 
1726                                         uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", xco, yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value"); 
1727                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-72, (textButWidth-5), 18, &(data->zmin), 0.0001, 1000, 0.1,0.5,"Lowest z value to allow"); 
1728                                 uiBlockEndAlign(block); 
1729                                 
1730                                 uiBlockBeginAlign(block); 
1731                                         uiDefButBitS(block, TOG, LIMIT_ZMAX, B_CONSTRAINT_TEST, "maxZ", xco+(width-(textButWidth-5)-togButWidth), yco-72, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum z value"); 
1732                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-72, (textButWidth-5), 18, &(data->zmax), 0.0001, 1000, 0.1,0.5,"Highest z value to allow"); 
1733                                 uiBlockEndAlign(block);
1734                                 
1735                                 /* special option(s) */
1736                                 uiDefButBitS(block, TOG, LIMIT_TRANSFORM, B_CONSTRAINT_TEST, "For Transform", xco+(width/4), yco-100, (width/2), 18, &data->flag2, 0, 24, 0, 0, "Transforms are affected by this constraint as well"); 
1737                                 
1738                                 /* constraint space settings */
1739                                 draw_constraint_spaceselect(block, con, xco, yco-130, is_armature_owner(ob), -1);
1740                         }
1741                         break;
1742                 case CONSTRAINT_TYPE_DISTLIMIT:
1743                         {
1744                                 bDistLimitConstraint *data = con->data;
1745                                 
1746                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1747                                 
1748                                 /* Draw target parameters */
1749                                 uiBlockBeginAlign(block);
1750                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1751                                         
1752                                         if (is_armature_target(data->tar)) {
1753                                                 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1754                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1755                                         }
1756                                         else if (is_geom_target(data->tar)) {
1757                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1758                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1759                                         }
1760                                         else {
1761                                                 strcpy(data->subtarget, "");
1762                                         }
1763                                 uiBlockEndAlign(block);
1764                                 
1765                                 uiBlockBeginAlign(block);
1766                                         if (is_armature_target(data->tar)) {
1767                                                 uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->dist, 0, 0, 0, 0, "Recalculate distance"); 
1768                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Distance:", xco+18, yco-60,139,18, &data->dist, 0.0, 100, 0.5, 0.5, "Radius of limiting sphere");
1769                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco+155, yco-60,100,18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1");
1770                                         }
1771                                         else {
1772                                                 uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->dist, 0, 0, 0, 0, "Recalculate distance"); 
1773                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Distance:", xco+18, yco-60, 237, 18, &data->dist, 0.0, 100, 0.5, 0.5, "Radius of limiting sphere");
1774                                         }
1775                                         
1776                                         /* disabled soft-distance controls... currently it doesn't work yet. It was intended to be used for soft-ik (see xsi-blog for details) */
1777 #if 0
1778                                         uiDefButBitS(block, TOG, LIMITDIST_USESOFT, B_CONSTRAINT_TEST, "Soft", xco, yco-82, 50, 18, &data->flag, 0, 24, 0, 0, "Enables soft-distance");
1779                                         if (data->flag & LIMITDIST_USESOFT)
1780                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Soft-Distance:", xco+50, yco-82, 187, 18, &data->soft, 0.0, 100, 0.5, 0.5, "Distance surrounding radius when transforms should get 'delayed'");
1781 #endif
1782                                 uiBlockEndAlign(block);
1783                                 
1784                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Clamp Region:",xco+((width/2)-110), yco-104,100,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1785                                 uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Limit Mode%t|Inside %x0|Outside %x1|Surface %x2", xco+(width/2), yco-104, 100, 18, &data->mode, 0, 24, 0, 0, "Distances in relation to sphere of influence to allow");
1786                         }
1787                         break;
1788                 case CONSTRAINT_TYPE_RIGIDBODYJOINT:
1789                         {
1790                                 bRigidBodyJointConstraint *data = con->data;
1791                                 float extremeLin = 999.f;
1792                                 float extremeAngX = 180.f;
1793                                 float extremeAngY = 45.f;
1794                                 float extremeAngZ = 45.f;
1795                                 int togButWidth = 70;
1796                                 int offsetY = 150;
1797                                 int textButWidth = ((width/2)-togButWidth);
1798                                 
1799                                 uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Generic 6DOF%x12",//|Extra Force%x6",
1800                                 //uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic 6DOF%x12",//|Extra Force%x6",
1801                                                                                                 xco, yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
1802
1803                                 uiDefButBitS(block, TOG, CONSTRAINT_DISABLE_LINKED_COLLISION, B_CONSTRAINT_TEST, "No Collision", xco+155, yco-25, 111, 18, &data->flag, 0, 24, 0, 0, "Disable Collision Between Linked Bodies");
1804
1805
1806                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", xco, yco-50, 130, 18, &data->tar, "Child Object");
1807                                 uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", xco+135, yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation");                                
1808                                 
1809                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", xco, yco-75, 130, 18, &data->pivX, -1000, 1000, 100, 0.0, "Offset pivot on X");
1810                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", xco, yco-100, 130, 18, &data->pivY, -1000, 1000, 100, 0.0, "Offset pivot on Y");
1811                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", xco, yco-125, 130, 18, &data->pivZ, -1000, 1000, 100, 0.0, "Offset pivot on z");
1812                                 
1813                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax X:", xco+135, yco-75, 130, 18, &data->axX, -360, 360, 1500, 0.0, "Rotate pivot on X Axis (in degrees)");
1814                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Y:", xco+135, yco-100, 130, 18, &data->axY, -360, 360, 1500, 0.0, "Rotate pivot on Y Axis (in degrees)");
1815                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Z:", xco+135, yco-125, 130, 18, &data->axZ, -360, 360, 1500, 0.0, "Rotate pivot on Z Axis (in degrees)");
1816                                 
1817                                 if (data->type==CONSTRAINT_RB_GENERIC6DOF) {
1818                                         /* Draw Pairs of LimitToggle+LimitValue */
1819                                         uiBlockBeginAlign(block); 
1820                                                 uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); 
1821                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit"); 
1822                                         uiBlockEndAlign(block);
1823                                         
1824                                         uiBlockBeginAlign(block); 
1825                                                 uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); 
1826                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"max x limit"); 
1827                                         uiBlockEndAlign(block);
1828                                         
1829                                         offsetY += 20;
1830                                         uiBlockBeginAlign(block); 
1831                                                 uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); 
1832                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"min y limit"); 
1833                                         uiBlockEndAlign(block);
1834                                         
1835                                         uiBlockBeginAlign(block); 
1836                                                 uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); 
1837                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"max y limit"); 
1838                                         uiBlockEndAlign(block);
1839                                         
1840                                         offsetY += 20;
1841                                         uiBlockBeginAlign(block); 
1842                                                 uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); 
1843                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"min z limit"); 
1844                                         uiBlockEndAlign(block);
1845                                         
1846                                         uiBlockBeginAlign(block); 
1847                                                 uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); 
1848                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"max z limit"); 
1849                                         uiBlockEndAlign(block);
1850                                         offsetY += 20;
1851                                 }
1852                                 if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) {
1853                                         /* Draw Pairs of LimitToggle+LimitValue */
1854                                         uiBlockBeginAlign(block); 
1855                                                 uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); 
1856                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit"); 
1857                                         uiBlockEndAlign(block);
1858                                         uiBlockBeginAlign(block); 
1859                                                 uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMaxX", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit"); 
1860                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"max x limit"); 
1861                                         uiBlockEndAlign(block);
1862                                         
1863                                         offsetY += 20;
1864                                         uiBlockBeginAlign(block); 
1865                                                 uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); 
1866                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"min y limit"); 
1867                                         uiBlockEndAlign(block);
1868                                         
1869                                         uiBlockBeginAlign(block); 
1870                                                 uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMaxY", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit"); 
1871                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"max y limit"); 
1872                                         uiBlockEndAlign(block);
1873                                         
1874                                         offsetY += 20;
1875                                         uiBlockBeginAlign(block); 
1876                                                 uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); 
1877                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"min z limit"); 
1878                                         uiBlockEndAlign(block);
1879                                         
1880                                         uiBlockBeginAlign(block); 
1881                                                 uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMaxZ", xco+(width-(textButWidth-5)-togButWidth), yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit"); 
1882                                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+(width-textButWidth-5), yco-offsetY, (textButWidth), 18, &(data->maxLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"max z limit"); 
1883                                         uiBlockEndAlign(block);
1884                                 }
1885                                 
1886                         }
1887                         break;
1888                 case CONSTRAINT_TYPE_CLAMPTO:
1889                         {
1890                                 bClampToConstraint *data = con->data;
1891                                 
1892                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1893                                 
1894                                 /* Draw target parameters */
1895                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
1896                                 
1897                                 /* Draw XYZ toggles */
1898                                 uiBlockBeginAlign(block);
1899                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Main Axis:", xco, yco-64, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1900                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST, "Auto", xco+100, yco-64, 50, 18, &data->flag, 12.0, CLAMPTO_AUTO, 0, 0, "Automatically determine main-axis of movement");
1901                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST, "X", xco+150, yco-64, 32, 18, &data->flag, 12.0, CLAMPTO_X, 0, 0, "Main axis of movement is x-axis");
1902                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST, "Y", xco+182, yco-64, 32, 18, &data->flag, 12.0, CLAMPTO_Y, 0, 0, "Main axis of movement is y-axis");
1903                                         uiDefButI(block, ROW, B_CONSTRAINT_TEST, "Z", xco+214, yco-64, 32, 18, &data->flag, 12.0, CLAMPTO_Z, 0, 0, "Main axis of movement is z-axis");
1904                                 uiBlockEndAlign(block);
1905                                 
1906                                 /* Extra Options Controlling Behaviour */
1907                                 //uiBlockBeginAlign(block);
1908                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Options:", xco, yco-88, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1909                                         uiDefButBitI(block, TOG, CLAMPTO_CYCLIC, B_CONSTRAINT_TEST, "Cyclic", xco+((width/2)), yco-88,60,19, &data->flag2, 0, 0, 0, 0, "Treat curve as cyclic curve (no clamping to curve bounding box)");
1910                                 //uiBlockEndAlign(block);
1911                         }
1912                         break;
1913                 case CONSTRAINT_TYPE_TRANSFORM:
1914                         {
1915                                 bTransformConstraint *data = con->data;
1916                                 float fmin, fmax, tmin, tmax;
1917                                 
1918                                 /* Draw target parameters */                    
1919                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1920                                 
1921                                 /* Draw target parameters */
1922                                 uiBlockBeginAlign(block);
1923                                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object to use as Parent"); 
1924                                         
1925                                         if (is_armature_target(data->tar)) {
1926                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone to use as Parent");
1927                                                 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1928                                         }
1929                                         else if (is_geom_target(data->tar)) {
1930                                                 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1931                                                 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1932                                         }
1933                                         else {
1934                                                 strcpy(data->subtarget, "");
1935                                         }
1936                                 uiBlockEndAlign(block);
1937                                 
1938                                 /* Extrapolate Ranges? */
1939                                 uiDefButBitC(block, TOG, 1, B_CONSTRAINT_TEST, "Extrapolate", xco-10, yco-42,80,19, &data->expo, 0, 0, 0, 0, "Extrapolate ranges");
1940                                 
1941                                 /* Draw options for source motion */
1942                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Source:", xco-10, yco-62, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1943                                 
1944                                 /*      draw Loc/Rot/Size toggles       */
1945                                 uiBlockBeginAlign(block);
1946                                         uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Loc", xco-5, yco-82, 45, 18, &data->from, 12.0, 0, 0, 0, "Use Location transform channels from Target");
1947                                         uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Rot", xco+40, yco-82, 45, 18, &data->from, 12.0, 1, 0, 0, "Use Rotation transform channels from Target");
1948                                         uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Scale", xco+85, yco-82, 45, 18, &data->from, 12.0, 2, 0, 0, "Use Scale transform channels from Target");
1949                                 uiBlockEndAlign(block);
1950                                 
1951                                 /* Draw Pairs of Axis: Min/Max Value*/
1952                                 if (data->from == 2) {
1953                                         fmin= 0.0001;
1954                                         fmax= 1000.0;
1955                                 }
1956                                 else if (data->from == 1) {
1957                                         fmin= -360.0;
1958                                         fmax= 360.0;
1959                                 }
1960                                 else {
1961                                         fmin = -1000.0;
1962                                         fmax= 1000.0;
1963                                 }
1964                                 
1965                                 uiBlockBeginAlign(block); 
1966                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "X:", xco-10, yco-107, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1967                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", xco+20, yco-107, 55, 18, &data->from_min[0], fmin, fmax, 0, 0, "Bottom of range of x-axis source motion for source->target mapping"); 
1968                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", xco+75, yco-107, 55, 18, &data->from_max[0], fmin, fmax, 0, 0, "Top of range of x-axis source motion for source->target mapping"); 
1969                                 uiBlockEndAlign(block); 
1970                                 
1971                                 uiBlockBeginAlign(block); 
1972                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Y:", xco-10, yco-127, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1973                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", xco+20, yco-127, 55, 18, &data->from_min[1], fmin, fmax, 0, 0, "Bottom of range of y-axis source motion for source->target mapping"); 
1974                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", xco+75, yco-127, 55, 18, &data->from_max[1], fmin, fmax, 0, 0, "Top of range of y-axis source motion for source->target mapping"); 
1975                                 uiBlockEndAlign(block);
1976                                 
1977                                 uiBlockBeginAlign(block); 
1978                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Z:", xco-10, yco-147, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1979                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", xco+20, yco-147, 55, 18, &data->from_min[2], fmin, fmax, 0, 0, "Bottom of range of z-axis source motion for source->target mapping"); 
1980                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", xco+75, yco-147, 55, 18, &data->from_max[2], fmin, fmax, 0, 0, "Top of range of z-axis source motion for source->target mapping"); 
1981                                 uiBlockEndAlign(block); 
1982                                 
1983                                 
1984                                 /* Draw options for target motion */
1985                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Destination:", xco+150, yco-62, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1986                                 
1987                                 /*      draw Loc/Rot/Size toggles       */
1988                                 uiBlockBeginAlign(block);
1989                                         uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Loc", xco+150, yco-82, 45, 18, &data->to, 12.0, 0, 0, 0, "Use as Location transform");
1990                                         uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Rot", xco+195, yco-82, 45, 18, &data->to, 12.0, 1, 0, 0, "Use as Rotation transform");
1991                                         uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Scale", xco+245, yco-82, 45, 18, &data->to, 12.0, 2, 0, 0, "Use as Scale transform");
1992                                 uiBlockEndAlign(block);
1993                                 
1994                                 /* Draw Pairs of Source-Axis: Min/Max Value*/
1995                                 if (data->to == 2) {
1996                                         tmin= 0.0001;
1997                                         tmax= 1000.0;
1998                                 }
1999                                 else if (data->to == 1) {
2000                                         tmin= -360.0;
2001                                         tmax= 360.0;
2002                                 }
2003                                 else {
2004                                         tmin = -1000.0;
2005                                         tmax= 1000.0;
2006                                 }
2007                                 
2008                                 uiBlockBeginAlign(block); 
2009                                         uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Axis Mapping%t|X->X%x0|Y->X%x1|Z->X%x2", xco+150, yco-107, 40, 18, &data->map[0], 0, 24, 0, 0, "Specify which source axis the x-axis destination uses");
2010                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", xco+175, yco-107, 50, 18, &data->to_min[0], tmin, tmax, 0, 0, "Bottom of range of x-axis destination motion for source->target mapping"); 
2011                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", xco+240, yco-107, 50, 18, &data->to_max[0], tmin, tmax, 0, 0, "Top of range of x-axis destination motion for source->target mapping"); 
2012                                 uiBlockEndAlign(block); 
2013                                 
2014                                 uiBlockBeginAlign(block); 
2015                                         uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Axis Mapping%t|X->Y%x0|Y->Y%x1|Z->Y%x2", xco+150, yco-127, 40, 18, &data->map[1], 0, 24, 0, 0, "Specify which source axis the y-axis destination uses");
2016                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", xco+175, yco-127, 50, 18, &data->to_min[1], tmin, tmax, 0, 0, "Bottom of range of y-axis destination motion for source->target mapping"); 
2017                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", xco+240, yco-127, 50, 18, &data->to_max[1], tmin, tmax, 0, 0, "Top of range of y-axis destination motion for source->target mapping"); 
2018                                 uiBlockEndAlign(block);
2019                                 
2020                                 uiBlockBeginAlign(block); 
2021                                         uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Axis Mapping%t|X->Z%x0|Y->Z%x1|Z->Z%x2", xco+150, yco-147, 40, 18, &data->map[2], 0, 24, 0, 0, "Specify which source axis the z-axis destination uses");
2022                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", xco+175, yco-147, 50, 18, &data->to_min[2], tmin, tmax, 0, 0, "Bottom of range of z-axis destination motion for source->target mapping"); 
2023                                         uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", xco+240, yco-147, 50, 18, &data->to_max[2], tmin, tmax, 0, 0, "Top of range of z-axis destination motion for source->target mapping"); 
2024                                 uiBlockEndAlign(block); 
2025                                 
2026                                 /* constraint space settings */
2027                                 draw_constraint_spaceselect(block, con, xco, yco-170, is_armature_owner(ob), is_armature_target(data->tar));
2028                         }
2029                         break;
2030                 case CONSTRAINT_TYPE_NULL:
2031                         {
2032                                 uiItemL(box, "", 0);
2033                         }
2034                         break;
2035
2036                 case CONSTRAINT_TYPE_SHRINKWRAP:
2037                         {
2038                                 bShrinkwrapConstraint *data = con->data;
2039
2040                                 /* Draw parameters */
2041                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
2042                                 uiDefIDPoinBut(block, test_meshobpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->target, "Target Object");
2043
2044                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Dist:", xco + 75, yco-42, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
2045                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+120, yco-42, 135, 18, &data->dist, -100.0f, 100.0f, 1.0f, 0.0f, "Distance to target");
2046
2047                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Type:", xco + 70, yco-60, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
2048                                 uiDefButS(block, MENU, B_MODIFIER_RECALC, "Shrinkwrap Type%t|Nearest Surface Point %x0|Projection %x1|Nearest Vertex %x2", xco+120, yco-60, 135, 18, &data->shrinkType, 0, 0, 0, 0, "Selects type of shrinkwrap algorithm for target position.");
2049
2050                                 if(data->shrinkType == MOD_SHRINKWRAP_PROJECT)
2051                                 {
2052                                         /* Draw XYZ toggles */
2053                                         uiDefBut(block, LABEL,B_CONSTRAINT_TEST, "Axis:", xco+ 75, yco-78, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
2054                                         uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS, B_CONSTRAINT_TEST, "X",xco+120, yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over X axis");
2055                                         uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS, B_CONSTRAINT_TEST, "Y",xco+165, yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over Y axis");
2056                                         uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS, B_CONSTRAINT_TEST, "Z",xco+210, yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over Z axis");
2057                                 }
2058                         }
2059                         break;
2060                 default:
2061                         result= box;
2062                         break;
2063                 }
2064         }
2065         
2066         /* clear any locks set up for proxies/lib-linking */
2067         uiBlockClearButLock(block);
2068
2069         return result;
2070 }
2071
2072 uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
2073 {
2074         Object *ob;
2075         bConstraint *con;
2076
2077         /* verify we have valid data */
2078         if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
2079                 printf("uiTemplateConstraint: expected constraint on object.\n");
2080                 return NULL;
2081         }
2082
2083         ob= ptr->id.data;
2084         con= ptr->data;
2085
2086         if(!ob || !(GS(ob->id.name) == ID_OB)) {
2087                 printf("uiTemplateConstraint: expected constraint on object.\n");
2088                 return NULL;
2089         }
2090         
2091         uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE);
2092
2093         /* hrms, the temporal constraint should not draw! */
2094         if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
2095                 bKinematicConstraint *data= con->data;
2096                 if(data->flag & CONSTRAINT_IK_TEMP)
2097                         return NULL;
2098         }
2099
2100         return draw_constraint(layout, ob, con);
2101 }
2102
2103 /************************* Group Template ***************************/
2104
2105 #if 0
2106 static void do_add_groupmenu(void *arg, int event)
2107 {
2108         Object *ob= OBACT;
2109         
2110         if(ob) {
2111                 
2112                 if(event== -1) {
2113                         Group *group= add_group( "Group" );
2114                         add_to_group(group, ob);
2115                 }
2116                 else
2117                         add_to_group(BLI_findlink(&G.main->group, event), ob);
2118                         
2119                 ob->flag |= OB_FROMGROUP;
2120                 BASACT->flag |= OB_FROMGROUP;
2121                 allqueue(REDRAWBUTSOBJECT, 0);
2122                 allqueue(REDRAWVIEW3D, 0);
2123         }               
2124 }
2125
2126 static uiBlock *add_groupmenu(void *arg_unused)
2127 {
2128         uiBlock *block;
2129         Group *group;
2130         short xco=0, yco= 0, index=0;
2131         char str[32];
2132         
2133         block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
2134         uiBlockSetButmFunc(block, do_add_groupmenu, NULL);
2135
2136         uiDefBut(block, BUTM, B_NOP, "ADD NEW",         0, 20, 160, 19, NULL, 0.0, 0.0, 1, -1, "");
2137         for(group= G.main->group.first; group; group= group->id.next, index++) {
2138                 
2139                 /*if(group->id.lib) strcpy(str, "L  ");*/ /* we cant allow adding objects inside linked groups, it wont be saved anyway */
2140                 if(group->id.lib==0) {
2141                         strcpy(str, "   ");
2142                         strcat(str, group->id.name+2);
2143                         uiDefBut(block, BUTM, B_NOP, str,       xco*160, -20*yco, 160, 19, NULL, 0.0, 0.0, 1, index, "");
2144                         
2145                         yco++;
2146                         if(yco>24) {
2147                                 yco= 0;
2148                                 xco++;
2149                         }
2150                 }
2151         }
2152         
2153         uiTextBoundsBlock(block, 50);
2154         uiBlockSetDirection(block, UI_DOWN);    
2155         
2156         return block;
2157 }
2158
2159 static void group_ob_rem(void *gr_v, void *ob_v)
2160 {
2161         Object *ob= OBACT;
2162         
2163         if(rem_from_group(gr_v, ob) && find_group(ob, NULL)==NULL) {
2164                 ob->flag &= ~OB_FROMGROUP;
2165                 BASACT->flag &= ~OB_FROMGROUP;
2166         }
2167         allqueue(REDRAWBUTSOBJECT, 0);
2168         allqueue(REDRAWVIEW3D, 0);
2169
2170 }
2171
2172 static void group_local(void *gr_v, void *unused)
2173 {
2174         Group *group= gr_v;
2175         
2176         group->id.lib= NULL;
2177         
2178         allqueue(REDRAWBUTSOBJECT, 0);
2179         allqueue(REDRAWVIEW3D, 0);
2180         
2181 }
2182
2183 uiLayout *uiTemplateGroup(uiLayout *layout, Object *ob, Group *group)
2184 {
2185         uiSetButLock(1, NULL);
2186         uiDefBlockBut(block, add_groupmenu, NULL, "Add to Group", 10,150,150,20, "Add Object to a new Group");
2187
2188         /* all groups */
2189         if(group->id.lib) {
2190                 uiLayoutRow()
2191                 uiBlockBeginAlign(block);
2192                 uiSetButLock(GET_INT_FROM_POINTER(group->id.lib), ERROR_LIBDATA_MESSAGE); /* We cant actually use this button */
2193                 uiDefBut(block, TEX, B_IDNAME, "GR:",   10, 120-yco, 100, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
2194                 uiClearButLock();
2195                 
2196                 but= uiDefIconBut(block, BUT, B_NOP, ICON_PARLIB, 110, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Make Group local");
2197                 uiButSetFunc(but, group_local, group, NULL);
2198                 uiBlockEndAlign(block);
2199         } else {
2200                 but = uiDefBut(block, TEX, B_IDNAME, "GR:",     10, 120-yco, 120, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
2201                 uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
2202         }
2203         
2204         xco = 290;
2205         if(group->id.lib==0) { /* cant remove objects from linked groups */
2206                 but = uiDefIconBut(block, BUT, B_NOP, VICON_X, xco, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove Group membership");
2207                 uiButSetFunc(but, group_ob_rem, group, ob);
2208         }
2209 }
2210 #endif
2211
2212 /************************* Preview Template ***************************/
2213
2214 #include "DNA_material_types.h"
2215
2216 #define B_MATPRV 1
2217
2218 void uiTemplatePreview(uiLayout *layout, ID *id)
2219 {
2220         uiLayout *row, *col;
2221         uiBlock *block;
2222         Material *ma;
2223
2224         if(!id || !ELEM3(GS(id->name), ID_MA, ID_TE, ID_WO)) {
2225                 printf("uiTemplatePreview: expected ID of type material, texture or world.\n");
2226                 return;
2227         }
2228
2229         block= uiLayoutGetBlock(layout);
2230
2231         row= uiLayoutRow(layout, 0);
2232
2233         col= uiLayoutColumn(row, 0);
2234         uiLayoutSetKeepAspect(col, 1);
2235         uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, NULL, 0.0, 0.0, 0, 0, "");
2236
2237         if(GS(id->name) == ID_MA) {
2238                 ma= (Material*)id;
2239
2240                 uiLayoutColumn(row, 1);
2241
2242                 uiDefIconButC(block, ROW, B_MATPRV, ICON_MATPLANE,  0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_FLAT, 0, 0, "Preview type: Flat XY plane");
2243                 uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE, 0, 0, "Preview type: Sphere");
2244                 uiDefIconButC(block, ROW, B_MATPRV, ICON_MATCUBE,   0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_CUBE, 0, 0, "Preview type: Cube");
2245                 uiDefIconButC(block, ROW, B_MATPRV, ICON_MONKEY,    0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_MONKEY, 0, 0, "Preview type: Monkey");
2246                 uiDefIconButC(block, ROW, B_MATPRV, ICON_HAIR,      0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_HAIR, 0, 0, "Preview type: Hair strands");
2247                 uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE_A, 0, 0, "Preview type: Large sphere with sky");
2248         }
2249
2250 }
2251