summaryrefslogtreecommitdiff
path: root/src/gui/pictureframe.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/pictureframe.c')
-rw-r--r--src/gui/pictureframe.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/gui/pictureframe.c b/src/gui/pictureframe.c
index 4126f59..a6a94bf 100644
--- a/src/gui/pictureframe.c
+++ b/src/gui/pictureframe.c
@@ -17,7 +17,7 @@ void pictureframe_draw_canvas(PictureFrame *pictureFrame){
17void pictureframe_print(Component *parameterSelf) { 17void pictureframe_print(Component *parameterSelf) {
18 PictureFrame *self = (PictureFrame *) parameterSelf; 18 PictureFrame *self = (PictureFrame *) parameterSelf;
19 pictureframe_draw_canvas(self); 19 pictureframe_draw_canvas(self);
20 if (mode != WAITING_BUTTON_HIDE) { 20 if (mode != WAITING_BUTTON_HIDE && mode != RENDERING) {
21 TriangleMap *p = self->morphing->first; 21 TriangleMap *p = self->morphing->first;
22 CartesianVector p1; 22 CartesianVector p1;
23 CartesianVector p2; 23 CartesianVector p2;
@@ -30,9 +30,9 @@ void pictureframe_print(Component *parameterSelf) {
30 p2 = self->cartesianMappingDivision(&(p->vertices[1])); 30 p2 = self->cartesianMappingDivision(&(p->vertices[1]));
31 p3 = self->cartesianMappingDivision(&(p->vertices[2])); 31 p3 = self->cartesianMappingDivision(&(p->vertices[2]));
32 32
33 pointToPrint1 = pictureframe_conversion_to_picture(p1.x, p1.y, self); 33 pointToPrint1 = pictureframe_conversion_to_origin(p1.x, p1.y, self);
34 pointToPrint2 = pictureframe_conversion_to_picture(p2.x, p2.y, self); 34 pointToPrint2 = pictureframe_conversion_to_origin(p2.x, p2.y, self);
35 pointToPrint3 = pictureframe_conversion_to_picture(p3.x, p3.y, self); 35 pointToPrint3 = pictureframe_conversion_to_origin(p3.x, p3.y, self);
36 36
37 MLV_draw_filled_circle(pointToPrint1.x, pointToPrint1.y, 2, MLV_COLOR_RED); 37 MLV_draw_filled_circle(pointToPrint1.x, pointToPrint1.y, 2, MLV_COLOR_RED);
38 MLV_draw_filled_circle(pointToPrint2.x, pointToPrint2.y, 2, MLV_COLOR_RED); 38 MLV_draw_filled_circle(pointToPrint2.x, pointToPrint2.y, 2, MLV_COLOR_RED);
@@ -47,8 +47,6 @@ void pictureframe_print(Component *parameterSelf) {
47} 47}
48 48
49bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame) { 49bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame) {
50 assert(x >= 0);
51 assert(y >= 0);
52 assert(pictureFrame != NULL); 50 assert(pictureFrame != NULL);
53 int x1 = pictureFrame->component.x_pos; 51 int x1 = pictureFrame->component.x_pos;
54 int y1 = pictureFrame->component.y_pos; 52 int y1 = pictureFrame->component.y_pos;
@@ -60,14 +58,14 @@ bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame) {
60 return false; 58 return false;
61} 59}
62 60
63CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame) { 61CartesianVector pictureframe_conversion_to_pic(int x, int y, PictureFrame *pictureFrame) {
64 CartesianVector vector; 62 CartesianVector vector;
65 vector.x = x - pictureFrame->component.x_pos; 63 vector.x = x - pictureFrame->component.x_pos;
66 vector.y = y - pictureFrame->component.y_pos; 64 vector.y = y - pictureFrame->component.y_pos;
67 return vector; 65 return vector;
68} 66}
69 67
70CartesianVector pictureframe_conversion_to_picture(int x, int y, PictureFrame *pictureFrame) { 68CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame) {
71 CartesianVector vector; 69 CartesianVector vector;
72 vector.x = x + pictureFrame->component.x_pos; 70 vector.x = x + pictureFrame->component.x_pos;
73 vector.y = y + pictureFrame->component.y_pos; 71 vector.y = y + pictureFrame->component.y_pos;
@@ -77,7 +75,7 @@ CartesianVector pictureframe_conversion_to_picture(int x, int y, PictureFrame *p
77void pictureframe_click_handler_origin(int x_pos, int y_pos, Component *parameterSelf) { 75void pictureframe_click_handler_origin(int x_pos, int y_pos, Component *parameterSelf) {
78 PictureFrame *self = (PictureFrame *) parameterSelf; 76 PictureFrame *self = (PictureFrame *) parameterSelf;
79 if (pictureframe_is_selected(x_pos, y_pos, self) && mode == INSERT_ORIGIN) { 77 if (pictureframe_is_selected(x_pos, y_pos, self) && mode == INSERT_ORIGIN) {
80 CartesianVector vector = pictureframe_conversion_to_origin(x_pos, y_pos, self); 78 CartesianVector vector = pictureframe_conversion_to_pic(x_pos, y_pos, self);
81 MLV_draw_filled_circle(x_pos, y_pos, 2, MLV_COLOR_BLUE); 79 MLV_draw_filled_circle(x_pos, y_pos, 2, MLV_COLOR_BLUE);
82 savedPoint = vector; 80 savedPoint = vector;
83 MLV_actualise_window(); 81 MLV_actualise_window();
@@ -88,7 +86,7 @@ void pictureframe_click_handler_origin(int x_pos, int y_pos, Component *paramete
88void pictureframe_click_handler_target(int x_pos, int y_pos, Component *parameterSelf) { 86void pictureframe_click_handler_target(int x_pos, int y_pos, Component *parameterSelf) {
89 PictureFrame *self = (PictureFrame *) parameterSelf; 87 PictureFrame *self = (PictureFrame *) parameterSelf;
90 if (pictureframe_is_selected(x_pos, y_pos, self) && mode == INSERT_TARGET) { 88 if (pictureframe_is_selected(x_pos, y_pos, self) && mode == INSERT_TARGET) {
91 CartesianVector vector = pictureframe_conversion_to_origin(x_pos, y_pos, self); 89 CartesianVector vector = pictureframe_conversion_to_pic(x_pos, y_pos, self);
92 morphing_add_constraint(self->morphing, savedPoint, vector); 90 morphing_add_constraint(self->morphing, savedPoint, vector);
93 mode = PRINTING; 91 mode = PRINTING;
94 } 92 }