Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0ab6a673 authored by Raphael Boucherie's avatar Raphael Boucherie Committed by BOUCHERIE Raphael
Browse files

added header for drawing function, fixed some commentary

parent 7f965afc
No related branches found
No related tags found
1 merge request!4Treewalk
/**
*
* @file libdraw.h - header for all the functions of drawing.
*
* PaStiX symbol structure routines
*
* @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Matthieu Faverge
* @date 2017-04-04
*
**/
#include <stdio.h>
#ifndef _LIBDRAW_H_
#define _LIBDRAW_H_
#undef BEGIN_C_DECLS
#undef END_C_DECLS
#if defined(c_plusplus) || defined(__cplusplus)
# define BEGIN_C_DECLS extern "C" {
# define END_C_DECLS }
#else
#define BEGIN_C_DECLS /* empty */
#define END_C_DECLS /* empty */
#endif
BEGIN_C_DECLS
/*
* function for treedraw
*/
void libhqr_writeheader(FILE *tree);
void libhqr_writecss();
void libhqr_writeend(FILE *tree);
void libhqr_drawTT(int x, int y, int k, FILE *tree);
void libhqr_drawTS(int x, int y, FILE *tree);
void libhqr_drawline(int x1, int y1, int x2, int y2, FILE *tree);
END_C_DECLS
#endif /* _LIBDRAW_H_ */
/**
*
* @file treedraw.c
* @file treedraw.c - All the functions required for drawing tree are here.
* TT and TS tiles are drawn in rectangle.
*
*
* PaStiX symbol structure routines
*
......@@ -9,53 +11,35 @@
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Matthieu Faverge
* @author Mathieu Faverge
* @date 2017-04-04
*
**/
#include "libhqr.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
//#if defined(LIBHQR_HAVE_STRING_H)
#include <string.h>
//#endif /* defined(PARSEC_HAVE_STRING_H) */
#define PRINT_PIVGEN 0
#ifdef PRINT_PIVGEN
#define myassert( test ) {if ( ! (test) ) return -1;}
#else
#define myassert(test) {assert((test)); return -1;}
#endif
#include "libdraw.h"
void libhqr_writeheader(){
FILE *tree = fopen("tree.svg", "w+");
void libhqr_writeheader(FILE *tree){
if(fprintf(tree, "<?xml version=\"1.0\" standalone=\"no\"?>\n") < 0) return;
if(fprintf(tree, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n ") < 0) return;
if(fprintf(tree, "<svg width=\"2000\" height=\"2000\" version=\"1.1\" \n xmlns=\"http://www.w3.org/2000/svg\">") <0) return;
if(fprintf(tree, "<svg width=\"2000\" height=\"2000\" version=\"1.1\" \n xmlns=\"http://www.w3.org/2000/svg\">\n") <0) return;
}
void libhqr_writecss();
void libhqr_drawTT(int x, int y, int k){
FILE *tree = fopen("tree.svg","a+");
if(fprintf(tree,"<rect x=\"50\" y=\"50\" width=\"50\" height=\"50\" fill=\"red\" />") < 0 ) return;
void libhqr_drawTT(int x, int y, int k, FILE *tree){
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"50\" height=\"50\" fill=\"red\" /> \n", x, y) < 0 ) return;
}
void libhqr_drawTS(int x, int y){
FILE *tree = fopen("tree.svg","a+");
if(fprintf(tree,"<rect x=\"40\" y=\"40\" width=\"50\" height=\"50\" />") < 0 ) return;
void libhqr_drawTS(int x, int y, FILE *tree){
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"50\" height=\"50\" /> \n", x, y) < 0 ) return;
}
void libhqr_drawline(int x1, int y1, int x2, int y2){
FILE *tree = fopen("tree.svg","a+");
if(fprintf(tree,"<line x1=\"20\" y1=\"80\" x2=\"130\" y2=\"200\" />") < 0 ) return;
void libhqr_drawline(int x1, int y1, int x2, int y2, FILE *tree){
if(fprintf(tree,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" /> \n", x1, y1, x2, y2) < 0 ) return;
}
void libhqr_writeend(){
FILE *tree = fopen("tree.svg", "a+");
if(fprintf(tree, "<\\svg>") < 0) return;
void libhqr_writeend(FILE *tree){
if(fprintf(tree, "</svg>") < 0) return;
}
/**
*
* @file testting_treedraw.c
* @file testting_treedraw.c - Testing file for drawing functions and drawing tree
*
* PaStiX symbol structure routines
*
......@@ -9,25 +9,24 @@
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Matthieu Faverge
* @author Mathieu Faverge
* @date 2017-04-04
*
**/
#include "libhqr.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "libdraw.h"
int main(int argc, char ** argv)
{
libhqr_writeheader();
libhqr_drawTT(50,50,1);
libhqr_drawTS(40,40);
libhqr_drawline(50,50,40,40);
libhqr_writeend();
FILE *tree = fopen("tree.svg","w+");
libhqr_writeheader(tree);
libhqr_drawTT(50,50,1,tree);
libhqr_drawTS(40,40,tree);
libhqr_drawline(50,50,40,40,tree);
libhqr_writeend(tree);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment