Esempio n. 1
0
static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
{
	RenderResult *rr;
	rcti rect;
	float colf[3];
	
	rr= BKE_image_acquire_renderresult(scene, ima);

	if(rr && rr->text) {
		rect= ar->winrct;
		rect.xmin= 0;
		rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT;
		rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
		rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
		
		/* clear header rect */
		UI_GetThemeColor3fv(TH_BACK, colf);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
		glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f);
		glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1);
		glDisable(GL_BLEND);
		
		UI_ThemeColor(TH_TEXT_HI);

		UI_DrawString(12, rect.ymin + 5, rr->text);
	}

	BKE_image_release_renderresult(scene, ima);
}
Esempio n. 2
0
void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
{
	Scene *scene= CTX_data_scene(C);
	RenderResult *rr;

	/* render layers and passes */
	if(ima && iuser) {
		const float dpi_fac= UI_DPI_FAC;
		rr= BKE_image_acquire_renderresult(scene, ima);
		uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL);
		BKE_image_release_renderresult(scene, ima);
	}
}
Esempio n. 3
0
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact)
{
#define MAX_INFO_LEN  128

	PropertyRNA *prop;
	PointerRNA imaptr;
	RNAUpdateCb *cb;
	Image *ima;
	ImageUser *iuser;
	Scene *scene = CTX_data_scene(C);
	uiLayout *row, *split, *col;
	uiBlock *block;
	char str[MAX_INFO_LEN];

	void *lock;

	if (!ptr->data)
		return;

	prop = RNA_struct_find_property(ptr, propname);
	if (!prop) {
		printf("%s: property not found: %s.%s\n",
		       __func__, RNA_struct_identifier(ptr->type), propname);
		return;
	}

	if (RNA_property_type(prop) != PROP_POINTER) {
		printf("%s: expected pointer property for %s.%s\n",
		       __func__, RNA_struct_identifier(ptr->type), propname);
		return;
	}

	block = uiLayoutGetBlock(layout);

	imaptr = RNA_property_pointer_get(ptr, prop);
	ima = imaptr.data;
	iuser = userptr->data;

	BKE_image_user_check_frame_calc(iuser, (int)scene->r.cfra, 0);

	cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
	cb->ptr = *ptr;
	cb->prop = prop;
	cb->iuser = iuser;

	uiLayoutSetContextPointer(layout, "edit_image", &imaptr);
	uiLayoutSetContextPointer(layout, "edit_image_user", userptr);

	if (!compact)
		uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL);

	if (ima) {
		uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);

		if (ima->source == IMA_SRC_VIEWER) {
			ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
			image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN);
			BKE_image_release_ibuf(ima, ibuf, lock);

			uiItemL(layout, ima->id.name + 2, ICON_NONE);
			uiItemL(layout, str, ICON_NONE);

			if (ima->type == IMA_TYPE_COMPOSITE) {
				// XXX not working yet
#if 0
				iuser = ntree_get_active_iuser(scene->nodetree);
				if (iuser) {
					uiBlockBeginAlign(block);
					uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, "");
					uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play",    110, 120, 100, 20, 0, 0, 0, 0, 0, "");
					but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");
					uiButSetFunc(but, image_freecache_cb, ima, NULL);
					
					if (iuser->frames)
						BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
					else strcpy(str, "Frames:");
					uiBlockBeginAlign(block);
					uiDefButI(block, NUM, imagechanged, str,        10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
					uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie");
				}
#endif
			}
			else if (ima->type == IMA_TYPE_R_RESULT) {
				/* browse layer/passes */
				RenderResult *rr;

				/* use BKE_image_acquire_renderresult  so we get the correct slot in the menu */
				rr = BKE_image_acquire_renderresult(scene, ima);
				uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot);
				BKE_image_release_renderresult(scene, ima);
			}
		}
		else {
			uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE);

			if (ima->source != IMA_SRC_GENERATED) {
				row = uiLayoutRow(layout, TRUE);
				if (ima->packedfile)
					uiItemO(row, "", ICON_PACKAGE, "image.unpack");
				else
					uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
				
				row = uiLayoutRow(row, TRUE);
				uiLayoutSetEnabled(row, ima->packedfile == NULL);
				uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
				uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
			}

			// XXX what was this for?
