Revision 1082

View differences:

branches/simulator/projects/simulator/simulator/gui/gtk_gui.c
7 7

  
8 8
#include "robot.h"
9 9

  
10
#define NEW_ROBOT 1
11
#define PAUSE 2
12
#define RESUME 3
10
#define NEW_ROBOT	1
11
#define PAUSE		2
12
#define QUIT		3
13 13

  
14 14
GtkWidget* window;
15 15
GtkWidget* view = NULL;
......
46 46
	}
47 47
	gtk_widget_destroy (dialog);
48 48
	
49
	gdk_threads_leave();
50
	robots_resume();
51
	gdk_threads_enter();
49
	if (!robots_paused)
50
	{
51
		gdk_threads_leave();
52
		robots_resume();
53
		gdk_threads_enter();
54
	}
52 55
}
53 56

  
54 57
static gboolean menuhandler(int type)
......
67 70
			robots_paused = !robots_paused;
68 71
			gdk_threads_enter();
69 72
			break;
70
		case RESUME:
71
			gdk_threads_leave();
72
			robots_resume();
73
			gdk_threads_enter();
73
		case QUIT:
74
			destroy_callback(0);
74 75
			break;
75 76
	}
76 77

  
......
101 102
	g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
102 103
		G_CALLBACK(menuhandler), (gint*)PAUSE);
103 104
	
105
	menu_item = gtk_menu_item_new_with_label("Quit");
106
	gtk_widget_show(menu_item);
107
	gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_item);
108
	g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
109
		G_CALLBACK(menuhandler), (gint*)QUIT);
110
	
104 111
	file_item = gtk_menu_item_new_with_label("File");
105 112
	gtk_widget_show(file_item);
106 113
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), file_menu);
branches/simulator/projects/simulator/simulator/gui/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