Revision 1007
get rid of the draw_funcs stuff.
branches/simulator/projects/simulator/simulator/gui/draw_funcs.c | ||
---|---|---|
1 |
#include "draw_funcs.h" |
|
2 |
#include <stdio.h> |
|
3 |
#include <math.h> |
|
4 |
|
|
5 |
void draw_robot(GdkDrawable* drawable, GdkGC* gc, int x, int y, int angle) |
|
6 |
{ |
|
7 |
if (!drawable || !gc) |
|
8 |
return; |
|
9 |
double ang_rad = angle * PI / 180; |
|
10 |
int x_c = x - ROBOT_DIAMETER / 2; |
|
11 |
int y_c = y - ROBOT_DIAMETER / 2; |
|
12 |
|
|
13 |
gdk_draw_arc(drawable, gc, FALSE, x_c, y_c, |
|
14 |
ROBOT_DIAMETER, ROBOT_DIAMETER, 0, FULL_CIR); |
|
15 |
|
|
16 |
gdk_draw_line(drawable, gc, x, y, |
|
17 |
x + (ROBOT_DIAMETER - 10) * cos(ang_rad), |
|
18 |
y - (ROBOT_DIAMETER - 10) * sin(ang_rad)); |
|
19 |
} |
|
20 |
|
branches/simulator/projects/simulator/simulator/gui/draw_funcs.h | ||
---|---|---|
1 |
#ifndef __DRAW_FUNCS_H |
|
2 |
#define __DRAW_FUNCS_H |
|
3 |
|
|
4 |
#include <gtk/gtk.h> |
|
5 |
|
|
6 |
#define PI 3.14159 |
|
7 |
#define ROBOT_DIAMETER 50 |
|
8 |
#define FULL_CIR 23040 |
|
9 |
|
|
10 |
void draw_robot(GdkDrawable* drawable, GdkGC* gc, int x, int y, int angle); |
|
11 |
|
|
12 |
#endif |
branches/simulator/projects/simulator/simulator/gui/gtk_environment_view.c | ||
---|---|---|
8 | 8 |
#include <gtk/gtksignal.h> |
9 | 9 |
|
10 | 10 |
#include "gtk_environment_view.h" |
11 |
#include "draw_funcs.h" |
|
12 | 11 |
|
13 | 12 |
#include "robot.h" |
14 | 13 |
|
15 | 14 |
#define ENVIRONMENT_VIEW_MIN_WIDTH 100 |
16 | 15 |
#define ENVIRONMENT_VIEW_MIN_HEIGHT 50 |
17 | 16 |
|
17 |
#define ENVIRONMENT_PI 3.14159 |
|
18 |
#define ENVIRONMENT_ROBOT_DIAMETER 50 |
|
19 |
|
|
18 | 20 |
static GtkWidgetClass* parent_class = NULL; |
19 | 21 |
|
20 | 22 |
static void gtk_environment_view_class_init(GtkEnvironmentViewClass* environmentClass); |
... | ... | |
35 | 37 |
static gboolean gtk_environment_view_mouse_move(GtkWidget* widget, |
36 | 38 |
GdkEventMotion* event); |
37 | 39 |
|
40 |
|
|
41 |
static void draw_robot(GdkDrawable* drawable, GdkGC* gc, |
|
42 |
int x, int y, int angle); |
|
43 |
|
|
38 | 44 |
GtkType gtk_environment_view_get_type(void) |
39 | 45 |
{ |
40 | 46 |
static GtkType environment_view_type = 0; |
... | ... | |
186 | 192 |
|
187 | 193 |
view = GTK_ENVIRONMENT_VIEW(widget); |
188 | 194 |
|
189 |
// gdk_draw_rectangle(widget->window, widget->style->fg_gc[ |
|
190 |
// GTK_WIDGET_STATE(widget)], 0, 100, 100, 100, 100); |
|
191 |
|
|
192 |
// gdk_draw_arc(widget->window, |
|
193 |
// widget->style->fg_gc[GTK_WIDGET_STATE(widget)], FALSE, 0, 0, |
|
194 |
// 100, 100, 0, 360*64); |
|
195 |
|
|
196 | 195 |
robot_iterator_reset(); |
197 | 196 |
Robot* r; |
198 |
while ((r = robot_iterator_next()) != NULL) |
|
197 |
while ((r = robot_iterator_next()) != NULL) { |
|
198 |
printf("x: %d, y:%d, Theta: %d\n", |
|
199 |
r->pose.x, r->pose.y, r->pose.theta); |
|
199 | 200 |
draw_robot(widget->window, |
200 |
widget->style->fg_gc[GTK_WIDGET_STATE(widget)], r->pose.x, r->pose.y, r->pose.theta); |
|
201 |
widget->style->fg_gc[GTK_WIDGET_STATE(widget)], |
|
202 |
r->pose.x, r->pose.y, r->pose.theta); |
|
203 |
} |
|
201 | 204 |
|
202 | 205 |
return FALSE; |
203 | 206 |
} |
... | ... | |
349 | 352 |
gdk_threads_leave(); |
350 | 353 |
} |
351 | 354 |
|
355 |
static void draw_robot(GdkDrawable* drawable, GdkGC* gc, |
|
356 |
int x, int y, int angle) |
|
357 |
{ |
|
358 |
if (!drawable || !gc) |
|
359 |
return; |
|
360 |
double ang_rad = angle * ENVIRONMENT_PI / 180; |
|
361 |
int x_c = x - ENVIRONMENT_ROBOT_DIAMETER / 2; |
|
362 |
int y_c = y - ENVIRONMENT_ROBOT_DIAMETER / 2; |
|
363 |
|
|
364 |
gdk_draw_arc(drawable, gc, FALSE, x_c, y_c, |
|
365 |
ENVIRONMENT_ROBOT_DIAMETER, ENVIRONMENT_ROBOT_DIAMETER, |
|
366 |
0, 360*64); |
|
367 |
|
|
368 |
gdk_draw_line(drawable, gc, x, y, |
|
369 |
x + (ENVIRONMENT_ROBOT_DIAMETER - 10) * cos(ang_rad), |
|
370 |
y - (ENVIRONMENT_ROBOT_DIAMETER - 10) * sin(ang_rad)); |
|
371 |
} |
|
372 |
|
Also available in: Unified diff