WIP: cleaning reset_all_situations_transparencies_to_value()

This commit is contained in:
Jean Sirmai 2024-07-20 19:04:08 +02:00
parent a9b4874956
commit d3e050641d
Signed by: jean
GPG Key ID: FB3115C340E057E3
8 changed files with 123 additions and 210 deletions

View File

@ -47,7 +47,8 @@ int fsm_get_SITUATIONS_box_RESET_VALUE ();
void fsm_set_EXEC_EDIT (int value);
void fsm_set_STATE_RULES_DATA (int value);
void fsm_set_OBJECTS_box_RESET_VALUE (int value);
void fsm_set_SITUATIONS_box_RESET_VALUE (int value);
void fsm_reset_all_objects_transparencies_at_value (int value);
void fsm_reset_all_situations_transparencies_at_value (int value);

View File

@ -67,7 +67,7 @@ void on_glarea_unrealize (GtkWidget *widget);
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
void on_OBJECTS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data);
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_clicked_HOME (GtkWidget *btt_reset, gpointer data);
//void on_clicked_MENU_list_box (GtkWidget *btt_reset, gpointer data);

View File

@ -38,6 +38,8 @@
/* W I N D O W S */
/******************************************************************************/
void widget_create_windows (GtkApplication *app);
void widget_create_main_window (GtkApplication *app);
void widget_create_dialog_window (GtkApplication *app);
void widget_create_text_window (GtkApplication *app);
@ -61,7 +63,8 @@ GtkWidget *widget_rec_state_page();
GtkWidget *widget_rec_rules_page();
GtkWidget *widget_rec_stock_page();
void reset_all_objects_transparencies_to_value (GtkScrollbar *object_bar[], int value);
void reset_all_objects_transparencies_to_value (int value);
void reset_all_situations_transparencies_to_value (int value);
GtkWidget *widget_rec_stock_text (gchar *text_name);

View File

@ -65,13 +65,26 @@ void fsm_set_STATE_RULES_DATA (int value)
}
}
void fsm_set_OBJECTS_box_RESET_VALUE (int value)
void fsm_reset_all_objects_transparencies_at_value (int value)
{
if (choice_OBJECTS_box_RESET_VALUE != value) {
// if (choice_OBJECTS_box_RESET_VALUE != value) { << NON: Je veux pouvoir
// d'emblée tout remettre à zéro sans avoir à manipuler le curseur auparavant.
// Tant pis si cette fonction s'exécute parce qu'un reset inutile a été demandé.
debug_printing (value, 2); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
reset_all_objects_transparencies_to_value (NULL, value);
}
reset_all_objects_transparencies_to_value (value);
}
void fsm_reset_all_situations_transparencies_at_value (int value)
{
// if (choice_SITUATIONS_box_RESET_VALUE != value) { << NON: Je veux pouvoir
// d'emblée tout remettre à zéro sans avoir à manipuler le curseur auparavant.
// Tant pis si cette fonction s'exécute parce qu'un reset inutile a été demandé.
debug_printing (value, 3); // SITUATIONS_box_RESET_VALUE is sub_automaton 3
choice_SITUATIONS_box_RESET_VALUE = value;
reset_all_situations_transparencies_to_value (value);
}
void fsm_set_SITUATIONS_box_RESET_VALUE (int value)

View File

@ -30,7 +30,7 @@
#include "../include/signal.h"
#include "../include/widget.h"
/* Sur quel modèle se guider pour structurer le client gem-graph ?
* https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel
@ -134,6 +134,10 @@
*/
#include "../include/widget.h"
#include "../include/signal.h"
int main (int argc, char **argv)
{
GtkApplication *app;
@ -142,6 +146,7 @@ int main (int argc, char **argv)
app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
if (0) widget_create_windows (app); // < Erreur de segmentation
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);

View File

