~ubuntu-branches/ubuntu/vivid/electric/vivid

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/io/input/Gerber.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-07-08 21:54:23 UTC
  • mfrom: (1.1.6) (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20140708215423-4zrgsca1e28tzcoc
Tags: 9.05+dfsg-1
* Imported Upstream version 9.05+dfsg.
* Add signing-key.pgp and check for valid upstream tarballs with uscan's
  pgpsigurlmangle feature.
* Move the package to Git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
package com.sun.electric.tool.io.input;
25
25
 
26
26
import com.sun.electric.database.EditingPreferences;
 
27
import com.sun.electric.database.geometry.EGraphics;
27
28
import com.sun.electric.database.geometry.EPoint;
28
29
import com.sun.electric.database.geometry.Poly;
29
30
import com.sun.electric.database.geometry.PolyBase;
34
35
import com.sun.electric.database.topology.ArcInst;
35
36
import com.sun.electric.database.topology.Geometric;
36
37
import com.sun.electric.database.topology.NodeInst;
 
38
import com.sun.electric.technology.Layer;
37
39
import com.sun.electric.technology.PrimitiveNode;
38
40
import com.sun.electric.technology.Technology;
39
41
import com.sun.electric.technology.technologies.Artwork;
157
159
        List<Poly.Point> polygonPoints = null;
158
160
        private static Technology pcbTech = Technology.findTechnology("pcb");
159
161
 
160
 
 
161
162
        public static class GerberPreferences extends InputPreferences
162
163
    {
163
164
                private boolean justThisFile;
164
165
                private boolean fillPolygons;
 
166
                private Map<String,Integer> layerColors;
165
167
 
166
168
                public GerberPreferences(boolean factory) {
167
169
            super(factory);
170
172
                justThisFile = !IOTool.isGerberReadsAllFiles();
171
173
                fillPolygons = IOTool.isGerberFillsPolygons();
172
174
            }
 
175
 
 
176
            // cache layer colors
 
177
            layerColors = new HashMap<String,Integer>();
 
178
                        for(int i=0; i<8; i++)
 
179
                        {
 
180
                                String layerName = "Signal-" + (i+1) + "-Node";
 
181
                                PrimitiveNode np = pcbTech.findNodeProto(layerName);
 
182
                                Layer layer = np.getNodeLayers()[0].getLayer();
 
183
                                EGraphics gra = factory ? layer.getFactoryGraphics() : layer.getGraphics();
 
184
                                int colorIndex = 0;
 
185
                                if (gra.getTransparentLayer() > 0)
 
186
                                        colorIndex = EGraphics.makeIndex(gra.getTransparentLayer()); else
 
187
                                                colorIndex = EGraphics.makeIndex(gra.getColor());
 
188
                                layerColors.put(layerName, new Integer(colorIndex));
 
189
 
 
190
                                layerName = "Power-" + (i+1) + "-Node";
 
191
                                np = pcbTech.findNodeProto(layerName);
 
192
                                layer = np.getNodeLayers()[0].getLayer();
 
193
                                gra = factory ? layer.getFactoryGraphics() : layer.getGraphics();
 
194
                                colorIndex = 0;
 
195
                                if (gra.getTransparentLayer() > 0)
 
196
                                        colorIndex = EGraphics.makeIndex(gra.getTransparentLayer()); else
 
197
                                                colorIndex = EGraphics.makeIndex(gra.getColor());
 
198
                                layerColors.put(layerName, new Integer(colorIndex));
 
199
                        }
173
200
        }
174
201
 
175
202
        @Override
226
253
                        // determine the current directory
227
254
                        String topDirName = TextUtils.getFilePath(lib.getLibFile());
228
255
 
229
 
                        // find all files that end with ".gbr" and include them in the search
 
256
                        // find all files that end with ".GBR" and include them in the search
230
257
                        File topDir = new File(topDirName);
231
258
                        String [] fileList = topDir.list();
232
259
                        for(int i=0; i<fileList.length; i++)
531
558
                                        PrimitiveNode pNp = currentLayer.pNp;
532
559
                                        currentLayer.usingIt();
533
560
                                        NodeInst ni = NodeInst.makeInstance(pNp, ep, ctr, width, height, curCell);
534
 
                                        if (width != 0 && height != 0)
 
561
                                        if (width != 0 || height != 0)
535
562
                                                ni.setTrace(points);
536
563
                                }
