Esempio n. 1
0
        // (gr_arc(start 155 111.5) (end 158.5 111.5) (angle 90) (layer Edge.Cuts) (width 0.15))
        public static gr_arc Parse(SExpression root_node)
        {
            gr_arc result = new gr_arc();

            foreach (SExpression node in root_node.Items)
            {
                if (node.Name == "start")
                {
                    float x = float.Parse((node.Items[0] as SNodeAtom).Value);
                    float y = float.Parse((node.Items[1] as SNodeAtom).Value);

                    result.start = new PointF(x, y);
                }
                else if (node.Name == "end")
                {
                    float x = float.Parse((node.Items[0] as SNodeAtom).Value);
                    float y = float.Parse((node.Items[1] as SNodeAtom).Value);

                    result.end = new PointF(x, y);
                }
                else if (node.Name == "layer")
                {
                    result.layer = (node.Items[0] as SNodeAtom).Value;
                }
                else if (node.Name == "width")
                {
                    result.width = (node.Items[0] as SNodeAtom).AsFloat;
                }
            }
            return(result);
        }
Esempio n. 2
0
        public bool LoadFromFile(string filename)
        {
            bool result = false;

            RootNode.LoadFromFile(filename);

            UnParsed = new List <SExpression>();

            if (RootNode.Name == "kicad_pcb")
            {
                SNodeBase pcb_node = RootNode;

                SExpression pcb_items = (pcb_node as SExpression);

                foreach (SExpression node in pcb_items.Items)
                {
                    string name = node.Name;

                    if (name == "gr_line")
                    {
                        //
                        gr_line g = gr_line.Parse(node);
                        if (Drawings == null)
                        {
                            Drawings = new List <graphic_base>();
                        }
                        Drawings.Add(g);
                    }
                    else if (name == "gr_text")
                    {
                        //
                        gr_text g = gr_text.Parse(node);
                        if (Drawings == null)
                        {
                            Drawings = new List <graphic_base>();
                        }
                        Drawings.Add(g);
                    }
                    else if (name == "gr_arc")
                    {
                        gr_arc g = gr_arc.Parse(node);
                        if (Drawings == null)
                        {
                            Drawings = new List <graphic_base>();
                        }
                        Drawings.Add(g);
                    }
                    else if (name == "gr_circle")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "module")
                    {
                        Module module = Module.Parse(node);
                        if (Modules == null)
                        {
                            Modules = new List <Module>();
                        }
                        Modules.Add(module);
                    }
                    else if (name == "version")
                    {
                        FileVersion = node.GetString();
                    }
                    else if (name == "host")
                    {
                        Host_Name    = (node.Items[0] as SNodeAtom).Value;
                        Host_Version = (node.Items[1] as SNodeAtom).Value;
                    }
                    else if (name == "general")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "page")
                    {
                        Page = node.GetString();
                    }
                    else if (name == "title_block")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "layers")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "setup")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "net")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "net_class")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "dimension")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "segment")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "via")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else if (name == "zone")
                    {
                        Trace("LoadPcb: todo: {0}", name);
                    }
                    else
                    {
                        Trace("LoadPcb: unrecognised: {0}", name);
                    }
                }
            }

            return(result);
        }