Exemple #1
0
static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
{
	View2D *v2d= &ar->v2d;
	float zoomx, zoomy, w, h;
	int width, height;

	ED_space_image_size(sima, &width, &height);
	ED_space_image_zoom(sima, ar, &zoomx, &zoomy);

	w= zoomx*width/256.0f;
	h= zoomy*height/256.0f;
	
	cpack(0xFFFFFF);
	glTranslatef(v2d->cursor[0], v2d->cursor[1], 0.0f);  
	fdrawline(-0.05/w, 0, 0, 0.05/h);
	fdrawline(0, 0.05/h, 0.05/w, 0);
	fdrawline(0.05/w, 0, 0, -0.05/h);
	fdrawline(0, -0.05/h, -0.05/w, 0);
	
	setlinestyle(4);
	cpack(0xFF);
	fdrawline(-0.05/w, 0, 0, 0.05/h);
	fdrawline(0, 0.05/h, 0.05/w, 0);
	fdrawline(0.05/w, 0, 0, -0.05/h);
	fdrawline(0, -0.05/h, -0.05/w, 0);
	
	
	setlinestyle(0);
	cpack(0x0);
	fdrawline(-0.020/w, 0, -0.1/w, 0);
	fdrawline(0.1/w, 0, .020/w, 0);
	fdrawline(0, -0.020/h, 0, -0.1/h);
	fdrawline(0, 0.1/h, 0, 0.020/h);
	
	setlinestyle(1);
	cpack(0xFFFFFF);
	fdrawline(-0.020/w, 0, -0.1/w, 0);
	fdrawline(0.1/w, 0, .020/w, 0);
	fdrawline(0, -0.020/h, 0, -0.1/h);
	fdrawline(0, 0.1/h, 0, 0.020/h);
	
	glTranslatef(-v2d->cursor[0], -v2d->cursor[1], 0.0f);
	setlinestyle(0);
}
Exemple #2
0
void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
{
	Image *ima;
	ImBuf *ibuf;
	float zoomx, zoomy;
	int show_viewer, show_render;
	void *lock;

	/* XXX can we do this in refresh? */
#if 0
	what_image(sima);
	
	if(sima->image) {
		ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
		
		/* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
		if(sima->image->type==IMA_TYPE_COMPOSITE) {
			ImageUser *iuser= ntree_get_active_iuser(scene->nodetree);
			if(iuser) {
				BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0);
				sima->iuser= *iuser;
			}
		}
		/* and we check for spare */
		ibuf= ED_space_image_buffer(sima);
	}
#endif

	/* retrieve the image and information about it */
	ima= ED_space_image(sima);
	ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
	ibuf= ED_space_image_acquire_buffer(sima, &lock);

	show_viewer= (ima && ima->source == IMA_SRC_VIEWER);
	show_render= (show_viewer && ima->type == IMA_TYPE_R_RESULT);

	/* draw the image or grid */
	if(ibuf==NULL)
		draw_image_grid(ar, zoomx, zoomy);
	else if(sima->flag & SI_DRAW_TILE)
		draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy);
	else if(ima && (ima->tpageflag & IMA_TILES))
		draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy);
	else
		draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);

	/* paint helpers */
	if(sima->flag & SI_DRAWTOOL)
		draw_image_paint_helpers(ar, scene, zoomx, zoomy);


	/* XXX integrate this code */
#if 0
	if(ibuf) {
		float xoffs=0.0f, yoffs= 0.0f;
		
		if(image_preview_active(sa, &xim, &yim)) {
			xoffs= scene->r.disprect.xmin;
			yoffs= scene->r.disprect.ymin;
			glColor3ub(0,0,0);
			calc_image_view(sima, 'f');	
			myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
			glRectf(0.0f, 0.0f, 1.0f, 1.0f);
			glLoadIdentity();
		}
	}
#endif

	ED_space_image_release_buffer(sima, lock);

	/* render info */
	if(ima && show_render)
		draw_render_info(scene, ima, ar);
}