diff --git a/include/widget.h b/include/widget.h index ba22532..1acb228 100644 --- a/include/widget.h +++ b/include/widget.h @@ -55,6 +55,11 @@ void *widget_get_state_page(); void *widget_get_rules_page(); void *widget_get_stock_page(); +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); diff --git a/src/widget/state.c b/src/widget/state.c.xx similarity index 100% rename from src/widget/state.c rename to src/widget/state.c.xx diff --git a/src/widget/state/bottom.c b/src/widget/state/bottom.c new file mode 100644 index 0000000..6b577d4 --- /dev/null +++ b/src/widget/state/bottom.c @@ -0,0 +1,77 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* 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 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 */ + +void *widget_get_space_edit_control() +{ + return gtk_label_new + ("_____________\n SPACE EDIT\n controls\n'''''''''''''''''''''''"); +} + +void *widget_get_sequence_control() +{ + 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); +} + diff --git a/src/widget/state/distrib.c b/src/widget/state/distrib.c new file mode 100644 index 0000000..2dc779a --- /dev/null +++ b/src/widget/state/distrib.c @@ -0,0 +1,67 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* 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" + + +/* 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 */ + + + +/******************************************************************************/ +/* g e t S T A T E p a g e */ +/******************************************************************************/ + + +void *widget_get_state_page() +{ + GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (page_box, GTK_WIDGET (widget_get_graph_view_control())); + gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (page_box, GTK_WIDGET (widget_get_space_view())); + 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 (widget_get_space_edit_control())); + else gtk_box_append (page_box, GTK_WIDGET (widget_get_sequence_control())); + return GTK_WIDGET (page_box); +} + + diff --git a/src/widget/state/middle.c b/src/widget/state/middle.c new file mode 100644 index 0000000..8613a89 --- /dev/null +++ b/src/widget/state/middle.c @@ -0,0 +1,107 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* 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" + + +/* 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; +} + + +void *widget_get_space_view() +{ + 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); +} + + diff --git a/src/widget/state/top.c b/src/widget/state/top.c new file mode 100644 index 0000000..db876d8 --- /dev/null +++ b/src/widget/state/top.c @@ -0,0 +1,171 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* 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 + +/* 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 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 */ +/******************************************************************************/ + +void *widget_get_graph_view_control() +{ + 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; +} + +