WIP: machine à états en construction (in_depth.c)
This commit is contained in:
parent
e8b0427aac
commit
bc5b03eaec
56
callback.c
56
callback.c
|
@ -160,58 +160,30 @@ 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_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_status (0);
|
// gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "document-edit-symbolic");
|
||||||
} else {
|
// 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), "document-edit-symbolic");
|
// gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " off ");
|
||||||
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "text-editor-symbolic"); // I hesitate
|
// gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), FALSE);
|
||||||
set_status (1);
|
|
||||||
// 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
|
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " off ");
|
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), FALSE);
|
|
||||||
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_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 ");
|
// gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), "stop");
|
||||||
set_status (0);
|
|
||||||
} else {
|
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), "stop");
|
|
||||||
set_status (1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// in_depth.c : enum { STATE, RULES, MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
|
|
||||||
|
|
||||||
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_status()) {
|
// gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "state");
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "state");
|
// gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "rules");
|
||||||
window_main_child (main_window, 0); // 0 = state page (see contain.c)
|
|
||||||
set_status (0);
|
|
||||||
} else {
|
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "rules");
|
|
||||||
window_main_child (main_window, 1); // 1 = rules page (see contain.c)
|
|
||||||
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_status()) {
|
// gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe");
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe");
|
// gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret");
|
||||||
window_main_child (main_window, 2); // 2 = measures page (see contain.c)
|
|
||||||
set_status (0);
|
|
||||||
} else {
|
|
||||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret");
|
|
||||||
window_main_child (main_window, 3); // 3 = observe page (see contain.c)
|
|
||||||
set_status (1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,8 +148,8 @@ GtkWidget *get_SPACE_EDIT_controls_box() {
|
||||||
|
|
||||||
|
|
||||||
void window_main_child_bottom (GtkBox *page_box){
|
void window_main_child_bottom (GtkBox *page_box){
|
||||||
if (! get_status ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
|
// 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()));
|
// gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void icons_for_fun (GtkHeaderBar *header_bar);
|
static void icons_for_fun (GtkHeaderBar *header_bar);
|
||||||
|
|
98
in_depth.c
98
in_depth.c
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
// (exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
// (exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
||||||
|
|
||||||
enum {
|
enum { // S T A T E S
|
||||||
EXEC_STOP,
|
EXEC_STOP,
|
||||||
EXEC_RUN,
|
EXEC_RUN,
|
||||||
EXEC_STOP_EDIT_RULE,
|
EXEC_STOP_EDIT_RULE,
|
||||||
|
@ -24,49 +24,77 @@ enum {
|
||||||
CONFIGURE
|
CONFIGURE
|
||||||
};
|
};
|
||||||
|
|
||||||
static int status = EXEC_STOP;
|
static int status = EXEC_STOP; // int get_status () {return status;}
|
||||||
int get_status () {return status;}
|
|
||||||
|
|
||||||
|
enum { // T R A N S I T I O N S
|
||||||
|
EXEC_TO_RUN,
|
||||||
|
RUN_TO_EXEC,
|
||||||
|
};
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* 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) {
|
void let_transition_be (int asked) {
|
||||||
status = prescribed; if (0) printf ("status = %d\n", status);
|
switch (asked) {
|
||||||
|
case (0) : // EXEC_TO_RUN
|
||||||
switch (status) {
|
|
||||||
case (0) : /* EXEC_STOP */
|
|
||||||
status = EXEC_RUN;
|
status = EXEC_RUN;
|
||||||
break;
|
break;
|
||||||
case (1) : /* EXEC_RUN */
|
case (1) : // RUN_TO_EXEC
|
||||||
|
// 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
|
||||||
status = EXEC_STOP;
|
status = EXEC_STOP;
|
||||||
break;
|
break;
|
||||||
case (2) : /* EXEC_STOP_EDIT_STOP */
|
|
||||||
status = EXEC_RUN_EDIT_RULE;
|
|
||||||
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 : ;
|
default : ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
void set_status (int prescribed) {
|
||||||
|
status = prescribed; if (0) printf ("status = %d\n", status);
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case (0) : // EXEC_STOP
|
||||||
|
status = EXEC_RUN;
|
||||||
|
break;
|
||||||
|
case (1) : // EXEC_RUN
|
||||||
|
// 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
|
||||||
|
status = EXEC_STOP;
|
||||||
|
break;
|
||||||
|
case (2) : // EXEC_STOP_EDIT_STOP
|
||||||
|
status = EXEC_RUN_EDIT_RULE;
|
||||||
|
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 : ;
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
|
Loading…
Reference in New Issue