From 7f965afc5fbd6e2a850981012d672ef47885a93a Mon Sep 17 00:00:00 2001
From: Raphael Boucherie <rboucher@zimbra.inria.fr>
Date: Tue, 4 Apr 2017 14:58:04 +0200
Subject: [PATCH] added test file for drawing tree, anf functions to the
 library

---
 include/libhqr.h            | 10 ++++++++++
 src/treedraw.c              | 16 +++++++++++++---
 testings/testing_treedraw.c | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 testings/testing_treedraw.c

diff --git a/include/libhqr.h b/include/libhqr.h
index d724e48..8850141 100644
--- a/include/libhqr.h
+++ b/include/libhqr.h
@@ -195,6 +195,16 @@ void libhqr_hqr_finalize( libhqr_tree_t *qrtree );
 
 void libhqr_treewalk(const libhqr_tree_t *qrtree,int k);
 
+/*
+ * function for treedraw
+ */
+void libhqr_writeheader();
+void libhqr_writecss();
+void libhqr_writeend();
+void libhqr_drawTT(int x, int y, int k);
+void libhqr_drawTS(int x, int y);
+void libhqr_drawline(int x1, int y1, int x2, int y2);
+
 /*
  * Debugging functions
  */
diff --git a/src/treedraw.c b/src/treedraw.c
index a723992..e0d8b4f 100644
--- a/src/treedraw.c
+++ b/src/treedraw.c
@@ -32,7 +32,7 @@
 
 
 void libhqr_writeheader(){
-  FILE *tree = fopen("../tree.xml", "w+");
+  FILE *tree = fopen("tree.svg", "w+");
   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;
@@ -41,11 +41,21 @@ void libhqr_writeheader(){
 void libhqr_writecss();
 
 void libhqr_drawTT(int x, int y, int k){
-  FILE *tree = fopen("../tree.xml","w+");
+  FILE *tree = fopen("tree.svg","a+");
   if(fprintf(tree,"<rect x=\"50\" y=\"50\" width=\"50\" height=\"50\" fill=\"red\" />") < 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_drawline(int x1, int y1, int x2, int y2){
-  FILE *tree = fopen("../tree.xml","w+");
+  FILE *tree = fopen("tree.svg","a+");
   if(fprintf(tree,"<line x1=\"20\" y1=\"80\" x2=\"130\" y2=\"200\" />") < 0 ) return;
 }
+
+void libhqr_writeend(){
+  FILE *tree = fopen("tree.svg", "a+");
+  if(fprintf(tree, "<\\svg>") < 0) return;
+}
diff --git a/testings/testing_treedraw.c b/testings/testing_treedraw.c
new file mode 100644
index 0000000..eaa4dab
--- /dev/null
+++ b/testings/testing_treedraw.c
@@ -0,0 +1,33 @@
+/**
+  *
+  * @file testting_treedraw.c
+  *
+  * 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 "libhqr.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.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();
+}
-- 
GitLab