From ff18925f51b000c23acf3bad8fd0809ce7956f7e Mon Sep 17 00:00:00 2001
From: Raphael Boucherie <raphael.boucherie@inria.fr>
Date: Thu, 6 Apr 2017 10:49:11 +0200
Subject: [PATCH] Updated makefille for treedraw test, finalyzed drawing of TS
 tile

---
 Makefile                    | 10 +++++---
 include/libdraw.h           | 14 +++-------
 src/treedraw.c              | 51 ++++++++++++++++++++-----------------
 testings/testing_treedraw.c | 36 +++++++++++++-------------
 4 files changed, 56 insertions(+), 55 deletions(-)

diff --git a/Makefile b/Makefile
index f4e9c8a..f4135c0 100644
--- a/Makefile
+++ b/Makefile
@@ -3,15 +3,16 @@ CFLAGS = -Iinclude -Wall -g3
 LDFLAGS = -lm
 LIBHQR=src/libhqr.a
 
-default: testing_pivgen testing_treewalk
+default: testing_pivgen testing_treewalk testing_treedraw
 
 src/queue.o:           include/queue.h include/common.h
 src/libhqr.o:          include/common.h include/libhqr.h
 src/libhqr_dbg.o:      include/common.h include/libhqr.h
 src/libhqr_systolic.o: include/common.h include/libhqr.h
 src/treewalk.o:        include/common.h include/libhqr.h include/queue.h
+src/treedraw.o:        include/common.h include/libhqr.h include/libdraw.h
 
-$(LIBHQR): src/libhqr.o src/libhqr_dbg.o src/libhqr_systolic.o src/treewalk.o src/queue.o
+$(LIBHQR): src/libhqr.o src/libhqr_dbg.o src/libhqr_systolic.o src/treewalk.o src/queue.o src/treedraw.o
 	ar cr $@ $^
 
 %.o : %.c
@@ -23,6 +24,9 @@ testing_pivgen : testings/testing_pivgen.o ${LIBHQR}
 testing_treewalk : testings/testing_treewalk.c ${LIBHQR}
 	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
 
+testing_treedraw : testings/testing_treedraw.o ${LIBHQR}
+	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
+
 clean :
 	rm -f include/*~
 	rm -f src/*.o src/*~
@@ -30,4 +34,4 @@ clean :
 
 cleanall: clean
 	rm -f ${LIBHQR}
-	rm -f testing_pivgen testing_treewalk
+	rm -f testing_pivgen testing_treewalk testing_treedraw tree.svg
diff --git a/include/libdraw.h b/include/libdraw.h
index 020abbe..0824b92 100644
--- a/include/libdraw.h
+++ b/include/libdraw.h
@@ -1,8 +1,8 @@
 /**
   *
-  * @file libdraw.h - header for all the functions of drawing.
+  * @file libdraw.h
   *
-  * PaStiX symbol structure routines
+  * Header file for all the functions of drawing.
   *
   * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
   *                      Univ. Bordeaux. All rights reserved.
@@ -18,15 +18,7 @@
 #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
+#include <common.h>
 
 BEGIN_C_DECLS
 
diff --git a/src/treedraw.c b/src/treedraw.c
index 9fa354d..f19307d 100644
--- a/src/treedraw.c
+++ b/src/treedraw.c
@@ -1,45 +1,50 @@
 /**
-  *
-  * @file treedraw.c - All the functions required for drawing tree are here.
-  *                    TT and TS tiles are drawn in rectangle.
-  *
-  *
-  * 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 Mathieu Faverge
-  * @date 2017-04-04
-  *
-  **/
+ *
+ * @file treedraw.c
+ *
+ * All the functions required for drawing tree are here.
+ *
+ * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ *                 Univ. Bordeaux. All rights reserved.
+ *
+ * @version 1.0.0
+ * @author Raphael Boucherie
+ * @author Mathieu Faverge
+ * @date 2017-04-04
+ *
+ */
 
 #include <string.h>
 #include <stdio.h>
 #include "libdraw.h"
 
+/*
+ * functions writing in the svg file
+ */
+
 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\">\n") <0) return;
+    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\">\n") <0) return;
 }
 
 void libhqr_writecss();
 
 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;
+    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){
-  if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"50\" height=\"50\" /> \n", x, y) < 0 ) return;
+    if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"50\" height=\"50\" fill =\"red\" /> \n", x, y) < 0 ) return;
+    int x2 = (x * 4)/3;
+    int y2 = (y * 4)/3;
+    if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"25\" height=\"25\" fill =\"white\"/> \n", x2, y2) < 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;
+    if(fprintf(tree,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" /> \n", x1, y1, x2, y2) < 0 ) return;
 }
 
 void libhqr_writeend(FILE *tree){
-  if(fprintf(tree, "</svg>") < 0) return;
+    if(fprintf(tree, "</svg>") < 0) return;
 }
diff --git a/testings/testing_treedraw.c b/testings/testing_treedraw.c
index 6b0b67f..d30e06a 100644
--- a/testings/testing_treedraw.c
+++ b/testings/testing_treedraw.c
@@ -1,18 +1,18 @@
 /**
-  *
-  * @file testting_treedraw.c - Testing file for drawing functions and drawing tree
-  *
-  * 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 Mathieu Faverge
-  * @date 2017-04-04
-  *
-  **/
+ *
+ * @file testting_treedraw.c
+ *
+ * Testing file for drawing functions and drawing tree
+ *
+ * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ *                      Univ. Bordeaux. All rights reserved.
+ *
+ * @version 1.0.0
+ * @author Raphael Boucherie
+ * @author Mathieu Faverge
+ * @date 2017-04-04
+ *
+ */
 
 
 #include <stdio.h>
@@ -21,12 +21,12 @@
 
 
 
-int main(int argc, char ** argv)
+int
+main(int argc, char ** argv)
 {
   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_drawTS(30,30,tree);
   libhqr_writeend(tree);
+  return 1;
 }
-- 
GitLab