#if 0
			/* check for re-render, only buttons */
			if (imagechanged == B_IMAGECHANGED) {
				if (iuser->flag & IMA_ANIM_REFRESHED) {
					iuser->flag &= ~IMA_ANIM_REFRESHED;
					WM_event_add_notifier(C, NC_IMAGE, ima);
				}
			}
#endif

			/* multilayer? */
			if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
				uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL);
			}
			else if (ima->source != IMA_SRC_GENERATED) {
				if (compact == 0) {
					ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
					image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN);
					BKE_image_release_ibuf(ima, ibuf, lock);
					uiItemL(layout, str, ICON_NONE);
				}
			}

			col = uiLayoutColumn(layout, FALSE);
			uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings");
			uiItemR(col, &imaptr, "use_view_as_render", 0, NULL, ICON_NONE);

			if (ima->source != IMA_SRC_GENERATED) {
				if (compact == 0) { /* background image view doesnt need these */
					ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
					int has_alpha = TRUE;

					if (ibuf) {
						int imtype = BKE_ftype_to_imtype(ibuf->ftype);
						char valid_channels = BKE_imtype_valid_channels(imtype);

						has_alpha = valid_channels & IMA_CHAN_FLAG_ALPHA;

						BKE_image_release_ibuf(ima, ibuf, NULL);
					}

					if (has_alpha) {
						col = uiLayoutColumn(layout, FALSE);
						uiItemR(col, &imaptr, "use_alpha", 0, NULL, ICON_NONE);
						uiItemR(col, &imaptr, "alpha_mode", 0, "Alpha", ICON_NONE);
					}

					uiItemS(layout);

					split = uiLayoutSplit(layout, 0.0f, FALSE);

					col = uiLayoutColumn(split, FALSE);
					/* XXX Why only display fields_per_frame only for video image types?
					 *     And why allow fields for non-video image types at all??? */
					if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
						uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE);
						uiLayout *subcol = uiLayoutColumn(subsplit, FALSE);
						uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE);
						subcol = uiLayoutColumn(subsplit, FALSE);
						uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields"));
						uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE);
					}
					else
						uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE);
					row = uiLayoutRow(col, FALSE);
					uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields"));
					uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
				}
			}

			if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
				uiItemS(layout);

				split = uiLayoutSplit(layout, 0.0f, FALSE);

				col = uiLayoutColumn(split, FALSE);

				BLI_snprintf(str, sizeof(str), IFACE_("(%d) Frames"), iuser->framenr);
				uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE);
				uiItemR(col, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
				uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE);

				col = uiLayoutColumn(split, FALSE);
				uiItemO(col, NULL, ICON_NONE, "IMAGE_OT_match_movie_length");
				uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE);
				uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE);
			}
			else if (ima->source == IMA_SRC_GENERATED) {
				split = uiLayoutSplit(layout, 0.0f, FALSE);

				col = uiLayoutColumn(split, TRUE);
				uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
				uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
				
				uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);

				uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
			}

		}

		uiBlockSetNFunc(block, NULL, NULL, NULL);
	}

	MEM_freeN(cb);

