WIP: machine à états dans 'in_depth'
This commit is contained in:
parent
c7bbc8b1e6
commit
e8b0427aac
26
callback.c
26
callback.c
|
@ -160,31 +160,31 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec)
|
void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec)
|
||||||
{
|
{
|
||||||
if (get_exec_edit_mode()) {
|
if (get_status()) {
|
||||||
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "power-profile-balanced-rtl-symbolic");
|
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "power-profile-balanced-rtl-symbolic");
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run ");
|
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run ");
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), TRUE);
|
gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), TRUE);
|
||||||
set_exec_edit_mode (0);
|
set_status (0);
|
||||||
} else {
|
} else {
|
||||||
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "document-edit-symbolic");
|
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "document-edit-symbolic");
|
||||||
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "text-editor-symbolic"); // I hesitate
|
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "text-editor-symbolic"); // I hesitate
|
||||||
set_exec_edit_mode (1);
|
set_status (1);
|
||||||
// Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon)
|
// Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon)
|
||||||
// S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues
|
// S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " off ");
|
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " off ");
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), FALSE);
|
gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), FALSE);
|
||||||
set_run_xor_stop_exec (0);
|
set_status (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data)
|
void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data)
|
||||||
{
|
{
|
||||||
if (get_run_xor_stop_exec() && ! get_exec_edit_mode()) {
|
if (get_status() && ! get_status()) {
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run ");
|
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run ");
|
||||||
set_run_xor_stop_exec (0);
|
set_status (0);
|
||||||
} else {
|
} else {
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), "stop");
|
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), "stop");
|
||||||
set_run_xor_stop_exec (1);
|
set_status (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,26 +192,26 @@ void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data)
|
||||||
|
|
||||||
void on_toggle_state_rules (GtkWidget *btt_toggle_state_rules, gpointer data)
|
void on_toggle_state_rules (GtkWidget *btt_toggle_state_rules, gpointer data)
|
||||||
{
|
{
|
||||||
if (get_run_xor_stop_exec()) {
|
if (get_status()) {
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "state");
|
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "state");
|
||||||
window_main_child (main_window, 0); // 0 = state page (see contain.c)
|
window_main_child (main_window, 0); // 0 = state page (see contain.c)
|
||||||
set_run_xor_stop_exec (0);
|
set_status (0);
|
||||||
} else {
|
} else {
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "rules");
|
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "rules");
|
||||||
window_main_child (main_window, 1); // 1 = rules page (see contain.c)
|
window_main_child (main_window, 1); // 1 = rules page (see contain.c)
|
||||||
set_run_xor_stop_exec (1);
|
set_status (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointer data)
|
void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointer data)
|
||||||
{
|
{
|
||||||
if (get_observ_interpret()) {
|
if (get_status()) {
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe");
|
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe");
|
||||||
window_main_child (main_window, 2); // 2 = measures page (see contain.c)
|
window_main_child (main_window, 2); // 2 = measures page (see contain.c)
|
||||||
set_observ_interpret (0);
|
set_status (0);
|
||||||
} else {
|
} else {
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret");
|
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret");
|
||||||
window_main_child (main_window, 3); // 3 = observe page (see contain.c)
|
window_main_child (main_window, 3); // 3 = observe page (see contain.c)
|
||||||
set_observ_interpret (1);
|
set_status (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ GtkWidget *get_SPACE_EDIT_controls_box() {
|
||||||
|
|
||||||
|
|
||||||
void window_main_child_bottom (GtkBox *page_box){
|
void window_main_child_bottom (GtkBox *page_box){
|
||||||
if (! get_exec_edit_mode ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
|
if (! get_status ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
|
||||||
else gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
|
else gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ void window_main_child (GtkWindow *main_window, int selected_page){
|
||||||
gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box()));
|
gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box()));
|
||||||
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
||||||
window_main_child_bottom (page_box);
|
window_main_child_bottom (page_box);
|
||||||
// if (get_exec_edit_mode ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
|
// if (get_status ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
|
||||||
// else gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
|
// else gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
|
||||||
gtk_window_set_child (main_window, GTK_WIDGET (page_box));
|
gtk_window_set_child (main_window, GTK_WIDGET (page_box));
|
||||||
break;
|
break;
|
||||||
|
|
67
in_depth.c
67
in_depth.c
|
@ -7,17 +7,17 @@
|
||||||
/* S T A T E S */
|
/* S T A T E S */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/*
|
// (exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
||||||
(exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// EXEC, EDIT, RUN, STOP, STATE, RULES, MEASURE, OBSERVE, INTERPRET, HELP, CONFIG
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
EXEC_STOP, EXEC_RUN,
|
EXEC_STOP,
|
||||||
EXEC_STOP_EDIT_RULE, EXEC_RUN_EDIT_RULE,
|
EXEC_RUN,
|
||||||
EXEC_STOP_EDIT_MEASURE, EXEC_RUN_EDIT_MEASURE,
|
EXEC_STOP_EDIT_RULE,
|
||||||
EDIT_STATE, EDIT_RULE,
|
EXEC_RUN_EDIT_RULE,
|
||||||
|
EXEC_STOP_EDIT_MEASURE,
|
||||||
|
EXEC_RUN_EDIT_MEASURE,
|
||||||
|
EDIT_STATE,
|
||||||
|
EDIT_RULE,
|
||||||
OBSERVE,
|
OBSERVE,
|
||||||
INTERPRET,
|
INTERPRET,
|
||||||
HELP,
|
HELP,
|
||||||
|
@ -25,19 +25,48 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int status = EXEC_STOP;
|
static int status = EXEC_STOP;
|
||||||
|
int get_status () {return status;}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* T R A N S I T I O N S */
|
/* T R A N S I T I O N S */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
void set_status (int prescribed) {
|
||||||
|
status = prescribed; if (0) printf ("status = %d\n", status);
|
||||||
|
|
||||||
int get_exec_edit_mode () {return status;}
|
switch (status) {
|
||||||
void set_exec_edit_mode (int prescribed) {status = prescribed;}
|
case (0) : /* EXEC_STOP */
|
||||||
|
status = EXEC_RUN;
|
||||||
int get_run_xor_stop_exec () {return status;}
|
break;
|
||||||
void set_run_xor_stop_exec (int prescribed) {status = prescribed;}
|
case (1) : /* EXEC_RUN */
|
||||||
|
status = EXEC_STOP;
|
||||||
int get_observ_interpret () {return status;}
|
break;
|
||||||
void set_observ_interpret (int prescribed) {status = prescribed;}
|
case (2) : /* EXEC_STOP_EDIT_STOP */
|
||||||
|
status = EXEC_RUN_EDIT_RULE;
|
||||||
// if (0) printf ("status = %d\n", status);
|
break;
|
||||||
|
case (3) : /* EXEC_RUN_EDIT_RULE */
|
||||||
|
status = EXEC_STOP_EDIT_RULE;
|
||||||
|
break;
|
||||||
|
case (4) : /* EXEC_STOP_EDIT_MEASURE */
|
||||||
|
status = EXEC_RUN_EDIT_MEASURE;
|
||||||
|
break;
|
||||||
|
case (5) : /* EXEC_RUN_EDIT_MEASURE */
|
||||||
|
status = EXEC_STOP_EDIT_MEASURE;
|
||||||
|
break;
|
||||||
|
case (6) : /* EDIT_STATE */
|
||||||
|
break;
|
||||||
|
case (7) : /* EDIT_RULE */
|
||||||
|
break;
|
||||||
|
case (8) : /* OBSERVE */
|
||||||
|
break;
|
||||||
|
case (9) : /* INTERPRET */
|
||||||
|
break;
|
||||||
|
case (10) : /* HELP */
|
||||||
|
break;
|
||||||
|
case (11) : /* CONFIGURE */
|
||||||
|
break;
|
||||||
|
case (12) : /* OTHER */
|
||||||
|
break;
|
||||||
|
default : ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
10
in_depth.h
10
in_depth.h
|
@ -1,12 +1,6 @@
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
void set_exec_edit_mode (int prescribed);
|
void set_status (int prescribed);
|
||||||
int get_exec_edit_mode ();
|
int get_status ();
|
||||||
|
|
||||||
void set_run_xor_stop_exec (int prescribed);
|
|
||||||
int get_run_xor_stop_exec ();
|
|
||||||
|
|
||||||
void set_observ_interpret (int prescribed);
|
|
||||||
int get_observ_interpret ();
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue