drawio update
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#ifndef DRAWIO_H
|
||||
# define DRAWIO_H
|
||||
|
||||
#include "../../libft.h"
|
||||
# include "../../libft.h"
|
||||
|
||||
typedef enum e_dio_elemtype
|
||||
{
|
||||
@@ -35,8 +35,8 @@ typedef struct s_dio_elem
|
||||
|
||||
} t_dio_elem;
|
||||
|
||||
int drawio_init(char *file_path);
|
||||
int drawio_create_elem(int fd, t_dio_elem *elem);
|
||||
void drawio_end_file(int fd);
|
||||
int drawio_init(char *file_path);
|
||||
int drawio_create_elem(int fd, t_dio_elem *elem);
|
||||
void drawio_end_file(int fd);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef DIO_PRIVATE
|
||||
# define DIO_PRIVATE
|
||||
#ifndef DIO_PRIVATE_H
|
||||
# define DIO_PRIVATE_H
|
||||
|
||||
int draw_rect(int fd, int id, t_dio_elem *elem);
|
||||
int draw_arrow(int fd, int id, t_dio_elem *elem);
|
||||
|
||||
@@ -17,12 +17,12 @@ int draw_rect(int fd, int id, t_dio_elem *elem)
|
||||
{
|
||||
ft_fprintf(fd, "<mxCell id=\"%d\" ", id);
|
||||
ft_fprintf(fd, "value=\"%s\" ", elem->text);
|
||||
ft_fprintf(fd, "style=\"rounded=%d;whiteSpace=wrap;html=1;\" ", elem->rounded);
|
||||
ft_fprintf(fd, "vertex=\"1\" parent=\"1\"> \n");
|
||||
ft_fprintf(fd, "<mxGeometry x=\"%d\" y=\"%d\" ", elem->x, elem->y);
|
||||
ft_fprintf(fd, "style=\"rounded=%d;whiteSpace=wrap;", elem->rounded);
|
||||
ft_fprintf(fd, "html=1;\" vertex=\"1\" parent=\"1\"> \n");
|
||||
ft_fprintf(fd, "<mxGeometry x=\"%d\" y=\"%d\" ", elem->x, elem->y);
|
||||
ft_fprintf(fd, "width=\"%d\" height=\"%d\" ", elem->w, elem->h);
|
||||
ft_fprintf(fd, "as=\"geometry\"/>\n");
|
||||
ft_fprintf(fd, "</mxCell>\n");
|
||||
ft_fprintf(fd, "</mxCell>\n");
|
||||
return (id);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ int draw_arrow(int fd, int id, t_dio_elem *elem)
|
||||
if (!elem->id_src || !elem->id_dst)
|
||||
return (0);
|
||||
ft_fprintf(fd, "<mxCell id=\"%d\" ", id);
|
||||
ft_fprintf(fd, "edge=\"1\" parent=\"1\" ");
|
||||
ft_fprintf(fd, "source=\"%d\" target=\"%d\">\n", elem->id_src, elem->id_dst);
|
||||
ft_fprintf(fd, "<mxGeometry relative=\"1\" as=\"geometry\"/>\n</mxCell>\n");
|
||||
ft_fprintf(fd, "edge=\"1\" parent=\"1\" source=");
|
||||
ft_fprintf(fd, "\"%d\" target=\"%d\">\n", elem->id_src, elem->id_dst);
|
||||
ft_fprintf(fd, "<mxGeometry relative=\"1\" as=\"geometry\"/>\n</mxCell>\n");
|
||||
return (id);
|
||||
}
|
||||
|
||||
@@ -13,33 +13,32 @@
|
||||
#include "../drawio.h"
|
||||
#include "../header/dio_private.h"
|
||||
|
||||
int drawio_init(char *file_path)
|
||||
int drawio_init(char *file_path)
|
||||
{
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
fd = open(file_path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
ft_fprintf(fd, "<mxfile host=\"app.diagrams.net\" ");
|
||||
ft_fprintf(fd, "modified=\"2025-01-24T12:00:00Z\" ");
|
||||
ft_fprintf(fd, "agent=\"c_generator\" version=\"15.8.7\" ");
|
||||
ft_fprintf(fd, "agent=\"c_generator\" version=\"15.8.7\" ");
|
||||
ft_fprintf(fd, "type=\"device\">\n");
|
||||
ft_fprintf(fd, "<diagram id=\"GEN\" name=\"GEN-Diagram\">\n");
|
||||
ft_fprintf(fd, "<mxGraphModel>\n");
|
||||
ft_fprintf(fd, "<root>\n");
|
||||
ft_fprintf(fd, "<mxCell id=\"0\"/>\n");
|
||||
ft_fprintf(fd, "<mxGraphModel>\n");
|
||||
ft_fprintf(fd, "<root>\n");
|
||||
ft_fprintf(fd, "<mxCell id=\"0\"/>\n");
|
||||
ft_fprintf(fd, "<mxCell id=\"1\" parent=\"0\"/>\n");
|
||||
return(fd);
|
||||
return (fd);
|
||||
}
|
||||
|
||||
void drawio_end_file(int fd)
|
||||
void drawio_end_file(int fd)
|
||||
{
|
||||
ft_fprintf(fd, "</root>\n</mxGraphModel>\n</diagram>\n</mxfile>");
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int drawio_create_elem(int fd, t_dio_elem *elem)
|
||||
int drawio_create_elem(int fd, t_dio_elem *elem)
|
||||
{
|
||||
static int id = 1;
|
||||
static int id = 1;
|
||||
|
||||
id ++;
|
||||
if (elem->type == ARROW)
|
||||
|
||||
Reference in New Issue
Block a user