Blender V2.61 - r43446

rna_curve.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Blender Foundation (2008), Juho Veps�l�inen
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 
00030 #include "RNA_define.h"
00031 
00032 #include "rna_internal.h"
00033 
00034 #include "DNA_curve_types.h"
00035 #include "DNA_key_types.h"
00036 #include "DNA_material_types.h"
00037 #include "DNA_scene_types.h"
00038 
00039 #include "BKE_font.h"
00040 
00041 #include "WM_types.h"
00042 
00043 #include "BKE_curve.h"
00044 #include "ED_curve.h"
00045 
00046 EnumPropertyItem beztriple_handle_type_items[] = {
00047         {HD_FREE, "FREE", 0, "Free", ""},
00048         {HD_VECT, "VECTOR", 0, "Vector", ""},
00049         {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
00050         {HD_AUTO, "AUTO", 0, "Auto", ""},
00051         {0, NULL, 0, NULL, NULL}};
00052         
00053 EnumPropertyItem keyframe_handle_type_items[] = {
00054         {HD_FREE, "FREE", 0, "Free", ""},
00055         {HD_VECT, "VECTOR", 0, "Vector", ""},
00056         {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
00057         {HD_AUTO, "AUTO", 0, "Automatic", ""},
00058         {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"},
00059         {0, NULL, 0, NULL, NULL}};
00060 
00061 EnumPropertyItem beztriple_interpolation_mode_items[] = {
00062         {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""},
00063         {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""},
00064         {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""},
00065         {0, NULL, 0, NULL, NULL}};
00066 
00067 EnumPropertyItem curve_type_items[] = {
00068     {CU_POLY, "POLY", 0, "Poly", ""},
00069     {CU_BEZIER, "BEZIER", 0, "Bezier", ""},
00070     {CU_BSPLINE, "BSPLINE", 0, "BSpline", ""},
00071     {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
00072     {CU_NURBS, "NURBS", 0, "Ease", ""},
00073     {0, NULL, 0, NULL, NULL}};
00074 
00075 static const EnumPropertyItem curve3d_fill_mode_items[]= {
00076     {0, "FULL", 0, "Full", ""},
00077     {CU_BACK, "BACK", 0, "Back", ""},
00078     {CU_FRONT, "FRONT", 0, "Front", ""},
00079     {CU_FRONT|CU_BACK, "HALF", 0, "Half", ""},
00080     {0, NULL, 0, NULL, NULL}};
00081 
00082 static const EnumPropertyItem curve2d_fill_mode_items[]= {
00083     {0, "NONE", 0, "None", ""},
00084     {CU_BACK, "BACK", 0, "Back", ""},
00085     {CU_FRONT, "FRONT", 0, "Front", ""},
00086     {CU_FRONT|CU_BACK, "BOTH", 0, "Both", ""},
00087     {0, NULL, 0, NULL, NULL}};
00088 
00089 #ifdef RNA_RUNTIME
00090 
00091 #include "BLI_math.h"
00092 
00093 #include "DNA_object_types.h"
00094 
00095 #include "BKE_curve.h"
00096 #include "BKE_depsgraph.h"
00097 #include "BKE_main.h"
00098 
00099 #include "WM_api.h"
00100 
00101 #include "MEM_guardedalloc.h"
00102 
00103 #include "ED_curve.h" /* for BKE_curve_nurbs */
00104 
00105 /* highly irritating but from RNA we cant know this */
00106 static Nurb *curve_nurb_from_point(Curve *cu, const void *point, int *nu_index, int *pt_index)
00107 {
00108     ListBase *nurbs= BKE_curve_nurbs(cu);
00109     Nurb *nu;
00110     int i= 0;
00111 
00112     for(nu= nurbs->first; nu; nu= nu->next, i++) {
00113         if(nu->type == CU_BEZIER) {
00114             if(point >= (void *)nu->bezt && point < (void *)(nu->bezt + nu->pntsu)) {
00115                 break;
00116             }
00117         }
00118         else {
00119             if(point >= (void *)nu->bp && point < (void *)(nu->bp + (nu->pntsu * nu->pntsv))) {
00120                 break;
00121             }
00122         }
00123     }
00124 
00125     if(nu) {
00126         if(nu_index) {
00127             *nu_index= i;
00128         }
00129     
00130         if(pt_index) {
00131             if(nu->type == CU_BEZIER)   *pt_index= (int)((BezTriple *)point - nu->bezt);
00132             else                        *pt_index= (int)((BPoint *)point - nu->bp);
00133         }
00134     }
00135 
00136     return nu;
00137 }
00138 
00139 static StructRNA *rna_Curve_refine(PointerRNA *ptr)
00140 {
00141     Curve *cu= (Curve*)ptr->data;
00142     short obtype= curve_type(cu);
00143     
00144     if(obtype == OB_FONT) return &RNA_TextCurve;
00145     else if(obtype == OB_SURF) return &RNA_SurfaceCurve;
00146     else return &RNA_Curve;
00147 }
00148 
00149 static void rna_BezTriple_handle1_get(PointerRNA *ptr, float *values)
00150 {
00151     BezTriple *bt= (BezTriple*)ptr->data;
00152 
00153     values[0]= bt->vec[0][0];
00154     values[1]= bt->vec[0][1];
00155     values[2]= bt->vec[0][2];
00156 }
00157 
00158 static void rna_BezTriple_handle1_set(PointerRNA *ptr, const float *values)
00159 {
00160     BezTriple *bt= (BezTriple*)ptr->data;
00161 
00162     bt->vec[0][0]= values[0];
00163     bt->vec[0][1]= values[1];
00164     bt->vec[0][2]= values[2];
00165 }
00166 
00167 static void rna_BezTriple_handle2_get(PointerRNA *ptr, float *values)
00168 {
00169     BezTriple *bt= (BezTriple*)ptr->data;
00170 
00171     values[0]= bt->vec[2][0];
00172     values[1]= bt->vec[2][1];
00173     values[2]= bt->vec[2][2];
00174 }
00175 
00176 static void rna_BezTriple_handle2_set(PointerRNA *ptr, const float *values)
00177 {
00178     BezTriple *bt= (BezTriple*)ptr->data;
00179 
00180     bt->vec[2][0]= values[0];
00181     bt->vec[2][1]= values[1];
00182     bt->vec[2][2]= values[2];
00183 }
00184 
00185 static void rna_BezTriple_ctrlpoint_get(PointerRNA *ptr, float *values)
00186 {
00187     BezTriple *bt= (BezTriple*)ptr->data;
00188 
00189     values[0]= bt->vec[1][0];
00190     values[1]= bt->vec[1][1];
00191     values[2]= bt->vec[1][2];
00192 }
00193 
00194 static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
00195 {
00196     BezTriple *bt= (BezTriple*)ptr->data;
00197 
00198     bt->vec[1][0]= values[0];
00199     bt->vec[1][1]= values[1];
00200     bt->vec[1][2]= values[2];
00201 }
00202 
00203 static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00204 {
00205     Curve *cu= (Curve*)ptr->data;
00206     
00207     if (cu->texflag & CU_AUTOSPACE)
00208         tex_space_curve(cu);
00209 }
00210 
00211 static int rna_Curve_texspace_editable(PointerRNA *ptr)
00212 {
00213     Curve *cu= (Curve*)ptr->data;
00214     return (cu->texflag & CU_AUTOSPACE)? 0: PROP_EDITABLE;
00215 }
00216 
00217 static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values)
00218 {
00219     Curve *cu= (Curve *)ptr->data;
00220     
00221     if (!cu->bb)
00222         tex_space_curve(cu);
00223     
00224     copy_v3_v3(values, cu->loc);
00225 }
00226 
00227 static void rna_Curve_texspace_loc_set(PointerRNA *ptr, const float *values)
00228 {
00229     Curve *cu= (Curve *)ptr->data;
00230     
00231     copy_v3_v3(cu->loc, values);
00232 }
00233 
00234 static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values)
00235 {
00236     Curve *cu= (Curve *)ptr->data;
00237     
00238     if (!cu->bb)
00239         tex_space_curve(cu);
00240     
00241     copy_v3_v3(values, cu->size);
00242 }
00243 
00244 static void rna_Curve_texspace_size_set(PointerRNA *ptr, const float *values)
00245 {
00246     Curve *cu= (Curve *)ptr->data;
00247     
00248     copy_v3_v3(cu->size, values);
00249 }
00250 
00251 static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max)
00252 {
00253     Curve *cu= (Curve*)ptr->id.data;
00254     *min= 0;
00255     *max= cu->totcol-1;
00256     *max= MAX2(0, *max);
00257 }
00258 
00259 static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max)
00260 {
00261     Curve *cu= (Curve*)ptr->id.data;
00262     *min= 0;
00263     *max= cu->totbox-1;
00264     *max= MAX2(0, *max);
00265 }
00266 
00267 
00268 static void rna_Curve_dimension_set(PointerRNA *ptr, int value)
00269 {
00270     Curve *cu= (Curve*)ptr->id.data;
00271     if(value==CU_3D) cu->flag |=  CU_3D;
00272     else cu->flag &= ~CU_3D;
00273 
00274     update_curve_dimension(cu);
00275 }
00276 
00277 static EnumPropertyItem *rna_Curve_fill_mode_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *UNUSED(free))
00278 {
00279     Curve *cu= (Curve*)ptr->id.data;
00280 
00281     /* cast to quiet warning it IS a const still */
00282     return (EnumPropertyItem *)((cu->flag & CU_3D) ? curve3d_fill_mode_items : curve2d_fill_mode_items);
00283 }
00284 
00285 static int rna_Nurb_length(PointerRNA *ptr)
00286 {
00287     Nurb *nu= (Nurb*)ptr->data;
00288     if(nu->type == CU_BEZIER) return 0;
00289     return nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu;
00290 }
00291 
00292 static void rna_Nurb_type_set(PointerRNA *ptr, int value)
00293 {
00294     Nurb *nu= (Nurb*)ptr->data;
00295     ED_nurb_set_spline_type(nu, value);
00296 }
00297 
00298 static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00299 {
00300     Nurb *nu= (Nurb*)ptr->data;
00301     rna_iterator_array_begin(iter, (void*)nu->bp, sizeof(BPoint), nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu, 0, NULL);
00302 }
00303 
00304 static void rna_Curve_update_data_id(Main *UNUSED(bmain), Scene *UNUSED(scene), ID *id)
00305 {
00306     DAG_id_tag_update(id, 0);
00307     WM_main_add_notifier(NC_GEOM|ND_DATA, id);
00308 }
00309 
00310 static void rna_Curve_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
00311 {
00312     rna_Curve_update_data_id(bmain, scene, ptr->id.data);
00313 }
00314 
00315 static void rna_Curve_update_deps(Main *bmain, Scene *scene, PointerRNA *ptr)
00316 {
00317     DAG_scene_sort(bmain, scene);
00318     rna_Curve_update_data(bmain, scene, ptr);
00319 }
00320 
00321 static void rna_Curve_update_points(Main *bmain, Scene *scene, PointerRNA *ptr)
00322 {
00323     Curve *cu= (Curve*)ptr->id.data;
00324     Nurb *nu= curve_nurb_from_point(cu, ptr->data, NULL, NULL);
00325 
00326     if(nu)
00327         calchandlesNurb(nu);
00328 
00329     rna_Curve_update_data(bmain, scene, ptr);
00330 }
00331 
00332 static PointerRNA rna_Curve_bevelObject_get(PointerRNA *ptr)
00333 {
00334     Curve *cu= (Curve*)ptr->id.data;
00335     Object *ob= cu->bevobj;
00336 
00337     if(ob)
00338         return rna_pointer_inherit_refine(ptr, &RNA_Object, ob);
00339 
00340     return rna_pointer_inherit_refine(ptr, NULL, NULL);
00341 }
00342 
00343 static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value)
00344 {
00345     Curve *cu= (Curve*)ptr->id.data;
00346     Object *ob= (Object*)value.data;
00347 
00348     if (ob) {
00349         /* if bevel object has got the save curve, as object, for which it's */
00350         /* set as bevobj, there could be infinity loop in displist calculation */
00351         if (ob->type == OB_CURVE && ob->data != cu) {
00352             cu->bevobj = ob;
00353         }
00354     } else {
00355         cu->bevobj = NULL;
00356     }
00357 }
00358 
00359 static int rna_Curve_otherObject_poll(PointerRNA *ptr, PointerRNA value)
00360 {
00361     Curve *cu= (Curve*)ptr->id.data;
00362     Object *ob= (Object*)value.data;
00363 
00364     if (ob) {
00365         if (ob->type == OB_CURVE && ob->data != cu) {
00366             return 1;
00367         }
00368     }
00369 
00370     return 0;
00371 }
00372 
00373 static PointerRNA rna_Curve_taperObject_get(PointerRNA *ptr)
00374 {
00375     Curve *cu= (Curve*)ptr->id.data;
00376     Object *ob= cu->taperobj;
00377 
00378     if(ob)
00379         return rna_pointer_inherit_refine(ptr, &RNA_Object, ob);
00380 
00381     return rna_pointer_inherit_refine(ptr, NULL, NULL);
00382 }
00383 
00384 static void rna_Curve_taperObject_set(PointerRNA *ptr, PointerRNA value)
00385 {
00386     Curve *cu= (Curve*)ptr->id.data;
00387     Object *ob= (Object*)value.data;
00388 
00389     if (ob) {
00390         /* if taper object has got the save curve, as object, for which it's */
00391         /* set as bevobj, there could be infinity loop in displist calculation */
00392         if (ob->type == OB_CURVE && ob->data != cu) {
00393             cu->taperobj = ob;
00394         }
00395     } else {
00396         cu->taperobj = NULL;
00397     }
00398 }
00399 
00400 static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
00401 {
00402     Curve *cu= (Curve*)ptr->id.data;
00403     ListBase *nurbs= BKE_curve_nurbs(cu);
00404     Nurb *nu= nurbs->first;
00405 
00406     while(nu) {
00407         nu->resolu= cu->resolu;
00408         nu= nu->next;
00409     }
00410     
00411     rna_Curve_update_data(bmain, scene, ptr);
00412 }
00413 
00414 static void rna_Curve_resolution_v_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
00415 {
00416     Curve *cu= (Curve*)ptr->id.data;
00417     ListBase *nurbs= BKE_curve_nurbs(cu);
00418     Nurb *nu=nurbs->first;
00419 
00420 
00421     while(nu) {
00422         nu->resolv= cu->resolv;
00423         nu= nu->next;
00424     }
00425 
00426     rna_Curve_update_data(bmain, scene, ptr);
00427 }
00428 
00429 static float rna_Curve_offset_get(PointerRNA *ptr)
00430 {
00431     Curve *cu= (Curve*)ptr->id.data;
00432     return cu->width - 1.0f;
00433 }
00434 
00435 static void rna_Curve_offset_set(PointerRNA *ptr, float value)
00436 {
00437     Curve *cu= (Curve*)ptr->id.data;
00438     cu->width= 1.0f + value;
00439 }
00440 
00441 /* name functions that ignore the first two ID characters */
00442 void rna_Curve_body_get(PointerRNA *ptr, char *value)
00443 {
00444     Curve *cu= (Curve*)ptr->id.data;
00445     BLI_strncpy(value, cu->str, cu->len+1);
00446 }
00447 
00448 int rna_Curve_body_length(PointerRNA *ptr)
00449 {
00450     Curve *cu= (Curve*)ptr->id.data;
00451     return cu->len;
00452 }
00453 
00454 /* TODO - check UTF & python play nice */
00455 void rna_Curve_body_set(PointerRNA *ptr, const char *value)
00456 {
00457     int len= strlen(value);
00458     Curve *cu= (Curve*)ptr->id.data;
00459 
00460     cu->len= cu->pos = len;
00461 
00462     if(cu->str)     MEM_freeN(cu->str);
00463     if(cu->strinfo) MEM_freeN(cu->strinfo);
00464 
00465     cu->str = MEM_callocN(len + sizeof(wchar_t), "str");
00466     cu->strinfo = MEM_callocN( (len+4) *sizeof(CharInfo), "strinfo"); /* don't know why this is +4, just duplicating load_editText() */
00467 
00468     //BLI_strncpy_wchar_as_utf8(cu->str, value, len+1); // value is not wchar_t
00469     BLI_strncpy(cu->str, value, len+1);
00470 }
00471 
00472 static void rna_Nurb_update_cyclic_u(Main *bmain, Scene *scene, PointerRNA *ptr)
00473 {
00474     Nurb *nu= (Nurb*)ptr->data;
00475 
00476     if(nu->type == CU_BEZIER) {
00477         calchandlesNurb(nu);
00478     } else {
00479         nurbs_knot_calc_u(nu);
00480     }
00481 
00482     rna_Curve_update_data(bmain, scene, ptr);
00483 }
00484 
00485 static void rna_Nurb_update_cyclic_v(Main *bmain, Scene *scene, PointerRNA *ptr)
00486 {
00487     Nurb *nu= (Nurb*)ptr->data;
00488 
00489     nurbs_knot_calc_v(nu);
00490 
00491     rna_Curve_update_data(bmain, scene, ptr);
00492 }
00493 
00494 static void rna_Nurb_update_knot_u(Main *bmain, Scene *scene, PointerRNA *ptr)
00495 {
00496     Nurb *nu= (Nurb*)ptr->data;
00497 
00498     clamp_nurb_order_u(nu);
00499     nurbs_knot_calc_u(nu);
00500 
00501     rna_Curve_update_data(bmain, scene, ptr);
00502 }
00503 
00504 static void rna_Nurb_update_knot_v(Main *bmain, Scene *scene, PointerRNA *ptr)
00505 {
00506     Nurb *nu= (Nurb*)ptr->data;
00507 
00508     clamp_nurb_order_v(nu);
00509     nurbs_knot_calc_v(nu);
00510 
00511     rna_Curve_update_data(bmain, scene, ptr);
00512 }
00513 
00514 static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, int number)
00515 {
00516     if(nu->type == CU_BEZIER) {
00517         BKE_report(reports, RPT_ERROR, "Bezier spline can't have points added");
00518     }
00519     else if(number==0) {
00520         // do nothing
00521     } else {
00522 
00523         addNurbPoints(nu, number);
00524 
00525         /* update */
00526         nurbs_knot_calc_u(nu);
00527 
00528         rna_Curve_update_data_id(NULL, NULL, id);
00529     }
00530 }
00531 
00532 static void rna_Curve_spline_bezpoints_add(ID *id, Nurb *nu, ReportList *reports, int number)
00533 {
00534     if(nu->type != CU_BEZIER) {
00535         BKE_report(reports, RPT_ERROR, "Only Bezier splines can be added");
00536     }
00537     else if(number==0) {
00538         // do nothing
00539     } else {
00540         addNurbPointsBezier(nu, number);
00541 
00542         /* update */
00543         nurbs_knot_calc_u(nu);
00544 
00545         rna_Curve_update_data_id(NULL, NULL, id);
00546     }
00547 }
00548 
00549 static Nurb *rna_Curve_spline_new(Curve *cu, int type)
00550 {
00551     Nurb *nu= ( Nurb * ) MEM_callocN( sizeof( Nurb ), "spline.new" );
00552 
00553     if(type==CU_BEZIER) {
00554         BezTriple *bezt= (BezTriple *)MEM_callocN(sizeof(BezTriple), "spline.new.bezt");
00555         bezt->radius= 1.0;
00556         nu->bezt= bezt;
00557     }
00558     else {
00559         BPoint *bp= (BPoint *)MEM_callocN(sizeof(BPoint), "spline.new.bp");
00560         bp->radius= 1.0f;
00561         nu->bp= bp;
00562     }
00563 
00564     nu->type= type;
00565     nu->pntsu= 1;
00566     nu->pntsv= 1;
00567 
00568     nu->orderu= nu->orderv= 4;
00569     nu->resolu= nu->resolv= 12;
00570     nu->flag= CU_SMOOTH;
00571 
00572     BLI_addtail(BKE_curve_nurbs(cu), nu);
00573 
00574     return nu;
00575 }
00576 
00577 static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu)
00578 {
00579     int found= 0;
00580     ListBase *nurbs= BKE_curve_nurbs(cu);
00581 
00582     found= BLI_remlink_safe(nurbs, nu);
00583 
00584     if(!found) {
00585         BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" does not contain spline given", cu->id.name+2);
00586         return;
00587     }
00588 
00589     freeNurb(nu);
00590     /* invalidate pointer!, no can do */
00591 
00592     DAG_id_tag_update(&cu->id, OB_RECALC_DATA);
00593     WM_main_add_notifier(NC_GEOM|ND_DATA, NULL);
00594 }
00595 
00596 static void rna_Curve_spline_clear(Curve *cu)
00597 {
00598     ListBase *nurbs= BKE_curve_nurbs(cu);
00599 
00600     freeNurblist(nurbs);
00601 
00602     DAG_id_tag_update(&cu->id, OB_RECALC_DATA);
00603     WM_main_add_notifier(NC_GEOM|ND_DATA, NULL);
00604 }
00605 
00606 static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr)
00607 {
00608     Curve *cu= (Curve*)ptr->data;
00609     Nurb *nu;
00610     ListBase *nurbs= BKE_curve_nurbs(cu);
00611 
00612     // for curve outside editmode will set to -1,  should be changed to be allowed outside of editmode.
00613     nu= BLI_findlink(nurbs, cu->actnu);
00614 
00615     if(nu)
00616         return rna_pointer_inherit_refine(ptr, &RNA_Spline, nu);
00617 
00618     return rna_pointer_inherit_refine(ptr, NULL, NULL);
00619 }
00620 
00621 static void rna_Curve_active_spline_set(PointerRNA *ptr, PointerRNA value)
00622 {
00623     Curve *cu= (Curve*)ptr->data;
00624     Nurb *nu= value.data;
00625     ListBase *nubase= BKE_curve_nurbs(cu);
00626 
00627     /* -1 is ok for an unset index */
00628     if(nu==NULL)
00629         cu->actnu= -1;
00630     else
00631         cu->actnu= BLI_findindex(nubase, nu);
00632 }
00633 
00634 static char *rna_Curve_spline_path(PointerRNA *ptr)
00635 {
00636     Curve *cu= (Curve*)ptr->id.data;
00637     ListBase *nubase= BKE_curve_nurbs(cu);
00638     Nurb *nu= ptr->data;
00639     int index= BLI_findindex(nubase, nu);
00640 
00641     if (index >= 0)
00642         return BLI_sprintfN("splines[%d]", index);
00643     else
00644         return BLI_strdup("");
00645 }
00646 
00647 /* use for both bezier and nurbs */
00648 static char *rna_Curve_spline_point_path(PointerRNA *ptr)
00649 {
00650     Curve *cu= (Curve*)ptr->id.data;
00651     Nurb *nu;
00652     void *point= ptr->data;
00653     int nu_index, pt_index;
00654 
00655     nu= curve_nurb_from_point(cu, point, &nu_index, &pt_index);
00656 
00657     if (nu) {
00658         if(nu->type == CU_BEZIER) {
00659             return BLI_sprintfN("splines[%d].bezier_points[%d]", nu_index, pt_index);
00660         }
00661         else {
00662             return BLI_sprintfN("splines[%d].points[%d]", nu_index, pt_index);
00663         }   
00664     }
00665     else {
00666         return BLI_strdup("");
00667     }
00668 }
00669 
00670 
00671 static char *rna_TextBox_path(PointerRNA *ptr)
00672 {
00673     Curve *cu= (Curve*)ptr->id.data;
00674     TextBox *tb= ptr->data;
00675     int index= (int)(tb - cu->tb);
00676 
00677     if (index >= 0 && index < cu->totbox)
00678         return BLI_sprintfN("text_boxes[%d]", index);
00679     else
00680         return BLI_strdup("");
00681 }
00682 
00683 static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00684 {
00685     Curve *cu= (Curve*)ptr->id.data;
00686     rna_iterator_listbase_begin(iter, BKE_curve_nurbs(cu), NULL);
00687 }
00688 
00689 #else
00690 
00691 static void rna_def_bpoint(BlenderRNA *brna)
00692 {
00693     StructRNA *srna;
00694     PropertyRNA *prop;
00695 
00696     srna= RNA_def_struct(brna, "SplinePoint", NULL);
00697     RNA_def_struct_sdna(srna, "BPoint");
00698     RNA_def_struct_ui_text(srna, "SplinePoint", "Spline point without handles");
00699 
00700     /* Boolean values */
00701     prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
00702     RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
00703     RNA_def_property_ui_text(prop, "Select", "Selection status");
00704     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00705 
00706     prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
00707     RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
00708     RNA_def_property_ui_text(prop, "Hide", "Visibility status");
00709     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00710 
00711     /* Vector value */
00712     prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
00713     RNA_def_property_array(prop, 3);
00714     RNA_def_property_float_sdna(prop, NULL, "vec");
00715     RNA_def_property_ui_text(prop, "Point", "Point coordinates");
00716     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00717 
00718     prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
00719     RNA_def_property_float_sdna(prop, NULL, "vec[3]");
00720     RNA_def_property_ui_text(prop, "Weight", "NURBS weight");
00721     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00722 
00723     /* Number values */
00724     prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
00725     RNA_def_property_float_sdna(prop, NULL, "alfa");
00726     /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
00727     RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
00728     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00729 
00730     prop= RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
00731     RNA_def_property_float_sdna(prop, NULL, "weight");
00732     RNA_def_property_range(prop, 0.01f, 100.0f);
00733     RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
00734     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00735 
00736     prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
00737     RNA_def_property_float_sdna(prop, NULL, "radius");
00738     RNA_def_property_range(prop, 0.0f, FLT_MAX);
00739     RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling");
00740     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00741 
00742     RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path");
00743 }
00744 
00745 static void rna_def_beztriple(BlenderRNA *brna)
00746 {
00747     StructRNA *srna;
00748     PropertyRNA *prop;
00749 
00750     srna= RNA_def_struct(brna, "BezierSplinePoint", NULL);
00751     RNA_def_struct_sdna(srna, "BezTriple");
00752     RNA_def_struct_ui_text(srna, "Bezier Curve Point", "Bezier curve point with two handles");
00753 
00754     /* Boolean values */
00755     prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
00756     RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
00757     RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
00758     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00759 
00760     prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
00761     RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
00762     RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
00763     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00764 
00765     prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
00766     RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
00767     RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status");
00768     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00769 
00770     prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
00771     RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
00772     RNA_def_property_ui_text(prop, "Hide", "Visibility status");
00773     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00774 
00775     /* Enums */
00776     prop= RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
00777     RNA_def_property_enum_sdna(prop, NULL, "h1");
00778     RNA_def_property_enum_items(prop, beztriple_handle_type_items);
00779     RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types");
00780     RNA_def_property_update(prop, 0, "rna_Curve_update_points");
00781 
00782     prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
00783     RNA_def_property_enum_sdna(prop, NULL, "h2");
00784     RNA_def_property_enum_items(prop, beztriple_handle_type_items);
00785     RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types");
00786     RNA_def_property_update(prop, 0, "rna_Curve_update_points");
00787 
00788     /* Vector values */
00789     prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
00790     RNA_def_property_array(prop, 3);
00791     RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL);
00792     RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
00793     RNA_def_property_update(prop, 0, "rna_Curve_update_points");
00794 
00795     prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
00796     RNA_def_property_array(prop, 3);
00797     RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL);
00798     RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
00799     RNA_def_property_update(prop, 0, "rna_Curve_update_points");
00800 
00801     prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
00802     RNA_def_property_array(prop, 3);
00803     RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL);
00804     RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
00805     RNA_def_property_update(prop, 0, "rna_Curve_update_points");
00806 
00807     /* Number values */
00808     prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
00809     RNA_def_property_float_sdna(prop, NULL, "alfa");
00810     /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
00811     RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
00812     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00813 
00814     prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
00815     RNA_def_property_range(prop, 0.01f, 100.0f);
00816     RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
00817     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00818 
00819     prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
00820     RNA_def_property_float_sdna(prop, NULL, "radius");
00821     RNA_def_property_range(prop, 0.0f, FLT_MAX);
00822     RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling");
00823     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00824 
00825     RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path");
00826 }
00827 
00828 static void rna_def_path(BlenderRNA *brna, StructRNA *srna)
00829 {
00830     PropertyRNA *prop;
00831     
00832     /* number values */
00833     prop= RNA_def_property(srna, "path_duration", PROP_INT, PROP_NONE);
00834     RNA_def_property_int_sdna(prop, NULL, "pathlen");
00835     RNA_def_property_range(prop, 1, MAXFRAME);
00836     RNA_def_property_ui_text(prop, "Path Length", "The number of frames that are needed to traverse the path, defining the maximum value for the 'Evaluation Time' setting");
00837     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00838     
00839     /* flags */
00840     prop= RNA_def_property(srna, "use_path", PROP_BOOLEAN, PROP_NONE);
00841     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH);
00842     RNA_def_property_ui_text(prop, "Path", "Enable the curve to become a translation path");
00843     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00844     
00845     prop= RNA_def_property(srna, "use_path_follow", PROP_BOOLEAN, PROP_NONE);
00846     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FOLLOW);
00847     RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path");
00848     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00849     
00850     prop= RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
00851     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH);
00852     RNA_def_property_ui_text(prop, "Stretch", "Option for curve-deform: make deformed child to stretch along entire path");
00853     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00854 
00855     prop= RNA_def_property(srna, "use_deform_bounds", PROP_BOOLEAN, PROP_NONE);
00856     RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_DEFORM_BOUNDS_OFF);
00857     RNA_def_property_ui_text(prop, "Bounds Clamp", "Use the mesh bounds to clamp the deformation");
00858     RNA_def_property_update(prop, 0, "rna_Curve_update_data");  
00859 
00860     prop= RNA_def_property(srna, "use_time_offset", PROP_BOOLEAN, PROP_NONE);
00861     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_OFFS_PATHDIST);
00862     RNA_def_property_ui_text(prop, "Offset Path Distance", "Children will use TimeOffs value as path distance offset");
00863     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00864 
00865     prop= RNA_def_property(srna, "use_radius", PROP_BOOLEAN, PROP_NONE);
00866     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH_RADIUS);
00867     RNA_def_property_ui_text(prop, "Radius", "Option for paths: apply the curve radius with path following it and deforming");
00868     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00869 }
00870 
00871 static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna)
00872 {
00873     PropertyRNA *prop;
00874     
00875     /* flags */
00876     prop= RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
00877     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
00878     RNA_def_property_ui_text(prop, "Use UV for Mapping", "Uses the UV values as Generated textured coordinates");
00879     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00880 }
00881 
00882 static void rna_def_font(BlenderRNA *brna, StructRNA *srna)
00883 {
00884     PropertyRNA *prop;
00885     
00886     static EnumPropertyItem prop_align_items[] = {
00887         {CU_LEFT, "LEFT", 0, "Left", "Align text to the left"},
00888         {CU_MIDDLE, "CENTER", 0, "Center", "Center text"},
00889         {CU_RIGHT, "RIGHT", 0, "Right", "Align text to the right"},
00890         {CU_JUSTIFY, "JUSTIFY", 0, "Justify", "Align to the left and the right"},
00891         {CU_FLUSH, "FLUSH", 0, "Flush", "Align to the left and the right, with equal character spacing"},
00892         {0, NULL, 0, NULL, NULL}};
00893         
00894     /* Enums */
00895     prop= RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE);
00896     RNA_def_property_enum_sdna(prop, NULL, "spacemode");
00897     RNA_def_property_enum_items(prop, prop_align_items);
00898     RNA_def_property_ui_text(prop, "Text Align", "Text align from the object center");
00899     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00900     
00901     /* number values */
00902     prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
00903     RNA_def_property_float_sdna(prop, NULL, "fsize");
00904     RNA_def_property_range(prop, 0.0001f, 10000.0f);
00905     RNA_def_property_ui_range(prop, 0.01, 10, 1, 3);
00906     RNA_def_property_ui_text(prop, "Font size", "");
00907     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00908     
00909     prop= RNA_def_property(srna, "small_caps_scale", PROP_FLOAT, PROP_NONE);
00910     RNA_def_property_float_sdna(prop, NULL, "smallcaps_scale");
00911     RNA_def_property_ui_range(prop, 0, 1.0, 1, 2);
00912     RNA_def_property_ui_text(prop, "Small Caps", "Scale of small capitals");
00913     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00914 
00915     prop= RNA_def_property(srna, "space_line", PROP_FLOAT, PROP_NONE);
00916     RNA_def_property_float_sdna(prop, NULL, "linedist");
00917     RNA_def_property_range(prop, 0.0f, 10.0f);
00918     RNA_def_property_ui_text(prop, "Distance between lines of text", "");
00919     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00920     
00921     prop= RNA_def_property(srna, "space_word", PROP_FLOAT, PROP_NONE);
00922     RNA_def_property_float_sdna(prop, NULL, "wordspace");
00923     RNA_def_property_range(prop, 0.0f, 10.0f);
00924     RNA_def_property_ui_text(prop, "Spacing between words", "");
00925     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00926     
00927     prop= RNA_def_property(srna, "space_character", PROP_FLOAT, PROP_NONE);
00928     RNA_def_property_float_sdna(prop, NULL, "spacing");
00929     RNA_def_property_range(prop, 0.0f, 10.0f);
00930     RNA_def_property_ui_text(prop, "Global spacing between characters", "");
00931     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00932     
00933     prop= RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE);
00934     RNA_def_property_float_sdna(prop, NULL, "shear");
00935     RNA_def_property_range(prop, -1.0f, 1.0f);
00936     RNA_def_property_ui_text(prop, "Shear", "Italic angle of the characters");
00937     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00938     
00939     prop= RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_NONE);
00940     RNA_def_property_float_sdna(prop, NULL, "xof");
00941     RNA_def_property_range(prop, -50.0f, 50.0f);
00942     RNA_def_property_ui_text(prop, "X Offset", "Horizontal offset from the object origin");
00943     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00944     
00945     prop= RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_NONE);
00946     RNA_def_property_float_sdna(prop, NULL, "yof");
00947     RNA_def_property_range(prop, -50.0f, 50.0f);
00948     RNA_def_property_ui_text(prop, "Y Offset", "Vertical offset from the object origin");
00949     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00950     
00951     prop= RNA_def_property(srna, "underline_position", PROP_FLOAT, PROP_NONE);
00952     RNA_def_property_float_sdna(prop, NULL, "ulpos");
00953     RNA_def_property_range(prop, -0.2f, 0.8f);
00954     RNA_def_property_ui_text(prop, "Underline Position", "Vertical position of underline");
00955     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00956     
00957     prop= RNA_def_property(srna, "underline_height", PROP_FLOAT, PROP_NONE);
00958     RNA_def_property_float_sdna(prop, NULL, "ulheight");
00959     RNA_def_property_range(prop, -0.2f, 0.8f);
00960     RNA_def_property_ui_text(prop, "Underline Thickness", "");
00961     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00962     
00963     prop= RNA_def_property(srna, "text_boxes", PROP_COLLECTION, PROP_NONE);
00964     RNA_def_property_collection_sdna(prop, NULL, "tb", "totbox");
00965     RNA_def_property_struct_type(prop, "TextBox");
00966     RNA_def_property_ui_text(prop, "Textboxes", "");
00967 
00968     prop= RNA_def_property(srna, "active_textbox", PROP_INT, PROP_NONE);
00969     RNA_def_property_int_sdna(prop, NULL, "actbox");
00970     RNA_def_property_ui_text(prop, "The active text box", "");
00971     RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_active_textbox_index_range");
00972     
00973     /* strings */
00974     prop= RNA_def_property(srna, "family", PROP_STRING, PROP_NONE);
00975     RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2);
00976     RNA_def_property_ui_text(prop, "Object Font", "Use Blender Objects as font characters (give font objects a common name followed by the character they represent, eg. familya, familyb, etc, and turn on Verts Duplication)");
00977     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00978     
00979     prop= RNA_def_property(srna, "body", PROP_STRING, PROP_NONE);
00980     RNA_def_property_string_sdna(prop, NULL, "str");
00981     RNA_def_property_ui_text(prop, "Body Text", "Content of this text object");
00982     RNA_def_property_string_funcs(prop, "rna_Curve_body_get", "rna_Curve_body_length", "rna_Curve_body_set");
00983     RNA_def_property_string_maxlength(prop, 8192); /* note that originally str did not have a limit! */
00984     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
00985 
00986     prop= RNA_def_property(srna, "body_format", PROP_COLLECTION, PROP_NONE);
00987     RNA_def_property_collection_sdna(prop, NULL, "strinfo", "len");
00988     RNA_def_property_struct_type(prop, "TextCharacterFormat");
00989     RNA_def_property_ui_text(prop, "Character Info", "Stores the style of each character");
00990     
00991     /* pointers */
00992     prop= RNA_def_property(srna, "follow_curve", PROP_POINTER, PROP_NONE);
00993     RNA_def_property_pointer_sdna(prop, NULL, "textoncurve");
00994     RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_otherObject_poll");
00995     RNA_def_property_flag(prop, PROP_EDITABLE);
00996     RNA_def_property_ui_text(prop, "Text on Curve", "Curve deforming text object");
00997     RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
00998     
00999     prop= RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE);
01000     RNA_def_property_pointer_sdna(prop, NULL, "vfont");
01001     RNA_def_property_ui_text(prop, "Font", "");
01002     RNA_def_property_flag(prop, PROP_EDITABLE);
01003     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01004 
01005     prop= RNA_def_property(srna, "font_bold", PROP_POINTER, PROP_NONE);
01006     RNA_def_property_pointer_sdna(prop, NULL, "vfontb");
01007     RNA_def_property_ui_text(prop, "Font Bold", "");
01008     RNA_def_property_flag(prop, PROP_EDITABLE);
01009     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01010 
01011     prop= RNA_def_property(srna, "font_italic", PROP_POINTER, PROP_NONE);
01012     RNA_def_property_pointer_sdna(prop, NULL, "vfonti");
01013     RNA_def_property_ui_text(prop, "Font Italic", "");
01014     RNA_def_property_flag(prop, PROP_EDITABLE);
01015     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01016 
01017     prop= RNA_def_property(srna, "font_bold_italic", PROP_POINTER, PROP_NONE);
01018     RNA_def_property_pointer_sdna(prop, NULL, "vfontbi");
01019     RNA_def_property_ui_text(prop, "Font Bold Italic", "");
01020     RNA_def_property_flag(prop, PROP_EDITABLE);
01021     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01022 
01023     prop= RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE);
01024     RNA_def_property_pointer_sdna(prop, NULL, "curinfo");
01025     RNA_def_property_ui_text(prop, "Edit Format", "Editing settings character formatting");
01026     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01027 
01028     /* flags */
01029     prop= RNA_def_property(srna, "use_fast_edit", PROP_BOOLEAN, PROP_NONE);
01030     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FAST);
01031     RNA_def_property_ui_text(prop, "Fast Editing", "Don't fill polygons while editing");
01032     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01033 }
01034 
01035 static void rna_def_textbox(BlenderRNA *brna)
01036 {
01037     StructRNA *srna;
01038     PropertyRNA *prop;
01039     
01040     srna= RNA_def_struct(brna, "TextBox", NULL);
01041     RNA_def_struct_ui_text(srna, "Text Box", "Text bounding box for layout");
01042     
01043     /* number values */
01044     prop= RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);
01045     RNA_def_property_float_sdna(prop, NULL, "x");
01046     RNA_def_property_range(prop, -50.0f, 50.0f);
01047     RNA_def_property_ui_text(prop, "Textbox X Offset", "");
01048     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01049     
01050     prop= RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE);
01051     RNA_def_property_float_sdna(prop, NULL, "y");
01052     RNA_def_property_range(prop, -50.0f, 50.0f);
01053     RNA_def_property_ui_text(prop, "Textbox Y Offset", "");
01054     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01055 
01056     prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE);
01057     RNA_def_property_float_sdna(prop, NULL, "w");
01058     RNA_def_property_range(prop, 0.0f, 50.0f);
01059     RNA_def_property_ui_text(prop, "Textbox Width", "");
01060     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01061 
01062     prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
01063     RNA_def_property_float_sdna(prop, NULL, "h");
01064     RNA_def_property_range(prop, 0.0f, 50.0f);
01065     RNA_def_property_ui_text(prop, "Textbox Height", "");
01066     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01067     
01068     RNA_def_struct_path_func(srna, "rna_TextBox_path");
01069 }
01070 
01071 static void rna_def_charinfo(BlenderRNA *brna)
01072 {
01073     StructRNA *srna;
01074     PropertyRNA *prop;
01075     
01076     srna= RNA_def_struct(brna, "TextCharacterFormat", NULL);
01077     RNA_def_struct_sdna(srna, "CharInfo");
01078     RNA_def_struct_ui_text(srna, "Text Character Format", "Text character formatting settings");
01079     
01080     /* flags */
01081     prop= RNA_def_property(srna, "use_bold", PROP_BOOLEAN, PROP_NONE);
01082     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD);
01083     RNA_def_property_ui_text(prop, "Bold", "");
01084     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01085     
01086     prop= RNA_def_property(srna, "use_italic", PROP_BOOLEAN, PROP_NONE);
01087     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC);
01088     RNA_def_property_ui_text(prop, "Italic", "");
01089     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01090     
01091     prop= RNA_def_property(srna, "use_underline", PROP_BOOLEAN, PROP_NONE);
01092     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE);
01093     RNA_def_property_ui_text(prop, "Underline", "");
01094     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01095     
01096     /* probably there is no reason to expose this */
01097     /* prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
01098     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP);
01099     RNA_def_property_ui_text(prop, "Wrap", "");
01100     RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */
01101 
01102     prop= RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE);
01103     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_SMALLCAPS);
01104     RNA_def_property_ui_text(prop, "Small Caps", "");
01105     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01106 }
01107 
01108 static void rna_def_surface(BlenderRNA *brna)
01109 {
01110     StructRNA *srna;
01111     
01112     srna= RNA_def_struct(brna, "SurfaceCurve", "Curve");
01113     RNA_def_struct_sdna(srna, "Curve");
01114     RNA_def_struct_ui_text(srna, "Surface Curve", "Curve datablock used for storing surfaces");
01115     RNA_def_struct_ui_icon(srna, ICON_SURFACE_DATA);
01116 
01117     rna_def_nurbs(brna, srna);
01118 }
01119 
01120 static void rna_def_text(BlenderRNA *brna)
01121 {
01122     StructRNA *srna;
01123     
01124     srna= RNA_def_struct(brna, "TextCurve", "Curve");
01125     RNA_def_struct_sdna(srna, "Curve");
01126     RNA_def_struct_ui_text(srna, "Text Curve", "Curve datablock used for storing text");
01127     RNA_def_struct_ui_icon(srna, ICON_FONT_DATA);
01128 
01129     rna_def_font(brna, srna);
01130     rna_def_nurbs(brna, srna);
01131 }
01132 
01133 
01134 /* curve.splines[0].points */
01135 static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop)
01136 {
01137     StructRNA *srna;
01138     //PropertyRNA *prop;
01139 
01140     FunctionRNA *func;
01141     //PropertyRNA *parm;
01142 
01143     RNA_def_property_srna(cprop, "SplinePoints");
01144     srna= RNA_def_struct(brna, "SplinePoints", NULL);
01145     RNA_def_struct_sdna(srna, "Nurb");
01146     RNA_def_struct_ui_text(srna, "Spline Points", "Collection of spline points");
01147 
01148     func= RNA_def_function(srna, "add", "rna_Curve_spline_points_add");
01149     RNA_def_function_ui_description(func, "Add a number of points to this spline");
01150     RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
01151     RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
01152 
01153     /*
01154     func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
01155     RNA_def_function_ui_description(func, "Remove a spline from a curve");
01156     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01157     parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
01158     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01159     */
01160 }
01161 
01162 static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop)
01163 {
01164     StructRNA *srna;
01165     //PropertyRNA *prop;
01166 
01167     FunctionRNA *func;
01168     //PropertyRNA *parm;
01169 
01170     RNA_def_property_srna(cprop, "SplineBezierPoints");
01171     srna= RNA_def_struct(brna, "SplineBezierPoints", NULL);
01172     RNA_def_struct_sdna(srna, "Nurb");
01173     RNA_def_struct_ui_text(srna, "Spline Bezier Points", "Collection of spline bezirt points");
01174 
01175     func= RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add");
01176     RNA_def_function_ui_description(func, "Add a number of points to this spline");
01177     RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
01178     RNA_def_int(func, "count", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
01179 
01180     /*
01181     func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
01182     RNA_def_function_ui_description(func, "Remove a spline from a curve");
01183     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01184     parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
01185     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01186     */
01187 }
01188 
01189 /* curve.splines */
01190 static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop)
01191 {
01192     StructRNA *srna;
01193     PropertyRNA *prop;
01194 
01195     FunctionRNA *func;
01196     PropertyRNA *parm;
01197 
01198     RNA_def_property_srna(cprop, "CurveSplines");
01199     srna= RNA_def_struct(brna, "CurveSplines", NULL);
01200     RNA_def_struct_sdna(srna, "Curve");
01201     RNA_def_struct_ui_text(srna, "Curve Splines", "Collection of curve splines");
01202 
01203     func= RNA_def_function(srna, "new", "rna_Curve_spline_new");
01204     RNA_def_function_ui_description(func, "Add a new spline to the curve");
01205     parm= RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline");
01206     RNA_def_property_flag(parm, PROP_REQUIRED);
01207     parm= RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline");
01208     RNA_def_function_return(func, parm);
01209 
01210     func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
01211     RNA_def_function_ui_description(func, "Remove a spline from a curve");
01212     RNA_def_function_flag(func, FUNC_USE_REPORTS);
01213     parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
01214     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
01215 
01216     func= RNA_def_function(srna, "clear", "rna_Curve_spline_clear");
01217     RNA_def_function_ui_description(func, "Remove all spline from a curve");
01218 
01219     prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
01220     RNA_def_property_struct_type(prop, "Object");
01221     RNA_def_property_pointer_funcs(prop, "rna_Curve_active_spline_get", "rna_Curve_active_spline_set", NULL, NULL);
01222     RNA_def_property_flag(prop, PROP_EDITABLE);
01223     RNA_def_property_ui_text(prop, "Active Spline", "Active curve spline");
01224     /* Could call: ED_base_object_activate(C, scene->basact);
01225      * but would be a bad level call and it seems the notifier is enough */
01226     RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL);
01227 }
01228 
01229 
01230 static void rna_def_curve(BlenderRNA *brna)
01231 {
01232     StructRNA *srna;
01233     PropertyRNA *prop;
01234     
01235     static EnumPropertyItem curve_twist_mode_items[] = {
01236             {CU_TWIST_Z_UP, "Z_UP", 0, "Z-Up", "Use Z-Up axis to calculate the curve twist at each point"},
01237             {CU_TWIST_MINIMUM, "MINIMUM", 0, "Minimum", "Use the least twist over the entire curve"},
01238             {CU_TWIST_TANGENT, "TANGENT", 0, "Tangent", "Use the tangent to calculate twist"},
01239             {0, NULL, 0, NULL, NULL}};
01240 
01241     static const EnumPropertyItem curve_axis_items[]= {
01242         {0, "2D", 0, "2D", "Clamp the Z axis of the curve"},
01243         {CU_3D, "3D", 0, "3D", "Allow editing on the Z axis of this curve, also allows tilt and curve radius to be used"},
01244         {0, NULL, 0, NULL, NULL}};
01245             
01246     srna= RNA_def_struct(brna, "Curve", "ID");
01247     RNA_def_struct_ui_text(srna, "Curve", "Curve datablock storing curves, splines and NURBS");
01248     RNA_def_struct_ui_icon(srna, ICON_CURVE_DATA);
01249     RNA_def_struct_refine_func(srna, "rna_Curve_refine");
01250     
01251     rna_def_animdata_common(srna);
01252 
01253     prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
01254     RNA_def_property_pointer_sdna(prop, NULL, "key");
01255     RNA_def_property_ui_text(prop, "Shape Keys", "");
01256 
01257 
01258     prop= RNA_def_property(srna, "splines", PROP_COLLECTION, PROP_NONE);
01259 #if 0
01260     RNA_def_property_collection_sdna(prop, NULL, "nurb", NULL);
01261 #else
01262     /* this way we get editmode nurbs too, keyframe in editmode */
01263     RNA_def_property_collection_funcs(prop, "rna_Curve_splines_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL);
01264 #endif
01265     RNA_def_property_struct_type(prop, "Spline");
01266     RNA_def_property_ui_text(prop, "Splines", "Collection of splines in this curve data object");
01267     rna_def_curve_splines(brna, prop);
01268 
01269     prop= RNA_def_property(srna, "show_handles", PROP_BOOLEAN, PROP_NONE);
01270     RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_HANDLES);
01271     RNA_def_property_ui_text(prop, "Draw Handles", "Display Bezier handles in editmode");
01272     RNA_def_property_update(prop, NC_GEOM|ND_DATA, NULL);
01273 
01274     prop= RNA_def_property(srna, "show_normal_face", PROP_BOOLEAN, PROP_NONE);
01275     RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_NORMALS);
01276     RNA_def_property_ui_text(prop, "Draw Normals", "Display 3D curve normals in editmode");
01277     RNA_def_property_update(prop, NC_GEOM|ND_DATA, NULL);
01278 
01279     rna_def_path(brna, srna);
01280     
01281     /* Number values */
01282     prop= RNA_def_property(srna, "bevel_resolution", PROP_INT, PROP_NONE);
01283     RNA_def_property_int_sdna(prop, NULL, "bevresol");
01284     RNA_def_property_range(prop, 0, 32);
01285     RNA_def_property_ui_range(prop, 0, 32, 1.0, 0);
01286     RNA_def_property_ui_text(prop, "Bevel Resolution", "Bevel resolution when depth is non-zero and no specific bevel object has been defined");
01287     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01288     
01289     prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
01290     RNA_def_property_float_sdna(prop, NULL, "width");
01291     RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
01292     RNA_def_property_float_funcs(prop, "rna_Curve_offset_get", "rna_Curve_offset_set", NULL);
01293     RNA_def_property_ui_text(prop, "Offset", "Offset the curve to adjust the width of a text");
01294     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01295     
01296     prop= RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
01297     RNA_def_property_float_sdna(prop, NULL, "ext1");
01298     RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
01299     RNA_def_property_range(prop, 0.0, FLT_MAX);
01300     RNA_def_property_ui_text(prop, "Extrude", "Amount of curve extrusion when not using a bevel object");
01301     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01302     
01303     prop= RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH);
01304     RNA_def_property_float_sdna(prop, NULL, "ext2");
01305     RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
01306     RNA_def_property_ui_text(prop, "Bevel Depth", "Bevel depth when not using a bevel object");
01307     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01308     
01309     prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE);
01310     RNA_def_property_int_sdna(prop, NULL, "resolu");
01311     RNA_def_property_range(prop, 1, SHRT_MAX);
01312     RNA_def_property_ui_range(prop, 1, 64, 1, 0);
01313     RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction");
01314     RNA_def_property_update(prop, 0, "rna_Curve_resolution_u_update_data");
01315     
01316     prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE);
01317     RNA_def_property_int_sdna(prop, NULL, "resolv");
01318     RNA_def_property_ui_range(prop, 1, 64, 1, 0);
01319     RNA_def_property_range(prop, 1, SHRT_MAX);
01320     RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction");
01321     RNA_def_property_update(prop, 0, "rna_Curve_resolution_v_update_data");
01322     
01323     prop= RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE);
01324     RNA_def_property_int_sdna(prop, NULL, "resolu_ren");
01325     RNA_def_property_range(prop, 0, SHRT_MAX);
01326     RNA_def_property_ui_range(prop, 0, 64, 1, 0);
01327     RNA_def_property_ui_text(prop, "Render Resolution U", "Surface resolution in U direction used while rendering (zero skips this property)");
01328     
01329     prop= RNA_def_property(srna, "render_resolution_v", PROP_INT, PROP_NONE);
01330     RNA_def_property_int_sdna(prop, NULL, "resolv_ren");
01331     RNA_def_property_ui_range(prop, 0, 64, 1, 0);
01332     RNA_def_property_range(prop, 0, SHRT_MAX);
01333     RNA_def_property_ui_text(prop, "Render Resolution V", "Surface resolution in V direction used while rendering (zero skips this property)");
01334     
01335     
01336     prop= RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
01337     RNA_def_property_float_sdna(prop, NULL, "ctime");
01338     RNA_def_property_ui_text(prop, "Evaluation Time", "Parametric position along the length of the curve that Objects 'following' it should be at (position is evaluated by dividing by the 'Path Length' value)");
01339     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01340     
01341     /* pointers */
01342     prop= RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE);
01343     RNA_def_property_struct_type(prop, "Object");
01344     RNA_def_property_pointer_sdna(prop, NULL, "bevobj");
01345     RNA_def_property_flag(prop, PROP_EDITABLE);
01346     RNA_def_property_ui_text(prop, "Bevel Object", "Curve object name that defines the bevel shape");
01347     RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
01348     RNA_def_property_pointer_funcs(prop, "rna_Curve_bevelObject_get", "rna_Curve_bevelObject_set", NULL, "rna_Curve_otherObject_poll");
01349 
01350     prop= RNA_def_property(srna, "taper_object", PROP_POINTER, PROP_NONE);
01351     RNA_def_property_struct_type(prop, "Object");
01352     RNA_def_property_pointer_sdna(prop, NULL, "taperobj");
01353     RNA_def_property_flag(prop, PROP_EDITABLE);
01354     RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width)");
01355     RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
01356     RNA_def_property_pointer_funcs(prop, "rna_Curve_taperObject_get", "rna_Curve_taperObject_set", NULL, "rna_Curve_otherObject_poll");
01357 
01358     /* Flags */
01359 
01360     prop= RNA_def_property(srna, "dimensions", PROP_ENUM, PROP_NONE); /* as an enum */
01361     RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
01362     RNA_def_property_enum_items(prop, curve_axis_items);
01363     RNA_def_property_enum_funcs(prop, NULL, "rna_Curve_dimension_set", NULL);
01364     RNA_def_property_ui_text(prop, "Dimensions", "Select 2D or 3D curve type");
01365     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01366     
01367     prop= RNA_def_property(srna, "fill_mode", PROP_ENUM, PROP_NONE);
01368     RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
01369     RNA_def_property_enum_items(prop, curve3d_fill_mode_items);
01370     RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Curve_fill_mode_itemf");
01371     RNA_def_property_ui_text(prop, "Fill Mode", "Mode of filling curve");
01372     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01373 
01374     prop= RNA_def_property(srna, "twist_mode", PROP_ENUM, PROP_NONE);
01375     RNA_def_property_enum_sdna(prop, NULL, "twist_mode");
01376     RNA_def_property_enum_items(prop, curve_twist_mode_items);
01377     RNA_def_property_ui_text(prop, "Twist Method", "The type of tilt calculation for 3D Curves");
01378     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01379 
01380     // XXX - would be nice to have a better way to do this, only add for testing.
01381     prop= RNA_def_property(srna, "twist_smooth", PROP_FLOAT, PROP_NONE);
01382     RNA_def_property_float_sdna(prop, NULL, "twist_smooth");
01383     RNA_def_property_ui_range(prop, 0, 100.0, 1, 2);
01384     RNA_def_property_ui_text(prop, "Twist Smooth", "Smoothing iteration for tangents");
01385     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01386 
01387     prop= RNA_def_property(srna, "use_fill_deform", PROP_BOOLEAN, PROP_NONE);
01388     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_DEFORM_FILL);
01389     RNA_def_property_ui_text(prop, "Fill deformed", "Fill curve after applying shape keys and all modifiers");
01390     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01391     
01392     /* texture space */
01393     prop= RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
01394     RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE);
01395     RNA_def_property_ui_text(prop, "Auto Texture Space", "Adjust active object's texture space automatically when transforming object");
01396     RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Curve_texspace_set");
01397 
01398     prop= RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
01399     RNA_def_property_array(prop, 3);
01400     RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
01401     RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
01402     RNA_def_property_float_funcs(prop, "rna_Curve_texspace_loc_get", "rna_Curve_texspace_loc_set", NULL);   
01403     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01404     
01405     prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
01406     RNA_def_property_array(prop, 3);
01407     RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
01408     RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
01409     RNA_def_property_float_funcs(prop, "rna_Curve_texspace_size_get", "rna_Curve_texspace_size_set", NULL);
01410     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01411     
01412     /* not supported yet
01413     prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
01414     RNA_def_property_float(prop, NULL, "rot");
01415     RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
01416     RNA_def_property_editable_func(prop, texspace_editable);
01417     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01418     */
01419     
01420     prop= RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
01421     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
01422     RNA_def_property_ui_text(prop, "Use UV for mapping", "Uses the UV values as Generated textured coordinates");
01423     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01424     
01425     /* materials */
01426     prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
01427     RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
01428     RNA_def_property_struct_type(prop, "Material");
01429     RNA_def_property_ui_text(prop, "Materials", "");
01430     RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
01431     RNA_def_property_collection_funcs(prop, 0, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
01432 }
01433 
01434 static void rna_def_curve_nurb(BlenderRNA *brna)
01435 {
01436     static EnumPropertyItem spline_interpolation_items[] = {
01437         {KEY_LINEAR, "LINEAR", 0, "Linear", ""},
01438         {KEY_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
01439         {KEY_BSPLINE, "BSPLINE", 0, "BSpline", ""},
01440         {KEY_CU_EASE, "EASE", 0, "Ease", ""}, /* todo, define somewhere, not one of BEZT_IPO_* */
01441         {0, NULL, 0, NULL, NULL}};
01442 
01443     StructRNA *srna;
01444     PropertyRNA *prop;
01445 
01446     srna= RNA_def_struct(brna, "Spline", NULL);
01447     RNA_def_struct_sdna(srna, "Nurb");
01448     RNA_def_struct_ui_text(srna, "Spline", "Element of a curve, either NURBS, Bezier or Polyline or a character with text objects");
01449 
01450     prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
01451     RNA_def_property_collection_sdna(prop, NULL, "bp", NULL);
01452     RNA_def_property_struct_type(prop, "SplinePoint");
01453     RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", NULL, NULL, NULL);
01454     RNA_def_property_ui_text(prop, "Points", "Collection of points that make up this poly or nurbs spline");
01455     rna_def_curve_spline_points(brna, prop);
01456 
01457     prop= RNA_def_property(srna, "bezier_points", PROP_COLLECTION, PROP_NONE);
01458     RNA_def_property_struct_type(prop, "BezierSplinePoint");
01459     RNA_def_property_collection_sdna(prop, NULL, "bezt", "pntsu");
01460     RNA_def_property_ui_text(prop, "Bezier Points", "Collection of points for Bezier curves only");
01461     rna_def_curve_spline_bezpoints(brna, prop);
01462 
01463     
01464     prop= RNA_def_property(srna, "tilt_interpolation", PROP_ENUM, PROP_NONE);
01465     RNA_def_property_enum_sdna(prop, NULL, "tilt_interp");
01466     RNA_def_property_enum_items(prop, spline_interpolation_items);
01467     RNA_def_property_ui_text(prop, "Tilt Interpolation", "The type of tilt interpolation for 3D, Bezier curves");
01468     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01469 
01470     prop= RNA_def_property(srna, "radius_interpolation", PROP_ENUM, PROP_NONE);
01471     RNA_def_property_enum_sdna(prop, NULL, "radius_interp");
01472     RNA_def_property_enum_items(prop, spline_interpolation_items);
01473     RNA_def_property_ui_text(prop, "Radius Interpolation", "The type of radius interpolation for Bezier curves");
01474     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01475 
01476     prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
01477     RNA_def_property_enum_items(prop, curve_type_items);
01478     RNA_def_property_enum_funcs(prop, NULL, "rna_Nurb_type_set", NULL);
01479     RNA_def_property_ui_text(prop, "Type", "The interpolation type for this curve element");
01480     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01481 
01482     prop= RNA_def_property(srna, "point_count_u", PROP_INT, PROP_UNSIGNED);
01483     RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
01484     RNA_def_property_int_sdna(prop, NULL, "pntsu");
01485     RNA_def_property_ui_text(prop, "Points U", "Total number points for the curve or surface in the U direction");
01486     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01487 
01488     prop= RNA_def_property(srna, "point_count_v", PROP_INT, PROP_UNSIGNED);
01489     RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
01490     RNA_def_property_int_sdna(prop, NULL, "pntsv");
01491     RNA_def_property_ui_text(prop, "Points V", "Total number points for the surface on the V direction");
01492     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01493 
01494 
01495     prop= RNA_def_property(srna, "order_u", PROP_INT, PROP_NONE);
01496     RNA_def_property_int_sdna(prop, NULL, "orderu");
01497     RNA_def_property_range(prop, 2, 6);
01498     RNA_def_property_ui_text(prop, "Order U", "NURBS order in the U direction (for splines and surfaces, higher values let points influence a greater area)");
01499     RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
01500 
01501     prop= RNA_def_property(srna, "order_v", PROP_INT, PROP_NONE);
01502     RNA_def_property_int_sdna(prop, NULL, "orderv");
01503     RNA_def_property_range(prop, 2, 6);
01504     RNA_def_property_ui_text(prop, "Order V", "NURBS order in the V direction (for surfaces only, higher values let points influence a greater area)");
01505     RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
01506 
01507 
01508     prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE);
01509     RNA_def_property_int_sdna(prop, NULL, "resolu");
01510     RNA_def_property_range(prop, 1, SHRT_MAX);
01511     RNA_def_property_ui_range(prop, 1, 64, 1, 0);
01512     RNA_def_property_ui_text(prop, "Resolution U", "Curve or Surface subdivisions per segment");
01513     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01514 
01515     prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE);
01516     RNA_def_property_int_sdna(prop, NULL, "resolv");
01517     RNA_def_property_range(prop, 1, SHRT_MAX);
01518     RNA_def_property_ui_range(prop, 1, 64, 1, 0);
01519     RNA_def_property_ui_text(prop, "Resolution V", "Surface subdivisions per segment");
01520     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01521 
01522     prop= RNA_def_property(srna, "use_cyclic_u", PROP_BOOLEAN, PROP_NONE);
01523     RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_CYCLIC);
01524     RNA_def_property_ui_text(prop, "Cyclic U", "Make this curve or surface a closed loop in the U direction");
01525     RNA_def_property_update(prop, 0, "rna_Nurb_update_cyclic_u");
01526 
01527     prop= RNA_def_property(srna, "use_cyclic_v", PROP_BOOLEAN, PROP_NONE);
01528     RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_CYCLIC);
01529     RNA_def_property_ui_text(prop, "Cyclic V", "Make this surface a closed loop in the V direction");
01530     RNA_def_property_update(prop, 0, "rna_Nurb_update_cyclic_v");
01531 
01532 
01533     /* Note, endpoint and bezier flags should never be on at the same time! */
01534     prop= RNA_def_property(srna, "use_endpoint_u", PROP_BOOLEAN, PROP_NONE);
01535     RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_ENDPOINT);
01536     RNA_def_property_ui_text(prop, "Endpoint U", "Make this nurbs curve or surface meet the endpoints in the U direction (Cyclic U must be disabled)");
01537     RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
01538 
01539     prop= RNA_def_property(srna, "use_endpoint_v", PROP_BOOLEAN, PROP_NONE);
01540     RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_ENDPOINT);
01541     RNA_def_property_ui_text(prop, "Endpoint V", "Make this nurbs surface meet the endpoints in the V direction (Cyclic V must be disabled)");
01542     RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
01543 
01544     prop= RNA_def_property(srna, "use_bezier_u", PROP_BOOLEAN, PROP_NONE);
01545     RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_BEZIER);
01546     RNA_def_property_ui_text(prop, "Bezier U", "Make this nurbs curve or surface act like a Bezier spline in the U direction (Order U must be 3 or 4, Cyclic U must be disabled)");
01547     RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
01548 
01549     prop= RNA_def_property(srna, "use_bezier_v", PROP_BOOLEAN, PROP_NONE);
01550     RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_BEZIER);
01551     RNA_def_property_ui_text(prop, "Bezier V", "Make this nurbs surface act like a Bezier spline in the V direction (Order V must be 3 or 4, Cyclic V must be disabled)");
01552     RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
01553 
01554 
01555     prop= RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
01556     RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMOOTH);
01557     RNA_def_property_ui_text(prop, "Smooth", "Smooth the normals of the surface or beveled curve");
01558     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01559 
01560     prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
01561     RNA_def_property_boolean_sdna(prop, NULL, "hide", 1);
01562     RNA_def_property_ui_text(prop, "Hide", "Hide this curve in editmode");
01563     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01564 
01565     prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
01566     RNA_def_property_int_sdna(prop, NULL, "mat_nr");
01567     RNA_def_property_ui_text(prop, "Material Index", "");
01568     RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_material_index_range");
01569     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01570     
01571     prop= RNA_def_property(srna, "character_index", PROP_INT, PROP_UNSIGNED);
01572     RNA_def_property_int_sdna(prop, NULL, "charidx");
01573     RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
01574     RNA_def_property_ui_text(prop, "Character Index", "Location of this character in the text data (only for text curves)");
01575     RNA_def_property_update(prop, 0, "rna_Curve_update_data");
01576 
01577     RNA_def_struct_path_func(srna, "rna_Curve_spline_path");
01578 }
01579 
01580 void RNA_def_curve(BlenderRNA *brna)
01581 {
01582     rna_def_curve(brna);
01583     rna_def_surface(brna);
01584     rna_def_text(brna);
01585     rna_def_textbox(brna);
01586     rna_def_charinfo(brna);
01587     rna_def_bpoint(brna);
01588     rna_def_beztriple(brna);
01589     rna_def_curve_nurb(brna);
01590 }
01591 
01592 #endif
01593