537
564
                        } else if (currentDCode == 3)
567
594
                                        addPolygonPoints(pointList);
568
595
                                } else
569
596
                                {
570
 
                                        PrimitiveNode pNp = currentLayer.pNp;
571
597
                                        currentLayer.usingIt();
572
 
                                        NodeInst ni = NodeInst.makeInstance(pNp, ep, ctr, diameter, diameter, curCell);
573
 
                                        Point2D[] doubledPointList = new Point2D[pointList.length*2-1];
574
 
                                        for(int i=0; i<pointList.length; i++)
575
 
                                        {
576
 
                                                doubledPointList[i] = pointList[i];
577
 
                                                if (i < pointList.length-1)
578
 
                                                        doubledPointList[i+pointList.length] = pointList[pointList.length-i-2];
579
 
                                        }
580
 
                                        ni.setTrace(doubledPointList);
581
 
 
582
 
//                                      PrimitiveNode pNp = Artwork.tech().circleNode;
583
 
//                                      NodeInst ni = NodeInst.makeInstance(pNp, ctr, diameter, diameter, curCell);
584
 
//                                      ni.setArcDegrees(rotation, angle);
 
598
                                        NodeInst ni = NodeInst.makeInstance(Artwork.tech().circleNode, ep, ctr, diameter, diameter, curCell);
 
599
                                        ni.setArcDegrees(rotation, angle, ep);
 
600
                                        Integer color = localPrefs.layerColors.get(currentLayer.pNp.getName());
 
601
                                        if (color != null)
 
602
                                                ni.newVar(Artwork.ART_COLOR, color, ep);
585
603
                                }
586
604
                        }
587
605
 
747
765
                int codeNumber = TextUtils.atoi(line.substring(4));
748
766
                int pos = 4;
749
767
                while (Character.isDigit(line.charAt(pos))) pos++;
 
768
                String params = line.substring(pos+1);
 
769
                List<StringPart> parts = parseString(params);
750
770
                if (line.charAt(pos) == 'C')
751
771
                {
752
 
                        List<StringPart> parts = parseString(line.substring(pos+1));
753
772
                        if (parts.size() < 1 || parts.size() > 3)
754
773
                        {
755
 
                                System.out.println("Illegal Standard Circle statement: " + line);
 
774
                                System.out.println("Illegal Standard Circle statement: '" + line + "' ('" + params + "' has " + parts.size() + " parts)");
756
775
                                return;
757
776
                        }
758
777
                        StandardCircle sc = new StandardCircle();
763
782
                        standardCircles.put(new Integer(codeNumber), sc);
764
783
                } else if (line.charAt(pos) == 'R')
765
784
                {
766
 
                        List<StringPart> parts = parseString(line.substring(pos+1));
767
 
                        if (parts.size() != 2 || parts.size() != 4)
 
785
                        if (parts.size() != 2 && parts.size() != 4)
768
786
                        {
769
 
                                System.out.println("Illegal Standard Rectangle statement: " + line);
 
787
                                System.out.println("Illegal Standard Rectangle statement: '" + line + "' ('" + params + "' has " + parts.size() + " parts)");
770
788
                                return;
771
789
                        }
772
790
                        StandardRectangle sr = new StandardRectangle();
801
819
                        boolean foundDecimal = false, neg = false;
802
820
                        for(;;)
803
821
                        {
 
822
                                if (pos >= str.length()) break;
804
823
                                char nxt = str.charAt(pos++);
805
824
                                if (nxt != '-' && nxt != '.' && !Character.isDigit(nxt)) break;
806
825
                                if (nxt == '-') { neg = true;   continue; }
819
838
                                switch (currentNumberFormat)
820
839
                                {
821
840
                                        case OMIT_LEADING_ZEROS:
822
 
                                                sb.insert(sb.length()-right, '.');
 
841
                                                int loc = sb.length() - right;
 
842
                                                if (loc < 0) loc = 0;
 
843
                                                sb.insert(loc, '.');
823
844
                                                break;
824
845
                                        case OMIT_TRAILING_ZEROS:
825
846
                                                while (sb.length() < left) sb.append('0');