diff --git a/data/dimers random walk.xml b/data/dimers random walk.xml index 12ae465..b2b0799 100644 --- a/data/dimers random walk.xml +++ b/data/dimers random walk.xml @@ -2,20 +2,20 @@ - Modèle de test + name - Léontine Patinette + owner - 2 + identity - 1630000000 + date 1.0 - Ref + reference language - + 0 9 @@ -42,8 +42,8 @@ - - + + @@ -53,8 +53,8 @@ - - + + @@ -73,7 +73,7 @@ - + @@ -93,7 +93,7 @@ - @@ -103,7 +103,7 @@ - diff --git a/docs/(notes) b/docs/(notes) deleted file mode 100644 index 930caee..0000000 --- a/docs/(notes) +++ /dev/null @@ -1,239 +0,0 @@ - -contain.c: (136) gtk_box_append (middle_box, GTK_WIDGET (get_GLArea())); - -graph_area.h: (177) static inline GLuint create_shader(const int stack_id, int type, const char *src) {...} - -graph_area.c: (153) graphics_draw (stack_index[i].stack_id); - -graph_area.c: (233) g_signal_connect (adj, "value-changed", G_CALLBACK(on_axis_value_change), (gpointer) label); -graph_area.c: (289) g_signal_connect(GTK_GL_AREA(gl_area), "render", G_CALLBACK(on_glarea_render), NULL); -graph_area.c: g_signal_connect(gl_area, "realize", G_CALLBACK(on_glarea_realize), NULL); -graph_area.c: g_signal_connect(gl_area, "unrealize", G_CALLBACK(on_glarea_unrealize), NULL); - -graph_stack.c: (149) if (!graphics_init_shaders(cur_id)) return -1; -graph_stack.c: (153) graphics_init_buffers(cur_id); - -graph_stack.c: (288) draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, space_X, space_Y, space_Z); -graph_stack.c: draw_space_ridges_lines (stack_id); -graph_stack.c: draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z); -graph_stack.c: draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, space_X, space_Y, space_Z); - -graph_stack.c: (316) stack->arrows_nb = set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z, arrow.load, arrow.site, arrow.x, arrow.y, arrow.z); - --------------------------------------------------------------------------------- - -contain is called (#included) in : callback, display, tree, graph_stack, graph_area, init, - --------------------------------------------------------------------------------- - -// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery -// https://docs.gtk.org/gtk4/section-text-widget.html -// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management -// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL - - - - - - - - - - - - -https://docs.gtk.org/gtk4/visual_index.html widgets gallery -https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/Makefile -https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management -// GtkSizeRequestMode get_request_mode (GtkWidget* widget); -// gtk_window_set_default_size (GTK_WINDOW (a_box), 30, 400); < TO STUDY -https://docs.gtk.org/gtk4/section-text-widget.html texts -https://docs.gtk.org/gtk4/drag-and-drop.html drag-and-drop -https://docs.gtk.org/gtk4/class.GestureZoom.html GtkGestureZoom -https://docs.gtk.org/gtk4/class.ListView.html -https://blog.gtk.org/2020/09/08/on-list-models/ < TODO -https://docs.gtk.org/gio/method.ActionMap.add_action_entries.html --------------------------------------------------------------------------------- - - -GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL - -GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT GTK_SIZE_REQUEST_CONSTANT_SIZE - -g_signal_connect (button, "clicked", G_CALLBACK (printf("%s\n", text)), text); -g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window); - --------------------------------------------------------------------------------- - -GtkBox GtkGrid GtkRevealer GtkStack -GtkOverlay GtkPaned GtkExpander GtkFixed - -box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); -gtk_widget_set_halign (box, GTK_ALIGN_FILL); -gtk_widget_set_valign (box, GTK_ALIGN_CENTER); // START CENTER END FILL -gtk_window_set_child (GTK_WINDOW (window), box); -puis, après déclaration du bouton, gtk_box_append (GTK_BOX (box), button); - -grid = gtk_grid_new (); -gtk_window_set_child (GTK_WINDOW (window), grid); -button = gtk_button_new_with_label (" I "); n fois -gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1); n fois - --------------------------------------------------------------------------------- - -TODO (or NOT TODO) - -GtkWidget *get_text_view(){ // WTF ?!& @Grr #~! - // https://docs.gtk.org/gtk4/section-text-widget.html - GtkWidget *my_view = gtk_text_view_new (); - GtkTextTagTable *my_table = gtk_text_tag_table_new (); - GtkTextBuffer *my_buffer = gtk_text_buffer_new (my_table); - - gtk_text_buffer_set_text (my_buffer, "Hello, this is some text", -1); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (my_view), my_buffer); - - /* Now you might put the view in a container and display it on the - * screen; when the user edits the text, signals on the buffer - * will be emitted, such as "changed", "insert_text", and so on. - */ - return my_view; -} - - - - - - -/* -https://docs.gtk.org/gtk4/class.ApplicationWindow.html - -GtkApplication *app = gtk_application_new ("org.gtk.test", 0); - -GtkBuilder *builder = gtk_builder_new_from_string ( - "" - " " - " " - " _Edit" - " " - " _Copy" - " win.copy" - " " - " " - " _Paste" - " win.paste" - " " - " " - " " - "", - -1); - -GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")); -gtk_application_set_menubar (GTK_APPLICATION (app), menubar); -g_object_unref (builder); - -// ... - -GtkWidget *window = gtk_application_window_new (app); - -*/ -//------------------------------------------------------------------------------ - -GtkScrolledWindow *get_scrolled_gl_area(){ - GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new()); - gtk_scrolled_window_set_min_content_width (scrolled, W_IMAGE); - gtk_scrolled_window_set_min_content_height (scrolled, H_IMAGE); -// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000); -// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000); - // (value, lower, upper, step_increment, page_increment, page_size) -// GtkWidget *GLarea = gtk_gl_area_new(); -// gtk_scrolled_window_set_child (scrolled, GLarea); -// https://docs.gtk.org/gtk4/class.GLArea.html - return scrolled; -} - - - - -// https://docs.gtk.org/gtk4/getting_started.html (m'aura bien servi, quand même !) - - - -//typedef anytype = {(int)(*fnct) {printf("typedef {(int)(*fnct) {printf("");}");} GtkModelFnct; - - - - - - - - - - - -/* - essai run-stop, speed et step by step dans une seule box controls - ----------------------------------------------------------------- - - -#include -#include -#include "cold.h" - -void print_text(GtkWidget *widget, gpointer data) {g_print (data);} - -GtkWidget *get_a_space_test_image(){ - GtkWidget *image; - image = GTK_WIDGET(get_scrolled_gl_area()); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/aXoris.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/gg sketch.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli resized.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/Getting_Started_with_GTK/E coli by David S. Goodsell (2009).png"); - return image; -} - -GtkWidget *get_scroll_speed(){ - GtkAdjustment *speed_adjust = gtk_adjustment_new (0, 0, 100, 1, 0, 0); - GtkWidget *scroll_speed = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, speed_adjust); - return scroll_speed; -} - -// TODO cliquer sur "RUN" --> affiche "STOP" (et inversement) -GtkBox *get_RUN_STOP_box(){ - GtkBox *RUN_STOP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2 - - GtkWidget *RUN_Label = GTK_WIDGET (gtk_label_new (NULL)); // "RUN")); - const char *str = " RUN\n STOP"; - const char *format = "\%s"; - char *markup; - - markup = g_markup_printf_escaped (format, str); - gtk_label_set_markup (GTK_LABEL (RUN_Label), markup); // Sets the labels text and attributes from markup. - g_free (markup); - - gtk_label_set_max_width_chars (GTK_LABEL(RUN_Label), 12); - gtk_label_set_wrap (GTK_LABEL(RUN_Label), TRUE); - gtk_label_set_xalign (GTK_LABEL(RUN_Label), 0.5); // xalign value, between 0 and 1 - gtk_label_set_yalign (GTK_LABEL(RUN_Label), 0.5); - gtk_label_set_selectable (GTK_LABEL(RUN_Label), FALSE); // default = FALSE - gtk_label_set_single_line_mode (GTK_LABEL(RUN_Label), TRUE); // default = TRUE - // - gtk_box_append (RUN_STOP_box, RUN_Label); - return RUN_STOP_box; -} - -GtkBox *get_STEP_by_STEP_box(){ - GtkBox *STEP_by_STEP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkWidget *STEP_by_STEP_Label = GTK_WIDGET (gtk_label_new ("ONE\nSTEP")); - gtk_box_append (STEP_by_STEP_box, STEP_by_STEP_Label); - return STEP_by_STEP_box; -} - -GtkBox *get_CONTROL_box(){ - GtkBox *CONTROL_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); - gtk_box_append (CONTROL_box, GTK_WIDGET (get_RUN_STOP_box())); - gtk_box_append (CONTROL_box, GTK_WIDGET (get_scroll_speed())); - gtk_box_append (CONTROL_box, GTK_WIDGET (get_STEP_by_STEP_box())); - return CONTROL_box; -} -*/ diff --git a/docs/(personnal notes) b/docs/(personnal notes) index f518ad2..ed5bca6 100644 --- a/docs/(personnal notes) +++ b/docs/(personnal notes) @@ -639,3 +639,243 @@ public class SingleTransition { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + +contain.c: (136) gtk_box_append (middle_box, GTK_WIDGET (get_GLArea())); + +graph_area.h: (177) static inline GLuint create_shader(const int stack_id, int type, const char *src) {...} + +graph_area.c: (153) graphics_draw (stack_index[i].stack_id); + +graph_area.c: (233) g_signal_connect (adj, "value-changed", G_CALLBACK(on_axis_value_change), (gpointer) label); +graph_area.c: (289) g_signal_connect(GTK_GL_AREA(gl_area), "render", G_CALLBACK(on_glarea_render), NULL); +graph_area.c: g_signal_connect(gl_area, "realize", G_CALLBACK(on_glarea_realize), NULL); +graph_area.c: g_signal_connect(gl_area, "unrealize", G_CALLBACK(on_glarea_unrealize), NULL); + +graph_stack.c: (149) if (!graphics_init_shaders(cur_id)) return -1; +graph_stack.c: (153) graphics_init_buffers(cur_id); + +graph_stack.c: (288) draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, space_X, space_Y, space_Z); +graph_stack.c: draw_space_ridges_lines (stack_id); +graph_stack.c: draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z); +graph_stack.c: draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, space_X, space_Y, space_Z); + +graph_stack.c: (316) stack->arrows_nb = set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z, arrow.load, arrow.site, arrow.x, arrow.y, arrow.z); + +-------------------------------------------------------------------------------- + +contain is called (#included) in : callback, display, tree, graph_stack, graph_area, init, + +-------------------------------------------------------------------------------- + +// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery +// https://docs.gtk.org/gtk4/section-text-widget.html +// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management +// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL + + + + + + + + + + + + +https://docs.gtk.org/gtk4/visual_index.html widgets gallery +https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/Makefile +https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management +// GtkSizeRequestMode get_request_mode (GtkWidget* widget); +// gtk_window_set_default_size (GTK_WINDOW (a_box), 30, 400); < TO STUDY +https://docs.gtk.org/gtk4/section-text-widget.html texts +https://docs.gtk.org/gtk4/drag-and-drop.html drag-and-drop +https://docs.gtk.org/gtk4/class.GestureZoom.html GtkGestureZoom +https://docs.gtk.org/gtk4/class.ListView.html +https://blog.gtk.org/2020/09/08/on-list-models/ < TODO +https://docs.gtk.org/gio/method.ActionMap.add_action_entries.html +-------------------------------------------------------------------------------- + + +GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL + +GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT GTK_SIZE_REQUEST_CONSTANT_SIZE + +g_signal_connect (button, "clicked", G_CALLBACK (printf("%s\n", text)), text); +g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window); + +-------------------------------------------------------------------------------- + +GtkBox GtkGrid GtkRevealer GtkStack +GtkOverlay GtkPaned GtkExpander GtkFixed + +box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); +gtk_widget_set_halign (box, GTK_ALIGN_FILL); +gtk_widget_set_valign (box, GTK_ALIGN_CENTER); // START CENTER END FILL +gtk_window_set_child (GTK_WINDOW (window), box); +puis, après déclaration du bouton, gtk_box_append (GTK_BOX (box), button); + +grid = gtk_grid_new (); +gtk_window_set_child (GTK_WINDOW (window), grid); +button = gtk_button_new_with_label (" I "); n fois +gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1); n fois + +-------------------------------------------------------------------------------- + +TODO (or NOT TODO) + +GtkWidget *get_text_view(){ // WTF ?!& @Grr #~! + // https://docs.gtk.org/gtk4/section-text-widget.html + GtkWidget *my_view = gtk_text_view_new (); + GtkTextTagTable *my_table = gtk_text_tag_table_new (); + GtkTextBuffer *my_buffer = gtk_text_buffer_new (my_table); + + gtk_text_buffer_set_text (my_buffer, "Hello, this is some text", -1); + gtk_text_view_set_buffer (GTK_TEXT_VIEW (my_view), my_buffer); + + /* Now you might put the view in a container and display it on the + * screen; when the user edits the text, signals on the buffer + * will be emitted, such as "changed", "insert_text", and so on. + */ + return my_view; +} + + + + + + +/* +https://docs.gtk.org/gtk4/class.ApplicationWindow.html + +GtkApplication *app = gtk_application_new ("org.gtk.test", 0); + +GtkBuilder *builder = gtk_builder_new_from_string ( + "" + " " + " " + " _Edit" + " " + " _Copy" + " win.copy" + " " + " " + " _Paste" + " win.paste" + " " + " " + " " + "", + -1); + +GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")); +gtk_application_set_menubar (GTK_APPLICATION (app), menubar); +g_object_unref (builder); + +// ... + +GtkWidget *window = gtk_application_window_new (app); + +*/ +//------------------------------------------------------------------------------ + +GtkScrolledWindow *get_scrolled_gl_area(){ + GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new()); + gtk_scrolled_window_set_min_content_width (scrolled, W_IMAGE); + gtk_scrolled_window_set_min_content_height (scrolled, H_IMAGE); +// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000); +// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000); + // (value, lower, upper, step_increment, page_increment, page_size) +// GtkWidget *GLarea = gtk_gl_area_new(); +// gtk_scrolled_window_set_child (scrolled, GLarea); +// https://docs.gtk.org/gtk4/class.GLArea.html + return scrolled; +} + + + + +// https://docs.gtk.org/gtk4/getting_started.html (m'aura bien servi, quand même !) + + + +//typedef anytype = {(int)(*fnct) {printf("typedef {(int)(*fnct) {printf("");}");} GtkModelFnct; + + + + + + + + + + + +/* + essai run-stop, speed et step by step dans une seule box controls + ----------------------------------------------------------------- + + +#include +#include +#include "cold.h" + +void print_text(GtkWidget *widget, gpointer data) {g_print (data);} + +GtkWidget *get_a_space_test_image(){ + GtkWidget *image; + image = GTK_WIDGET(get_scrolled_gl_area()); + image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/aXoris.png"); + image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/gg sketch.png"); + image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli.png"); + image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli resized.png"); + image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/Getting_Started_with_GTK/E coli by David S. Goodsell (2009).png"); + return image; +} + +GtkWidget *get_scroll_speed(){ + GtkAdjustment *speed_adjust = gtk_adjustment_new (0, 0, 100, 1, 0, 0); + GtkWidget *scroll_speed = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, speed_adjust); + return scroll_speed; +} + +// TODO cliquer sur "RUN" --> affiche "STOP" (et inversement) +GtkBox *get_RUN_STOP_box(){ + GtkBox *RUN_STOP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2 + + GtkWidget *RUN_Label = GTK_WIDGET (gtk_label_new (NULL)); // "RUN")); + const char *str = " RUN\n STOP"; + const char *format = "\%s"; + char *markup; + + markup = g_markup_printf_escaped (format, str); + gtk_label_set_markup (GTK_LABEL (RUN_Label), markup); // Sets the labels text and attributes from markup. + g_free (markup); + + gtk_label_set_max_width_chars (GTK_LABEL(RUN_Label), 12); + gtk_label_set_wrap (GTK_LABEL(RUN_Label), TRUE); + gtk_label_set_xalign (GTK_LABEL(RUN_Label), 0.5); // xalign value, between 0 and 1 + gtk_label_set_yalign (GTK_LABEL(RUN_Label), 0.5); + gtk_label_set_selectable (GTK_LABEL(RUN_Label), FALSE); // default = FALSE + gtk_label_set_single_line_mode (GTK_LABEL(RUN_Label), TRUE); // default = TRUE + // + gtk_box_append (RUN_STOP_box, RUN_Label); + return RUN_STOP_box; +} + +GtkBox *get_STEP_by_STEP_box(){ + GtkBox *STEP_by_STEP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); + GtkWidget *STEP_by_STEP_Label = GTK_WIDGET (gtk_label_new ("ONE\nSTEP")); + gtk_box_append (STEP_by_STEP_box, STEP_by_STEP_Label); + return STEP_by_STEP_box; +} + +GtkBox *get_CONTROL_box(){ + GtkBox *CONTROL_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); + gtk_box_append (CONTROL_box, GTK_WIDGET (get_RUN_STOP_box())); + gtk_box_append (CONTROL_box, GTK_WIDGET (get_scroll_speed())); + gtk_box_append (CONTROL_box, GTK_WIDGET (get_STEP_by_STEP_box())); + return CONTROL_box; +} +*/ diff --git a/include/base.h b/include/base.h deleted file mode 100644 index 365d60f..0000000 --- a/include/base.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Gem-graph OpenGL experiments - * - * Desc: Base header - * - * Copyright (C) 2023 Arthur Menges - * Copyright (C) 2023 Adrien Bourmault - * - * This file is part of Gem-graph. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#define G_APPLICATION_DEFAULT_FLAGS 0 - -enum { X_AXIS, Y_AXIS, Z_AXIS, N_AXIS }; // < used by : graph_area.h -enum { HOME_MODE, RUN_MODE, EDIT_MODE, PRESENTATION_MODE, N_MODE }; // Gem-graph modes -struct arrow_t { uint load; uint site; uint x; uint y; uint z; }; // describes an arrow -static inline char *read_file(char *filename); // < used by : init.c - -/* I'm standing on Earth (or any spinning spheroid) and looking towards its North pole, then : - X - X = EAST - WEST = rouge - cyan - Y - Y = ZENITH - NADIR = vert - magenta (fuschia) - Z - Z = NORTH - SOUTH = bleu - jaune */ - -#define EAST 0 // + x rouge -#define WEST 1 // - x cyan -#define ZENITH 2 // + y vert -#define NADIR 3 // - y magenta -#define SOUTH 4 // + z bleu -#define NORTH 5 // - z jaune - - -/* - * char *read_file(char *filename) reads a file from filename into a provided buffer - * - * @param filename, file name - * contents, target ptr - * - * @return void - */ -static inline char *read_file(char *filename) -{ - int fd; - int filesize; - char *contents; - - fd = open(filename, O_RDONLY); - if(fd < 0) { - printf("Couldn't read file: %s\n",filename); - return NULL; - } - - filesize = lseek(fd, 0, SEEK_END) + 1 ; - contents = g_malloc(filesize * sizeof(char)); - assert (contents); - - lseek(fd, 0, SEEK_SET); - read(fd,contents,filesize); - - contents[filesize-1] = '\0'; - - close(fd); - - return contents; -} - diff --git a/include/fsm.h b/include/fsm.h new file mode 100644 index 0000000..cc466d0 --- /dev/null +++ b/include/fsm.h @@ -0,0 +1,303 @@ +/** + * @file + * FSM (Finite State Machine) header + * + * This file is part of Gem-graph. + * + * @cond LICENSE + * Copyright © 2021 Libre en Communs + * Copyright © 2021-2024 Adrien Bourmault + * Copyright © 2021-2024 Jean Sirmai + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Affero General Public License as published by the Free + * Software Foundation, eisrc/log/ther version 3 of the License, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more + * details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * @endcond + * + * + * The fsm header lists all the structures that the log will need. + * + * The two structures and the two enums listed below will stay in the fsm header. + * + * All functions but the last one will be in a dedicated file: src/log/oper.c + * This file will contain the declaration of the log with the static attribute, + * which will force all the functions that read or write it to be in it. + * Forcing all functions that read or write to the log to be grouped together + * will prevent uncontrolled operations. + * + * The four most important functions are: + * - fsm_init_log() + * - fsm_publish_log() + * - fsm_clear_log() + * - fsm_add_log_event() + * . + * + * A typical list would also feature the last three functions: + * - fsm_get_log_length() + * - fsm_seek_log() + * - fsm_remove_log() + * . + * but in the case of a log, their usefulness remains to be demonstrated. + * + * + * A last function: fsm_add_log() will be in another file: src/log/manager.c. + * All events sent to the log must pass through this function, which allows them + * to be filtered before being published in the log. + * + * Here's how the procedure works. + * A message is send to the fsm_add_log() function for each documented event. + * If there are too many events, this is the only function that allows you to + * apply one or more filters before publication. This allows you to select the + * events of interest, which can vary depending on the type of session. + * These filters can operate on any the following five parameters: + * severity, source, file_source, function_source, string_value. + * They can be combined using any logical operators and parentheses. + * + * 'severity' is one of the following pre-defined values: + * FATAL - ERROR - WARN - INFO - DEBUG - TRACE + * + * 'source' is a pre-defined value (typically a name of a structure) that can be + * associated to each event. It can be set to 'NULL'. + * + * file_source, function_source and string_value are three strings. + * + * Here is the list of all the structures that the log will need. The functions + * will be documented in future commits. + * + * - fsm_log_struct() + * - fsm_log_struct_unit() + * . + * + * - fsm_enum_log_severity() + * - fsm_enum_log_source() + * . + * + * - fsm_init_log() + * - fsm_publish_log() + * - fsm_clear_log() + * - fsm_add_log_event() + * - fsm_get_log_length() + * - fsm_seek_log() + * - fsm_remove_log() + * . + * + * - fsm_add_log() + * . + */ + + +#pragma once + +/******************************************************************************/ +/* L O G / J O U R N A L */ +/******************************************************************************/ + +/** + * The 'severity' enum conforms to canonical log levels: + * FATAL, ERROR, WARN, INFO, DEBUG, TRACE + * + * https://betterstack.com/community/guides/logging/logging-best-practices/ + * https://en.wikipedia.org/wiki/Syslog + * + * All logs must contain at least one item from this enum and only one. + * This item can not be set to NULL. + * + * @see fsm_add_log() + */ +enum fsm_enum_log_severity { + FATAL, /**< (or CRITICAL) an unrecoverable failure that prevents the whole + application from doing any further useful work */ + ERROR, /**< an irremediable situation that hinders the execution of a + specific operation within the application */ + WARN, /**< something unexpected has occurred, but the application can + continue to function normally for the time being */ + INFO, /**< (or MESSAGE) a significant event occurs while the system is + operating normally */ + DEBUG, /**< a description of system states in sufficient detail to give + developers clues as to the cause of an error */ + TRACE /**< provides a systematic overview of code execution but comes at + a cost in terms of performance */ +}; + +/** + * A list of structures or states that may be involved in program events. + * + * All logs must contain at least one item from this list or the value NULL. + * + * Only some main items of this list are commented on today. Further comments + * will depend on its usage and structure which are just beginning to evolve. + * + * NB about PAGE: user_tree and selected_rule are two vertical panes which it + * is a good idea to place next to each other on the rules page so that you can + * switch between them more easily or have a parallel view of the two. + * + * @see fsm_add_log() + */ +enum fsm_enum_log_source { + AUTO_NOTIFICATION, /**< (not a source) */ + DESTINATION, /**< SOURCE, TARGET */ SOURCE, TARGET, + FSM_CONTENT, /**< LOG, FSM, PREFER */ LOG, FSM, PREFER, + SRC_CONTENT, /**< MAIN, APP, WIDGETS, SIGNAL */ MAIN, APP, WIDGETS, SIGNAL, + WINDOW, /**< MAIN, DIALOG, MODAL, TEXT */ + MAIN_WINDOW, DIALOG_WINDOW, MODAL_WINDOW, TEXT_WINDOW, + TOPBAR, /**< LEFT, CENTER, RIGHT */ TOPBAR_LEFT, TOPBAR_CENTER, TOPBAR_RIGHT, + PAGE, /**< SYNTH, STATE, RULES, [USER TREE], [SELECTED_RULE], MEASURES, RESULTS */ + SYNTH_PAGE, STATE_PAGE, RULES_PAGE, MEASURES_PAGE, RESULTS_PAGE, + SYNTHESIS, /**< GLAREA, CAMERA, CONTROLS, RESULTS (duplicates from other pages) */ + SYNTH_GLAREA, SYNTH_CAMERA, SYNTH_CONTROLS, SYNTH_RESULTS, + SYNTH_DATA, /**< SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS */ + SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS, + STATE_VIEW, /**< TOP, BOTTOM, GLAREA, CAMERA */ + STATE_TOP, STATE_BOTTOM, STATE_GLAREA, STATE_CAMERA, + SINGLE_RULE, /**< RULE_GEOMETRY, RULE_ALGEBRA */ + RULE_GEOMETRY, /**< VIEW_BEFORE, VIEW_AFTER, RULE_GLAREA, RULE_CAMERA */ + VIEW_BEFORE, VIEW_AFTER, RULE_GLAREA, RULE_CAMERA, + RULE_ALGEBRA, /**< LIST_CONDITIONS, LIST_ASSIGNMENTS, IDENTITY */ + RULE_LIST_CONDITION, RULE_LIST_ASSIGNMENTS, RULE_IDENTITY, + TREE_RULES, /**< TREE, COMPARE, USE */ + RULES_TREE, RULES_COMPARE, RULES_USE, + MEASURES, /**< TOOLS, ACTIVITY, DISPLAY */ + MEASURES_TOOLS, MEASURES_ACTIVITY, MEASURES_DISPLAY, + RESULTS, /**< TIME_DEPPENDENT, TIME_INDEPENDENT */ + TIME_DEP_RESULTS, TIME_INDEP_RESULTS, + GTK_WIDGETS, /**< LABEL, BUTTON, SCROLL, GLAREA, SLIDER, EXPANDER,... + * (non limitative) */ + WIDGET, BUTTON, SCROLL, GLAREA, TEXT, LABEL, TREE, SLIDER, EXPANDER, + ENTRY, SLIDER_X, SLIDER_Y, SLIDER_Z, SLIDER_A, SLIDER_B, SLIDER_C, + OTHERS, /**< fsm possible states: [EXEC / EDIT], [STATE / RULES / DATA], + * (non limitative) */ + ON_SWITCH_EXEC_EDIT, ON_SWITCH_STATE_RULES_DATA, +}; + +//----------------------------------------------------------------------------- + +/** + * Structure of a log unit. + * + * @callergraph + * @see fsm_log_struct + */ +typedef struct fsm_log_struct_unit + { + long yy_dd_mm; /**< * date of the event reported in the log */ + long usec; /**< * with microseconds precision */ + const char *file_source; /**< * emitter file */ + const char *function_source; /**< * emitter function */ + const char *string_value; /**< * any event descriptors */ + struct fsm_log_struct_unit *prev; /**< * chained list */ + struct fsm_log_struct_unit *next; /**< * chained list */ + } + fsm_log_struct_unit; + + +/** + * Two links towards the previous and the next unit are required to initialize + * and manage a double-chained list. + * + * @callgraph + * @see fsm_log_struct_unit + * + * @callergraph + * @see fsm_init_log() + * @see fsm_publish_log() + * @see fsm_clear_log() + * @see fsm_add_log_event() + * @see fsm_get_log_length() + * @see fsm_seek_log() + * @see fsm_remove_log() + */ +typedef struct { + fsm_log_struct_unit *first; /**< * required */ + fsm_log_struct_unit *last; /**< * required */ + } + fsm_log_struct; + +//----------------------------------------------------------------------------- + +void fsm_init_log (fsm_log_struct *jj); +void fsm_publish_log (fsm_log_struct jj); +void fsm_clear_log (fsm_log_struct *jj); + +void fsm_add_log_event (fsm_log_struct *jj, + const char *file_source, + const char *function_source, + const char *string_value); + +int fsm_get_log_length(fsm_log_struct jj); +void fsm_seek_log (fsm_log_struct jj, + long usec, + const char *file_source, + const char *function_source, + const char *string_value); +long fsm_remove_log (fsm_log_struct *jj, + const char *file_source, + const char *function_source, + const char *string_value); + + +/** + * @brief (1) This comment is not a duplicate: it will be displaced in the file: + * src/log/manager.c in next commits. + * + * It will be mandatory for any event to call the function fsm_add_log() + * to be published in the journal and it is here and only here that filters will + * be found. + * + * -- + * + * @details The fsm_struct_journal (gg_logs) will be a static instance in a + * dedicated file: src/log/manager.c + * Therefore, all the functions that read or write it will be in this file. + * This is to avoid uncontrolled operations on it. + * + * While the program is running, messages will be sent to the fsm_add_log() + * function for each documented event. + * If there are too many events, this is the only function that allows you to + * apply one or more filters before publication. This allows you to select the + * events of interest, which can vary depending on the type of session. + * + * These filters can operate on any of the following five parameters: + * severity, source, file_source, function_source, string_value . + * They can be combined using any logical operators and parentheses. + * + * -- + * + * @since 2024-08 + * + * @callgraph + * @see fsm_add_log_event() insertion into the log list + * + * @callergraph @see Almost all functions will have to report events and will + * therefore call fsm_add_log(). + * @see main() will send the first and last messages. + * + * + * @param severity: one of the following pre-defined values + * + * FATAL - ERROR - WARN - INFO - DEBUG - TRACE + * + * @param source: a pre-defined value (a name of a structure) that can be + * associated to each event. It can be set to 'NULL'. + * + * @param *file_source the name of the file that emits the event + * @param *function_source the function that emits the event + * @param *string_value any value that better specifies the event + * + * @see fsm_enum_log_severity + * @see fsm_enum_log_source + */ +void fsm_add_log (int severity, + int source, + const char *file_source, + const char *function_source, + const char *string_value); + diff --git a/src/main.c b/src/main.c index 2f3bafd..4a577d9 100644 --- a/src/main.c +++ b/src/main.c @@ -3,7 +3,7 @@ * * Gem-graph main file * - * This file is part of Gem-graph. + * This file is part of Gem-graph. It contains only the main() function. * * @cond LICENSE * Copyright © 2021 Libre en Communs @@ -23,6 +23,23 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * @endcond + * + * --- + * + * The main() function will **initialise** the log, the finite state machine (fsm), + * the application and the windows and **close** all the elements it opened + * before the end of program execution. + * In this commit, it does not implement g_application_activate() and has no + * handlers connected to the 'activate' signal (which triggers an error message). + * + * The default values of the fsm initial state will be specified in: + * src/fsm/dispatch(). They are user preference and, in accordance, the overview + * page of the current model will be displayed as they specify it in: + * src/widget/main_window/designer/widget_design_main_window(). + * + * About code organization, see src/readme.dox + * + * --- */ #include @@ -32,9 +49,11 @@ int main (int argc, char **argv) GtkApplication *app; int status; - app = gtk_application_new ("org.jean.GTK4_GG_hack", G_APPLICATION_DEFAULT_FLAGS); + app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); + //g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), NULL); //g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), NULL); + status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); diff --git a/src/readme.docs.c b/src/readme.docs.c new file mode 100644 index 0000000..00862d1 --- /dev/null +++ b/src/readme.docs.c @@ -0,0 +1,63 @@ +/** + * @file + * Gem-graph-client src/readme.docs file + * + * This file is part of Gem-graph. + * + * @cond LICENSE + * Copyright © 2021 Libre en Communs + * Copyright © 2021-2024 Adrien Bourmault + * Copyright © 2021-2024 Jean Sirmai + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Affero General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more + * details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * @endcond + * + * @details + * The code files are all located in the src (sources) directory. + * + * They are divided according to several *types of organisation*: + * + * - *hierarchical*: the widgets that give the windows their appearance are + * organised in the form of a tree. + * Windows are the first level of depth. + * Next come the windows contents: the title bars and the pages. + * The pages are designed to occupy the windows space below the title bars. + * Each of these pages has its own hierarchical structure: it can be divided + * into horizontal or vertical strips, which can themselves be divided in the + * same way, with varying levels of depth right down to the last containers + * which contain lists of widgets such as buttons, bars, entries or images. + * + * - *list*: the main *sections* of the fsm (finite state machine) constitute + * a list of at least four elements, each of which defines a set of possible + * states : + * -# execute or edit (managing the appropriate tools states in both cases) + * -# measure, operate on data, prepare displayable results + * -# user preferences + * -# desired state of windows and widgets + * + * The state of the fsm is uniquely defined at all times by all the parameters + * listed in these sections. All program actions depend on this state. + * + * - *transversal*: the other functions that must be easily accessible by all + * the previous functions. They are therefore all located at the root. + * These are the functions that manage graphics, callbacks and utilities. + * Although 'transversal', the log is part of the fsm. + * + * --- + * + * @see + * Model–view–controller || Model–view–viewmodel || Action–domain–responder || + * Multitier_architecture https://en.wikipedia.org/wiki/Multitier_architecture + * (presentation, logic, data) + */