예제 #1
0
        public void ParseTest4()
        {
            string code =
                @"%some text
\begin{tikzpicture}[scale=2]
\draw (1,2) node (v) {bla} -- (3,3);
\end{tikzpicture}
";
            Tikz_ParseTree actual = TikzParser.Parse(code);

            Tikz_Picture tp = actual.GetTikzPicture();
            Tikz_Node    n  = tp.GetNodeByName("v");

            System.Windows.Point p;
            bool ret = n.GetAbsPos(out p);

            Assert.IsTrue(ret);
            Assert.AreEqual(2, p.X);
            Assert.AreEqual(4, p.Y);
            Assert.AreEqual("bla", n.label);
        }
예제 #2
0
        public void ParseTest2()
        {
            string code =
                @"\begin{tikzpicture}
\draw (1,2) -- (3,3);
\end{tikzpicture}
";
            Tikz_ParseTree actual = TikzParser.Parse(code);

            Tikz_Picture tp = actual.GetTikzPicture();

            Assert.AreEqual(0, tp.StartPosition());
            Tikz_Path tpa = tp.Children.Find(tpi => tpi is Tikz_Path) as Tikz_Path;

            Assert.AreEqual(21, tpa.StartPosition());
            Tikz_Coord tc = tpa.Children.Find(tpi => tpi is Tikz_Coord) as Tikz_Coord;

            Assert.AreEqual(1, tc.uX.number);
            Assert.AreEqual(2, tc.uY.number);

            Assert.AreEqual(27, tc.StartPosition());
        }
예제 #3
0
        /// <summary>
        /// Scans for duplicate node names in the parse tree and changes them to make them unique.
        /// Also updates references.
        /// </summary>
        /// <param name="tp"></param>
        public static void UniquefyNodeNames(Tikz_ParseTree tpt)
        {
            if (tpt == null)
            {
                return;
            }

            Dictionary <string, Tikz_Node> nodelist = new Dictionary <string, Tikz_Node>();

            Tikz_Picture tp = tpt.GetTikzPicture();

            if (tp == null)
            {
                return;
            }

            tpt.BeginModify();
            // clear current node refs
            tp.nodelist.Clear();
            // scan for nodes, rename and re-register noderefs
            ScanTree(tp, nodelist, tp);
            tpt.EndModify();
        }