@ -312,78 +312,17 @@ void on_toggle_STATE_RULES_DATA (GtkWidget *toggled_button, gpointer user_data)
switch_STATE_RULES_DATA();
}
}
void on_OBJECTS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{
GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar);
double db = gtk_adjustment_get_value (adj_obj);
puts("on_OBJECTS_box_DO_RESET");
fsm_set_OBJECTS_box_RESET_VALUE (db);
fsm_reset_all_objects_transparencies_at_value (gtk_adjustment_get_value (adj_obj));
}
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data)
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{
puts("on_SITUATIONS_box_DO_RESET");
fsm_set_SITUATIONS_box_RESET_VALUE (1);
GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar);
fsm_reset_all_situations_transparencies_at_value (gtk_adjustment_get_value (adj_situ));
}

View File

@ -42,6 +42,17 @@ void *widget_topbar_get_main_window() { return main_window; }
void *widget_topbar_get_dialog_window() { return dialog_window; }
void *widget_topbar_get_text_window() { return text_window; }
void widget_create_windows (GtkApplication *app)
{
main_window = GTK_WINDOW (gtk_application_window_new (app));
dialog_window = GTK_WINDOW (gtk_application_window_new (app));
text_window = GTK_WINDOW (gtk_application_window_new (app));
widget_topbar_design_main_window (main_window);
widget_topbar_design_dialog_window (main_window, dialog_window);
widget_topbar_design_text_window (main_window, text_window);
}
void widget_create_main_window (GtkApplication *app)
{ main_window = GTK_WINDOW (gtk_application_window_new (app)); }

View File

@ -34,14 +34,15 @@
#define UPPER_COMPARTMENT_PARTITION 600
#define LOWER_COMPARTMENT_PARTITION 1300
/* L'image de l'état de l'espace (au centre) est entourée par trois panneaux:
* "haut", "milieu", "bas"
/* 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.
*
* ou encore, si l'on nomme ces panneaux 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
* 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 */
@ -86,154 +87,94 @@ static GtkBox *rec_ZOOM_box()
}
static GtkScrollbar *object_bar [n_objects];
static GtkAdjustment *adjust_bar [n_objects];
static GtkAdjustment *object_adjust [n_objects];
void reset_all_objects_transparencies_to_value (GtkScrollbar *object_bar[],
int value)
void reset_all_objects_transparencies_to_value (int value)
{
for (int i = 0; i < n_objects; i++)
gtk_adjustment_set_value (adjust_bar [i], value);
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_with_label ("r\ne\ns\ne\nt");
g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_OBJECTS_box_DO_RESET), reset_scrollbar);
gtk_box_append (objects_box, btt_reset);
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_with_label ("r\ne\ns\ne\nt");
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]));
}
reset_all_objects_transparencies_to_value (-1);
// GtkAdjustment *adjust_bar [n_objects]; // (value, lower, upper, step_increment, page_increment, page_size)
for (int i = 0; i < n_objects; i++)
{
adjust_bar [i] = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 0);
object_bar [i] = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust_bar [i]));
gtk_box_append (objects_box, GTK_WIDGET (object_bar [i]));
}
// for (int i = 0; i < n_objects; i++) reset_all_objects_transparency_to_value (*object_bar, 100);
return objects_box;
}
static GtkScrollbar *situation_bar [n_situations];
static GtkAdjustment *situation_adjust [n_situations];
void 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_with_label ("r\ne\ns\ne\nt");
g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_SITUATIONS_box_DO_RESET), NULL);
gtk_box_append (situations_box, btt_reset);
GtkAdjustment *adjust = NULL;
for (int i = 0; i < 128; i++)
{
adjust = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 4);
GtkScrollbar *scrollbar_i = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust));
char tooltip_text[8];
sprintf(tooltip_text, "\n%d\n", i);
if (0 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), "transcription");
if (1 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), "transport Na/K");
if (2 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), "ubiquitination");
if (3 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), "glycolyse aérobie");
if (4 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), "cycle de Krebs");
if (5 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), "shunt des pentoses");
if (6 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), "any situation name");
if (7 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), tooltip_text);
gtk_box_append (situations_box, GTK_WIDGET (scrollbar_i));
}
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_with_label ("r\ne\ns\ne\nt");
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]));
}
reset_all_situations_transparencies_to_value (-1);
return situations_box;
}
/*
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);
*/
/******************************************************************************/
/* 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 */