[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50261] trunk/blender/source/blender: new image operator now allows color grid (before was only grid on/off)

Campbell Barton ideasman42 at gmail.com
Wed Aug 29 10:17:39 CEST 2012


Revision: 50261
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50261
Author:   campbellbarton
Date:     2012-08-29 08:17:38 +0000 (Wed, 29 Aug 2012)
Log Message:
-----------
new image operator now allows color grid (before was only grid on/off)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_image.h
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/editors/space_image/image_ops.c
    trunk/blender/source/blender/makesrna/RNA_enum_types.h
    trunk/blender/source/blender/makesrna/intern/rna_image.c

Modified: trunk/blender/source/blender/blenkernel/BKE_image.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_image.h	2012-08-29 07:58:36 UTC (rev 50260)
+++ trunk/blender/source/blender/blenkernel/BKE_image.h	2012-08-29 08:17:38 UTC (rev 50261)
@@ -106,6 +106,12 @@
 #define IMA_TYPE_R_RESULT   4
 #define IMA_TYPE_COMPOSITE  5
 
+enum {
+	IMA_GENTYPE_BLANK = 0,
+	IMA_GENTYPE_GRID = 1,
+	IMA_GENTYPE_GRID_COLOR = 2
+};
+
 /* ima->ok */
 #define IMA_OK              1
 #define IMA_OK_LOADED       2

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2012-08-29 07:58:36 UTC (rev 50260)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2012-08-29 08:17:38 UTC (rev 50261)
@@ -595,7 +595,7 @@
 	return BKE_image_load(filepath);
 }
 
-static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4])
+static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4])
 {
 	ImBuf *ibuf;
 	unsigned char *rect = NULL;
@@ -615,11 +615,11 @@
 	BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
 	ibuf->userflags |= IB_BITMAPDIRTY;
 
-	switch (uvtestgrid) {
-		case 1:
+	switch (gen_type) {
+		case IMA_GENTYPE_GRID:
 			BKE_image_buf_fill_checker(rect, rect_float, width, height);
 			break;
-		case 2:
+		case IMA_GENTYPE_GRID_COLOR:
 			BKE_image_buf_fill_checker_color(rect, rect_float, width, height);
 			break;
 		default:
@@ -630,7 +630,7 @@
 }
 
 /* adds new image block, creates ImBuf and initializes color */
-Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4])
+Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, float color[4])
 {
 	/* on save, type is changed to FILE in editsima.c */
 	Image *ima = image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
@@ -641,10 +641,10 @@
 		/* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */
 		ima->gen_x = width;
 		ima->gen_y = height;
-		ima->gen_type = uvtestgrid;
+		ima->gen_type = gen_type;
 		ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
 
-		ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color);
+		ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color);
 		image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
 
 		ima->ok = IMA_OK_LOADED;

Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c	2012-08-29 07:58:36 UTC (rev 50260)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2012-08-29 08:17:38 UTC (rev 50261)
@@ -1586,7 +1586,7 @@
 	PropertyRNA *prop;
 	char name[MAX_ID_NAME - 2];
 	float color[4];
-	int width, height, floatbuf, uvtestgrid, alpha;
+	int width, height, floatbuf, gen_type, alpha;
 
 	/* retrieve state */
 	sima = CTX_wm_space_image(C);
@@ -1597,7 +1597,7 @@
 	width = RNA_int_get(op->ptr, "width");
 	height = RNA_int_get(op->ptr, "height");
 	floatbuf = RNA_boolean_get(op->ptr, "float");
-	uvtestgrid = RNA_boolean_get(op->ptr, "uv_test_grid");
+	gen_type = RNA_enum_get(op->ptr, "generated_type");
 	RNA_float_get_array(op->ptr, "color", color);
 	alpha = RNA_boolean_get(op->ptr, "alpha");
 	
@@ -1607,7 +1607,7 @@
 	if (!alpha)
 		color[3] = 1.0f;
 
-	ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color);
+	ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color);
 
 	if (!ima)
 		return OPERATOR_CANCELLED;
@@ -1664,7 +1664,8 @@
 	prop = RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
 	RNA_def_property_float_array_default(prop, default_color);
 	RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
-	RNA_def_boolean(ot->srna, "uv_test_grid", 0, "UV Test Grid", "Fill the image with a grid for UV map testing");
+	RNA_def_enum(ot->srna, "generated_type", image_generated_type_items, IMA_GENTYPE_BLANK,
+	             "Generated Type", "Fill the image with a grid for UV map testing");
 	RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth");
 }
 

Modified: trunk/blender/source/blender/makesrna/RNA_enum_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_enum_types.h	2012-08-29 07:58:36 UTC (rev 50260)
+++ trunk/blender/source/blender/makesrna/RNA_enum_types.h	2012-08-29 08:17:38 UTC (rev 50261)
@@ -57,6 +57,7 @@
 extern EnumPropertyItem image_type_items[];
 extern EnumPropertyItem image_color_mode_items[];
 extern EnumPropertyItem image_depth_mode_items[];
+extern EnumPropertyItem image_generated_type_items[];
 
 extern EnumPropertyItem color_sets_items[];
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_image.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_image.c	2012-08-29 07:58:36 UTC (rev 50260)
+++ trunk/blender/source/blender/makesrna/intern/rna_image.c	2012-08-29 08:17:38 UTC (rev 50261)
@@ -42,6 +42,13 @@
 #include "WM_types.h"
 #include "WM_api.h"
 
+EnumPropertyItem image_generated_type_items[] = {
+	{IMA_GENTYPE_BLANK, "BLANK", 0, "Blank", "Generate a blank image"},
+	{IMA_GENTYPE_GRID, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
+	{IMA_GENTYPE_GRID_COLOR, "COLOR_GRID", 0, "Color Grid", "Generated improved UV grid to test UV mappings"},
+	{0, NULL, 0, NULL, NULL}
+};
+
 static EnumPropertyItem image_source_items[] = {
 	{IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"},
 	{IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"},
@@ -436,12 +443,6 @@
 		{IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
 		{0, NULL, 0, NULL, NULL}
 	};
-	static const EnumPropertyItem prop_generated_type_items[] = {
-		{0, "BLANK", 0, "Blank", "Generate a blank image"},
-		{1, "UV_GRID", 0, "UV Grid", "Generated grid to test UV mappings"},
-		{2, "COLOR_GRID", 0, "Color Grid", "Generated improved UV grid to test UV mappings"},
-		{0, NULL, 0, NULL, NULL}
-	};
 	static const EnumPropertyItem prop_mapping_items[] = {
 		{0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"},
 		{IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"},
@@ -520,7 +521,7 @@
 	/* generated image (image_generated_change_cb) */
 	prop = RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "gen_type");
-	RNA_def_property_enum_items(prop, prop_generated_type_items);
+	RNA_def_property_enum_items(prop, image_generated_type_items);
 	RNA_def_property_ui_text(prop, "Generated Type", "Generated image type");
 	RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
 




More information about the Bf-blender-cvs mailing list