Blender V2.61 - r43446

rna_color.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).
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 #include <stdio.h>
00030 
00031 #include "RNA_define.h"
00032 #include "rna_internal.h"
00033 
00034 #include "DNA_color_types.h"
00035 #include "DNA_texture_types.h"
00036 
00037 #ifdef RNA_RUNTIME
00038 
00039 #include "RNA_access.h"
00040 
00041 #include "DNA_material_types.h"
00042 #include "DNA_node_types.h"
00043 
00044 #include "MEM_guardedalloc.h"
00045 
00046 #include "BKE_colortools.h"
00047 #include "BKE_depsgraph.h"
00048 #include "BKE_node.h"
00049 #include "BKE_texture.h"
00050 
00051 #include "WM_api.h"
00052 #include "WM_types.h"
00053 
00054 #include "ED_node.h"
00055 
00056 static int rna_CurveMapping_curves_length(PointerRNA *ptr)
00057 {
00058     CurveMapping *cumap= (CurveMapping*)ptr->data;
00059     int len;
00060 
00061     for(len=0; len<CM_TOT; len++)
00062         if(!cumap->cm[len].curve)
00063             break;
00064     
00065     return len;
00066 }
00067 
00068 static void rna_CurveMapping_curves_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00069 {
00070     CurveMapping *cumap= (CurveMapping*)ptr->data;
00071 
00072     rna_iterator_array_begin(iter, cumap->cm, sizeof(CurveMap), rna_CurveMapping_curves_length(ptr), 0, NULL);
00073 }
00074 
00075 static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
00076 {
00077     CurveMapping *cumap= (CurveMapping*)ptr->data;
00078 
00079     if(value) cumap->flag |= CUMA_DO_CLIP;
00080     else cumap->flag &= ~CUMA_DO_CLIP;
00081 
00082     curvemapping_changed(cumap, 0);
00083 }
00084 
00085 static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values)
00086 {
00087     CurveMapping *cumap= (CurveMapping*)ptr->data;
00088     cumap->black[0]= values[0];
00089     cumap->black[1]= values[1];
00090     cumap->black[2]= values[2];
00091     curvemapping_set_black_white(cumap, NULL, NULL);
00092 }
00093 
00094 static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *values)
00095 {
00096     CurveMapping *cumap= (CurveMapping*)ptr->data;
00097     cumap->white[0]= values[0];
00098     cumap->white[1]= values[1];
00099     cumap->white[2]= values[2];
00100     curvemapping_set_black_white(cumap, NULL, NULL);
00101 }
00102 
00103 static void rna_CurveMapping_clipminx_range(PointerRNA *ptr, float *min, float *max)
00104 {
00105     CurveMapping *cumap= (CurveMapping*)ptr->data;
00106 
00107     *min= -100.0f;
00108     *max= cumap->clipr.xmax;
00109 }
00110 
00111 static void rna_CurveMapping_clipminy_range(PointerRNA *ptr, float *min, float *max)
00112 {
00113     CurveMapping *cumap= (CurveMapping*)ptr->data;
00114 
00115     *min= -100.0f;
00116     *max= cumap->clipr.ymax;
00117 }
00118 
00119 static void rna_CurveMapping_clipmaxx_range(PointerRNA *ptr, float *min, float *max)
00120 {
00121     CurveMapping *cumap= (CurveMapping*)ptr->data;
00122 
00123     *min= cumap->clipr.xmin;
00124     *max= 100.0f;
00125 }
00126 
00127 static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float *max)
00128 {
00129     CurveMapping *cumap= (CurveMapping*)ptr->data;
00130 
00131     *min= cumap->clipr.ymin;
00132     *max= 100.0f;
00133 }
00134 
00135 
00136 static char *rna_ColorRamp_path(PointerRNA *ptr)
00137 {
00138     /* handle the cases where a single datablock may have 2 ramp types */
00139     if (ptr->id.data) {
00140         ID *id= ptr->id.data;
00141         
00142         switch (GS(id->name)) {
00143             case ID_MA: /* material has 2 cases - diffuse and specular */ 
00144             {
00145                 Material *ma= (Material*)id;
00146                 
00147                 if (ptr->data == ma->ramp_col) 
00148                     return BLI_strdup("diffuse_ramp");
00149                 else if (ptr->data == ma->ramp_spec)
00150                     return BLI_strdup("specular_ramp");
00151             }
00152                 break;
00153         }
00154     }
00155     
00156     /* everything else just uses 'color_ramp' */
00157     return BLI_strdup("color_ramp");
00158 }
00159 
00160 static char *rna_ColorRampElement_path(PointerRNA *ptr)
00161 {
00162     PointerRNA ramp_ptr;
00163     PropertyRNA *prop;
00164     char *path = NULL;
00165     int index;
00166     
00167     /* helper macro for use here to try and get the path 
00168      *  - this calls the standard code for getting a path to a texture...
00169      */
00170 
00171 #define COLRAMP_GETPATH                                                       \
00172 {                                                                             \
00173     prop= RNA_struct_find_property(&ramp_ptr, "elements");                    \
00174     if (prop) {                                                               \
00175         index= RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr);    \
00176         if (index >= 0) {                                                     \
00177             char *texture_path= rna_ColorRamp_path(&ramp_ptr);                \
00178             path= BLI_sprintfN("%s.elements[%d]", texture_path, index);       \
00179             MEM_freeN(texture_path);                                          \
00180         }                                                                     \
00181     }                                                                         \
00182 }
00183 
00184     /* determine the path from the ID-block to the ramp */
00185     // FIXME: this is a very slow way to do it, but it will have to suffice...
00186     if (ptr->id.data) {
00187         ID *id= ptr->id.data;
00188         
00189         switch (GS(id->name)) {
00190             case ID_MA: /* 2 cases for material - diffuse and spec */
00191             {
00192                 Material *ma= (Material *)id;
00193                 
00194                 /* try diffuse first */
00195                 if (ma->ramp_col) {
00196                     RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_col, &ramp_ptr);
00197                     COLRAMP_GETPATH;
00198                 }
00199                 /* try specular if not diffuse */
00200                 if (!path && ma->ramp_spec) {
00201                     RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_spec, &ramp_ptr);
00202                     COLRAMP_GETPATH;
00203                 }
00204             }
00205                 break;
00206                 
00207                 // TODO: node trees need special attention
00208             case ID_NT: 
00209             {
00210                 bNodeTree *ntree = (bNodeTree *)id;
00211                 bNode *node;
00212                 
00213                 for(node=ntree->nodes.first; node; node=node->next) {
00214                     if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
00215                         RNA_pointer_create(id, &RNA_ColorRamp, node->storage, &ramp_ptr);
00216                         COLRAMP_GETPATH;
00217                     }
00218                 }
00219             }
00220                 break;
00221                 
00222             default: /* everything else should have a "color_ramp" property */
00223             {
00224                 /* create pointer to the ID block, and try to resolve "color_ramp" pointer */
00225                 RNA_id_pointer_create(id, &ramp_ptr);
00226                 if (RNA_path_resolve(&ramp_ptr, "color_ramp", &ramp_ptr, &prop)) {
00227                     COLRAMP_GETPATH;
00228                 }
00229             }
00230         }
00231     }
00232     
00233     /* cleanup the macro we defined */
00234 #undef COLRAMP_GETPATH
00235     
00236     return path;
00237 }
00238 
00239 static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
00240 {
00241     if (ptr->id.data) {
00242         ID *id= ptr->id.data;
00243         
00244         switch (GS(id->name)) {
00245             case ID_MA:
00246             {
00247                 Material *ma= ptr->id.data;
00248                 
00249                 DAG_id_tag_update(&ma->id, 0);
00250                 WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, ma);
00251             }
00252                 break;
00253             case ID_NT:
00254             {
00255                 bNodeTree *ntree = (bNodeTree *)id;
00256                 bNode *node;
00257 
00258                 for(node=ntree->nodes.first; node; node=node->next) {
00259                     if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
00260                         ED_node_generic_update(bmain, ntree, node);
00261                     }
00262                 }
00263             }
00264                 break;
00265             case ID_TE:
00266             {
00267                 Tex *tex= ptr->id.data;
00268 
00269                 DAG_id_tag_update(&tex->id, 0);
00270                 WM_main_add_notifier(NC_TEXTURE, tex);
00271             }
00272                 break;
00273             default:
00274                 break;
00275         }
00276     }
00277 }
00278 
00279 static void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4])
00280 {
00281     do_colorband(coba, position, color);
00282 }
00283 
00284 static CBData *rna_ColorRampElement_new(struct ColorBand *coba, ReportList *reports, float position)
00285 {
00286     CBData *element= colorband_element_add(coba, position);
00287 
00288     if(element==NULL)
00289         BKE_reportf(reports, RPT_ERROR, "Unable to add element to colorband (limit %d)", MAXCOLORBAND);
00290 
00291     return element;
00292 }
00293 
00294 static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, CBData *element)
00295 {
00296     int index = (int)(element - coba->data);
00297     if(colorband_element_remove(coba, index) == 0)
00298         BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element");
00299 
00300 }
00301 
00302 static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00303 {
00304     Scopes *s= (Scopes*)ptr->data;
00305     s->ok = 0;
00306 }
00307 
00308 #else
00309 
00310 static void rna_def_curvemappoint(BlenderRNA *brna)
00311 {
00312     StructRNA *srna;
00313     PropertyRNA *prop;
00314     static EnumPropertyItem prop_handle_type_items[] = {
00315         {0, "AUTO", 0, "Auto Handle", ""},
00316         {CUMA_VECTOR, "VECTOR", 0, "Vector Handle", ""},
00317         {0, NULL, 0, NULL, NULL}
00318     };
00319 
00320     srna= RNA_def_struct(brna, "CurveMapPoint", NULL);
00321     RNA_def_struct_ui_text(srna, "CurveMapPoint", "Point of a curve used for a curve mapping");
00322 
00323     /* not editable for now, need to have CurveMapping to do curvemapping_changed */
00324 
00325     prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
00326     RNA_def_property_float_sdna(prop, NULL, "x");
00327     RNA_def_property_array(prop, 2);
00328     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00329     RNA_def_property_ui_text(prop, "Location", "X/Y coordinates of the curve point");
00330 
00331     prop= RNA_def_property(srna, "handle_type", PROP_ENUM, PROP_NONE);
00332     RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
00333     RNA_def_property_enum_items(prop, prop_handle_type_items);
00334     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00335     RNA_def_property_ui_text(prop, "Handle Type", "Curve interpolation at this point: Bezier or vector");
00336 
00337     prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
00338     RNA_def_property_boolean_sdna(prop, NULL, "flag", CUMA_SELECT);
00339     RNA_def_property_ui_text(prop, "Select", "Selection state of the curve point");
00340 }
00341 
00342 static void rna_def_curvemap(BlenderRNA *brna)
00343 {
00344     StructRNA *srna;
00345     PropertyRNA *prop;
00346     static EnumPropertyItem prop_extend_items[] = {
00347         {0, "HORIZONTAL", 0, "Horizontal", ""},
00348         {CUMA_EXTEND_EXTRAPOLATE, "EXTRAPOLATED", 0, "Extrapolated", ""},
00349         {0, NULL, 0, NULL, NULL}
00350     };
00351 
00352     srna= RNA_def_struct(brna, "CurveMap", NULL);
00353     RNA_def_struct_ui_text(srna, "CurveMap", "Curve in a curve mapping");
00354 
00355     /* not editable for now, need to have CurveMapping to do curvemapping_changed */
00356 
00357     prop= RNA_def_property(srna, "extend", PROP_ENUM, PROP_NONE);
00358     RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
00359     RNA_def_property_enum_items(prop, prop_extend_items);
00360     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00361     RNA_def_property_ui_text(prop, "Extend", "Extrapolate the curve or extend it horizontally");
00362 
00363     prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
00364     RNA_def_property_collection_sdna(prop, NULL, "curve", "totpoint");
00365     RNA_def_property_struct_type(prop, "CurveMapPoint");
00366     RNA_def_property_ui_text(prop, "Points", "");
00367 }
00368 
00369 static void rna_def_curvemapping(BlenderRNA *brna)
00370 {
00371     StructRNA *srna;
00372     PropertyRNA *prop;
00373 
00374     srna= RNA_def_struct(brna, "CurveMapping", NULL);
00375     RNA_def_struct_ui_text(srna, "CurveMapping", "Curve mapping to map color, vector and scalar values to other values using a user defined curve");
00376     
00377     prop= RNA_def_property(srna, "use_clip", PROP_BOOLEAN, PROP_NONE);
00378     RNA_def_property_boolean_sdna(prop, NULL, "flag", CUMA_DO_CLIP);
00379     RNA_def_property_ui_text(prop, "Clip", "Force the curve view to fit a defined boundary");
00380     RNA_def_property_boolean_funcs(prop, NULL, "rna_CurveMapping_clip_set");
00381 
00382     prop= RNA_def_property(srna, "clip_min_x", PROP_FLOAT, PROP_NONE);
00383     RNA_def_property_float_sdna(prop, NULL, "clipr.xmin");
00384     RNA_def_property_range(prop, -100.0f, 100.0f);
00385     RNA_def_property_ui_text(prop, "Clip Min X", "");
00386     RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipminx_range");
00387 
00388     prop= RNA_def_property(srna, "clip_min_y", PROP_FLOAT, PROP_NONE);
00389     RNA_def_property_float_sdna(prop, NULL, "clipr.ymin");
00390     RNA_def_property_range(prop, -100.0f, 100.0f);
00391     RNA_def_property_ui_text(prop, "Clip Min Y", "");
00392     RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipminy_range");
00393 
00394     prop= RNA_def_property(srna, "clip_max_x", PROP_FLOAT, PROP_NONE);
00395     RNA_def_property_float_sdna(prop, NULL, "clipr.xmax");
00396     RNA_def_property_range(prop, -100.0f, 100.0f);
00397     RNA_def_property_ui_text(prop, "Clip Max X", "");
00398     RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxx_range");
00399 
00400     prop= RNA_def_property(srna, "clip_max_y", PROP_FLOAT, PROP_NONE);
00401     RNA_def_property_float_sdna(prop, NULL, "clipr.ymax");
00402     RNA_def_property_range(prop, -100.0f, 100.0f);
00403     RNA_def_property_ui_text(prop, "Clip Max Y", "");
00404     RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxy_range");
00405 
00406     prop= RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE);
00407     RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", NULL, NULL, NULL);
00408     RNA_def_property_struct_type(prop, "CurveMap");
00409     RNA_def_property_ui_text(prop, "Curves", "");
00410 
00411     prop= RNA_def_property(srna, "black_level", PROP_FLOAT, PROP_COLOR);
00412     RNA_def_property_float_sdna(prop, NULL, "black");
00413     RNA_def_property_range(prop, -1000.0f, 1000.0f);
00414     RNA_def_property_ui_text(prop, "Black Level", "For RGB curves, the color that black is mapped to");
00415     RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_black_level_set", NULL);
00416 
00417     prop= RNA_def_property(srna, "white_level", PROP_FLOAT, PROP_COLOR);
00418     RNA_def_property_float_sdna(prop, NULL, "white");
00419     RNA_def_property_range(prop, -1000.0f, 1000.0f);
00420     RNA_def_property_ui_text(prop, "White Level", "For RGB curves, the color that white is mapped to");
00421     RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_white_level_set", NULL);
00422 }
00423 
00424 static void rna_def_color_ramp_element(BlenderRNA *brna)
00425 {
00426     StructRNA *srna;
00427     PropertyRNA *prop;
00428 
00429     srna= RNA_def_struct(brna, "ColorRampElement", NULL);
00430     RNA_def_struct_sdna(srna, "CBData");
00431     RNA_def_struct_path_func(srna, "rna_ColorRampElement_path");
00432     RNA_def_struct_ui_text(srna, "Color Ramp Element", "Element defining a color at a position in the color ramp");
00433     
00434     prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
00435     RNA_def_property_float_sdna(prop, NULL, "r");
00436     RNA_def_property_array(prop, 4);
00437     RNA_def_property_ui_text(prop, "Color", "Set color of selected color stop");
00438     RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
00439     
00440     prop= RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE);
00441     RNA_def_property_float_sdna(prop, NULL, "pos");
00442     RNA_def_property_range(prop, 0, 1);
00443     RNA_def_property_ui_text(prop, "Position", "Set position of selected color stop");
00444     RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
00445 }
00446 
00447 static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop)
00448 {
00449     StructRNA *srna;
00450     PropertyRNA *parm;
00451     FunctionRNA *func;
00452 
00453     RNA_def_property_srna(cprop, "ColorRampElements");
00454     srna= RNA_def_struct(brna, "ColorRampElements", NULL);
00455     RNA_def_struct_sdna(srna, "ColorBand");
00456     RNA_def_struct_path_func(srna, "rna_ColorRampElement_path");
00457     RNA_def_struct_ui_text(srna, "Color Ramp Elements", "Collection of Color Ramp Elements");
00458 
00459     /* TODO, make these functions generic in texture.c */
00460     func = RNA_def_function(srna, "new", "rna_ColorRampElement_new");
00461     RNA_def_function_ui_description(func, "Add element to ColorRamp");
00462     RNA_def_function_flag(func, FUNC_USE_REPORTS);
00463     parm= RNA_def_float(func, "position", 0.0f, 0.0f, 1.0f, "Position", "Position to add element", 0.0f, 1.0f);
00464     RNA_def_property_flag(parm, PROP_REQUIRED);
00465     /* return type */
00466     parm= RNA_def_pointer(func, "element", "ColorRampElement", "", "New element");
00467     RNA_def_function_return(func, parm);
00468 
00469     func = RNA_def_function(srna, "remove", "rna_ColorRampElement_remove");
00470     RNA_def_function_ui_description(func, "Delete element from ColorRamp");
00471     RNA_def_function_flag(func, FUNC_USE_REPORTS);
00472     parm= RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove");
00473     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00474 }
00475 
00476 static void rna_def_color_ramp(BlenderRNA *brna)
00477 {
00478     StructRNA *srna;
00479     PropertyRNA *prop;
00480     FunctionRNA *func;
00481 
00482     static EnumPropertyItem prop_interpolation_items[] = {
00483         {1, "EASE", 0, "Ease", ""},
00484         {3, "CARDINAL", 0, "Cardinal", ""},
00485         {0, "LINEAR", 0, "Linear", ""},
00486         {2, "B_SPLINE", 0, "B-Spline", ""},
00487         {4, "CONSTANT", 0, "Constant", ""},
00488         {0, NULL, 0, NULL, NULL}};
00489     
00490     srna= RNA_def_struct(brna, "ColorRamp", NULL);
00491     RNA_def_struct_sdna(srna, "ColorBand");
00492     RNA_def_struct_path_func(srna, "rna_ColorRamp_path");
00493     RNA_def_struct_ui_text(srna, "Color Ramp", "Color ramp mapping a scalar value to a color");
00494     
00495     prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_COLOR);
00496     RNA_def_property_collection_sdna(prop, NULL, "data", "tot");
00497     RNA_def_property_struct_type(prop, "ColorRampElement");
00498     RNA_def_property_ui_text(prop, "Elements", "");
00499     RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
00500     rna_def_color_ramp_element_api(brna, prop);
00501 
00502     prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
00503     RNA_def_property_enum_sdna(prop, NULL, "ipotype");
00504     RNA_def_property_enum_items(prop, prop_interpolation_items);
00505     RNA_def_property_ui_text(prop, "Interpolation", "");
00506     RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
00507 
00508 #if 0 // use len(elements)
00509     prop= RNA_def_property(srna, "total", PROP_INT, PROP_NONE);
00510     RNA_def_property_int_sdna(prop, NULL, "tot");
00511     /* needs a function to do the right thing when adding elements like colorband_add_cb() */
00512     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00513     RNA_def_property_range(prop, 0, 31); /* MAXCOLORBAND = 32 */
00514     RNA_def_property_ui_text(prop, "Total", "Total number of elements");
00515     RNA_def_property_update(prop, 0, "rna_ColorRamp_update");
00516 #endif
00517     
00518     func = RNA_def_function(srna, "evaluate", "rna_ColorRamp_eval");
00519     RNA_def_function_ui_description(func, "Evaluate ColorRamp");
00520     prop= RNA_def_float(func, "position", 1.0f, 0.0f, 1.0f, "Position", "Evaluate ColorRamp at position", 0.0f, 1.0f);
00521     RNA_def_property_flag(prop, PROP_REQUIRED);
00522     /* return */
00523     prop = RNA_def_float_color(func, "color", 4, NULL, -FLT_MAX, FLT_MAX, "Color", "Color at given position", -FLT_MAX, FLT_MAX);
00524     RNA_def_property_flag(prop, PROP_THICK_WRAP);
00525     RNA_def_function_output(func, prop);
00526 }
00527 
00528 static void rna_def_histogram(BlenderRNA *brna)
00529 {
00530     StructRNA *srna;
00531     PropertyRNA *prop;
00532     
00533     static EnumPropertyItem prop_mode_items[] = {
00534         {HISTO_MODE_LUMA, "LUMA", ICON_COLOR, "Luma", ""},
00535         {HISTO_MODE_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""},
00536         {HISTO_MODE_R, "R", ICON_COLOR, "Red", ""},
00537         {HISTO_MODE_G, "G", ICON_COLOR, "Green", ""},
00538         {HISTO_MODE_B, "B", ICON_COLOR, "Blue", ""},
00539         {0, NULL, 0, NULL, NULL}};
00540         
00541     srna= RNA_def_struct(brna, "Histogram", NULL);
00542     RNA_def_struct_ui_text(srna, "Histogram", "Statistical view of the levels of color in an image");
00543     
00544     prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
00545     RNA_def_property_enum_sdna(prop, NULL, "mode");
00546     RNA_def_property_enum_items(prop, prop_mode_items);
00547     RNA_def_property_ui_text(prop, "Mode", "Channels to display when drawing the histogram");
00548     
00549 }
00550 
00551 static void rna_def_scopes(BlenderRNA *brna)
00552 {
00553     StructRNA *srna;
00554     PropertyRNA *prop;
00555 
00556     static EnumPropertyItem prop_wavefrm_mode_items[] = {
00557         {SCOPES_WAVEFRM_LUMA, "LUMA", ICON_COLOR, "Luma", ""},
00558         {SCOPES_WAVEFRM_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""},
00559         {SCOPES_WAVEFRM_YCC_601, "YCBCR601", ICON_COLOR, "YCbCr (ITU 601)", ""},
00560         {SCOPES_WAVEFRM_YCC_709, "YCBCR709", ICON_COLOR, "YCbCr (ITU 709)", ""},
00561         {SCOPES_WAVEFRM_YCC_JPEG, "YCBCRJPG", ICON_COLOR, "YCbCr (Jpeg)", ""},
00562         {0, NULL, 0, NULL, NULL}};
00563 
00564     srna= RNA_def_struct(brna, "Scopes", NULL);
00565     RNA_def_struct_ui_text(srna, "Scopes", "Scopes for statistical view of an image");
00566     
00567     prop= RNA_def_property(srna, "use_full_resolution", PROP_BOOLEAN, PROP_NONE);
00568     RNA_def_property_boolean_sdna(prop, "Scopes", "sample_full", 1);
00569     RNA_def_property_ui_text(prop, "Full Sample", "Sample every pixel of the image");
00570     RNA_def_property_update(prop, 0, "rna_Scopes_update");
00571     
00572     prop= RNA_def_property(srna, "accuracy", PROP_FLOAT, PROP_PERCENTAGE);
00573     RNA_def_property_float_sdna(prop, "Scopes", "accuracy");
00574     RNA_def_property_range(prop, 0.0, 100.0);
00575     RNA_def_property_ui_range(prop, 0.0, 100.0, 10, 1);
00576     RNA_def_property_ui_text(prop, "Accuracy", "Proportion of original image source pixel lines to sample");
00577     RNA_def_property_update(prop, 0, "rna_Scopes_update");
00578 
00579     prop= RNA_def_property(srna, "histogram", PROP_POINTER, PROP_NONE);
00580     RNA_def_property_pointer_sdna(prop, "Scopes", "hist");
00581     RNA_def_property_struct_type(prop, "Histogram");
00582     RNA_def_property_ui_text(prop, "Histogram", "Histogram for viewing image statistics");
00583 
00584     prop= RNA_def_property(srna, "waveform_mode", PROP_ENUM, PROP_NONE);
00585     RNA_def_property_enum_sdna(prop, "Scopes", "wavefrm_mode");
00586     RNA_def_property_enum_items(prop, prop_wavefrm_mode_items);
00587     RNA_def_property_ui_text(prop, "Waveform Mode", "");
00588     RNA_def_property_update(prop, 0, "rna_Scopes_update");
00589 
00590     prop= RNA_def_property(srna, "waveform_alpha", PROP_FLOAT, PROP_PERCENTAGE);
00591     RNA_def_property_float_sdna(prop, "Scopes", "wavefrm_alpha");
00592     RNA_def_property_range(prop, 0, 1);
00593     RNA_def_property_ui_text(prop, "Waveform Opacity", "Opacity of the points");
00594 
00595     prop= RNA_def_property(srna, "vectorscope_alpha", PROP_FLOAT, PROP_PERCENTAGE);
00596     RNA_def_property_float_sdna(prop, "Scopes", "vecscope_alpha");
00597     RNA_def_property_range(prop, 0, 1);
00598     RNA_def_property_ui_text(prop, "Vectorscope Opacity", "Opacity of the points");
00599 }
00600 
00601 
00602 void RNA_def_color(BlenderRNA *brna)
00603 {
00604     rna_def_curvemappoint(brna);
00605     rna_def_curvemap(brna);
00606     rna_def_curvemapping(brna);
00607     rna_def_color_ramp_element(brna);
00608     rna_def_color_ramp(brna);
00609     rna_def_histogram(brna);
00610     rna_def_scopes(brna);
00611 }
00612 
00613 #endif
00614