[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43314] trunk/blender/source/blender/ editors: de-duplicate function copy-paste for node color sampling.

Campbell Barton ideasman42 at gmail.com
Thu Jan 12 06:47:01 CET 2012


Revision: 43314
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43314
Author:   campbellbarton
Date:     2012-01-12 05:46:45 +0000 (Thu, 12 Jan 2012)
Log Message:
-----------
de-duplicate function copy-paste for node color sampling.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_image.h
    trunk/blender/source/blender/editors/space_image/image_draw.c
    trunk/blender/source/blender/editors/space_image/image_intern.h
    trunk/blender/source/blender/editors/space_image/image_ops.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_node/node_edit.c

Modified: trunk/blender/source/blender/editors/include/ED_image.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_image.h	2012-01-12 03:39:32 UTC (rev 43313)
+++ trunk/blender/source/blender/editors/include/ED_image.h	2012-01-12 05:46:45 UTC (rev 43314)
@@ -66,5 +66,8 @@
 /* UI level image (texture) updating... render calls own stuff (too) */
 void ED_image_update_frame(const struct Main *mainp, int cfra);
 
+void ED_image_draw_info(struct ARegion *ar, int color_manage, int channels,
+                        int x, int y, const char cp[4], const float fp[4], int *zp, float *zpf);
+
 #endif /* ED_IMAGE_H */
 

Modified: trunk/blender/source/blender/editors/space_image/image_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_draw.c	2012-01-12 03:39:32 UTC (rev 43313)
+++ trunk/blender/source/blender/editors/space_image/image_draw.c	2012-01-12 05:46:45 UTC (rev 43314)
@@ -110,7 +110,8 @@
 	BKE_image_release_renderresult(scene, ima);
 }
 
-void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4], int *zp, float *zpf)
+/* used by node view too */
+void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4], int *zp, float *zpf)
 {
 	char str[256];
 	float dx= 6;

Modified: trunk/blender/source/blender/editors/space_image/image_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_intern.h	2012-01-12 03:39:32 UTC (rev 43313)
+++ trunk/blender/source/blender/editors/space_image/image_intern.h	2012-01-12 05:46:45 UTC (rev 43314)
@@ -55,7 +55,6 @@
 
 /* image_draw.c */
 void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
-void draw_image_info(struct ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4], int *zp, float *zpf);
 void draw_image_grease_pencil(struct bContext *C, short onlyv2d);
 
 /* image_ops.c */

Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c	2012-01-12 03:39:32 UTC (rev 43313)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2012-01-12 05:46:45 UTC (rev 43314)
@@ -1772,7 +1772,7 @@
 	ImageSampleInfo *info= arg_info;
 	if(info->draw) {
 		/* no color management needed for images (color_manage=0) */
-		draw_image_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
+		ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
 	}
 }
 

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c	2012-01-12 03:39:32 UTC (rev 43313)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c	2012-01-12 05:46:45 UTC (rev 43314)
@@ -2279,211 +2279,6 @@
 	}
 }
 
