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