Revision 1082 branches/simulator/projects/simulator/simulator/gui/gtk_environment_view.c

View differences:

gtk_environment_view.c
15 15
#define ENVIRONMENT_VIEW_MIN_WIDTH		100
16 16
#define ENVIRONMENT_VIEW_MIN_HEIGHT		50
17 17

  
18
#define ENVIRONMENT_PI      			3.14159
19
#define ENVIRONMENT_ROBOT_DIAMETER		50
18
#define ROBOT_DIAMETER					30
20 19

  
21 20
static GtkWidgetClass* parent_class = NULL;
22 21

  
......
411 410
static void draw_robot(GdkDrawable* drawable, GdkGC* gc, 
412 411
                        float x, float y, float angle)
413 412
{
414
	if (!drawable || !gc)
415
		return;
416

  
417 413
	double leftx = world.win.p1.x;
418 414
	double upy = world.win.p1.x;
419 415
	double xwidth = world.win.p2.x - leftx;
420 416
	double yheight = world.win.p2.y - upy;
417
	double rx, ry;
421 418
	int width, height;
419
	
420
	if (!drawable || !gc)
421
		return;
422 422
	gdk_drawable_get_size(drawable, &width, &height);
423 423
	if (xwidth / width < yheight / height)
424 424
		width = (int)(height / yheight * xwidth);
425 425
	else
426 426
		height = (int)(width / xwidth * yheight);
427
	
428
	rx = (double)ROBOT_DIAMETER / xwidth * width;
429
	ry = (double)ROBOT_DIAMETER / yheight * height;
427 430

  
428 431
	x = ((x - leftx) / xwidth * width);
429 432
	y = ((y - upy) / yheight * height);
430
	int x_c = (int)x - ENVIRONMENT_ROBOT_DIAMETER / 2;
431
	int y_c = (int)y - ENVIRONMENT_ROBOT_DIAMETER / 2;
432 433

  
433
	gdk_draw_arc(drawable, gc, FALSE, x_c, y_c, 
434
	  	ENVIRONMENT_ROBOT_DIAMETER, ENVIRONMENT_ROBOT_DIAMETER, 
435
        0, 360*64);
434
	gdk_draw_arc(drawable, gc, FALSE, (int)(x - rx / 2), (int)(y - ry / 2), 
435
		rx, ry, 0, 360*64);
436 436

  
437
	//TODO: scale radius
438 437
	gdk_draw_line(drawable, gc, x, y, 
439
		x + (ENVIRONMENT_ROBOT_DIAMETER - 10) * cos(-angle),
440
		y - (ENVIRONMENT_ROBOT_DIAMETER - 10) * sin(-angle));
438
		x + (rx / 1.8) * cos(-angle),
439
		y - (ry / 1.8) * sin(-angle));
441 440
}
442 441

  

Also available in: Unified diff