WIP: lecture + mises en forme (arrays) perso; qui fait quoi ?

This commit is contained in:
Jean Sirmai 2023-11-10 09:51:37 +01:00
parent 97bc0ef4b6
commit b8e70e8231
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 80 additions and 293 deletions

View File

@ -1,143 +0,0 @@
static GLuint *buffer_lines_origin = NULL;
---
long get_buffer_lines_size() {return buffer_lines_size / 2;}
void inc_buffer_lines_size(long inc) {buffer_lines_size += inc * 2;}
void dec_buffer_lines_size(long dec) {buffer_lines_size -= dec * 2;}
void xxx_draw_line (GLuint *lines_origin, int a, int b, long lines_index)
{
// https://docs.gtk.org/glib/func.realloc.html
printf("xxx_draw_line %ld\n", lines_index);
buffer_lines_origin = g_realloc(lines_origin, sizeof(GLuint) * 2);
*(lines_origin + lines_index + 0) = a; // lines_index ++;
*(lines_origin + lines_index + 1) = b; // lines_index ++;
}
/* (gdb) help
List of classes of commands:
aliases -- User-defined aliases of other commands.
breakpoints -- Making program stop at certain points.
data -- Examining data.
files -- Specifying and examining files.
internals -- Maintenance commands.
obscure -- Obscure features.
running -- Running the program.
stack -- Examining the stack.
status -- Status inquiries.
support -- Support facilities.
text-user-interface -- TUI is the GDB text based interface.
tracepoints -- Tracing of program execution without stopping the program.
user-defined -- User-defined commands.
*/
-------------------------------------------------------------------------------------------
GLuint arrows[] = {
1, 0, 0, 0, 0,
/* 1, 1, 1, 0, 0, */
/* 1, 2, 2, 1, 1, */
/* 1, 3, 2, 2, 1, */
/* 1, 4, 3, 0, 1, */
/* 1, 5, 3, 0, 2, */
/* 1, 1, 3, 0, 2, */
/* 1, 0, 2, 0, 2, */
/* 1, 5, 2, 1, 1, */
// load, site, x, y, z
};
static void get_model_data_and_user_preferences(){
model_space_size_x = 1; // 0 < model_space_size_x
model_space_size_y = 1; // 0 < model_space_size_y
model_space_size_z = 1; // 0 < model_space_size_z
// XXX ONLY space drawed, no arrows yet
model_arrows_nb = sizeof(arrows); // assert : l'emplacement des flèches est contraint
// par model_space_size_x, y, z et le nombre de sites
central_stars_nb = 0; // à calculer TODO
// ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites)
central_stars_nb = model_arrows_nb;
// pref_mark_unit_space = 0; // 0 = no marks, 1 = 1st, 2 = last, 3 = both
// pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix
// pref_style_mix_colors = 0; // TODO
pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
// xyz, 0, x, y, z, xy, xz, yz, xyz
pref_test_diagonal = 1;
}
-------------------------------------------------------------------------------------------
in buffers.c (line 283)
static void draw_line (GLuint *lines_origin, int a, int b)
{
xxx_draw_line (lines_origin, a, b, lines_index);
lines_index += 2;
// *(lines_origin + lines_index) = a; lines_index ++;
// *(lines_origin + lines_index) = b; lines_index ++;
}
---------------------------------------------------------------------------
[ n] load site x y z ---- < arrows array > ------------------------------------------------------------
[ 0] = 1, 0, 0, 0, 0
[ 1] = 0, 0, 0, 217808480, 32708
[ 2] = 217809344, 32708, 217807968, 32708, 217810080
[ 3] = 32708, -69297984, 32707, 229965808, 32708
[ 4] = 229944176, 32708, 217808608, 32708, 229970384
[ 5] = 32708, 217808576, 32708, 217809024, 32708
[ 6] = 217808992, 32708, -69297888, 32707, 229954976
[ 7] = 32708, 217808512, 32708, 229949456, 32708
[ 8] = 229942736, 32708, 0, 0, 0
[ 9] = 0, 0, 0, 226977440, 32708
[10] = 217810048, 32708, 217808352, 32708, 217808704
[11] = 32708, -69297600, 32707, 217808448, 32708
[12] = 217807808, 32708, 217808896, 32708, 217809312
[13] = 32708, 217807872, 32708, 225561296, 32708
[14] = 217814880, 32708, 217814944, 32708, 217807776
[15] = 32708, 229974752, 32708, 217811040, 32708
[16] = 229947200, 32708, 0, 0, 33506144
[17] = 0, 0, 0, 0, 0
[18] = 33204048, 0, 0, 0, 33587952
[19] = 0, 30217696, 0, 30245088, 0
[ n] load site x y z ---- < arrows array > ------------------------------------------------------------
[ 0] = 1, 0, 0, 0, 0
[ 1] = 0, 0, 0, 2105314912, 32683
[ 2] = 2105315776, 32683, 2105314400, 32683, 2105316512
[ 3] = 32683, 2019551424, 32683, 2117545968, 32683
[ 4] = 2117524336, 32683, 2105315040, 32683, 2117550544
[ 5] = 32683, 2105315008, 32683, 2105315456, 32683
[ 6] = 2105315424, 32683, 2019551520, 32683, 2117535136
[ 7] = 32683, 2105314944, 32683, 2117529616, 32683
[ 8] = 2117522896, 32683, 0, 0, 0
[ 9] = 0, 0, 0, 2114557600, 32683
[10] = 2105316480, 32683, 2105314784, 32683, 2105315136
[11] = 32683, 2019551808, 32683, 2105314880, 32683
[12] = 2105314240, 32683, 2105315328, 32683, 2105315744
[13] = 32683, 2105314304, 32683, 2113141456, 32683
[14] = 2105321312, 32683, 2105321376, 32683, 2105314208
[15] = 32683, 2117554912, 32683, 2105317472, 32683
[16] = 2117527360, 32683, 0, 0, 16032608
[17] = 0, 0, 0, 0, 0
[18] = 15766240, 0, 0, 0, 15950576
[19] = 0, 12654048, 0, 12681440, 0

