include/GasteXConverter.hpp

Go to the documentation of this file.
00001 // GasteXConverter.hpp: this file is part of the REGAL project.
00002 //
00003 // REGAL : Random and Exhaustive Generators for Automata - Library
00004 //
00005 // Copyright (C) 2007 Julien DAVID.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 //
00016 #ifndef GASTEXCONVERTER
00017 #define GASTEXCONVERTER
00018 
00019 #include "Converter.hpp"
00020 
00021 namespace regal{
00022   
00023   class GasteXConverter: public Converter{
00024   private:
00025     
00029     void beginGasteXDocument(){
00030       fprintf(output,"\\documentclass{article}\n");
00031       fprintf(output,"\\usepackage[usenames]{color}\n");
00032       fprintf(output,"\\usepackage{gastex}\n");
00033       fprintf(output,"\\begin{document}\n");
00034     }
00035     
00036     
00040     void endGasteXDocument(){
00041       fprintf(output,"\n\\end{document}\n");
00042       fclose(output);
00043     }
00044     
00045   public:
00046     
00050     void draw_node(char * & name,int posx,int posy,bool initial,bool final){
00051       fprintf(output,"\\node");
00052       if(initial==true&&final==false)
00053         fprintf(output,"[Nmarks=i]");
00054       else if(initial==false&&final==true)
00055         fprintf(output,"[Nmarks=f,fangle=270]");
00056       if(initial==true&&final==true)
00057         fprintf(output,"[Nmarks=fi,fangle=270]");
00058       fprintf(output,"(%s)(%d,%d){%s}\n",name,posx,posy,name);
00059     }
00060     
00061     
00066     void draw_edge(char * & start,char * & end,char * & word){
00067       if(strcmp(start,end)==0)
00068         fprintf(output,"\\drawloop[loopangle=90](%s){$%s$}\n",start,word);
00069       else
00070         fprintf(output,"\\drawedge[linecolor=Red](%s,%s){$%s$}\n",start,end,word);
00071     }
00072     
00073     
00079     void beginAutomaton(const int & sizeX,const int & sizeY){
00080       fprintf(output,"\n\n\\begin{center}\n");
00081       fprintf(output,"\\begin{picture}(%d,%d)(-20,-28)\n",sizeX,sizeY);
00082       fprintf(output,"\\gasset{Nw=5,Nh=5,Nmr=2.5,curvedepth=4}\n");
00083       fprintf(output,"\\thinlines\n");
00084       fprintf(output,"\\put(0,0){\n");
00085     }
00086     
00090     void endAutomaton(){
00091       fprintf(output,"}\n");
00092       fprintf(output,"\\end{picture}\n");
00093       fprintf(output,"\\end{center}\n\n\n");
00094       fprintf(output,"\\newpage\n\n\n");
00095     }
00096     
00097     GasteXConverter(const char *  path){
00098       if((output=fopen(path,"w"))==NULL)
00099         throw new InvalidFileException();
00100       beginGasteXDocument();
00101       verbose("Creation of a GasteXConverter");
00102     }
00103     
00104     ~GasteXConverter(){
00105       endGasteXDocument();
00106       verbose("Destruction of a GasteXConverter");
00107     }
00108     
00109   };
00110 
00111 }
00112 
00113 #endif

Generated on Mon Sep 29 16:33:58 2008 for REGAL by  doxygen 1.5.1