-void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int x, int y, const char cp[4], const float fp[4])
-{
-	char str[256];
-	float dx= 6;
-	/* text colors */
-	/* XXX colored text not allowed in Blender UI */
-	#if 0
-	unsigned char red[3] = {255, 50, 50};
-	unsigned char green[3] = {0, 255, 0};
-	unsigned char blue[3] = {100, 100, 255};
-	#else
-	unsigned char red[3] = {255, 255, 255};
-	unsigned char green[3] = {255, 255, 255};
-	unsigned char blue[3] = {255, 255, 255};
-	#endif
-	float hue=0, sat=0, val=0, lum=0, u=0, v=0;
-	float col[4], finalcol[4];
-
-	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-	glEnable(GL_BLEND);
-
-	/* noisy, high contrast make impossible to read if lower alpha is used. */
-	glColor4ub(0, 0, 0, 190);
-	glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20);
-	glDisable(GL_BLEND);
-
-	BLF_size(blf_mono_font, 11, 72);
-
-	glColor3ub(255, 255, 255);
-	BLI_snprintf(str, sizeof(str), "X:%-4d  Y:%-4d |", x, y);
-	// UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
-	BLF_position(blf_mono_font, dx, 6, 0);
-	BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-	dx += BLF_width(blf_mono_font, str);
-
-	#if 0	/* XXX no Z value in compo backdrop atm */
-	if(zp) {
-		glColor3ub(255, 255, 255);
-		BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-	}
-	if(zpf) {
-		glColor3ub(255, 255, 255);
-		BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf);
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-	}
-	#endif
-
-	if(channels >= 3) {
-		glColor3ubv(red);
-		if (fp)
-			BLI_snprintf(str, sizeof(str), "  R:%-.4f", fp[0]);
-		else if (cp)
-			BLI_snprintf(str, sizeof(str), "  R:%-3d", cp[0]);
-		else
-			BLI_snprintf(str, sizeof(str), "  R:-");
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-		
-		glColor3ubv(green);
-		if (fp)
-			BLI_snprintf(str, sizeof(str), "  G:%-.4f", fp[1]);
-		else if (cp)
-			BLI_snprintf(str, sizeof(str), "  G:%-3d", cp[1]);
-		else
-			BLI_snprintf(str, sizeof(str), "  G:-");
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-		
-		glColor3ubv(blue);
-		if (fp)
-			BLI_snprintf(str, sizeof(str), "  B:%-.4f", fp[2]);
-		else if (cp)
-			BLI_snprintf(str, sizeof(str), "  B:%-3d", cp[2]);
-		else
-			BLI_snprintf(str, sizeof(str), "  B:-");
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-		
-		if(channels == 4) {
-			glColor3ub(255, 255, 255);
-			if (fp)
-				BLI_snprintf(str, sizeof(str), "  A:%-.4f", fp[3]);
-			else if (cp)
-				BLI_snprintf(str, sizeof(str), "  A:%-3d", cp[3]);
-			else
-				BLI_snprintf(str, sizeof(str), "- ");
-			BLF_position(blf_mono_font, dx, 6, 0);
-			BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-			dx += BLF_width(blf_mono_font, str);
-		}
-	}
-	
-	/* color rectangle */
-	if (channels==1) {
-		if (fp)
-			col[0] = col[1] = col[2] = fp[0];
-		else if (cp)
-			col[0] = col[1] = col[2] = (float)cp[0]/255.0f;
-		else
-			col[0] = col[1] = col[2] = 0.0f;
-	}
-	else if (channels==3) {
-		if (fp)
-			copy_v3_v3(col, fp);
-		else if (cp) {
-			col[0] = (float)cp[0]/255.0f;
-			col[1] = (float)cp[1]/255.0f;
-			col[2] = (float)cp[2]/255.0f;
-		}
-		else
-			zero_v3(col);
-	}
-	else if (channels==4) {
-		if (fp)
-			copy_v4_v4(col, fp);
-		else if (cp) {
-			col[0] = (float)cp[0]/255.0f;
-			col[1] = (float)cp[1]/255.0f;
-			col[2] = (float)cp[2]/255.0f;
-			col[3] = (float)cp[3]/255.0f;
-		}
-		else
-			zero_v4(col);
-	}
-	if (color_manage) {
-		linearrgb_to_srgb_v3_v3(finalcol, col);
-		finalcol[3] = col[3];
-	}
-	else {
-		copy_v4_v4(finalcol, col);
-	}
-	glDisable(GL_BLEND);
-	glColor3fv(finalcol);
-	dx += 5;
-	glBegin(GL_QUADS);
-	glVertex2f(dx, 3);
-	glVertex2f(dx, 17);
-	glVertex2f(dx+30, 17);
-	glVertex2f(dx+30, 3);
-	glEnd();
-	dx += 35;
-
-	glColor3ub(255, 255, 255);
-	if(channels == 1) {
-		if (fp) {
-			rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
-			rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v);
-		}
-		else if (cp) {
-			rgb_to_hsv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &hue, &sat, &val);
-			rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v);
-		}
-		
-		BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-
-		BLI_snprintf(str, sizeof(str), "   L:%-.4f", lum);
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-	}
-	else if(channels >= 3) {
-		if (fp) {
-			rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val);
-			rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v);
-		}
-		else if (cp) {
-			rgb_to_hsv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &hue, &sat, &val);
-			rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v);
-		}
-
-		BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-
-		BLI_snprintf(str, sizeof(str), "  S:%-.4f", sat);
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-
-		BLI_snprintf(str, sizeof(str), "  V:%-.4f", val);
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-
-		BLI_snprintf(str, sizeof(str), "   L:%-.4f", lum);
-		BLF_position(blf_mono_font, dx, 6, 0);
-		BLF_draw_ascii(blf_mono_font, str, sizeof(str));
-		dx += BLF_width(blf_mono_font, str);
-	}
-
-	(void)dx;
-}
-
 #if 0
 /* note: needs to be userpref or opengl profile option */
 static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode)

Modified: trunk/blender/source/blender/editors/space_node/node_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_edit.c	2012-01-12 03:39:32 UTC (rev 43313)
+++ trunk/blender/source/blender/editors/space_node/node_edit.c	2012-01-12 05:46:45 UTC (rev 43314)
@@ -71,6 +71,7 @@
 #include "IMB_imbuf_types.h"
 
 #include "ED_node.h"
+#include "ED_image.h"
 #include "ED_screen.h"
 #include "ED_space_api.h"
 #include "ED_render.h"
@@ -1343,8 +1344,10 @@
 {
 	ImageSampleInfo *info= arg_info;
 
-	draw_nodespace_color_info(ar, (CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
-							  info->x, info->y, info->col, info->colf);
+	ED_image_draw_info(ar, (CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+	                   info->x, info->y, info->col, info->colf,
+	                   NULL, NULL /* zbuf - unused for nodes */
+	                   );
 }
 

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list