View File

@ -96,21 +96,11 @@ static void gem_graph_client_application_init(GemGraphClientApplication *self)
self); self);
// Setup shortcuts // Setup shortcuts
gtk_application_set_accels_for_action(GTK_APPLICATION(self), gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.quit", (const char *[]) { "<primary>q", NULL });
"app.quit", gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.editmode", (const char *[]) { "<primary>e", NULL });
(const char *[]) { "<primary>q", NULL }); gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.runmode", (const char *[]) { "<primary>r", NULL });
gtk_application_set_accels_for_action(GTK_APPLICATION(self), gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.presentmode",(const char *[]) { "<primary>p", NULL });
"app.editmode", gtk_application_set_accels_for_action(GTK_APPLICATION(self), "app.savefile", (const char *[]) { "<primary>s", NULL });
(const char *[]) { "<primary>e", NULL });
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
"app.runmode",
(const char *[]) { "<primary>r", NULL });
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
"app.presentmode",
(const char *[]) { "<primary>p", NULL });
gtk_application_set_accels_for_action(GTK_APPLICATION(self),
"app.savefile",
(const char *[]) { "<primary>s", NULL });
application = self; application = self;

View File

@ -4,8 +4,8 @@
<!-- interface-name gem-graph.ui --> <!-- interface-name gem-graph.ui -->
<requires lib="gtk" version="4.6"/> <requires lib="gtk" version="4.6"/>
<template class="GemGraphClientWindow" parent="GtkApplicationWindow"> <template class="GemGraphClientWindow" parent="GtkApplicationWindow">
<property name="default-height">900</property> <property name="default-height">700</property>
<property name="default-width">1400</property> <property name="default-width">440</property>
<property name="icon-name">application-x-executable</property> <property name="icon-name">application-x-executable</property>
<property name="title">GemGraph 0.1.0</property> <property name="title">GemGraph 0.1.0</property>
<style> <style>
@ -41,7 +41,7 @@
<object class="GtkOverlay" id="toast_overlay"> <object class="GtkOverlay" id="toast_overlay">
<child> <child>
<object class="GtkPaned" id="main_paned"> <object class="GtkPaned" id="main_paned">
<property name="position">400</property> <property name="position">440</property>
<child> <child>
<object class="GtkStack" id="side_stack"> <object class="GtkStack" id="side_stack">
<child> <child>
@ -52,11 +52,14 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox" id="run_controls"> <object class="GtkBox" id="run_controls">
<property name="margin-top">50</property> <property name="margin-top">0</property>
<property name="margin-bottom">50</property> <property name="margin-bottom">0</property>
<property name="orientation">horizontal</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkToggleButton" id="run_play_control"> <object class="GtkToggleButton" id="run_play_control">
<property name="margin-top">0</property>
<property name="margin-bottom">0</property>
<!--property name="label" translatable="yes">Hello !</property-->
<property name="icon-name"></property> <property name="icon-name"></property>
</object> </object>
</child> </child>
@ -70,6 +73,22 @@
</child> </child>
<child> <child>
<object class="GtkStack" id="runlib_stack"> <object class="GtkStack" id="runlib_stack">
<child>
<object class="GtkStackPage">
<property name="name">runlib_conditions_and_rules</property>
<property name="title" translatable="yes">Rules</property>
<property name="visible">True</property>
<property name="child">
<object class="GtkLabel" id="label_runlib_conditions_and_rules">
<property name="justify">center</property>
<property name="label" translatable="yes">&lt;b&gt;runlib_conditions_and_rules&lt;/b&gt;</property>
<property name="use-markup">True</property>
<property name="margin-top">50</property>
<property name="margin-bottom">50</property>
</object>
</property>
</object>
</child>
<child> <child>
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">runlib_objects</property> <property name="name">runlib_objects</property>
@ -91,26 +110,10 @@
</property> </property>
</object> </object>
</child> </child>
<child>
<object class="GtkStackPage">
<property name="name">runlib_conditions_and_rules</property>
<property name="title" translatable="yes">Rules &amp; Conds</property>
<property name="visible">True</property>
<property name="child">
<object class="GtkLabel" id="label_runlib_conditions_and_rules">
<property name="justify">center</property>
<property name="label" translatable="yes">&lt;b&gt;runlib_conditions_and_rules&lt;/b&gt;</property>
<property name="use-markup">True</property>
<property name="margin-top">50</property>
<property name="margin-bottom">50</property>
</object>
</property>
</object>
</child>
<child> <child>
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">runlib_states</property> <property name="name">runlib_states</property>
<property name="title" translatable="yes">Savedstates</property> <property name="title" translatable="yes">States</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="child"> <property name="child">
<object class="GtkLabel" id="label_runlib_states"> <object class="GtkLabel" id="label_runlib_states">
@ -346,3 +349,4 @@
</section> </section>
</menu> </menu>
</interface> </interface>

