Compare commits
No commits in common. "352b3ff7484244c633ad9c54bca8ceb600806390" and "b05510e48214a4e1cafd8837a92904c798b87a5f" have entirely different histories.
352b3ff748
...
b05510e482
|
@ -1,2 +0,0 @@
|
||||||
bin/*
|
|
||||||
build/*
|
|
178
Makefile
178
Makefile
|
@ -2,8 +2,7 @@
|
||||||
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
|
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
|
||||||
.DEFAULT_GOAL: all
|
.DEFAULT_GOAL: all
|
||||||
|
|
||||||
CPUS ?= $(shell (nproc --all || sysctl -n hw.ncpu) 2>/dev/null || echo 1)
|
NTHREADS= $(shell nproc)
|
||||||
MAKEFLAGS += --jobs=$(CPUS)
|
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=`pkg-config --cflags gtk4 gl glib-2.0 libxml-2.0`
|
CFLAGS=`pkg-config --cflags gtk4 gl glib-2.0 libxml-2.0`
|
||||||
|
@ -16,67 +15,144 @@ BINDIR=bin
|
||||||
BUILDDIR=build
|
BUILDDIR=build
|
||||||
SRCDIR=src
|
SRCDIR=src
|
||||||
|
|
||||||
SOURCES = $(shell find $(SRCDIR) -type f -name "*.c")
|
sources = $(shell find . -maxdepth 1 -type f -name "*.c")
|
||||||
OBJECTS = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
objects = $(patsubst %.c,%.o,$(sources))
|
||||||
DEPENDENCIES = $(patsubst %.c,$(BUILDDIR)/%.d,$(SOURCES))
|
dependencies = $(patsubst %.c,%.d,$(sources))
|
||||||
|
|
||||||
all: $(BINDIR)/gem-graph-client
|
all: myprogram
|
||||||
|
|
||||||
-include /etc/os-release
|
-include $(dependencies)
|
||||||
|
|
||||||
#
|
myprogram: $(objects)
|
||||||
# Directories
|
$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
|
||||||
#
|
|
||||||
$(BUILDDIR):
|
|
||||||
@mkdir -p $@
|
|
||||||
@echo " MKDIR $@"
|
|
||||||
|
|
||||||
$(BINDIR):
|
%.o: %.c Makefile
|
||||||
@mkdir -p $@
|
$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
|
||||||
@echo " MKDIR $@"
|
|
||||||
|
|
||||||
#
|
%.d: %.c Makefile
|
||||||
# Dependencies
|
$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
||||||
#
|
|
||||||
-include $(DEPENDENCIES)
|
|
||||||
|
|
||||||
$(BUILDDIR)/%.d: %.c Makefile | $(BUILDDIR)
|
|
||||||
@mkdir -p $(shell dirname $@)
|
|
||||||
@$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
|
||||||
@echo " DEP $@"
|
|
||||||
|
|
||||||
#
|
|
||||||
# Main program
|
|
||||||
#
|
|
||||||
$(BINDIR)/gem-graph-client: $(OBJECTS) | $(BINDIR)
|
|
||||||
@$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
|
|
||||||
@echo " LD $@"
|
|
||||||
|
|
||||||
#
|
|
||||||
# Objects
|
|
||||||
#
|
|
||||||
$(BUILDDIR)/%.o: %.c Makefile | $(BUILDDIR)
|
|
||||||
@mkdir -p $(shell dirname $@)
|
|
||||||
@$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
|
|
||||||
@echo " CC $@"
|
|
||||||
|
|
||||||
#
|
|
||||||
# Virtual recipes
|
|
||||||
#
|
|
||||||
install:
|
install:
|
||||||
@echo "Installing is not supported"
|
echo "Installing is not supported"
|
||||||
|
|
||||||
run: $(BINDIR)/gem-graph-client
|
run: myprogram
|
||||||
$(BINDIR)/gem-graph-client
|
./myprogram
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -rf $(BINDIR)
|
rm -f myprogram
|
||||||
@echo " RM $(BINDIR)"
|
rm -f *.o
|
||||||
@rm -rf $(BUILDDIR)
|
rm -f *.d
|
||||||
@echo " RM $(BUILDDIR)"
|
|
||||||
|
# /!\ erreur fatale: GL/glu.h <?>
|
||||||
|
# gcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -g -Wall -Wextra
|
||||||
|
# -std=c99 -lm *.c -o formattage `pkg-config --cflags --libs glib-2.0`
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
# 'make' has an implicit rule for updating a ‘.o’ file #
|
||||||
|
# from a correspondingly named ‘.c’ file #
|
||||||
|
# using a ‘cc -c’ command. #
|
||||||
|
# Implicit rules are listed and applied in a predefined order (C before P...) #
|
||||||
|
# Predefined implicit rules are implemented in make as suffix rules #
|
||||||
|
# The default suffix list is: .out, .a, .ln, .o, .c, .cc, .C, .cpp, .p,... #
|
||||||
|
# Rules whose suffixes fail to be on the list are disabled. #
|
||||||
|
# You can define your own implicit rules by writing pattern rules. #
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
# If there are many implicit rules with the same target pattern,
|
||||||
|
# the rule that actually applies is the one whose prerequisites exist or can be made
|
||||||
|
# ex: a .o can be made from a .c (C compiler) or a .p (Pascal compiler)
|
||||||
|
|
||||||
|
# Variables allow a text string to be defined once
|
||||||
|
# and substituted in multiple places later.
|
||||||
|
# (see Chapter 6 [How to Use Variables], page 65)
|
||||||
|
|
||||||
|
|
||||||
# More docs :
|
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
# To study : how can the following commands be modified ? #
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
#SHELL = /bin/sh
|
||||||
|
#.SUFFIXES:
|
||||||
|
#.SUFFIXES: .c .o .h # is .h useful ?
|
||||||
|
#.PHONY = run
|
||||||
|
#.PHONY = clean
|
||||||
|
#.PHONY: Makefile
|
||||||
|
|
||||||
|
#CC=gcc
|
||||||
|
#CFLAGS=`pkg-config --cflags gtk4 --libs gtk4`
|
||||||
|
#WARNINGS = -Wall
|
||||||
|
#DEBUG = -ggdb -fno-omit-frame-pointer
|
||||||
|
#OPTIMIZE = -O2
|
||||||
|
|
||||||
|
# in exec.o:
|
||||||
|
# $(WARNINGS) $(DEBUG) $(OPTIMIZE) < ne sont pas indispensables
|
||||||
|
# si le $@ est supprimé, main.cest modifié
|
||||||
|
#all:
|
||||||
|
# exec
|
||||||
|
|
||||||
|
#install:
|
||||||
|
# echo "Installing is not supported"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
# Personnal notes & links #
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
|
||||||
|
# gcc $( pkg-config --cflags gtk4 ) -o exec main.c $( pkg-config --libs gtk4 )
|
||||||
|
|
||||||
# https://www.gnu.org/software/make/manual/
|
# https://www.gnu.org/software/make/manual/
|
||||||
|
|
||||||
|
# Makefiles contain five kinds of things:
|
||||||
|
# explicit rules, implicit rules, variable definitions, directives and comments.
|
||||||
|
|
||||||
|
|
||||||
|
# Variables automatiques --------------------------------------------------
|
||||||
|
# $@ fait référence à la cible de la règle (au nom de la cible).
|
||||||
|
# $< fait référence à la première dépendance.
|
||||||
|
# $? fait référence aux noms de touess les dépendances plus récentes que la cible.
|
||||||
|
# = les fichiers qui ont été modifiés après la compilation de code la plus récente
|
||||||
|
# $^ fait référence aux noms de touess les dépendances avec des espaces entre eux.
|
||||||
|
|
||||||
|
# Variables implicites -------------------------------------------------
|
||||||
|
# VPATH Équivalent utilitaire de la variable PATH de Bash. Vide par défaut.
|
||||||
|
# Les chemins sont séparés par le signe deux-points (:).
|
||||||
|
# CC Le programme pour compiler des fichiers C.
|
||||||
|
# La valeur par défaut est cc. (Habituellement, cc pointe vers gcc.)
|
||||||
|
# CPP Le programme qui exécute le préprocesseur C.
|
||||||
|
# La valeur par défaut est $ (CC) -E.
|
||||||
|
# LEX Le programme qui transforme les grammaires lexicales en code source.
|
||||||
|
# La valeur par défaut est lex. (Vous devriez remplacer cela par flex.)
|
||||||
|
# LINT Le programme qui lint votre code source. La valeur par défaut est lint.
|
||||||
|
# RM La commande pour supprimer un fichier. La valeur par défaut est rm -f.
|
||||||
|
# CFLAGS Contient tous les indicateurs du compilateur C (cc).
|
||||||
|
# CPPFLAGS tous les indicateurs du préprocesseur C.
|
||||||
|
# .PHONY Spécifie des cibles qui ne ressemblent pas au nom d'un fichier.
|
||||||
|
# Un exemple est la cible "make clean" ; où clean est une valeur de .PHONY
|
||||||
|
|
||||||
|
# Syntaxe de Base
|
||||||
|
# Règles : Une règle se compose d'une cible, des dépendances et des commandes.
|
||||||
|
# Elle est généralement structurée comme suit :
|
||||||
|
# cible: dépendances
|
||||||
|
# commande
|
||||||
|
#
|
||||||
|
# La cible (target) est le fichier à générer,
|
||||||
|
# les dépendances (prerequisites) sont les fichiers requis pour construire la cible
|
||||||
|
# et les commandes (recipe) sont les instructions exécutées pour créer la cible.
|
||||||
|
#
|
||||||
|
# A simple makefile consists of “rules” with the following shape:
|
||||||
|
# target ... : prerequisites ...
|
||||||
|
# recipe
|
||||||
|
# ...
|
||||||
|
# A target is usually the name of a file that is generated by a program;
|
||||||
|
# examples of targets are executable or object files.
|
||||||
|
# A target can also be the name of an action to carry out, such as ‘clean’
|
||||||
|
|
||||||
|
|
||||||
# accessoirement : https://blog.stephane-robert.info/docs/makefile/ & /docs/task/
|
# accessoirement : https://blog.stephane-robert.info/docs/makefile/ & /docs/task/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include "callback.h"
|
||||||
|
#include "automaton.h"
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* S T A T E S */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/* (exec / edit) < MODE
|
||||||
|
* X
|
||||||
|
* (state / rules / data) < STATUS
|
||||||
|
* X
|
||||||
|
* (measure / analyse / interpret)
|
||||||
|
* X
|
||||||
|
* (read / write)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int mode = RUN;
|
||||||
|
void set_mode (int prescribed) {mode = prescribed;}
|
||||||
|
int get_mode () {return mode;}
|
||||||
|
|
||||||
|
static int status = INTER; // int get_status () {return status;}
|
||||||
|
void set_status (int prescribed) {status = prescribed;}
|
||||||
|
int get_status () {return status;}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* T R A N S I T I O N S */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
void SWITCH_TO (int asked) {
|
||||||
|
switch (asked) {
|
||||||
|
case (INTER) :
|
||||||
|
status = INTER; printf ("SWITCH_TO INTER\n");
|
||||||
|
break;
|
||||||
|
case (STATE) : // BEGIN_TO_EXEC_STOP
|
||||||
|
status = STATE; printf ("SWITCH_TO STATE\n");
|
||||||
|
break;
|
||||||
|
case (RULES) : // EXEC_STOP_TO_RUN
|
||||||
|
status = RULES; printf ("SWITCH_TO RULES\n");
|
||||||
|
break;
|
||||||
|
case (DATA) : // EXEC_RUN_TO_STOP
|
||||||
|
status = DATA; printf ("SWITCH_TO DATA\n");
|
||||||
|
break;
|
||||||
|
default : ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//q gtk_window_present (GTK_WINDOW (main_window));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
enum { // S T A T E S
|
||||||
|
INTER,
|
||||||
|
EXEC_STOP,
|
||||||
|
EXEC_RUN,
|
||||||
|
EDIT_STATE,
|
||||||
|
EDIT_RULES_TREE,
|
||||||
|
EDIT_RULE,
|
||||||
|
EDIT_MEASURE,
|
||||||
|
OBSERVE,
|
||||||
|
ANALYSE,
|
||||||
|
HELP,
|
||||||
|
CONFIGURE
|
||||||
|
};
|
||||||
|
|
||||||
|
static int status = EXEC_STOP; // int get_status () {return status;}
|
||||||
|
|
||||||
|
enum { // T R A N S I T I O N S
|
||||||
|
BEGIN_TO_EXEC_STOP
|
||||||
|
EXEC_STOP_TO_RUN,
|
||||||
|
EXEC_RUN_TO_STOP,
|
||||||
|
EXEC_TO_INTER,
|
||||||
|
INTER_TO_EDIT,
|
||||||
|
EDIT_TO_INTER,
|
||||||
|
INTER_TO_EXEC,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void set_status (int prescribed) {
|
||||||
|
status = prescribed; if (0) printf ("status = %d\n", status);
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case (0) : // EXEC_STOP DATA_ANALYSIS
|
||||||
|
status = EXEC_RUN;
|
||||||
|
break;
|
||||||
|
case (1) : // EXEC_RUN
|
||||||
|
// Ici, il faudra prévenir l'utilisateur par une pop-up window : (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 : ;
|
||||||
|
}
|
||||||
|
} */
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
void set_status (int prescribed);
|
||||||
|
int get_status ();
|
||||||
|
void set_mode (int prescribed);
|
||||||
|
int get_mode ();
|
||||||
|
|
||||||
|
enum mode { RUN, EDIT };
|
||||||
|
enum choice { INTER, STATE, RULES, DATA };
|
||||||
|
// MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
|
||||||
|
|
||||||
|
void SWITCH_TO (int asked);
|
|
@ -1,15 +1,14 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
|
||||||
#include "../include/callback.h"
|
#include "callback.h"
|
||||||
#include "../include/contain.h"
|
#include "tree.h"
|
||||||
#include "../include/tree.h"
|
#include "contain.h"
|
||||||
#include "../include/contain.h"
|
#include "dialog.h"
|
||||||
#include "../include/dialog.h"
|
#include "texts.h"
|
||||||
#include "../include/texts.h"
|
#include "automaton.h"
|
||||||
#include "../include/automaton.h"
|
#include "parsing.h"
|
||||||
#include "../include/parsing.h"
|
#include "graph_area.h"
|
||||||
#include "../include/graph_area.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* W I N D O W S A C T I V A T I O N */
|
/* W I N D O W S A C T I V A T I O N */
|
||||||
|
@ -80,14 +79,14 @@ gboolean on_glarea_render(GtkGLArea *area, GdkGLContext *context)
|
||||||
{
|
{
|
||||||
// Check if the widget is a glarea
|
// Check if the widget is a glarea
|
||||||
if(gtk_gl_area_get_error(area) != NULL) {
|
if(gtk_gl_area_get_error(area) != NULL) {
|
||||||
on_auto_notification("An OpenGL error occured !");
|
////////////////////////// on_auto_notification("An OpenGL error occured !");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_render_stack(gtk_widget_get_parent(GTK_WIDGET(area))) == false) {
|
////////////////////////// if (ui_render_stack(gtk_widget_get_parent(GTK_WIDGET(area))) == false) {
|
||||||
on_auto_notification("Failed to render corresponding graphic stack !");
|
////////////////////////// on_auto_notification("Failed to render corresponding graphic stack !");
|
||||||
return false;
|
////////////////////////// return false;
|
||||||
}
|
////////////////////////// }
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -163,53 +162,94 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* B U T T O N S */
|
/* B U T T O N S */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data) {
|
||||||
|
if (strcmp (gtk_button_get_label (GTK_BUTTON (btt_MODEL_RUN_STOP)), " run "))
|
||||||
|
gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " run ");
|
||||||
|
else gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " stop ");
|
||||||
|
}
|
||||||
|
|
||||||
void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data) {
|
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *btt_MODEL_RUN_STOP) {
|
||||||
|
if (get_mode()) {
|
||||||
if (get_EXEC_EDIT ()) {
|
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "power-profile-balanced-rtl-symbolic");
|
||||||
gtk_button_set_icon_name (GTK_BUTTON (toggled_button), "power-profile-balanced-rtl-symbolic");
|
gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " run ");
|
||||||
set_EXEC_EDIT (EXEC);
|
gtk_widget_set_sensitive (GTK_WIDGET (btt_MODEL_RUN_STOP), TRUE);
|
||||||
|
set_mode (0);
|
||||||
} else {
|
} else {
|
||||||
gtk_button_set_icon_name (GTK_BUTTON (toggled_button), "text-editor-symbolic");
|
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "preferences-system-symbolic");
|
||||||
set_EXEC_EDIT (EDIT);
|
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "emblem-ok-symbolic"); // Transport Steam Engine !!
|
||||||
}
|
gtk_widget_set_sensitive (GTK_WIDGET (btt_MODEL_RUN_STOP), FALSE);
|
||||||
switch (get_STATE_RULES_DATA()) {
|
set_mode (1);
|
||||||
case (STATE) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE())); break;
|
|
||||||
case (RULES) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES())); break;
|
|
||||||
case (DATA) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA())); break;
|
|
||||||
default : printf("default in callback.on_toggle_STATE_RULES_DATA()\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_toggle_STATE_RULES_DATA (GtkWidget *toggled_button, gpointer user_data) {
|
|
||||||
|
|
||||||
const char *toggled_button_name = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button));
|
|
||||||
int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button));
|
|
||||||
|
|
||||||
if (! strcmp (toggled_button_name, "state")) set_STATE_RULES_DATA (STATE);
|
|
||||||
if (! strcmp (toggled_button_name, "rules")) set_STATE_RULES_DATA (RULES);
|
|
||||||
if (! strcmp (toggled_button_name, "data analysis")) set_STATE_RULES_DATA (DATA);
|
|
||||||
|
|
||||||
if (is_active)
|
|
||||||
switch (get_STATE_RULES_DATA()) {
|
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer user_data) {
|
||||||
case (STATE) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE())); break;
|
if (0) printf("on_open_STATE status = %d\n", get_status ());
|
||||||
case (RULES) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES())); break;
|
printf("gtk_check_button_get_active > after = %d, %d, %d from callback : on_open_STATE()\n",\
|
||||||
case (DATA) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA())); break;
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("state"))), // (GTK_CHECK_BUTTON (btt_open_STATE)),
|
||||||
default : printf("default in callback.on_toggle_STATE_RULES_DATA()\n");
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("rules"))), // (GTK_CHECK_BUTTON (btt_open_RULES)),
|
||||||
}
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("data analysis")))); // (GTK_CHECK_BUTTON (btt_open_DATA)));
|
||||||
|
|
||||||
|
if (! gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("state"))))
|
||||||
|
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE())); // window_main_child (main_window, STATE);
|
||||||
|
} // SWITCH_TO (STATE);}
|
||||||
|
|
||||||
|
void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data) {
|
||||||
|
if (0) printf("on_open_RULES status = %d\n", get_status ());
|
||||||
|
if (! gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("rules"))))
|
||||||
|
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES())); // window_main_child (main_window, RULES);
|
||||||
|
}// SWITCH_TO (RULES);}
|
||||||
|
|
||||||
|
void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data) {
|
||||||
|
if (0) printf("on_open_DATA status = %d\n", get_status ());
|
||||||
|
if (! gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("data analysis"))))
|
||||||
|
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA())); // window_main_child (main_window, DATA);
|
||||||
|
}// SWITCH_TO (DATA);}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void on_toggle_STATE_RULES_DATA (GtkWidget *btt, gpointer user_data) {
|
||||||
|
// https://docs.gtk.org/gtk4/class.ToggleButton.html < f..k ! bad code ++
|
||||||
|
|
||||||
|
const char *btt_name = gtk_check_button_get_label (GTK_CHECK_BUTTON (btt));
|
||||||
|
int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (btt));
|
||||||
|
|
||||||
|
int is_state_active = ! strcmp (btt_name, "state");
|
||||||
|
int is_rules_active = ! strcmp (btt_name, "rules");
|
||||||
|
int is_data_active = ! strcmp (btt_name, "data analysis");
|
||||||
|
if (0 && is_active) printf ("> [%d] %d, %d, %d %14s\n",
|
||||||
|
is_active, is_state_active, is_rules_active, is_data_active, btt_name);
|
||||||
|
|
||||||
|
if (is_active) {
|
||||||
|
if (is_state_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE()));
|
||||||
|
else if (is_rules_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES()));
|
||||||
|
else if (is_data_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
|
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
|
||||||
printf ("callback.c (line 201) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
|
printf ("callback.c (line 201) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
|
||||||
|
SWITCH_TO (INTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
||||||
gtk_window_close (GTK_WINDOW (data));
|
gtk_window_close (GTK_WINDOW (data));
|
||||||
printf ("callback.c (line 206) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
|
printf ("callback.c (line 206) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
|
||||||
|
SWITCH_TO (RULES);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) {
|
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) {
|
|
@ -14,7 +14,7 @@ void on_glarea_unrealize (GtkWidget *widget);
|
||||||
|
|
||||||
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
|
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
|
||||||
|
|
||||||
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, gpointer user_data);
|
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *btt_MODEL_RUN_STOP);
|
||||||
void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data);
|
void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data);
|
||||||
|
|
||||||
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data);
|
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data);
|
|
@ -1,12 +1,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
|
||||||
#include "../include/graph_area.h"
|
#include "callback.h"
|
||||||
#include "../include/callback.h"
|
#include "automaton.h"
|
||||||
#include "../include/automaton.h"
|
#include "display.h"
|
||||||
#include "../include/display.h"
|
#include "tree.h"
|
||||||
#include "../include/tree.h"
|
#include "texts.h"
|
||||||
#include "../include/texts.h"
|
|
||||||
|
|
||||||
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
|
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
|
||||||
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
|
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
|
||||||
|
@ -135,8 +134,7 @@ GtkWidget *get_SPACE_VIEW_box(){
|
||||||
|
|
||||||
GtkBox *middle_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
GtkBox *middle_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
||||||
gtk_box_append (middle_box, GTK_WIDGET (get_image_ALL_SPACE()));
|
gtk_box_append (middle_box, GTK_WIDGET (get_image_ALL_SPACE()));
|
||||||
// ui_setup_glarea (0, GTK_WIDGET (middle_box));
|
////////////////////////// gtk_box_append (middle_box, GTK_WIDGET (get_GLArea()));
|
||||||
|
|
||||||
gtk_box_append (middle_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
gtk_box_append (middle_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
||||||
gtk_box_append (middle_box, GTK_WIDGET (right_box));
|
gtk_box_append (middle_box, GTK_WIDGET (right_box));
|
||||||
return GTK_WIDGET (middle_box);
|
return GTK_WIDGET (middle_box);
|
||||||
|
@ -149,6 +147,11 @@ GtkWidget *get_SPACE_EDIT_controls_box() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void window_main_child_bottom (GtkBox *page_box){
|
||||||
|
// gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_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);
|
||||||
|
|
||||||
static GtkButton *btt_open_STATE;
|
static GtkButton *btt_open_STATE;
|
||||||
|
@ -173,31 +176,63 @@ void window_header_bar (GtkWindow *window, char *title){
|
||||||
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
|
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
|
||||||
gtk_window_set_titlebar (window, header_bar);
|
gtk_window_set_titlebar (window, header_bar);
|
||||||
|
|
||||||
|
// GtkWidget my_window_controls = *gtk_window_controls_new (GTK_PACK_END); // _START
|
||||||
|
// gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS(my_window_controls), NULL); // const char* layout);
|
||||||
|
|
||||||
gpointer no_local_data = NULL;
|
gpointer no_local_data = NULL;
|
||||||
|
|
||||||
|
GtkButton *btt_MODEL_RUN_STOP = GTK_BUTTON (gtk_button_new_with_label (" run "));
|
||||||
|
g_signal_connect (btt_MODEL_RUN_STOP, "clicked", G_CALLBACK (on_toggle_MODEL_RUN_STOP), no_local_data);
|
||||||
|
|
||||||
GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ());
|
GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ());
|
||||||
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic");
|
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic"); // https://thenounproject.com/icon/train-134324/
|
||||||
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "process-stop-symbolic");
|
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "process-stop-symbolic");
|
||||||
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "power-profile-balanced-rtl-symbolic");
|
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "power-profile-balanced-rtl-symbolic");
|
||||||
g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), no_local_data);
|
g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), btt_MODEL_RUN_STOP);
|
||||||
|
|
||||||
|
// GtkWidget* separe = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
|
||||||
|
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (separe));
|
||||||
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | "));
|
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | "));
|
||||||
|
|
||||||
GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_new ());
|
GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_new ());
|
||||||
|
|
||||||
btt_open_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state"));
|
btt_open_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state"));
|
||||||
|
// g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_open_STATE), no_local_data);
|
||||||
g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
|
g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
|
||||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_STATE), group_STATE_RULES_DATA);
|
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_STATE), group_STATE_RULES_DATA);
|
||||||
|
|
||||||
btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules"));
|
btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules"));
|
||||||
|
// g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_open_RULES), no_local_data);
|
||||||
g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
|
g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
|
||||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_RULES), group_STATE_RULES_DATA);
|
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_RULES), group_STATE_RULES_DATA);
|
||||||
|
|
||||||
btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis"));
|
btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis"));
|
||||||
|
// g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_open_DATA), no_local_data);
|
||||||
g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
|
g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
|
||||||
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA);
|
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA);
|
||||||
|
|
||||||
|
// gtk_check_button_set_label (GTK_CHECK_BUTTON (btt_open_DATA), "any label");
|
||||||
|
if (0) printf("gtk_check_button_get_label(s) = %s, %s, %s\n",\
|
||||||
|
gtk_check_button_get_label (GTK_CHECK_BUTTON (btt_open_STATE)),
|
||||||
|
gtk_check_button_get_label (GTK_CHECK_BUTTON (btt_open_RULES)),
|
||||||
|
gtk_check_button_get_label (GTK_CHECK_BUTTON (btt_open_DATA)));
|
||||||
|
|
||||||
|
if (0) printf("gtk_check_button_get_active > before = %d, %d, %d\n",\
|
||||||
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("state"))),
|
||||||
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("rules"))),
|
||||||
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("data analysis"))));
|
||||||
|
|
||||||
|
// gtk_check_button_set_active (GTK_CHECK_BUTTON (get_GtkButton ("state")), TRUE);
|
||||||
|
|
||||||
|
if (0) printf("gtk_check_button_get_active > after = %d, %d, %d\n",\
|
||||||
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("state"))), // (GTK_CHECK_BUTTON (btt_open_STATE)),
|
||||||
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("rules"))), // (GTK_CHECK_BUTTON (btt_open_RULES)),
|
||||||
|
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("data analysis")))); // (GTK_CHECK_BUTTON (btt_open_DATA)));
|
||||||
|
|
||||||
|
// on_toggle_STATE_RULES_DATA (, NULL) ;
|
||||||
|
|
||||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_XOR_EXEC_EDIT));
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_XOR_EXEC_EDIT));
|
||||||
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_MODEL_RUN_STOP)); // << pas ici ! TODO
|
||||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (any_Label));
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (any_Label));
|
||||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_STATE));
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_STATE));
|
||||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_RULES));
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_RULES));
|
||||||
|
@ -205,15 +240,15 @@ void window_header_bar (GtkWindow *window, char *title){
|
||||||
|
|
||||||
|
|
||||||
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
|
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
|
||||||
// https://iconduck.com/sets/carbon-icons < pas mal ...
|
// https://iconduck.com/sets/carbon-icons < pas mal ...
|
||||||
// https://thenounproject.com/icon/train-134324/
|
// ma préférée : Transport Steam Engine Icon mais : [ process icon ] semble un bon choix...
|
||||||
// ma préférée : Transport Steam Engine Icon mais : [ process icon ] semble un bon choix...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_window_design (GtkWindow *main_window){
|
void main_window_design (GtkWindow *main_window){
|
||||||
window_header_bar (main_window,
|
window_header_bar (main_window,
|
||||||
"E coli (with permission from David S. Goodsell, 2009)");
|
"E coli (with permission from David S. Goodsell, 2009)");
|
||||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE);
|
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE())); // window_main_child (main_window, STATE);
|
||||||
|
// set_check_button_active (GTK_BUTTON (btt_open_STATE), 1);
|
||||||
gtk_window_present (GTK_WINDOW (main_window));
|
gtk_window_present (GTK_WINDOW (main_window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,21 +263,90 @@ void main_window_design (GtkWindow *main_window){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void icons_for_fun (GtkHeaderBar *header_bar)
|
||||||
|
{
|
||||||
|
GtkButton *go_home = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (go_home, "go-home-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (go_home));
|
||||||
|
|
||||||
|
GtkButton *user_trash = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (user_trash, "user-trash-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (user_trash));
|
||||||
|
|
||||||
|
GtkButton *help_biblio = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (help_biblio, "accessories-dictionary-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_biblio));
|
||||||
|
|
||||||
|
GtkButton *help_doc = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (help_doc, "emblem-documents-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_doc));
|
||||||
|
|
||||||
|
GtkButton *help_about = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (help_about, "help-about-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_about));
|
||||||
|
|
||||||
|
GtkButton *help_faq = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (help_faq, "help-faq-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_faq));
|
||||||
|
|
||||||
|
GtkButton *terminal = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (terminal, "utilities-terminal-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (terminal));
|
||||||
|
|
||||||
|
GtkButton *search = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (search, "folder-saved-search-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (search));
|
||||||
|
|
||||||
|
GtkButton *preferences_desktop_appearance = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (preferences_desktop_appearance, "preferences-desktop-appearance-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (preferences_desktop_appearance));
|
||||||
|
|
||||||
|
GtkButton *preferences_system = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (preferences_system, "preferences-system-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (preferences_system));
|
||||||
|
|
||||||
|
GtkButton *document_properties = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (document_properties, "document-properties-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (document_properties));
|
||||||
|
|
||||||
|
GtkButton *text_edit = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (text_edit, "text-editor-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (text_edit));
|
||||||
|
|
||||||
|
GtkButton *applications_utilities = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (applications_utilities, "applications-utilities-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (applications_utilities));
|
||||||
|
|
||||||
|
GtkButton *open_menu = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (open_menu, "open-menu-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (open_menu));
|
||||||
|
|
||||||
|
GtkButton *power_max = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (power_max, "power-profile-performance-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_max));
|
||||||
|
|
||||||
|
GtkButton *power_middle = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (power_middle, "power-profile-balanced-rtl-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_middle));
|
||||||
|
|
||||||
|
GtkButton *power_low = GTK_BUTTON (gtk_button_new ());
|
||||||
|
gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic");
|
||||||
|
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low));
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *get_window_child_STATE() {
|
GtkWidget *get_window_child_STATE() {
|
||||||
if (0) printf("contain.get_window_child_STATE (line 235)\n");
|
|
||||||
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
|
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
|
||||||
gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS()));
|
gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS()));
|
||||||
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)));
|
||||||
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)));
|
||||||
if (get_EXEC_EDIT ()) gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
|
if (!get_mode ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
|
||||||
else 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()));
|
||||||
|
//SWITCH_TO (STATE);
|
||||||
return GTK_WIDGET (page_box);
|
return GTK_WIDGET (page_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *get_window_child_RULES(){
|
GtkWidget *get_window_child_RULES(){
|
||||||
if (0) printf("contain.get_window_child_RULES (line 246)\n");
|
|
||||||
GtkPaned *H_tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
|
GtkPaned *H_tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
|
||||||
// GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre des règles");
|
// GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre des règles");
|
||||||
// GtkWidget *édition_de_la_règle_sélectionnée_n_1 = gtk_frame_new ("Inspection");
|
// GtkWidget *édition_de_la_règle_sélectionnée_n_1 = gtk_frame_new ("Inspection");
|
||||||
|
@ -250,11 +354,11 @@ GtkWidget *get_window_child_RULES(){
|
||||||
gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (get_selected_rules_vpaned_new()));
|
gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (get_selected_rules_vpaned_new()));
|
||||||
gtk_paned_set_position (H_tree_vs_selected, 400); // WARNING : c'est une position "absolue"
|
gtk_paned_set_position (H_tree_vs_selected, 400); // WARNING : c'est une position "absolue"
|
||||||
gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE);
|
gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE);
|
||||||
|
//SWITCH_TO (RULES);
|
||||||
return GTK_WIDGET (H_tree_vs_selected);
|
return GTK_WIDGET (H_tree_vs_selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *get_window_child_DATA (){
|
GtkWidget *get_window_child_DATA (){
|
||||||
if (0) printf("contain.get_window_child_DATA (line 259)\n");
|
|
||||||
GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 32));
|
GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 32));
|
||||||
|
|
||||||
GtkWidget* frame_rule_effect = gtk_frame_new ("rule effect\n-----------");
|
GtkWidget* frame_rule_effect = gtk_frame_new ("rule effect\n-----------");
|
||||||
|
@ -353,74 +457,3 @@ GtkWidget *get_window_child_DATA (){
|
||||||
return GTK_WIDGET (data_box);
|
return GTK_WIDGET (data_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void icons_for_fun (GtkHeaderBar *header_bar)
|
|
||||||
{
|
|
||||||
GtkButton *go_home = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (go_home, "go-home-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (go_home));
|
|
||||||
|
|
||||||
GtkButton *user_trash = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (user_trash, "user-trash-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (user_trash));
|
|
||||||
|
|
||||||
GtkButton *help_biblio = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (help_biblio, "accessories-dictionary-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_biblio));
|
|
||||||
|
|
||||||
GtkButton *help_doc = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (help_doc, "emblem-documents-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_doc));
|
|
||||||
|
|
||||||
GtkButton *help_about = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (help_about, "help-about-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_about));
|
|
||||||
|
|
||||||
GtkButton *help_faq = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (help_faq, "help-faq-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_faq));
|
|
||||||
|
|
||||||
GtkButton *terminal = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (terminal, "utilities-terminal-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (terminal));
|
|
||||||
|
|
||||||
GtkButton *search = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (search, "folder-saved-search-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (search));
|
|
||||||
|
|
||||||
GtkButton *preferences_desktop_appearance = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (preferences_desktop_appearance, "preferences-desktop-appearance-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (preferences_desktop_appearance));
|
|
||||||
|
|
||||||
GtkButton *preferences_system = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (preferences_system, "preferences-system-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (preferences_system));
|
|
||||||
|
|
||||||
GtkButton *document_properties = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (document_properties, "document-properties-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (document_properties));
|
|
||||||
|
|
||||||
GtkButton *text_edit = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (text_edit, "text-editor-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (text_edit));
|
|
||||||
|
|
||||||
GtkButton *applications_utilities = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (applications_utilities, "applications-utilities-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (applications_utilities));
|
|
||||||
|
|
||||||
GtkButton *open_menu = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (open_menu, "open-menu-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (open_menu));
|
|
||||||
|
|
||||||
GtkButton *power_max = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (power_max, "power-profile-performance-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_max));
|
|
||||||
|
|
||||||
GtkButton *power_middle = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (power_middle, "power-profile-balanced-rtl-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_middle));
|
|
||||||
|
|
||||||
GtkButton *power_low = GTK_BUTTON (gtk_button_new ());
|
|
||||||
gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic");
|
|
||||||
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low));
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,13 +31,12 @@ G_END_DECLS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void main_window_design (GtkWindow *main_window);
|
void main_window_design (GtkWindow *main_window);
|
||||||
void set_check_button_active (GtkButton *button, int active);
|
|
||||||
void two_notebooks_in_two_panes (GtkWindow *window);
|
void two_notebooks_in_two_panes (GtkWindow *window);
|
||||||
|
|
||||||
GtkFrame *get_frame_with_label();
|
|
||||||
GtkWidget *get_selected_rules_vpaned_new();
|
GtkWidget *get_selected_rules_vpaned_new();
|
||||||
GtkWidget *get_TIME_EXEC_controls_box();
|
GtkFrame *get_frame_with_label();
|
||||||
GtkWidget *get_SPACE_EDIT_controls_box();
|
void window_main_child_bottom (GtkBox *page_box);
|
||||||
|
//void window_main_child (GtkWindow *main_window, int selected_page);
|
||||||
|
void set_check_button_active (GtkButton *button, int active);
|
||||||
GtkButton *get_GtkButton (char *btt_name);
|
GtkButton *get_GtkButton (char *btt_name);
|
||||||
GtkWidget *get_window_child_STATE();
|
GtkWidget *get_window_child_STATE();
|
||||||
GtkWidget *get_window_child_RULES();
|
GtkWidget *get_window_child_RULES();
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../include/callback.h"
|
#include "callback.h"
|
||||||
|
|
||||||
void dialog_window_design (GtkWindow *main_window, GtkWindow *dialog_window){
|
void dialog_window_design (GtkWindow *main_window, GtkWindow *dialog_window){
|
||||||
char *title = " Save the current model before modifying it? ";
|
char *title = " Save the current model before modifying it? ";
|
|
@ -1,9 +1,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
|
||||||
#include "../include/contain.h"
|
#include "contain.h"
|
||||||
#include "../include/tree.h"
|
#include "tree.h"
|
||||||
#include "../include/texts.h"
|
#include "texts.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <cglm/cglm.h>
|
#include <cglm/cglm.h>
|
||||||
#include "../include/base.h"
|
#include "base.h"
|
||||||
//#include "../include/ui.h"
|
//#include "ui.h"
|
||||||
#include "../include/graph_area.h"
|
#include "graph_area.h"
|
||||||
|
|
||||||
void graphics_draw_vertex (const int stack_id,
|
void graphics_draw_vertex (const int stack_id,
|
||||||
GLfloat x,
|
GLfloat x,
|
||||||
|
@ -151,9 +151,9 @@ void graphics_draw(const int stack_id)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
||||||
|
|
||||||
g_printerr("[debug] graphics_draw() started\n");
|
//g_printerr("[debug] graphics_draw() started\n");
|
||||||
|
|
||||||
print_stack(stack_id);
|
//print_stack(stack_id);
|
||||||
|
|
||||||
GLint cur_viewport[4];
|
GLint cur_viewport[4];
|
||||||
glGetIntegerv(GL_VIEWPORT, cur_viewport);
|
glGetIntegerv(GL_VIEWPORT, cur_viewport);
|
||||||
|
@ -166,9 +166,9 @@ void graphics_draw(const int stack_id)
|
||||||
mat4 v = GLM_MAT4_IDENTITY_INIT; // XXX define zoom and translations here ?
|
mat4 v = GLM_MAT4_IDENTITY_INIT; // XXX define zoom and translations here ?
|
||||||
|
|
||||||
mat4 p = GLM_MAT4_IDENTITY_INIT;
|
mat4 p = GLM_MAT4_IDENTITY_INIT;
|
||||||
glm_ortho(-1.0f, +1.0f, -1.0f, +1.0f, -1.0f, +1.0f, p);
|
//glm_ortho(-1.0f, +1.0f, -1.0f, +1.0f, -1.0f, +1.0f, p);
|
||||||
glm_ortho_default((float)cur_viewport[2] / (float)cur_viewport[3], p);
|
glm_ortho_default((float)cur_viewport[2] / (float)cur_viewport[3], p);
|
||||||
glm_perspective_default((float)cur_viewport[2] / (float)cur_viewport[3], p);
|
//glm_perspective_default((float)cur_viewport[2] / (float)cur_viewport[3], p);
|
||||||
|
|
||||||
/* Use our shaders */
|
/* Use our shaders */
|
||||||
glUseProgram(stack->program);
|
glUseProgram(stack->program);
|
||||||
|
@ -191,7 +191,7 @@ void graphics_draw(const int stack_id)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, stack->color_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, stack->color_buffer);
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0,(void*)0);
|
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0,(void*)0);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
//glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glDrawElements(GL_LINES, stack->buffer_lines_size, GL_UNSIGNED_INT, stack->buffer_lines_origin);
|
glDrawElements(GL_LINES, stack->buffer_lines_size, GL_UNSIGNED_INT, stack->buffer_lines_origin);
|
||||||
glDrawElements(GL_TRIANGLES, stack->buffer_plans_size, GL_UNSIGNED_INT, stack->buffer_plans_origin);
|
glDrawElements(GL_TRIANGLES, stack->buffer_plans_size, GL_UNSIGNED_INT, stack->buffer_plans_origin);
|
||||||
|
@ -203,5 +203,5 @@ void graphics_draw(const int stack_id)
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
g_printerr("[debug] graphics_draw() ended\n");
|
//g_printerr("[debug] graphics_draw() ended\n");
|
||||||
}
|
}
|
|
@ -25,9 +25,9 @@
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
#include <glib-2.0/glib.h>
|
#include <glib-2.0/glib.h>
|
||||||
|
|
||||||
#include "../include/contain.h"
|
#include "contain.h"
|
||||||
#include "../include/graph_area.h"
|
#include "graph_area.h"
|
||||||
#include "../include/callback.h"
|
#include "callback.h"
|
||||||
|
|
||||||
struct stack_index_t {
|
struct stack_index_t {
|
||||||
long stack_id;
|
long stack_id;
|
||||||
|
@ -39,23 +39,6 @@ static struct stack_index_t *stack_index = NULL;
|
||||||
size_t stack_index_size = 0;
|
size_t stack_index_size = 0;
|
||||||
|
|
||||||
|
|
||||||
int set_arrow (int stack_id, // 2024-06-27 DEBUG !
|
|
||||||
int arrows_nb,
|
|
||||||
int space_X,
|
|
||||||
int space_Y,
|
|
||||||
int space_Z,
|
|
||||||
int requested_weight,
|
|
||||||
int site,
|
|
||||||
int arrow_x,
|
|
||||||
int arrow_y,
|
|
||||||
int arrow_z) {
|
|
||||||
printf("graph_area.c > int set_arrow (...) 2024-06-27 DEBUG\n");
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
} // 2024-06-27 DEBUG !
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look for stack entry and returns stack_id
|
* Look for stack entry and returns stack_id
|
||||||
*
|
*
|
||||||
|
@ -101,19 +84,19 @@ long ui_is_graphic_stack_ready(void *container_widget)
|
||||||
*/
|
*/
|
||||||
bool ui_init_graphic_stack(void *container_widget, GError *error_buffer)
|
bool ui_init_graphic_stack(void *container_widget, GError *error_buffer)
|
||||||
{
|
{
|
||||||
g_printerr("[debug] ui_init_graphic_stack()\n");
|
//g_printerr("[debug] ui_init_graphic_stack()\n");
|
||||||
|
|
||||||
g_printerr("[debug] ui_init_graphic_stack() : target is %p\n", container_widget);
|
//g_printerr("[debug] ui_init_graphic_stack() : target is %p\n", container_widget);
|
||||||
|
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
g_printerr("[debug] ui_init_graphic_stack() : i is %d\n", i);
|
//g_printerr("[debug] ui_init_graphic_stack() : i is %d\n", i);
|
||||||
g_printerr("[debug] ui_init_graphic_stack() : target would be %p\n",
|
//g_printerr("[debug] ui_init_graphic_stack() : target would be %p\n",
|
||||||
stack_index[i].container_widget);
|
//stack_index[i].container_widget);
|
||||||
if (stack_index[i].container_widget == (void *)container_widget) {
|
if (stack_index[i].container_widget == (void *)container_widget) {
|
||||||
stack_index[i].stack_id = graphics_init(&error_buffer);
|
stack_index[i].stack_id = graphics_init(&error_buffer);
|
||||||
g_printerr("[debug] ui_init_graphic_stack() : stack_id is %ld\n",
|
//g_printerr("[debug] ui_init_graphic_stack() : stack_id is %d\n",
|
||||||
stack_index[i].stack_id);
|
//stack_index[i].stack_id);
|
||||||
if (stack_index[i].stack_id >= 0)
|
if (stack_index[i].stack_id >= 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
@ -168,15 +151,13 @@ bool ui_render_stack(GtkWidget *container_widget)
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
if (stack_index[i].container_widget == (void *)container_widget) {
|
if (stack_index[i].container_widget == (void *)container_widget) {
|
||||||
graphics_draw (stack_index[i].stack_id);
|
////////////////////////// graphics_draw (stack_index[i].stack_id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void graphics_draw(const int stack_id) {printf("graph_area.c > void graphics_draw(const int stack_id) (161)\n");}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look for stack entry and triggers OpenGL for drawing
|
* Look for stack entry and triggers OpenGL for drawing
|
||||||
*
|
*
|
||||||
|
@ -273,11 +254,11 @@ bool ui_setup_glarea(int target_mode, GtkWidget *target_widget)
|
||||||
{
|
{
|
||||||
GtkWidget *gl_area;
|
GtkWidget *gl_area;
|
||||||
|
|
||||||
g_printerr("[debug] ui_setup_glarea()\n");
|
////g_printerr("[debug] ui_setup_glarea()\n");
|
||||||
|
|
||||||
assert(target_widget);
|
assert(target_widget);
|
||||||
|
|
||||||
g_printerr("[debug] ui_setup_glarea() : target is %p\n", target_widget);
|
////g_printerr("[debug] ui_setup_glarea() : target is %p\n", target_widget);
|
||||||
|
|
||||||
if (stack_index == NULL) {
|
if (stack_index == NULL) {
|
||||||
stack_index = g_malloc(sizeof(struct stack_index_t));
|
stack_index = g_malloc(sizeof(struct stack_index_t));
|
||||||
|
@ -298,12 +279,12 @@ bool ui_setup_glarea(int target_mode, GtkWidget *target_widget)
|
||||||
gl_area = GTK_WIDGET(gtk_gl_area_new());
|
gl_area = GTK_WIDGET(gtk_gl_area_new());
|
||||||
assert(gl_area);
|
assert(gl_area);
|
||||||
|
|
||||||
gtk_widget_set_size_request(gl_area, 1000, 1000);
|
//gtk_widget_set_size_request(gl_area, 1000, 1000);
|
||||||
gtk_gl_area_set_auto_render(GTK_GL_AREA(gl_area), true);
|
gtk_gl_area_set_auto_render(GTK_GL_AREA(gl_area), true);
|
||||||
gtk_widget_set_hexpand(gl_area, TRUE);
|
gtk_widget_set_hexpand(gl_area, TRUE);
|
||||||
gtk_widget_set_vexpand(gl_area, TRUE);
|
gtk_widget_set_vexpand(gl_area, TRUE);
|
||||||
gtk_widget_set_halign(gl_area, GTK_ALIGN_CENTER);
|
//gtk_widget_set_halign(gl_area, GTK_ALIGN_CENTER);
|
||||||
gtk_widget_set_valign(gl_area, GTK_ALIGN_CENTER);
|
//gtk_widget_set_valign(gl_area, GTK_ALIGN_CENTER);
|
||||||
|
|
||||||
// The main "draw" call for GtkGLArea
|
// The main "draw" call for GtkGLArea
|
||||||
g_signal_connect(GTK_GL_AREA(gl_area), "render", G_CALLBACK(on_glarea_render), NULL);
|
g_signal_connect(GTK_GL_AREA(gl_area), "render", G_CALLBACK(on_glarea_render), NULL);
|
||||||
|
@ -315,13 +296,13 @@ bool ui_setup_glarea(int target_mode, GtkWidget *target_widget)
|
||||||
|
|
||||||
stack_index[stack_index_size-1].gl_area = (void*)gl_area;
|
stack_index[stack_index_size-1].gl_area = (void*)gl_area;
|
||||||
|
|
||||||
g_printerr("[debug] ui_setup_glarea() : set target to %p\n", target_widget);
|
////g_printerr("[debug] ui_setup_glarea() : set target to %p\n", target_widget);
|
||||||
|
|
||||||
g_printerr("[debug] ui_setup_glarea() : stack_index (@0x%p) had %ld elements\n",
|
////g_printerr("[debug] ui_setup_glarea() : stack_index (@0x%p) had %ld elements\n",
|
||||||
stack_index,
|
//stack_index,
|
||||||
stack_index_size);
|
//stack_index_size);
|
||||||
|
|
||||||
gtk_box_append (GTK_BOX (target_widget), gl_area);
|
gtk_box_append(GTK_BOX(target_widget), gl_area);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (gl_area), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (gl_area), TRUE);
|
||||||
|
|
||||||
// Create sliders
|
// Create sliders
|
|
@ -25,8 +25,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
|
||||||
#include <glib-2.0/glib.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <epoxy/gl.h>
|
#include <epoxy/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
@ -36,10 +34,8 @@
|
||||||
#include "base.h"
|
#include "base.h"
|
||||||
//#include "draw.c"
|
//#include "draw.c"
|
||||||
|
|
||||||
// #define VERTEX_SHADER_FILE "src/graphics/shaders/shader.vert"
|
#define VERTEX_SHADER_FILE "src/graphics/shaders/shader.vert"
|
||||||
// #define FRAG_SHADER_FILE "src/graphics/shaders/shader.frag"
|
#define FRAG_SHADER_FILE "src/graphics/shaders/shader.frag"
|
||||||
#define VERTEX_SHADER_FILE "shader.vert"
|
|
||||||
#define FRAG_SHADER_FILE "shader.frag"
|
|
||||||
#define GL_TARGET_MAJOR_VERSION 0
|
#define GL_TARGET_MAJOR_VERSION 0
|
||||||
#define GL_TARGET_MINOR_VERSION 4
|
#define GL_TARGET_MINOR_VERSION 4
|
||||||
|
|
||||||
|
@ -81,10 +77,6 @@ struct graphic_stack_t {
|
||||||
long buffer_plans_0_arrow;
|
long buffer_plans_0_arrow;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ui_render_stack(GtkWidget *container_widget);
|
|
||||||
|
|
||||||
bool ui_setup_glarea(int target_mode, GtkWidget *target_widget);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dynamic array of ptrs to dynamically allocated gl_area_entry
|
* Dynamic array of ptrs to dynamically allocated gl_area_entry
|
||||||
*/
|
*/
|
|
@ -26,9 +26,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "../include/contain.h"
|
#include "contain.h"
|
||||||
#include "../include/graph_area.h"
|
#include "graph_area.h"
|
||||||
#include "../include/parsing.h"
|
#include "parsing.h"
|
||||||
|
|
||||||
#define TEST 0
|
#define TEST 0
|
||||||
|
|
||||||
|
@ -111,12 +111,12 @@ int graphics_init(void *error_buffer)
|
||||||
int cur_id = 0;
|
int cur_id = 0;
|
||||||
struct graphic_stack_t *stack;
|
struct graphic_stack_t *stack;
|
||||||
|
|
||||||
g_printerr("[debug] graphics_init()\n");
|
/* g_printerr("[debug] graphics_init()\n"); */
|
||||||
|
|
||||||
if (graphic_stack == NULL) {
|
if (graphic_stack == NULL) {
|
||||||
graphic_stack = g_malloc0(sizeof(struct graphic_stack_t));
|
graphic_stack = g_malloc0(sizeof(struct graphic_stack_t));
|
||||||
graphic_stack_size = 1;
|
graphic_stack_size = 1;
|
||||||
g_printerr("[debug] graphics_init(): init graphic_stack @ %p\n", graphic_stack);
|
/* g_printerr("[debug] graphics_init(): init graphic_stack @ %p\n", graphic_stack); */
|
||||||
} else {
|
} else {
|
||||||
// Check if there are free slots
|
// Check if there are free slots
|
||||||
if (free_stack_slot_size) {
|
if (free_stack_slot_size) {
|
||||||
|
@ -136,9 +136,9 @@ int graphics_init(void *error_buffer)
|
||||||
|
|
||||||
memset(&graphic_stack[cur_id], 0, sizeof(struct graphic_stack_t));
|
memset(&graphic_stack[cur_id], 0, sizeof(struct graphic_stack_t));
|
||||||
|
|
||||||
g_printerr("[debug] graphics_init() : graphic_stack (@0x%p) has %ld elements\n",
|
/* g_printerr("[debug] graphics_init() : graphic_stack (@0x%p) has %ld elements\n", */
|
||||||
graphic_stack,
|
/* graphic_stack, */
|
||||||
graphic_stack_size);
|
/* graphic_stack_size); */
|
||||||
|
|
||||||
stack = &graphic_stack[cur_id];
|
stack = &graphic_stack[cur_id];
|
||||||
stack->id = cur_id;
|
stack->id = cur_id;
|
||||||
|
@ -147,11 +147,11 @@ int graphics_init(void *error_buffer)
|
||||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
if (!graphics_init_shaders(cur_id)) return -1;
|
////////////////////////// if (!graphics_init_shaders(cur_id)) return -1;
|
||||||
|
|
||||||
print_stack(cur_id);
|
//print_stack(cur_id);
|
||||||
|
|
||||||
graphics_init_buffers(cur_id);
|
////////////////////////// graphics_init_buffers(cur_id);
|
||||||
|
|
||||||
glDebugMessageCallback(graphics_debug_callback, NULL);
|
glDebugMessageCallback(graphics_debug_callback, NULL);
|
||||||
|
|
||||||
|
@ -286,10 +286,10 @@ void graphics_model_setup (const int stack_id)
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, space_X, space_Y, space_Z);
|
////////////////////////// draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, space_X, space_Y, space_Z);
|
||||||
draw_space_ridges_lines (stack_id);
|
////////////////////////// draw_space_ridges_lines (stack_id);
|
||||||
draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z);
|
////////////////////////// draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z);
|
||||||
draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, space_X, space_Y, space_Z);
|
////////////////////////// draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, space_X, space_Y, space_Z);
|
||||||
|
|
||||||
stack->buffer_vertex_0_arrow = stack->buffer_vertex_size;
|
stack->buffer_vertex_0_arrow = stack->buffer_vertex_size;
|
||||||
stack->buffer_colors_0_arrow = stack->buffer_colors_size;
|
stack->buffer_colors_0_arrow = stack->buffer_colors_size;
|
||||||
|
@ -314,10 +314,10 @@ void graphics_model_setup (const int stack_id)
|
||||||
|
|
||||||
while (model_get_next_arrow(&arrow, (char *)&state_id, dimension)) {
|
while (model_get_next_arrow(&arrow, (char *)&state_id, dimension)) {
|
||||||
g_print("[GRAPH DEBUG] cur arrow has x = %d\n", arrow.x);
|
g_print("[GRAPH DEBUG] cur arrow has x = %d\n", arrow.x);
|
||||||
stack->arrows_nb = set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z, arrow.load, arrow.site, arrow.x, arrow.y, arrow.z);
|
////////////////////////// stack->arrows_nb = set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z, arrow.load, arrow.site, arrow.x, arrow.y, arrow.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack->arrows_nb != announced_arrows_nb)
|
if (stack->arrows_nb != announced_arrows_nb)
|
||||||
g_printerr("ARGH : not all arrows have been parsed !\n");
|
g_printerr("ARGH : all the arrows have not been parsed !\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
enum choice_EXEC_EDIT { EXEC, EDIT };
|
|
||||||
enum choice_STATE_RULES_DATA { STATE, RULES, DATA };
|
|
||||||
// MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE }; ?
|
|
||||||
|
|
||||||
void set_EXEC_EDIT (int prescribed);
|
|
||||||
void set_STATE_RULES_DATA (int prescribed);
|
|
||||||
|
|
||||||
int get_EXEC_EDIT ();
|
|
||||||
int get_STATE_RULES_DATA ();
|
|
||||||
|
|
||||||
// char *get_str_EXEC_EDIT (int value);
|
|
||||||
// char *get_str_STATE_RULES_DATA (int value);
|
|
||||||
|
|
|
@ -1,314 +0,0 @@
|
||||||
/*
|
|
||||||
* Gem-graph OpenGL experiments
|
|
||||||
*
|
|
||||||
* Desc: OpenGL utils header
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
|
||||||
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
|
|
||||||
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "base.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <epoxy/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GL/glext.h>
|
|
||||||
#include <cglm/cglm.h>
|
|
||||||
|
|
||||||
#define VERTEX_SHADER_FILE "src/graphics/shaders/shader.vert"
|
|
||||||
#define FRAG_SHADER_FILE "src/graphics/shaders/shader.frag"
|
|
||||||
#define GL_TARGET_MAJOR_VERSION 0
|
|
||||||
#define GL_TARGET_MINOR_VERSION 4
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure describing a gl_area and its parameters, used to create a table
|
|
||||||
* of Gem-graph client current gl_areas
|
|
||||||
*/
|
|
||||||
struct graphic_stack_t {
|
|
||||||
|
|
||||||
int id;
|
|
||||||
int mode;
|
|
||||||
|
|
||||||
float rotation_angles[N_AXIS]; // Rotation angles on each axis
|
|
||||||
|
|
||||||
GLuint vao; // init_buffers
|
|
||||||
GLuint position_buffer; // shutdown, draw
|
|
||||||
GLuint color_buffer; // shutdown, draw
|
|
||||||
GLuint program; // shutdown, init_shaders, draw
|
|
||||||
GLuint m; // init_shaders, draw
|
|
||||||
GLuint v; // init_shaders, draw
|
|
||||||
GLuint p; // init_shaders, draw
|
|
||||||
|
|
||||||
struct arrow_t *arrows_ptr;
|
|
||||||
long arrows_nb;
|
|
||||||
|
|
||||||
GLfloat *buffer_vertex_origin;
|
|
||||||
GLfloat *buffer_colors_origin;
|
|
||||||
GLuint *buffer_lines_origin;
|
|
||||||
GLuint *buffer_plans_origin;
|
|
||||||
|
|
||||||
long buffer_vertex_size;
|
|
||||||
long buffer_colors_size;
|
|
||||||
long buffer_lines_size;
|
|
||||||
long buffer_plans_size;
|
|
||||||
|
|
||||||
long buffer_vertex_0_arrow;
|
|
||||||
long buffer_colors_0_arrow;
|
|
||||||
long buffer_lines_0_arrow;
|
|
||||||
long buffer_plans_0_arrow;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Dynamic array of ptrs to dynamically allocated gl_area_entry
|
|
||||||
*/
|
|
||||||
extern struct graphic_stack_t *graphic_stack;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initializes a gl_area
|
|
||||||
*
|
|
||||||
* @param gl_area, ptr to the gl_area widget
|
|
||||||
*
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
int graphics_init(void *error_buffer);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draws the current buffer to a gl_area
|
|
||||||
*
|
|
||||||
* @param gl_area, ptr to the gl_area widget
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
//void graphics_draw(const int stack_id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Shutdowns a gl_area
|
|
||||||
*
|
|
||||||
* @param gl_area, ptr to the gl_area widget
|
|
||||||
*
|
|
||||||
* @return true if success
|
|
||||||
*/
|
|
||||||
bool graphics_shutdown(const int stack_id, void *error_buffer);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initializes the shaders of a gl_area and link them to a program
|
|
||||||
*
|
|
||||||
* @param gl_area, ptr to the gl_area widget
|
|
||||||
*
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
bool graphics_init_shaders(const int stack_id);
|
|
||||||
|
|
||||||
/* Initializes the buffer of a gl_area
|
|
||||||
* Calls according to the user preferences
|
|
||||||
* @param gl_area, ptr to the gl_area widget
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
void graphics_init_buffers(const int stack_id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draws a vertex (x, y, z)
|
|
||||||
* if (console) prints (x, y, z) values to console
|
|
||||||
*
|
|
||||||
* @param GLfloat x, GLfloat y, GLfloat z
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
void graphics_draw_vertex (const int stack_id,
|
|
||||||
GLfloat x,
|
|
||||||
GLfloat y,
|
|
||||||
GLfloat z);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draws the color (r, g, b) associated to a vertex
|
|
||||||
* if (console) prints (r, g, b) values to console
|
|
||||||
*
|
|
||||||
* @param GLfloat r, GLfloat g, GLfloat b
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
void graphics_draw_color (const int stack_id, GLfloat r, GLfloat g, GLfloat b);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes values to describe a line from a to b into the line buffer
|
|
||||||
*
|
|
||||||
* @param coords GLuint (a,b)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
void graphics_draw_line (const int stack_id, GLuint a, GLuint b);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
|
||||||
*
|
|
||||||
* @param coords GLuint (a,b,c)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
void graphics_draw_plan (const int stack_id, GLuint a, GLuint b, GLuint c);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Created and compile a shader
|
|
||||||
*
|
|
||||||
* @param type, shader type
|
|
||||||
* src, source code of shader
|
|
||||||
*
|
|
||||||
* @return shader id
|
|
||||||
*/
|
|
||||||
static inline GLuint create_shader(const int stack_id, int type, const char *src)
|
|
||||||
{
|
|
||||||
GLuint shader;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
shader = glCreateShader(type);
|
|
||||||
glShaderSource(shader, 1, &src, NULL);
|
|
||||||
glCompileShader(shader);
|
|
||||||
|
|
||||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
|
|
||||||
if(status == GL_FALSE) {
|
|
||||||
int log_len;
|
|
||||||
char *buffer;
|
|
||||||
|
|
||||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_len);
|
|
||||||
|
|
||||||
buffer = g_malloc(log_len + 1);
|
|
||||||
assert (buffer);
|
|
||||||
glGetShaderInfoLog(shader, log_len, NULL, buffer);
|
|
||||||
|
|
||||||
g_warning("Compile failure in %s shader:\n%s",
|
|
||||||
type == GL_VERTEX_SHADER ? "vertex" : "fragment",
|
|
||||||
buffer);
|
|
||||||
|
|
||||||
g_free(buffer);
|
|
||||||
|
|
||||||
glDeleteShader(shader);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return shader;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void print_stack(int stack_id)
|
|
||||||
{
|
|
||||||
static int n = 0;
|
|
||||||
|
|
||||||
printf("\n[n=%d]***************", n);
|
|
||||||
|
|
||||||
printf("id = %d\tmode = %d\n",
|
|
||||||
graphic_stack[stack_id].id,
|
|
||||||
graphic_stack[stack_id].mode);
|
|
||||||
|
|
||||||
printf("rotation_angles = ");
|
|
||||||
for (int i = 0; i < N_AXIS; i++) {
|
|
||||||
printf("%f\t", graphic_stack[stack_id].rotation_angles[i]); // Rotation angles on each axis
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("vao = %d\n", graphic_stack[stack_id].vao);
|
|
||||||
printf("position_buffer = %d\n", graphic_stack[stack_id].position_buffer);
|
|
||||||
printf("color_buffer = %d\n", graphic_stack[stack_id].color_buffer);
|
|
||||||
printf("program = %d\n", graphic_stack[stack_id].program);
|
|
||||||
printf("m = %d\n", graphic_stack[stack_id].m);
|
|
||||||
printf("v = %d\n", graphic_stack[stack_id].v);
|
|
||||||
printf("p = %d\n", graphic_stack[stack_id].p);
|
|
||||||
|
|
||||||
printf("arrows_ptr = %p\n", graphic_stack[stack_id].arrows_ptr);
|
|
||||||
printf("arrows_nb = %ld\n", graphic_stack[stack_id].arrows_nb);
|
|
||||||
|
|
||||||
printf("buffer_vertex_origin = %p\n", graphic_stack[stack_id].buffer_vertex_origin);
|
|
||||||
printf("buffer_colors_origin = %p\n", graphic_stack[stack_id].buffer_colors_origin);
|
|
||||||
printf("buffer_lines_origin = %p\n", graphic_stack[stack_id].buffer_lines_origin);
|
|
||||||
printf("buffer_plans_origin = %p\n", graphic_stack[stack_id].buffer_plans_origin);
|
|
||||||
|
|
||||||
printf("buffer_vertex_size = %ld\n", graphic_stack[stack_id].buffer_vertex_size);
|
|
||||||
printf("buffer_colors_size = %ld\n", graphic_stack[stack_id].buffer_colors_size);
|
|
||||||
printf("buffer_lines_size = %ld\n", graphic_stack[stack_id].buffer_lines_size);
|
|
||||||
printf("buffer_plans_size = %ld\n", graphic_stack[stack_id].buffer_plans_size);
|
|
||||||
|
|
||||||
printf("buffer_vertex_0_arrow = %ld\n", graphic_stack[stack_id].buffer_vertex_0_arrow);
|
|
||||||
printf("buffer_colors_0_arrow = %ld\n", graphic_stack[stack_id].buffer_colors_0_arrow);
|
|
||||||
printf("buffer_lines_0_arrow = %ld\n", graphic_stack[stack_id].buffer_lines_0_arrow);
|
|
||||||
printf("buffer_plans_0_arrow = %ld\n", graphic_stack[stack_id].buffer_plans_0_arrow);
|
|
||||||
|
|
||||||
printf("********************\n");
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void graphics_model_setup (const int stack_id);
|
|
||||||
|
|
||||||
int draw_one_arrow_vertex (const int stack_id,
|
|
||||||
int space_X,
|
|
||||||
int space_Y,
|
|
||||||
int space_Z,
|
|
||||||
int weight,
|
|
||||||
int site,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z);
|
|
||||||
|
|
||||||
int draw_one_arrow_line(const int stack_id,
|
|
||||||
int offset_vertex);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes grid ridges to vertex and color buffers
|
|
||||||
*
|
|
||||||
* @param coords long (x,y,z), step_x, step_y, step_z
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
int draw_space_ridges_vertex (const int stack_id,
|
|
||||||
long offset_vertex,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z);
|
|
||||||
|
|
||||||
int draw_space_ridges_lines (const int stack_id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes grid lines on space faces
|
|
||||||
*
|
|
||||||
* @param coords long (x,y,z)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
long draw_grids_on_space_faces_vertex (const int stack_id,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z);
|
|
||||||
|
|
||||||
long draw_grids_on_space_faces_lines (const int stack_id,
|
|
||||||
long offset_vertex,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z);
|
|
||||||
|
|
||||||
int set_arrow (int stack_id,
|
|
||||||
int arrows_nb,
|
|
||||||
int space_X,
|
|
||||||
int space_Y,
|
|
||||||
int space_Z,
|
|
||||||
int requested_weight,
|
|
||||||
int site,
|
|
||||||
int arrow_x,
|
|
||||||
int arrow_y,
|
|
||||||
int arrow_z);
|
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "../include/base.h"
|
#include "base.h"
|
||||||
#include "../include/contain.h" // instead of "ui.h"
|
#include "contain.h" // instead of "ui.h"
|
||||||
#include "../include/graph_area.h"
|
#include "graph_area.h"
|
||||||
|
|
||||||
/* Initializes the buffer of a gl_area
|
/* Initializes the buffer of a gl_area
|
||||||
* Calls according to the user preferences
|
* Calls according to the user preferences
|
||||||
|
@ -119,28 +119,12 @@ bool graphics_init_shaders(const int stack_id)
|
||||||
|
|
||||||
// Link shaders to program
|
// Link shaders to program
|
||||||
program = glCreateProgram();
|
program = glCreateProgram();
|
||||||
printf("\n------------------------------------------------------------------------------------------\n");
|
|
||||||
printf("[debug] graphics_init_shaders() : program = %d, vertex = %d, fragment = %d\n\
|
|
||||||
exec > ** (myprogram:-----): WARNING ** : --:--:--:---: Linking failure: (address)\n",
|
|
||||||
program, vertex, fragment);
|
|
||||||
|
|
||||||
/* (myprogram:11732): WARNING **: 10:37:34.233: v plusieurs 'run' successifs
|
|
||||||
* (myprogram:11883): WARNING **: 10:38:22.979: glLinkProgram(program); < commenté
|
|
||||||
* (myprogram:11953): WARNING **: 10:38:46.170:
|
|
||||||
* (myprogram:12034): WARNING **: 10:39:14.709:
|
|
||||||
* (myprogram:12182): WARNING **: 10:40:49.788:
|
|
||||||
* > probablement la même adresse dans la librairie 'mesa' d'OpenGL (?) */
|
|
||||||
|
|
||||||
glAttachShader(program, vertex);
|
glAttachShader(program, vertex);
|
||||||
glAttachShader(program, fragment);
|
glAttachShader(program, fragment);
|
||||||
|
|
||||||
printf("Failed to link the graphic stack to widgets ! <> see init.c graphics_init_shaders()\n");
|
glLinkProgram(program);
|
||||||
printf("the error in not : vertex shader lacks `main' but : failed to link... (comment line 140)\n");
|
|
||||||
// https://registry.khronos.org/OpenGL-Refpages/gl4/html/glLinkProgram.xhtml
|
|
||||||
// glLinkProgram(program); // Linking failure: (address)
|
|
||||||
printf("------------------------------------------------------------------------------------------\n");
|
|
||||||
|
|
||||||
glGetProgramiv(program, GL_LINK_STATUS, &status); // Linking failure: (address)
|
glGetProgramiv(program, GL_LINK_STATUS, &status);
|
||||||
|
|
||||||
if(status == GL_FALSE) {
|
if(status == GL_FALSE) {
|
||||||
int log_len;
|
int log_len;
|
|
@ -0,0 +1,175 @@
|
||||||
|
/*
|
||||||
|
* Gem-graph OpenGL experiments
|
||||||
|
*
|
||||||
|
* Desc: GL functions
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
||||||
|
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include "base.h"
|
||||||
|
#include "contain.h" // instead of "ui.h"
|
||||||
|
#include "graph_area.h"
|
||||||
|
|
||||||
|
/* Initializes the buffer of a gl_area
|
||||||
|
* Calls according to the user preferences
|
||||||
|
* @param gl_area, ptr to the gl_area widget
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void graphics_init_buffers(const int stack_id)
|
||||||
|
{
|
||||||
|
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
||||||
|
|
||||||
|
//XXX
|
||||||
|
graphics_model_setup(stack_id);
|
||||||
|
|
||||||
|
GLuint vao, vertex_buffer, color_buffer;
|
||||||
|
|
||||||
|
glGenBuffers(1, &vertex_buffer);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER,
|
||||||
|
stack->buffer_vertex_size *
|
||||||
|
sizeof(stack->buffer_vertex_origin[0]),
|
||||||
|
stack->buffer_vertex_origin,
|
||||||
|
GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// colors
|
||||||
|
glGenBuffers(1, &color_buffer);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, stack->buffer_colors_size *
|
||||||
|
sizeof(stack->buffer_colors_origin[0]),
|
||||||
|
stack->buffer_colors_origin,
|
||||||
|
GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
// We only use one VAO, so we always keep it bound
|
||||||
|
glGenVertexArrays(1, &vao);
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
|
||||||
|
stack->vao = vao;
|
||||||
|
stack->position_buffer = vertex_buffer;
|
||||||
|
stack->color_buffer = color_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initializes the shaders of a gl_area and link them to a program
|
||||||
|
*
|
||||||
|
* @param gl_area, ptr to the gl_area widget
|
||||||
|
*
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
|
bool graphics_init_shaders(const int stack_id)
|
||||||
|
{
|
||||||
|
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
||||||
|
char *vertex_shader;
|
||||||
|
char *fragment_shader;
|
||||||
|
int status;
|
||||||
|
GLuint vertex = 0, fragment; // 2024-06-05 j'initialise vertex à 0 (au pif !)
|
||||||
|
GLuint program = 0;
|
||||||
|
GLuint m = 0;
|
||||||
|
GLuint v = 0;
|
||||||
|
GLuint p = 0;
|
||||||
|
|
||||||
|
// Load vertex shader file
|
||||||
|
vertex_shader = read_file(VERTEX_SHADER_FILE);
|
||||||
|
if (vertex_shader == NULL)
|
||||||
|
return false;
|
||||||
|
vertex = create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader);
|
||||||
|
|
||||||
|
if(vertex == 0) {
|
||||||
|
stack->program = 0;
|
||||||
|
g_free(vertex_shader);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load fragment shader file
|
||||||
|
fragment_shader = read_file(FRAG_SHADER_FILE);
|
||||||
|
if (fragment_shader == NULL)
|
||||||
|
return false;
|
||||||
|
fragment = create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader);
|
||||||
|
|
||||||
|
if(fragment == 0) {
|
||||||
|
glDeleteShader(vertex);
|
||||||
|
stack->program = 0;
|
||||||
|
g_free(vertex_shader);
|
||||||
|
g_free(fragment_shader);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link shaders to program
|
||||||
|
program = glCreateProgram();
|
||||||
|
glAttachShader(program, vertex);
|
||||||
|
glAttachShader(program, fragment);
|
||||||
|
|
||||||
|
glLinkProgram(program);
|
||||||
|
|
||||||
|
glGetProgramiv(program, GL_LINK_STATUS, &status);
|
||||||
|
|
||||||
|
if(status == GL_FALSE) {
|
||||||
|
int log_len;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_len);
|
||||||
|
|
||||||
|
buffer = g_malloc(log_len + 1);
|
||||||
|
assert(buffer);
|
||||||
|
glGetProgramInfoLog(program, log_len, NULL, buffer);
|
||||||
|
|
||||||
|
g_warning("Linking failure:\n%s", buffer);
|
||||||
|
|
||||||
|
g_free(buffer);
|
||||||
|
|
||||||
|
glDeleteProgram(program);
|
||||||
|
program = 0;
|
||||||
|
|
||||||
|
glDeleteShader(vertex);
|
||||||
|
glDeleteShader(fragment);
|
||||||
|
|
||||||
|
g_free(vertex_shader);
|
||||||
|
g_free(fragment_shader);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the location of the "mvp" uniform */
|
||||||
|
m = glGetUniformLocation(program, "model_matrix");
|
||||||
|
v = glGetUniformLocation(program, "view_matrix");
|
||||||
|
p = glGetUniformLocation(program, "projection_matrix");
|
||||||
|
|
||||||
|
glDetachShader(program, vertex);
|
||||||
|
glDetachShader(program, fragment);
|
||||||
|
|
||||||
|
glDeleteShader(vertex);
|
||||||
|
glDeleteShader(fragment);
|
||||||
|
|
||||||
|
stack->program = program;
|
||||||
|
stack->m = m;
|
||||||
|
stack->v = v;
|
||||||
|
stack->p = p;
|
||||||
|
|
||||||
|
g_free(vertex_shader);
|
||||||
|
g_free(fragment_shader);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
2
main.c
2
main.c
|
@ -20,7 +20,5 @@ int main (int argc, char **argv)
|
||||||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||||
g_object_unref (app);
|
g_object_unref (app);
|
||||||
|
|
||||||
printf("in contain.get_SPACE_VIEW_box() (line 138) > ui_setup_glarea (0, GTK_WIDGET (middle_box)); < commented 2024/06/27 > TODO\n");
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <libxml/xmlreader.h> // http://xmlsoft.org/examples/#parse1.c
|
#include <libxml/xmlreader.h> // http://xmlsoft.org/examples/#parse1.c
|
||||||
// https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/general.html
|
// https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/general.html
|
||||||
|
|
||||||
#include "../include/base.h"
|
#include "base.h"
|
||||||
|
|
||||||
#define READ_SITE 1 << 0
|
#define READ_SITE 1 << 0
|
||||||
#define READ_WEIGHT 1 << 1
|
#define READ_WEIGHT 1 << 1
|
|
@ -1,79 +0,0 @@
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include "../include/callback.h"
|
|
||||||
#include "../include/automaton.h"
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* S T A T E S */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
static int choice_EXEC_EDIT = EXEC;
|
|
||||||
static int choice_STATE_RULES_DATA = STATE;
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* T R A N S I T I O N S */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
static void debug_printing (int prescribed, int sub_automaton);
|
|
||||||
|
|
||||||
void set_EXEC_EDIT (int prescribed) {
|
|
||||||
if (choice_EXEC_EDIT != prescribed) {
|
|
||||||
debug_printing (prescribed, 0); // EXEC_EDIT is sub_automaton 0
|
|
||||||
choice_EXEC_EDIT = prescribed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_STATE_RULES_DATA (int prescribed) {
|
|
||||||
if (choice_STATE_RULES_DATA != prescribed) {
|
|
||||||
debug_printing (prescribed, 1); // STATE_RULES_DATA is sub_automaton 1
|
|
||||||
choice_STATE_RULES_DATA = prescribed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* G E T T E R S & D E B U G G E R S */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
int get_EXEC_EDIT () {return choice_EXEC_EDIT;}
|
|
||||||
int get_STATE_RULES_DATA () {return choice_STATE_RULES_DATA;}
|
|
||||||
|
|
||||||
static char *get_str_EXEC_EDIT (int value) {
|
|
||||||
switch (value) {
|
|
||||||
case (EXEC) : return "EXEC";
|
|
||||||
case (EDIT) : return "EDIT";
|
|
||||||
default : printf("default in automaton.get_EXEC_EDIT ()\n"); return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *get_str_STATE_RULES_DATA (int value) {
|
|
||||||
switch (value) {
|
|
||||||
case (STATE) : return "STATE";
|
|
||||||
case (RULES) : return "RULES";
|
|
||||||
case (DATA) : return "DATA";
|
|
||||||
default : printf("default in automaton.get_STATE_RULES_DATA ()\n"); return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void debug_printing (int prescribed, int sub_automaton) {
|
|
||||||
switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and
|
|
||||||
// sub_automaton 1 is STATE_RULES_DATA
|
|
||||||
case (0) : printf("switch > %5s X %5s <> %5s X %5s\n",
|
|
||||||
get_str_EXEC_EDIT (choice_EXEC_EDIT),
|
|
||||||
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
|
|
||||||
get_str_EXEC_EDIT (prescribed),
|
|
||||||
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA));
|
|
||||||
break;
|
|
||||||
case (1) : printf("switch > %5s X %5s <> %5s X %5s\n",
|
|
||||||
get_str_EXEC_EDIT (choice_EXEC_EDIT),
|
|
||||||
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
|
|
||||||
get_str_EXEC_EDIT (choice_EXEC_EDIT),
|
|
||||||
get_str_STATE_RULES_DATA (prescribed));
|
|
||||||
break;
|
|
||||||
default : printf("default in automaton.debug_printing()\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
162
src/grid.c
162
src/grid.c
|
@ -1,162 +0,0 @@
|
||||||
/*
|
|
||||||
* Gem-graph
|
|
||||||
*
|
|
||||||
* Desc: OpenGL grid functions
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
|
||||||
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include "../include/base.h"
|
|
||||||
//#include "../include/ui.h"
|
|
||||||
#include "../include/graphics.h"
|
|
||||||
|
|
||||||
int draw_space_ridges_vertex (const int stack_id,
|
|
||||||
long offset_vertex,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z)
|
|
||||||
{
|
|
||||||
GLfloat max = fmax(x, y); max = fmax(max, z);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex - y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex + y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex - y / max, + z / max);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex + y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex - y / max, + z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex + y / max, + z / max);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, + y / max, + z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
int draw_space_ridges_lines (const int stack_id)
|
|
||||||
{
|
|
||||||
graphics_draw_line (stack_id, 0, 1); graphics_draw_line (stack_id, 7, 4);
|
|
||||||
graphics_draw_line (stack_id, 0, 2); graphics_draw_line (stack_id, 7, 5);
|
|
||||||
graphics_draw_line (stack_id, 0, 3); graphics_draw_line (stack_id, 7, 6);
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, 1, 4); graphics_draw_line (stack_id, 2, 4);
|
|
||||||
graphics_draw_line (stack_id, 1, 5); graphics_draw_line (stack_id, 3, 5);
|
|
||||||
graphics_draw_line (stack_id, 2, 6); graphics_draw_line (stack_id, 3, 6);
|
|
||||||
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
long draw_grids_on_space_faces_vertex (const int stack_id,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z)
|
|
||||||
{
|
|
||||||
float i, max = fmax(x, y); max = fmax(max, z);
|
|
||||||
|
|
||||||
for (i = 1; i < x; i++) {
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, - y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, - y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, y / max, - z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
|
||||||
|
|
||||||
for (i = 1; i < y; i++) {
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, (2 * i / y - 1) * y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, (2 * i / y - 1) * y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, (2 * i / y - 1) * y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, (2 * i / y - 1) * y / max, - z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
|
||||||
|
|
||||||
for (i = 1; i < z; i++) {
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, - y / max, (2 * i / z - 1) * z / max);
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, y / max, (2 * i / z - 1) * z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, y / max, (2 * i / z - 1) * z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, - y / max, (2 * i / z - 1) * z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (x + y + z - 3) * 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
long draw_grids_on_space_faces_lines (const int stack_id,
|
|
||||||
long offset_vertex,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z)
|
|
||||||
{
|
|
||||||
offset_vertex = offset_vertex / 3;
|
|
||||||
|
|
||||||
for (int i = 0; i < x - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset_vertex += (x - 1) * 4;
|
|
||||||
|
|
||||||
for (int i = 0; i < y - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset_vertex += (y - 1) * 4;
|
|
||||||
|
|
||||||
for (int i = 0; i < z - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (x + y + z - 3) * 4;
|
|
||||||
}
|
|
||||||
|
|
26
src/main.c
26
src/main.c
|
@ -1,26 +0,0 @@
|
||||||
/******************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* E coli by David S. Goodsell (2009) */
|
|
||||||
/* --- */
|
|
||||||
/* Let this freeze frame guide us towards the model */
|
|
||||||
/* that alone can account for the phenomenon ! */
|
|
||||||
/* */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
#include "../include/callback.h"
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
GtkApplication *app;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
app = gtk_application_new ("org.jean.GTK4_GG_hack", G_APPLICATION_DEFAULT_FLAGS);
|
|
||||||
g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), NULL);
|
|
||||||
g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), NULL);
|
|
||||||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
|
||||||
g_object_unref (app);
|
|
||||||
|
|
||||||
printf("in contain.get_SPACE_VIEW_box() (line 138) > ui_setup_glarea (0, GTK_WIDGET (middle_box)); < commented 2024/06/27 > TODO\n");
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "../include/contain.h"
|
#include "contain.h"
|
||||||
#include "../include/texts.h"
|
#include "texts.h"
|
||||||
#include "../include/callback.h"
|
#include "callback.h"
|
||||||
|
|
||||||
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
|
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
|
||||||
// https://docs.gtk.org/gtk4/section-text-widget.html
|
// https://docs.gtk.org/gtk4/section-text-widget.html
|
Loading…
Reference in New Issue