From 2f3d8ebc9b5e10e56bed5da316f5ef098dda0997 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Wed, 3 Jan 2018 19:40:51 +0100 Subject: Updating documentation, cleaning includes, updating report --- include/gui/button.h | 90 +++++++++++++++++++++++++++++++++------------- include/gui/component.h | 13 +++++++ include/gui/gui.h | 53 ++++++++++++++++++++++----- include/gui/pictureframe.h | 52 +++++++++++++++------------ include/gui/window.h | 62 +++++++++++++++++++------------- 5 files changed, 189 insertions(+), 81 deletions(-) (limited to 'include') diff --git a/include/gui/button.h b/include/gui/button.h index 41008c1..b5908cb 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -5,7 +5,6 @@ * Buttons handling */ -#include #include "component.h" /** @@ -24,67 +23,108 @@ typedef struct { } Button; /** - * Function: button_init - * Initializes the button. + * Function: button_create + * Allocates and initializes the button. * * Parameters: - * *button - pointer to the input button * text - label for the button * sizeInterligne - parameter to initialize padding inside the button * x_pos - position of the button on x axis * y_pos - position of the button on y axis * clickHandler - pointer of function that will be loaded inside our button to perform its purpose + * + * Returns: + * A pointer of Button */ -void button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler); +Button * +button_create(const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler); /** - * Function: button_print - * Prints the button. + * Function: button_destroy + * Frees the resources for the Button * * Parameters: - * *parameterSelf - pointer to the button + * *button - pointer to the button */ -void button_print(Component *parameterSelf); +void button_destroy(Button *button); /** - * Function: button_click_test - * Debug function to test if the click is working on the current button. + * Function: button_click_add_constraint + * Allows to add a constraint point in order on the first picture, then on the second. * * Parameters: * x - position of the click on x axis * y - position of the click on y axis * *parameterSelf - pointer on the button that is clicked */ -void button_click_test(int x, int y, Component *parameterSelf); - void button_click_add_constraint(int x, int y, Component *parameterSelf); +/** + * Function: button_click_show_hide + * Allows to show and hide the constraint points and triangles. + * + * Parameters: + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked + */ void button_click_show_hide(int x, int y, Component *parameterSelf); +/** + * Function: button_click_exit + * Quit the program. + * + * Parameters: + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked. + */ void button_click_exit(int x, int y, Component *parameterSelf); +/** + * Function: button_click_none + * Allows the button to do nothing on click. + * + * Parameters: + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked + */ void button_click_none(int x, int y, Component *parameterSelf); + +/** + * Function: button_click_more_frame + * Multiplies by two the number of frames to create when rendering. + * + * Parameters: + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked + */ void button_click_more_frame(int x, int y, Component *parameterSelf); +/** + * Function: button_click_less_frame + * Divides by two the number of frames to create when rendering. + * + * Parameters: + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked + */ void button_click_less_frame(int x, int y, Component *parameterSelf); -void button_click_rendering(int x, int y, Component *parameterSelf); - - /** - * Function: button_is_selected - * Checks if the button is selected or not. + * Function: button_click_rendering + * Launches the rendering of the morphing * * Parameters: - * x - position in x for the check - * y - position in y for the check - * *button - pointer to the current button - * - * Returns: - * A bool from stdbool + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked */ +void button_click_rendering(int x, int y, Component *parameterSelf); -bool button_is_selected(int x, int y, Button *button); #endif diff --git a/include/gui/component.h b/include/gui/component.h index 0275d45..9700dfe 100644 --- a/include/gui/component.h +++ b/include/gui/component.h @@ -1,5 +1,18 @@ #ifndef UPEM_C_COMPONENT_H #define UPEM_C_COMPONENT_H + +/** + * Enum: Mode + * + * WAITING_BUTTON_SHOW - Waits a click on buttons to perform actions and paints the constraint points on the GUI + * WAITING_BUTTON_HIDE - Waits a click on buttons to perform actions and does not print the constraint points on the GUI + * INSERT_ORIGIN - Waits a click on the origin pictureframe and lock other components + * INSERT_TARGET - Waits a click on the target pictureframe and lock other components + * PRINTING - Force the application to paint the pictureframes + * EXITING - Exits the programme + * PRINTING_BUTTONS - paints the buttons + * RENDERING - launches the rendering mode + */ typedef enum { WAITING_BUTTON_SHOW, WAITING_BUTTON_HIDE, INSERT_ORIGIN, INSERT_TARGET, PRINTING, EXITING, PRINTING_BUTTONS, RENDERING } Mode; diff --git a/include/gui/gui.h b/include/gui/gui.h index daaf8de..10f59e8 100644 --- a/include/gui/gui.h +++ b/include/gui/gui.h @@ -1,11 +1,32 @@ #ifndef UPEM_MORPHING_GUI #define UPEM_MORPHING_GUI -#include +#include "gui/window.h" + /** * File: gui.h */ + +/** + * Struct: GUI + * Supports all the parts of the GUI + * + * Fields: + * *window - pointer to the Window + * *button1 - pointer to the button 1 + * *button2 - pointer to the button 2 + * *button3 - pointer to the button 3 + * *button4 - pointer to the button 4 + * *button5 - pointer to the button 5 + * *button6 - pointer to the button 6 + * *button7 - pointer to the button 7 + * *pictureFrame1 - pointer to the picture frame 1 + * *pictureFrame2 - pointer to the picture frame 2 + * *canvasSrc - pointer to the canvas 1 + * *canvasTrg - pointer to the canvas 2 + * *morphing - pointer to the current morphing + */ typedef struct { Window *window; Button *button1; @@ -20,20 +41,36 @@ typedef struct { Canvas *canvasSrc; Canvas *canvasTrg; Morphing *morphing; - MLV_Keyboard_button keyboardButton; - MLV_Keyboard_modifier keyboardModifier; - int unicode; - int mouse_x; - int mouse_y; } GUI; +/** + * Function: gui_create + * + * + * Parameters: + * *fpath1 - path to the first picture + * *fpath2 - path to the second picture + * + * Returns: + * A pointer to a GUI structure + */ +GUI *gui_create(const char *fpath1, const char *fpath2); -GUI *gui_init(const char *fpath1, const char *fpath2); /** * Function: gui_handle_event * Builds and opens the graphical user interface. + * + * Parameters: + * *gui - pointer to the current GUI structure */ void gui_handle_event(GUI *gui); -void gui_free(GUI *gui); +/** + * Function: gui_destroy + * Frees the resources allocated for the GUI + * Parameters: + * *gui - pointer to the current GUI structure + */ +void gui_destroy(GUI *gui); + #endif diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index 7b9644e..a070190 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h @@ -1,14 +1,17 @@ #ifndef UPEM_MORPHING_PITUREFRAME #define UPEM_MORPHING_PITUREFRAME -#include -#include +#include "morpher/morphing.h" +#include "painter/canvas.h" #include "component.h" + /** * File: pictureframe.h */ +/*Needed storage point to share memory between the origin PictureFrame and the target PictureFrame. It ables to cancel the Add constraint functionality*/ CartesianVector savedPoint; + /** * Type: CartesianMappingDivision * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved @@ -50,24 +53,35 @@ CartesianVector pictureframe_origin_split(const CartesianMapping *cartesianMappi */ CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping); -bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame); - /** - * Function: pictureframe_conversion_to_origin - * Returns the relative coordinate on the picture corresponding to the input values + * Function: pictureframe_create + * Allocates and initializes the PictureFrame. * * Parameters: - * x - value on x axis from the origin of the window to convert - * y - value on y axis from the origin of the window to convert - * *pictureFrame - pointer to the reference pictureframe that will give his relative coordinates + * width - width of the current picture + * height - height of the current picture + * x_pos - position of the button on x axis + * y_pos - position of the button on y axis + * cartesianMappingDivision - pointer of function needed to select the right CartesianVector inside the morphing's CartesianMapping + * *morphing - pointer to the morphing + * *canvas - pointer to the canvas + * clickHandler - pointer of function that will be loaded inside our pictureframe + * + * Returns: + * A pointer of PictureFrame */ -CartesianVector pictureframe_conversion_to_pic(int x, int y, PictureFrame *pictureFrame); +PictureFrame *pictureframe_create(int width, int height, int x_pos, int y_pos, + CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas, + ClickHandler clickHandler); -CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame); - -void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, - CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas, - ClickHandler clickHandler); +/** + * Function: pictureframe_destroy + * Frees the current PictureFrame + * + * Parameters: + * *pictureframe - pointer to the current PictureFrame + */ +void pictureframe_destroy(PictureFrame *pictureFrame); /** * Function: pictureframe_draw_canvas @@ -78,14 +92,6 @@ void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_ */ void pictureframe_draw_canvas(PictureFrame *pictureFrame); -/** - * Function: pictureframe_print - * Prints the PictureFrame (The Canvas involved, plus the triangles and points of the Morphing) - * - * Parameters: - * *parameterSelf - pointer that will be casted into a PictureFrame to be printed - */ -void pictureframe_print(Component *parameterSelf); /** * Function: pictureframe_click_handler_origin diff --git a/include/gui/window.h b/include/gui/window.h index 10f0e74..e6b14dc 100644 --- a/include/gui/window.h +++ b/include/gui/window.h @@ -1,20 +1,15 @@ #ifndef UPEM_MORPHING_WINDOW #define UPEM_MORPHING_WINDOW +#include "MLV/MLV_keyboard.h" +#include "group.h" +#include "button.h" +#include "pictureframe.h" /** * File: window.h * Windows and components handling. - * - * See also: - * The famous OS */ -#include -#include "group.h" -#include "component.h" -#include "button.h" -#include "pictureframe.h" - /** * Struct: Window * Supports and handles components. @@ -34,25 +29,26 @@ typedef struct { } Window; /** - * Function: window_init - * Initializes a window. + * Function: window_create + * Allocates and initializes a window. * * Parameters: - * *window - pointer to the input window * width - width of the window to initialize * height - height of the window to initialize * *title - title of the actual window + * Returns: + * A pointer to a Window */ -void window_init(Window *window, int width, int height, char *title); +Window *window_create(int width, int height, char *title); /** - * Function: window_free + * Function: window_destroy * Frees the resources supported by the window and the window itself. * * Parameters: * *window - pointer to the input window */ -void window_free(Window *window); +void window_destroy(Window *window); /** * Function: window_add_button @@ -74,15 +70,6 @@ void window_add_button(Window *window, Button *button); */ void window_add_pictureframe(Window *window, PictureFrame *pictureFrame); -/** - * Function: window_create - * Initializes the resources to create a window. - * - * Parameters: - * *window - pointer to the input window - */ -void window_create(Window *window); - /** * Function: window_print_buttons * Prints all the buttons to the screen @@ -101,9 +88,34 @@ void window_print_buttons(Window *window); */ void window_print_pictureframes(Window *window); +/** + * Function: window_click_keyboard_handler + * Handles click and keyboard. + * + * Parameters: + * *window - pointer to the current window + * *keyboardButton - code of the keyboard key that is pushed or released + * *keyboardModifier - mode of the keyboard when a key is push or released + * *unicode - character coded in unicode of the letter obtained by combining the code and the mode + * *mouse_x - coordinate on the X axis of the mouse + * *mouse_y - coordinate on the Y axis of the mouse + */ void window_click_keyboard_handler(Window *window, MLV_Keyboard_button *keyboardButton, MLV_Keyboard_modifier *keyboardModifier, int *unicode, int *mouse_x, int *mouse_y); -void window_rendering(Window *window,PictureFrame *pictureFrame1,Canvas *canvasSrc, Canvas *canvasTarget, Morphing *morphing); + +/** + * Function: window_rendering + * Launches the rendering on the pictureframe origin. + * + * Parameters: + * *window - pointer to the current window + * *pictureFrame1 - pointer to the origin PictureFrame + * *canvasSrc - pointer to the source Canvas + * *canvasTarget - pointer to the target Canvas + * *morphing - pointer to the Morphing that will makes the transformation + */ +void window_rendering(Window *window, PictureFrame *pictureFrame1, Canvas *canvasSrc, Canvas *canvasTarget, + Morphing *morphing); #endif -- cgit v1.2.3