2023-01-23 18:52:57 +01:00
|
|
|
/*
|
|
|
|
* Gem-graph OpenGL experiments
|
|
|
|
*
|
|
|
|
* Desc: Base header
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2024-05-24 16:28:51 +02:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* E coli by David S. Goodsell (2009) */
|
|
|
|
/* --- */
|
|
|
|
/* Let this freeze frame guide us towards the model */
|
|
|
|
/* that alone can account for the phenomenon ! */
|
|
|
|
/* */
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-01-23 18:52:57 +01:00
|
|
|
#pragma once
|
2023-09-05 15:00:48 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <math.h>
|
2023-02-23 19:51:02 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2023-09-05 15:00:48 +02:00
|
|
|
#include <string.h>
|
2023-02-23 19:51:02 +01:00
|
|
|
#include <stdbool.h>
|
2023-09-05 15:00:48 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2023-02-23 19:51:02 +01:00
|
|
|
#include <unistd.h>
|
2023-09-05 15:00:48 +02:00
|
|
|
#include <glib-2.0/glib.h>
|
2024-04-18 16:42:53 +02:00
|
|
|
//#define G_APPLICATION_DEFAULT_FLAGS 0
|
2023-01-23 18:52:57 +01:00
|
|
|
|
2024-05-24 16:28:51 +02:00
|
|
|
|
|
|
|
#define W 1920
|
|
|
|
#define H 960
|
|
|
|
#define W_IMAGE W - 320
|
|
|
|
#define H_IMAGE H - 126
|
|
|
|
#define H_STYLES_PANE 30
|
|
|
|
#define W_IMAGE_LOCAL W / 16
|
|
|
|
#define H_IMAGE_LOCAL H / 16
|
|
|
|
|
|
|
|
//GtkWidget *get_selected_rules_vpaned_new();
|
|
|
|
|
|
|
|
//void activate (GtkApplication *app, gpointer user_data);
|
|
|
|
|
|
|
|
|
2023-12-19 21:46:51 +01:00
|
|
|
// Graphical axis
|
2023-01-23 18:52:57 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
X_AXIS,
|
|
|
|
Y_AXIS,
|
|
|
|
Z_AXIS,
|
|
|
|
|
|
|
|
N_AXIS
|
|
|
|
};
|
2023-02-23 19:51:02 +01:00
|
|
|
|
2023-12-19 21:46:51 +01:00
|
|
|
// Gem-graph modes
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HOME_MODE,
|
|
|
|
RUN_MODE,
|
|
|
|
EDIT_MODE,
|
|
|
|
PRESENTATION_MODE,
|
|
|
|
|
|
|
|
N_MODE
|
|
|
|
};
|
|
|
|
|
2024-01-12 17:23:06 +01:00
|
|
|
/*
|
|
|
|
* Structure describing an arrow
|
|
|
|
*/
|
|
|
|
struct arrow_t {
|
|
|
|
uint load;
|
|
|
|
uint site;
|
|
|
|
uint x;
|
|
|
|
uint y;
|
|
|
|
uint z;
|
|
|
|
};
|
|
|
|
|
2023-02-23 19:51:02 +01:00
|
|
|
/*
|
|
|
|
* Read a file from filename into a provided buffer
|
|
|
|
*
|
|
|
|
* @param filename, file name
|
|
|
|
* contents, target ptr
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-02-25 21:23:37 +01:00
|
|
|
static inline char *read_file(char *filename)
|
2023-02-23 19:51:02 +01:00
|
|
|
{
|
2023-02-23 21:54:22 +01:00
|
|
|
int fd;
|
|
|
|
int filesize;
|
2023-02-25 21:23:37 +01:00
|
|
|
char *contents;
|
2023-02-23 19:51:02 +01:00
|
|
|
|
2023-02-23 21:54:22 +01:00
|
|
|
fd = open(filename, O_RDONLY);
|
2023-02-23 19:51:02 +01:00
|
|
|
if(fd < 0) {
|
|
|
|
printf("Couldn't read file: %s\n",filename);
|
2023-02-25 21:23:37 +01:00
|
|
|
return NULL;
|
2023-02-23 19:51:02 +01:00
|
|
|
}
|
|
|
|
|
2023-02-25 21:23:37 +01:00
|
|
|
filesize = lseek(fd, 0, SEEK_END) + 1 ;
|
2023-06-09 15:03:28 +02:00
|
|
|
contents = g_malloc(filesize * sizeof(char));
|
2023-09-05 15:00:48 +02:00
|
|
|
assert (contents);
|
2023-02-23 19:51:02 +01:00
|
|
|
|
|
|
|
lseek(fd, 0, SEEK_SET);
|
2023-02-25 21:23:37 +01:00
|
|
|
read(fd,contents,filesize);
|
2023-02-23 19:51:02 +01:00
|
|
|
|
2023-02-25 21:23:37 +01:00
|
|
|
contents[filesize-1] = '\0';
|
2023-02-23 19:51:02 +01:00
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
2023-02-25 21:23:37 +01:00
|
|
|
return contents;
|
2023-02-23 19:51:02 +01:00
|
|
|
}
|
2023-09-05 15:00:48 +02:00
|
|
|
|
|
|
|
/* I'm standing on Earth (any planet or star or spinning spheroid, in fact)
|
|
|
|
* and looking towards its North pole
|
|
|
|
*
|
|
|
|
* X - X = EAST - WEST = rouge - cyan
|
|
|
|
* Y - Y = ZENITH - NADIR = vert - magenta
|
|
|
|
* Z - Z = NORTH - SOUTH = bleu - jaune
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define EAST 0 // + x rouge
|
|
|
|
#define WEST 1 // - x cyan
|
|
|
|
#define ZENITH 2 // + y vert
|
|
|
|
#define NADIR 3 // - y magenta
|
2023-11-03 22:35:16 +01:00
|
|
|
#define SOUTH 4 // + z bleu
|
|
|
|
#define NORTH 5 // - z jaune
|