#undef MAX_INFO_LEN
}
Esempio n. 4
0
static void draw_render_info(const bContext *C,
                             Scene *scene,
                             Image *ima,
                             ARegion *ar,
                             float zoomx,
                             float zoomy)
{
	RenderResult *rr;
	Render *re = RE_GetRender(scene->id.name);
	RenderData *rd = RE_engine_get_render_data(re);
	Scene *stats_scene = ED_render_job_get_scene(C);
	if (stats_scene == NULL) {
		stats_scene = CTX_data_scene(C);
	}

	rr = BKE_image_acquire_renderresult(stats_scene, ima);

	if (rr && rr->text) {
		float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
		ED_region_info_draw(ar, rr->text, 1, fill_color);
	}

	BKE_image_release_renderresult(stats_scene, ima);

	if (re) {
		int total_tiles;
		bool need_free_tiles;
		rcti *tiles;

		tiles = RE_engine_get_current_tiles(re, &total_tiles, &need_free_tiles);

		if (total_tiles) {
			int i, x, y;
			rcti *tile;

			/* find window pixel coordinates of origin */
			UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);

			glPushMatrix();
			glTranslatef(x, y, 0.0f);
			glScalef(zoomx, zoomy, 1.0f);

			if (rd->mode & R_BORDER) {
				glTranslatef((int)(-rd->border.xmin * rd->xsch * rd->size / 100.0f),
				             (int)(-rd->border.ymin * rd->ysch * rd->size / 100.0f),
				             0.0f);
			}

			UI_ThemeColor(TH_FACE_SELECT);

			for (i = 0, tile = tiles; i < total_tiles; i++, tile++) {
				glaDrawBorderCorners(tile, zoomx, zoomy);
			}

			if (need_free_tiles) {
				MEM_freeN(tiles);
			}

			glPopMatrix();
		}
	}
}
Esempio n. 5
0
static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx, float zoomy)
{
	RenderResult *rr;
	Render *re = RE_GetRender(scene->id.name);

	rr = BKE_image_acquire_renderresult(scene, ima);

	if (rr && rr->text) {
		ED_region_info_draw(ar, rr->text, 1, 0.25);
	}

	BKE_image_release_renderresult(scene, ima);

	if (re) {
		int total_tiles;
		rcti *tiles;

		RE_engine_get_current_tiles(re, &total_tiles, &tiles);

		if (total_tiles) {
			int i, x, y;
			rcti *tile;

			/* find window pixel coordinates of origin */
			UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);

			glPushMatrix();
			glTranslatef(x, y, 0.0f);
			glScalef(zoomx, zoomy, 1.0f);

			if (scene->r.mode & R_BORDER) {
				glTranslatef(-scene->r.border.xmin * scene->r.xsch * scene->r.size / 100.0f,
				             -scene->r.border.ymin * scene->r.ysch * scene->r.size / 100.0f,
				             0.0f);
			}

			UI_ThemeColor(TH_FACE_SELECT);

			for (i = 0, tile = tiles; i < total_tiles; i++, tile++) {
				float delta_x = 4.0f * UI_DPI_FAC / zoomx;
				float delta_y = 4.0f * UI_DPI_FAC / zoomy;

				delta_x = min_ff(delta_x, tile->xmax - tile->xmin);
				delta_y = min_ff(delta_y, tile->ymax - tile->ymin);

				/* left bottom corner */
				glBegin(GL_LINE_STRIP);
				glVertex2f(tile->xmin, tile->ymin + delta_y);
				glVertex2f(tile->xmin, tile->ymin);
				glVertex2f(tile->xmin + delta_x, tile->ymin);
				glEnd();

				/* left top corner */
				glBegin(GL_LINE_STRIP);
				glVertex2f(tile->xmin, tile->ymax - delta_y);
				glVertex2f(tile->xmin, tile->ymax);
				glVertex2f(tile->xmin + delta_x, tile->ymax);
				glEnd();

				/* right bottom corner */
				glBegin(GL_LINE_STRIP);
				glVertex2f(tile->xmax - delta_x, tile->ymin);
				glVertex2f(tile->xmax, tile->ymin);
				glVertex2f(tile->xmax, tile->ymin + delta_y);
				glEnd();

				/* right top corner */
				glBegin(GL_LINE_STRIP);
				glVertex2f(tile->xmax - delta_x, tile->ymax);
				glVertex2f(tile->xmax, tile->ymax);
				glVertex2f(tile->xmax, tile->ymax - delta_y);
				glEnd();
			}

			MEM_freeN(tiles);

			glPopMatrix();
		}
	}
}