From bff9a693e8f96e9b3979412fc0fc6a49e2189929 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 22 Jul 2024 18:02:14 +0200 Subject: [PATCH] some more comments in the 'include' files --- include/fsm.h | 1 + include/widget.h | 55 +++++--- src/widget/state.c.xx | 285 ------------------------------------------ 3 files changed, 41 insertions(+), 300 deletions(-) delete mode 100644 src/widget/state.c.xx diff --git a/include/fsm.h b/include/fsm.h index e80e8bc..55c55a9 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -36,6 +36,7 @@ /******************************************************************************/ /* S T A T E M A C H I N E */ /******************************************************************************/ +// called by widgets through signal functions enum fsm_choice_EXEC_EDIT { EXEC, EDIT }; // xor enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor diff --git a/include/widget.h b/include/widget.h index 1acb228..001ad42 100644 --- a/include/widget.h +++ b/include/widget.h @@ -35,13 +35,19 @@ #define n_situations 128 /******************************************************************************/ -/* W I N D O W S (see "init.c") */ +/* W I N D O W S */ /******************************************************************************/ +// called in init.c +// functions are in topbar.c void widget_design_main_window (GtkWindow *main_window); void widget_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window); void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window); + +// called in topbar.c +// functions are in init.c + void *widget_get_main_window(); void *widget_get_dialog_window(); void *widget_get_text_window(); @@ -50,23 +56,39 @@ void *widget_get_text_window(); /******************************************************************************/ /* W I D G E T S */ /******************************************************************************/ +// called in signal.c -void *widget_get_state_page(); -void *widget_get_rules_page(); -void *widget_get_stock_page(); +void *widget_get_state_page(); // in : src/widget/state/distrib.c +void *widget_get_rules_page(); // in : src/widget/rules.c +void *widget_get_stock_page(); // in : src/widget/stock.c -void *widget_get_space_view(); -void *widget_get_space_edit_control(); -void *widget_get_sequence_control(); -void *widget_get_graph_view_control(); -void widget_reset_all_objects_transparencies_to_value (int value); -void widget_reset_all_situations_transparencies_to_value (int value); +/******************************************************************************/ +/* S T A T E */ +/******************************************************************************/ +// called in : src/widget/state/distrib.c + +void *widget_get_space_view(); // middle +void *widget_get_graph_view_control(); // middle + +void *widget_get_space_edit_control(); // bottom +void *widget_get_sequence_control(); // bottom + +// called in : src/widget/state/top.c + +void widget_reset_all_objects_transparencies_to_value (int value); // top +void widget_reset_all_situations_transparencies_to_value (int value); // top + + +/******************************************************************************/ +/* S T O C K */ +/******************************************************************************/ +// in : stock.c +// called by topbar.c.widget_design_text_window() void *widget_get_stock_text (gchar *text_name); - /******************************************************************************/ /* T R E E */ /******************************************************************************/ @@ -82,8 +104,9 @@ void *widget_get_user_rules_tree (); // see "labo.c" for specification of the tr /******************************************************************************/ /* I M A G E S */ /******************************************************************************/ -// images are in : data / image / -// functions are in : widget / stock.c +// images in : data / image / +// functions in : widget / stock.c +// used by : widget / rules.c void *widget_get_image_E_coli(); void *widget_get_image_glutamate(); @@ -95,8 +118,9 @@ void *widget_get_image_AMP(); /******************************************************************************/ /* T E X T S */ /******************************************************************************/ -// texts are in : data / text / -// functions are in : widget / stock.c +// texts in : data / text / +// functions in : widget / stock.c +// used by text_window (see topbar.c)) char *widget_get_text_address_theory (); char *widget_get_text_address_about_commands (); @@ -106,6 +130,7 @@ char *widget_get_text_address_any (); /******************************************************************************/ /* L A B O */ /******************************************************************************/ +// called by tree.c widget_get_user_rules_tree() void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root); diff --git a/src/widget/state.c.xx b/src/widget/state.c.xx deleted file mode 100644 index f9c4c88..0000000 --- a/src/widget/state.c.xx +++ /dev/null @@ -1,285 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * -* * -* Gem-graph client * -* * -* State * -* * -* Copyright © 2021 Libre en Communs * -* Copyright © 2021 Jean Sirmai * -* * -* 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 . * -* * -* * * * * * * * * * * * * * * * * * * * * * * * * * */ - - -#include "../../include/fsm.h" -#include "../../include/widget.h" -#include "../../include/signal.h" - -#define UPPER_COMPARTMENT_PARTITION 600 -#define LOWER_COMPARTMENT_PARTITION 1300 - -/* L'image de l'état de l'espace (au centre) fait partie d'un panneau "milieu", - * qui est encadré par les deux panneaux: "haut" et "bas". - * La partie droite du panneau "milieu" est elle-même un panneau de commandes. - * - * Si l'on nomme ces panneaux selon leur fonction, on trouvera: - * - CONTROL ou EDIT en bas permet de contrôler / choisir un état et / ou de l'éditer. - * ce panneau peut avoir deux apparences (et fonctions) différentes: - * - en mode EDIT, seuls les outils d'édition de l'état sont disponibles - * - en mode EXEC, seuls les outils de déplacement dans la séquence sont disponibles - * - CAMERA à droite permet de choisir la position de la caméra - * - CONTRAST en haut permet de modifier un à un les contrastes des objets et des situations - * afin de mieux mettre en évidence l'objet ou le phénomène d'intérêt */ - -static GtkBox *rec_XYZ_box() -{ - GtkBox *XYZ_labels_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); // spacing = 2 - GtkBox *XYZ_scrollbar_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); - // GtkWidget *scale_X = gtk_scale_button_new (0, 360, 10, NULL); < à étudier - // (double min, double max, double step, const char** icons) - GtkAdjustment *X_adjust = gtk_adjustment_new (rand() % 100, 0, 380, 1, 0, 0); - GtkAdjustment *Y_adjust = gtk_adjustment_new (rand() % 200, 0, 380, 1, 0, 0); - GtkAdjustment *Z_adjust = gtk_adjustment_new (rand() % 300, 0, 380, 1, 0, 0); - GtkWidget *scroll_X = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, X_adjust); - GtkWidget *scroll_Y = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Y_adjust); - GtkWidget *scroll_Z = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Z_adjust); - gtk_widget_set_size_request (GTK_WIDGET (scroll_X), 1, 400); - - gtk_box_append (XYZ_scrollbar_box, GTK_WIDGET (gtk_label_new (" "))); // AD HOC (pour "centrer") - gtk_box_append (XYZ_scrollbar_box, scroll_X); - gtk_box_append (XYZ_scrollbar_box, scroll_Y); - gtk_box_append (XYZ_scrollbar_box, scroll_Z); - gtk_box_append (XYZ_scrollbar_box, GTK_WIDGET (gtk_label_new (" "))); // AD HOC (pour "centrer") - - GtkWidget *btt_reset = gtk_toggle_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic"); - gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new ("\nX Y Z"))); - gtk_box_append (XYZ_labels_box, GTK_WIDGET (XYZ_scrollbar_box)); - gtk_box_append (XYZ_labels_box, GTK_WIDGET (btt_reset)); - gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new (""))); - return XYZ_labels_box; -} - -static GtkBox *rec_ZOOM_box() -{ - GtkBox *ZOOM_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkWidget *ZOOM_Label = GTK_WIDGET (gtk_label_new (\ - "\n TOOLS\n ---\n zoom\n ---\n space\n struct.\n\ - ---\n arrows\n struct.\n ---\n orient\n state\n in space\n")); - gtk_widget_set_size_request (GTK_WIDGET (ZOOM_box), 10, 80); - gtk_box_append (ZOOM_box, ZOOM_Label); - return ZOOM_box; -} - - -static GtkScrollbar *object_bar [n_objects]; -static GtkAdjustment *object_adjust [n_objects]; - -void widget_reset_all_objects_transparencies_to_value (int value) -{ - for (int i = 0; i < n_objects; i++) - if (value > -1) - gtk_adjustment_set_value (object_adjust [i], value); - else gtk_adjustment_set_value (object_adjust [i], rand() % 127); -} - -static GtkBox *rec_OBJECTS_box() -{ - GtkBox *objects_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkAdjustment *reset_value = gtk_adjustment_new (0, 0, 127, 1, 0, 0); - GtkScrollbar *reset_scrollbar = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, reset_value)); - gtk_box_append (objects_box, gtk_label_new (" ")); // AD HOC (pour "centrer") - gtk_box_append (objects_box, GTK_WIDGET (reset_scrollbar)); - GtkWidget *btt_reset = gtk_toggle_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic"); - g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_objects_box_do_reset), reset_scrollbar); - gtk_box_append (objects_box, btt_reset); - - // GtkAdjustment *object_adjust [n_objects]; // (value, lower, upper, step_increment, page_increment, page_size) - for (int i = 0; i < n_objects; i++) - { - object_adjust [i] = gtk_adjustment_new (0, 0, 127, 1, 0, 0); - object_bar [i] = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, - object_adjust [i])); - char tooltip_text[8]; - sprintf(tooltip_text, "\n%d\n", i); - if (0 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (object_bar [i]), "membrane"); - if (1 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (object_bar [i]), "co-enzyme A"); - if (2 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (object_bar [i]), "ATP synthase"); - if (3 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (object_bar [i]), "any object name"); - if (4 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (object_bar [i]), tooltip_text); - - gtk_box_append (objects_box, GTK_WIDGET (object_bar [i])); - } - widget_reset_all_objects_transparencies_to_value (-1); - - return objects_box; -} - -static GtkScrollbar *situation_bar [n_situations]; -static GtkAdjustment *situation_adjust [n_situations]; - -void widget_reset_all_situations_transparencies_to_value (int value) -{ - for (int i = 0; i < n_situations; i++) - if (value > -1) - gtk_adjustment_set_value (situation_adjust [i], value); - else gtk_adjustment_set_value (situation_adjust [i], rand() % 127); -} - -static GtkBox *rec_SITUATIONS_box() -{ - GtkBox *situations_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkAdjustment *reset_value = gtk_adjustment_new (0, 0, 127, 1, 0, 0); - GtkScrollbar *reset_scrollbar = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, reset_value)); - gtk_box_append (situations_box, gtk_label_new (" ")); - gtk_box_append (situations_box, GTK_WIDGET (reset_scrollbar)); - GtkWidget *btt_reset = gtk_toggle_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic"); - g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_situations_box_do_reset), reset_scrollbar); - gtk_box_append (situations_box, btt_reset); - - for (int i = 0; i < n_situations; i++) - { - situation_adjust [i] = gtk_adjustment_new (0, 0, 127, 1, 0, 4); - situation_bar [i] = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, - situation_adjust [i])); - char tooltip_text[8]; - sprintf(tooltip_text, "\n%d\n", i); - if (0 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), "transcription"); - if (1 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), "transport Na/K"); - if (2 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), "ubiquitination"); - if (3 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), "glycolyse aérobie"); - if (4 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), "cycle de Krebs"); - if (5 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), "shunt des pentoses"); - if (6 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), "any situation name"); - if (7 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (situation_bar [i]), tooltip_text); - - gtk_box_append (situations_box, GTK_WIDGET (situation_bar [i])); - } - widget_reset_all_situations_transparencies_to_value (-1); - - return situations_box; -} - - -/******************************************************************************/ -/* S T A T E p a g e > t h r e e t o p l e v e l b o x e s */ -/******************************************************************************/ - -static GtkWidget *rec_OBJECTS_and_SITUATIONS() -{ - GtkWidget *scroll_objects = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_objects), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - - GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparency - gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (rec_OBJECTS_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_objects), frame_objects); - - GtkWidget *scroll_situations = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_situations), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification - gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (rec_SITUATIONS_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_situations), frame_situations); - - GtkWidget *objects_and_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); - gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_objects)); - gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_situations)); - gtk_paned_set_position (GTK_PANED (objects_and_situations_horizontal_pane), UPPER_COMPARTMENT_PARTITION); - gtk_paned_set_shrink_start_child (GTK_PANED (objects_and_situations_horizontal_pane), FALSE); - gtk_paned_set_shrink_end_child (GTK_PANED (objects_and_situations_horizontal_pane), FALSE); - gtk_widget_set_size_request (objects_and_situations_horizontal_pane, 0, 127); - - return objects_and_situations_horizontal_pane; -} - -static GtkWidget *rec_SPACE_VIEW_box() -{ - GtkBox *right_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (right_box, GTK_WIDGET (rec_XYZ_box())); - gtk_box_append (right_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - gtk_box_append (right_box, GTK_WIDGET (rec_ZOOM_box())); - - GtkBox *central_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); - - // TODO - gtk_box_append (central_box, GTK_WIDGET (widget_get_image_E_coli())); - // ui_setup_glarea (0, GTK_WIDGET (central_box)); - - gtk_box_append (central_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); - gtk_box_append (central_box, GTK_WIDGET (right_box)); - return GTK_WIDGET (central_box); -} - -static GtkWidget *rec_SPACE_EDIT_CONTROL_box() -{ - return gtk_label_new - ("_____________\n SPACE EDIT\n controls\n'''''''''''''''''''''''"); -} - -static GtkWidget *rec_SEQUENCE_CONTROL_box() -{ - GtkBox *SEQUENCE_CONTROL_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); - - GtkBox *DO_UNDO_REDO_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\ - a progress bar showing the time elapsed during the simulation"))); - gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET (gtk_progress_bar_new ())); - GtkAdjustment *adjust = gtk_adjustment_new (30, 0, 100, 1, 0, 0); - gtk_box_append (DO_UNDO_REDO_box, - GTK_WIDGET (gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjust))); - gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\ - DO - UNDO - REDO"))); - gtk_widget_set_size_request (GTK_WIDGET (DO_UNDO_REDO_box), LOWER_COMPARTMENT_PARTITION, 0); - - gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (DO_UNDO_REDO_box)); - gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (gtk_button_new_with_label ("R U N / S T O P"))); - gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (gtk_button_new_with_label ("SPEED UP <> SLOW DOWN"))); - gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (gtk_button_new_with_label ("STEP by STEP (+ show active rule)"))); - - return GTK_WIDGET (SEQUENCE_CONTROL_box); -} - -/******************************************************************************/ -/* g e t S T A T E p a g e */ -/******************************************************************************/ - -/* L'image de l'état de l'espace (au centre) est entourée par trois panneaux: - * Si on les nomme selon leur fonction, - * - * - CONTROL ou EDIT en bas permet de contrôler / choisir un état et / ou de l'éditer - * en mode EDIT, seuls les outils d'édition de l'état sont disponibles - * en mode EXEC, seuls les outils de déplacement dans la séquence sont disponibles - * - CAMERA à droite permet de choisir la position de la caméra - * - CONTRAST en haut permet de modifier un à un les contrastes des objets et des situations - * afin de mieux mettre en évidence l'objet ou le phénomène d'intérêt */ - -void *widget_get_state_page() -{ - GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (page_box, GTK_WIDGET (rec_OBJECTS_and_SITUATIONS())); - gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - gtk_box_append (page_box, GTK_WIDGET (rec_SPACE_VIEW_box())); - gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - if (fsm_get_exec_edit ()) gtk_box_append (page_box, GTK_WIDGET (rec_SPACE_EDIT_CONTROL_box())); - else gtk_box_append (page_box, GTK_WIDGET (rec_SEQUENCE_CONTROL_box())); - return GTK_WIDGET (page_box); -} - -