View File

@ -80,45 +80,19 @@ static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass)
bytes = g_bytes_new_take(contents, len); bytes = g_bytes_new_take(contents, len);
gtk_widget_class_set_template(GTK_WIDGET_CLASS(klass), bytes); gtk_widget_class_set_template(GTK_WIDGET_CLASS(klass), bytes);
gtk_widget_class_bind_template_child(widget_class, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_titlebar);
GemGraphClientWindow, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_stack);
main_titlebar); gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, side_stack);
gtk_widget_class_bind_template_child(widget_class, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_paned);
GemGraphClientWindow, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_button_mode);
main_stack); gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, main_button_sidebar);
gtk_widget_class_bind_template_child(widget_class, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, toast_revealer);
GemGraphClientWindow, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, toast_close_button);
side_stack); gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, toast_text);
gtk_widget_class_bind_template_child(widget_class, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, run_glarea);
GemGraphClientWindow, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, run_controls);
main_paned); gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, runlib_stack);
gtk_widget_class_bind_template_child(widget_class, gtk_widget_class_bind_template_child(widget_class, GemGraphClientWindow, runlib_objects);
GemGraphClientWindow,
main_button_mode);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
main_button_sidebar);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
toast_revealer);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
toast_close_button);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
toast_text);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
run_glarea);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
run_controls);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
runlib_stack);
gtk_widget_class_bind_template_child(widget_class,
GemGraphClientWindow,
runlib_objects);
} }
static void gem_graph_client_window_init(GemGraphClientWindow *self) static void gem_graph_client_window_init(GemGraphClientWindow *self)
@ -138,56 +112,26 @@ static void gem_graph_client_window_init(GemGraphClientWindow *self)
void ui_set_stack(const char *mode) void ui_set_stack(const char *mode)
{ {
if (window->main_stack == NULL) { if (window->main_stack == NULL) { g_printerr("Can't find self->main_stack !\n"); return;}
g_printerr("Can't find self->main_stack !\n"); if (window->side_stack == NULL) { g_printerr("Can't find self->side_stack !\n"); return;}
return; gtk_stack_set_visible_child_full(window->main_stack, mode, GTK_STACK_TRANSITION_TYPE_CROSSFADE);
} gtk_stack_set_visible_child_full(window->side_stack, mode, GTK_STACK_TRANSITION_TYPE_CROSSFADE);
if (window->side_stack == NULL) {
g_printerr("Can't find self->side_stack !\n");
return;
}
gtk_stack_set_visible_child_full(window->main_stack,
mode,
GTK_STACK_TRANSITION_TYPE_CROSSFADE);
gtk_stack_set_visible_child_full(window->side_stack,
mode,
GTK_STACK_TRANSITION_TYPE_CROSSFADE);
// Switch on the first letter of the mode, because switch is soooo simple :) // Switch on the first letter of the mode, because switch is soooo simple :)
switch(mode[0]) { switch(mode[0]) {
case 'e': case 'e': gtk_menu_button_set_icon_name(window->main_button_mode, "document-edit-symbolic"); break;
gtk_menu_button_set_icon_name(window->main_button_mode, case 'r': gtk_menu_button_set_icon_name(window->main_button_mode, "system-run-symbolic"); break;
"document-edit-symbolic"); case 'p': gtk_menu_button_set_icon_name(window->main_button_mode, "x-office-presentation-symbolic");break;
break; case 'h': gtk_paned_set_position(window->main_paned, 0);
case 'r': gtk_menu_button_set_icon_name(window->main_button_mode, "user-home-symbolic"); break;
gtk_menu_button_set_icon_name(window->main_button_mode, default: break;
"system-run-symbolic");
break;
case 'p':
gtk_menu_button_set_icon_name(window->main_button_mode,
"x-office-presentation-symbolic");
break;
case 'h':
gtk_paned_set_position(window->main_paned, 0);
gtk_menu_button_set_icon_name(window->main_button_mode,
"user-home-symbolic");
break;
default:
break;
} }
} }
void ui_send_internal_notification(const char *message) void ui_send_internal_notification(const char *message)
{ {
if (window->toast_revealer == NULL) { if (window->toast_revealer == NULL) {g_printerr("Can't find self->toast_overlay !\n"); return;}
g_printerr("Can't find self->toast_overlay !\n"); if (window->toast_text == NULL) {g_printerr("Can't find self->toast_overlay !\n"); return;}
return;
}
if (window->toast_text == NULL) {
g_printerr("Can't find self->toast_overlay !\n");
return;
}
gtk_label_set_label(window->toast_text, message); gtk_label_set_label(window->toast_text, message);
gtk_revealer_set_reveal_child(window->toast_revealer, true); gtk_revealer_set_reveal_child(window->toast_revealer, true);
@ -195,15 +139,8 @@ void ui_send_internal_notification(const char *message)
void ui_close_internal_notification(void) void ui_close_internal_notification(void)
{ {
if (window->toast_revealer == NULL) { if (window->toast_revealer == NULL) {g_printerr("Can't find self->toast_overlay !\n"); return;}
g_printerr("Can't find self->toast_overlay !\n"); if (window->toast_text == NULL) {g_printerr("Can't find self->toast_overlay !\n"); return;}
return;
}
if (window->toast_text == NULL) {
g_printerr("Can't find self->toast_overlay !\n");
return;
}
gtk_revealer_set_reveal_child(window->toast_revealer, false); gtk_revealer_set_reveal_child(window->toast_revealer, false);
} }
@ -217,20 +154,10 @@ static inline GtkWidget *create_axis_slider(int axis)
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
switch (axis) { switch (axis) {
case X_AXIS: case X_AXIS: text = "X"; break;
text = "X"; case Y_AXIS: text = "Y"; break;
break; case Z_AXIS: text = "Z"; break;
default: g_assert_not_reached();
case Y_AXIS:
text = "Y";
break;
case Z_AXIS:
text = "Z";
break;
default:
g_assert_not_reached();
} }
label = gtk_label_new(text); label = gtk_label_new(text);
@ -238,8 +165,7 @@ static inline GtkWidget *create_axis_slider(int axis)
gtk_widget_show(label); gtk_widget_show(label);
adj = gtk_adjustment_new(0.0, 0.0, 360.0, 1.0, 12.0, 0.0); adj = gtk_adjustment_new(0.0, 0.0, 360.0, 1.0, 12.0, 0.0);
g_signal_connect(adj, "value-changed", g_signal_connect(adj, "value-changed", G_CALLBACK(on_axis_value_change),
G_CALLBACK(on_axis_value_change),
GINT_TO_POINTER(axis)); GINT_TO_POINTER(axis));
slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adj); slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adj);
gtk_box_append(GTK_BOX(box), slider); gtk_box_append(GTK_BOX(box), slider);
@ -290,10 +216,7 @@ void ui_toggle_sidebar(void)
{ {
int position = gtk_paned_get_position(window->main_paned); int position = gtk_paned_get_position(window->main_paned);
if (position != 0) { if (position != 0) gtk_paned_set_position(window->main_paned, 0);
gtk_paned_set_position(window->main_paned, 0); else gtk_paned_set_position(window->main_paned, 400);
} else {
gtk_paned_set_position(window->main_paned, 400);
}
} }

View File

@ -0,0 +1,13 @@
<child>
<object class="GtkBox" id="run_controls">
<property name="margin-top">50</property>
<property name="margin-bottom">50</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkToggleButton" id="run_play_control">
<property name="icon-name"></property>
</object>
</child>
</object>
</child>