Ejemplo n.º 1
0
        private static Converter ConverterFromArgs(string[] args)
        {
            Converter conv = new Converter();

                conv.ReadFromSBML(args[0], Array.IndexOf(args, "-UseSBGN") != -1);

            foreach (string arg in args)
            {
                // if dimensions{w,h} is in args
                if (arg.IndexOf("}") == arg.Length - 1 && arg.Contains("-dimensions{"))
                {
                    string dims = arg.Split(new string[] { "{", "}" }, StringSplitOptions.RemoveEmptyEntries)[1];
                    try
                    {
                        string[] dimArgs = dims.Split(',');
                        if (dimArgs.Length != 2)
                        {
                            throw new Exception("The number of arguments in -dimensions{w,h} is incorrect");
                        }
                        string width = dimArgs[0];
                        string height = dimArgs[1];

                        double w = parseDimToPoints(width);
                        double h = parseDimToPoints(height);
                        conv.specs.setDimensions(h, w, units.pts, units.pts);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }

                }
            }
            return conv;
        }
Ejemplo n.º 2
0
 public MainForm()
 {
     conv = new Converter();
     Hashtable fontTeXTable = getFonts();
     if (fontTeXTable.Count != 0)
     {
         conv.fontTeXTable = fontTeXTable;
     }
     compileWithPdflatex = false;
     nameChange += new fileNameChangeHandler(displayChange); // Used to change the sbml file loaded
     compileWithPdfLaTeXChange += new compileToPdfChangeHandler(enableShowPDFCheckBox);
     //Complete mainform initialization
     InitializeComponent();
     InitializeMyComponents(); // sets default values to UserAppDataRegistry values
     setToolTips();
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //if (args.Length < 1 || args.Length > 2)
            //{
            //    Console.WriteLine("Pass one or two arguments; the name of the SBML file and optionally, the output .tex file name");
            //    Environment.Exit(-1);
            //}

            //string fileName = args[0];
            //Converter conv = new Converter(fileName);
            //string outputFileName;
            //if (args.Length == 1)
            //{
            //    outputFileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".tex");
            //}
            //else
            //{
            //    outputFileName = args[1];
            //}

            //using (StreamWriter writer = new StreamWriter(outputFileName))
            //{
            //    writer.WriteLine(conv.WriteFromLayout());
            //}

            //string fileName = "C:\\Users\\Si Yuan\\Desktop\\testcases\\CaMK-Activation.xml";
            string fileName = @"C:\Users\Si yuan\Documents\SBML Models\linear1.xml"; ;
            //string curDir = Directory.GetCurrentDirectory();
            //string fontdatafile = curDir + "\\Fonts.txt";

            Converter conv = new Converter(fileName, false);
            string outputFileName = @"C:\Users\Si yuan\Desktop\test.tex";
            using (StreamWriter writer = new StreamWriter(outputFileName))
            {
                writer.WriteLine(conv.WriteFromLayout());
            }
            //File.WriteAllBytes(outputFileName, conv.ToPDF());
        }
Ejemplo n.º 4
0
        public FileResult TikZ()
        {
            var converter = new Converter {Layout = CurrentLayout, specs = new RenderSpecs(CurrentLayout)};
            var tex = converter.ToTex(CurrentLayout);

            return new FileContentResult(System.Text.Encoding.UTF8.GetBytes(tex), "application/x-tex")
            {
                 FileDownloadName="layout.tex"
            };
        }
Ejemplo n.º 5
0
 public FileResult PDF()
 {
     var converter = new Converter { Layout = CurrentLayout };
     Converter.LastCompileException = null;
     var tex = converter.ToTex(CurrentLayout);
     //var pdf  = CompileTikZToPDF(tex);
     //if (pdf == null || pdf.Length == 0)
     //{
     //    return new FileContentResult(System.Text.Encoding.UTF8.GetBytes(LastMessage), "text/plain");
     //}
     var pdf = converter.ToPDF();
     if (Converter.LastCompileException != null)
     {
         var errorMessage = Converter.LastCompileException.Message;
         errorMessage += Environment.NewLine + Environment.NewLine + Converter.LastCompileException.StackTrace;
         return new FileContentResult(System.Text.Encoding.UTF8.GetBytes(errorMessage), "text/plain");
     }
     return new FileContentResult(pdf, "application/pdf")
     {
         FileDownloadName = "layout.pdf"
     };
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Convenience method for obtaining a PGF/TikZ
 /// document. Returns a string of PGF/TikZ that
 /// draws a specified set of rendering information
 /// in the SBML file of the path passed. The 
 /// rendering may be replaced with SBGN default.
 /// </summary>
 /// <param name="filename">string indicating
 /// path of the SBML file</param>
 /// <param name="selectedLayoutNum">int indicating
 /// which set of rendering information to use</param>
 /// <param name="useSBGN">boolean indicating 
 /// whether the layout should be replaced by 
 /// SBGN default</param>
 /// <returns></returns>
 public static string ToTex(string filename, int selectedLayoutNum, Boolean useSBGN)
 {
     var conv = new Converter();
     conv.ReadFromSBML(filename, useSBGN);
     return conv.WriteFromLayout(selectedLayoutNum);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Convenience method for obtaining a PGF/TikZ 
 /// document. Returns a string of PGF/TikZ that 
 /// draws the first set of rendering information 
 /// in the SBML file of the path passed.
 /// </summary>
 /// <param name="filename">string indicating path 
 /// of the SBML file</param>
 /// <returns>string of PGF/TikZ commands</returns>
 public static string ToTex(string filename)
 {
     var conv = new Converter(filename);
     return conv.WriteFromLayout();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns a <c>Converter</c> object with
 /// <c>Layout</c> and <c>RenderSpecs</c> 
 /// for the SBML string passed. The 
 /// <c>Layout</c> may be overwritten with SBGN. 
 /// </summary>
 /// <param name="sbmlContent">stroring of 
 /// SBML file contents</param>
 /// <param name="useSBGN">boolean indicating 
 /// whether the layout should be replaced by 
 /// SBGN default</param>
 /// <returns><c>Converter</c> with a 
 /// <c>Layout</c> and <c>RenderSpecs</c>
 /// </returns>
 public static Converter FromSBMLContent(string sbmlContent, bool useSBGN)
 {
     var converter = new Converter();
     converter.ReadFromSBMLString(sbmlContent, useSBGN);
     return converter;
 }