📄 manipulate.java
字号:
if (color != 0) new SetLayerPatternJob(pni, 0); } // redraw the demo layer in this cell new RedoLayerGraphicsJob(ni.getParent()); break; case 2: // invert pattern for(Iterator<NodeInst> it = ni.getParent().getNodes(); it.hasNext(); ) { NodeInst pni = it.next(); int opt = getOptionOnNode(pni); if (opt != Info.LAYERPATTERN) continue; int color = getLayerColor(pni); new SetLayerPatternJob(pni, ~color); } // redraw the demo layer in this cell new RedoLayerGraphicsJob(ni.getParent()); break; case 3: // copy pattern LayerInfo li = LayerInfo.parseCell(ni.getParent()); if (li == null) return; copiedPattern = li.desc.getPattern(); break; case 4: // paste pattern if (copiedPattern == null) return; setLayerPattern(ni.getParent(), copiedPattern); // redraw the demo layer in this cell new RedoLayerGraphicsJob(ni.getParent()); break; } } /** * Method to return the color in layer-pattern node "ni" (off is 0, on is 0xFFFF). */ private static int getLayerColor(NodeInst ni) { if (ni.getProto() == Artwork.tech().boxNode) return 0; if (ni.getProto() != Artwork.tech().filledBoxNode) return 0; Variable var = ni.getVar(Artwork.ART_PATTERN); if (var == null) return 0xFFFF; return ((Short[])var.getObject())[0].intValue(); } /** * Class to create a technology-library from a technology. */ private static class SetLayerPatternJob extends Job { private NodeInst ni; private int color; private SetLayerPatternJob(NodeInst ni, int color) { super("Change Pattern In Layer", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.ni = ni; this.color = color; startJob(); } public boolean doIt() throws JobException { if (ni.getProto() == Artwork.tech().boxNode) { if (color == 0) return true; ni.replace(Artwork.tech().filledBoxNode, false, false); } else if (ni.getProto() == Artwork.tech().filledBoxNode) { Short [] col = new Short[16]; for(int i=0; i<16; i++) col[i] = new Short((short)color); ni.newVar(Artwork.ART_PATTERN, col); } return true; } } /** * Method to toggle the color of layer-pattern node "ni" (called when the user does a * "technology edit" click on the node). */ private static void modLayerPattern(EditWindow wnd, NodeInst ni) { int color = getLayerColor(ni); new SetLayerPatternJob(ni, ~color); Highlighter h = wnd.getHighlighter(); h.clear(); h.addElectricObject(ni, ni.getParent()); // redraw the demo layer in this cell new RedoLayerGraphicsJob(ni.getParent()); } /** * Method to get a list of layers in the current library (in the proper order). * @return an array of strings with the names of the layers. */ private static String [] getLayerNameList() { Library [] dependentlibs = Info.getDependentLibraries(Library.getCurrent()); Cell [] layerCells = Info.findCellSequence(dependentlibs, "layer-", Info.LAYERSEQUENCE_KEY); // build and fill array of layers for DRC parsing String [] layerNames = new String[layerCells.length]; for(int i=0; i<layerCells.length; i++) layerNames[i] = layerCells[i].getName().substring(6); return layerNames; } /** * Method to get a list of arcs in the current library (in the proper order). * @return an array of strings with the names of the arcs. */ private static String [] getArcNameList() { Library [] dependentlibs = Info.getDependentLibraries(Library.getCurrent()); Cell [] arcCells = Info.findCellSequence(dependentlibs, "arc-", Info.ARCSEQUENCE_KEY); // build and fill array of layers for DRC parsing String [] arcNames = new String[arcCells.length]; for(int i=0; i<arcCells.length; i++) arcNames[i] = arcCells[i].getName().substring(4); return arcNames; } /** * Method to get a list of arcs in the current library (in the proper order). * @return an array of strings with the names of the arcs. */ private static String [] getNodeNameList() { Library [] dependentlibs = Info.getDependentLibraries(Library.getCurrent()); Cell [] nodeCells = Info.findCellSequence(dependentlibs, "node-", Info.NODESEQUENCE_KEY); // build and fill array of nodes String [] nodeNames = new String[nodeCells.length]; for(int i=0; i<nodeCells.length; i++) nodeNames[i] = nodeCells[i].getName().substring(5); return nodeNames; } /** * Method to modify the layer information in node "ni". */ private static void modLayerPatch(EditWindow wnd, NodeInst ni) { Library [] dependentlibs = Info.getDependentLibraries(Library.getCurrent()); Cell [] layerCells = Info.findCellSequence(dependentlibs, "layer-", Info.LAYERSEQUENCE_KEY); if (layerCells == null) return; String [] options = new String[layerCells.length + 2]; for(int i=0; i<layerCells.length; i++) options[i] = layerCells[i].getName().substring(6); options[layerCells.length] = "SET-MINIMUM-SIZE"; options[layerCells.length+1] = "CLEAR-MINIMUM-SIZE"; String initial = options[0]; Variable curLay = ni.getVar(Info.LAYER_KEY); if (curLay != null) { CellId cID = (CellId)curLay.getObject(); Cell cell = EDatabase.serverDatabase().getCell(cID); if (cell != null) initial = cell.getName().substring(6); } String choice = PromptAt.showPromptAt(wnd, ni, "Change Layer", "New layer for this geometry:", initial, options); if (choice == null) return; // save the results new ModifyLayerJob(ni, choice, layerCells); } /** * Class to modify a port object in a node of the technology editor. */ private static class ModifyLayerJob extends Job { private NodeInst ni; private String choice; private Cell [] layerCells; private ModifyLayerJob(NodeInst ni, String choice, Cell [] layerCells) { super("Change Layer Information", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.ni = ni; this.choice = choice; this.layerCells = layerCells; startJob(); } public boolean doIt() throws JobException { if (choice.equals("SET-MINIMUM-SIZE")) { if (!ni.getParent().getName().startsWith("node-")) { System.out.println("Can only set minimum size in node descriptions"); return true; } ni.newDisplayVar(Info.MINSIZEBOX_KEY, "MIN"); return true; } if (choice.equals("CLEAR-MINIMUM-SIZE")) { if (ni.getVar(Info.MINSIZEBOX_KEY) == null) { System.out.println("Minimum size is not set on this layer"); return true; } ni.delVar(Info.MINSIZEBOX_KEY); return true; } // find the actual cell with that layer specification for(int i=0; i<layerCells.length; i++) { if (choice.equals(layerCells[i].getName().substring(6))) { // found the name, set the patch LayerInfo li = LayerInfo.parseCell(layerCells[i]); if (li != null) { setPatch(ni, li.desc); ni.newVar(Info.LAYER_KEY, layerCells[i].getId()); } return true; } } System.out.println("Cannot find layer primitive " + choice); return true; } } /** * Method to modify port characteristics */ private static void modPort(EditWindow wnd, NodeInst ni) { // count the number of arcs in this technology List<Cell> allArcs = new ArrayList<Cell>(); for(Iterator<Cell> it = ni.getParent().getLibrary().getCells(); it.hasNext(); ) { Cell cell = it.next(); if (cell.getName().startsWith("arc-")) allArcs.add(cell); } // make a set of those arcs which can connect to this port Set<NodeProto> connectSet = new HashSet<NodeProto>(); Variable var = ni.getVar(Info.CONNECTION_KEY); if (var != null) { CellId [] connects = (CellId [])var.getObject(); for(int i=0; i<connects.length; i++) { if (connects[i] != null) connectSet.add(EDatabase.serverDatabase().getCell(connects[i])); } } // build an array of arc connections PromptAt.Field [] fields = new PromptAt.Field[allArcs.size()+3]; for(int i=0; i<allArcs.size(); i++) { Cell cell = allArcs.get(i); boolean doesConnect = connectSet.contains(cell); fields[i] = new PromptAt.Field(cell.getName().substring(4), new String [] {"Allowed", "Disallowed"}, (doesConnect ? "Allowed" : "Disallowed")); } Variable angVar = ni.getVar(Info.PORTANGLE_KEY); int ang = 0; if (angVar != null) ang = ((Integer)angVar.getObject()).intValue(); Variable rangeVar = ni.getVar(Info.PORTRANGE_KEY); int range = 180; if (rangeVar != null) range = ((Integer)rangeVar.getObject()).intValue(); Variable meaningVar = ni.getVar(Info.PORTMEANING_KEY); int meaning = 0; if (meaningVar != null) meaning = ((Integer)meaningVar.getObject()).intValue(); fields[allArcs.size()] = new PromptAt.Field("Angle:", TextUtils.formatDouble(ang)); fields[allArcs.size()+1] = new PromptAt.Field("Angle range:", TextUtils.formatDouble(range)); String[] meanings = new String[]{"No meaning", "Gate", "Gated"}; fields[allArcs.size()+2] = new PromptAt.Field("Transistor meaning:", meanings, meanings[meaning]); String choice = PromptAt.showPromptAt(wnd, ni, "Change Port", fields); if (choice == null) return; // save the results String [] fieldValues = new String[fields.length]; for(int i=0; i<fields.length; i++) fieldValues[i] = (String)fields[i].getFinal(); new ModifyPortJob(ni, allArcs, fieldValues); } /** * Class to modify a port object in a node of the technology editor. */ private static class ModifyPortJob extends Job { private NodeInst ni; private List<Cell> allArcs; private String [] fieldValues; private ModifyPortJob(NodeInst ni, List<Cell> allArcs, String [] fieldValues) { super("Change Port Information", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.ni = ni; this.allArcs = allArcs; this.fieldValues = fieldValues; startJob(); } public boolean doIt() throws JobException { int numConnects = 0; for(int i=0; i<allArcs.size(); i++) { String answer = fieldValues[i]; if (answer.equals("Allowed")) numConnects++; } CellId [] newConnects = new CellId[numConnects]; int k = 0; for(int i=0; i<allArcs.size(); i++) { String answer = fieldValues[i]; if (answer.equals("Allowed")) newConnects[k++] = allArcs.get(i).getId(); } ni.newVar(Info.CONNECTION_KEY, newConnects); int newAngle = TextUtils.atoi(fieldValues[allArcs.size()]); ni.newVar(Info.PORTANGLE_KEY, new Integer(newAngle)); int newRange = TextUtils.atoi(fieldValues[allArcs.size()+1]); ni.newVar(Info.PORTRANGE_KEY, new Integer(newRange)); String newMeaning = fieldValues[allArcs.size()+2]; int meaning = 0; if (newMeaning.equals("Gate")) meaning = 1; else if (newMeaning.equals("Gated")) meaning = 2; ni.newVar(Info.PORTMEANING_KEY, new Integer(meaning)); return true; } } private static void modArcFunction(EditWindow wnd, NodeInst ni) { String initialFuncName = Info.getValueOnNode(ni); List<ArcProto.Function> funs = ArcProto.Function.getFunctions(); String [] functionNames = new String[funs.size()]; for(int i=0; i<funs.size(); i++) { ArcProto.Function fun = funs.get(i); functionNames[i] = fun.toString(); } String choice = PromptAt.showPromptAt(wnd, ni, "Change Arc Function", "New function for this arc:", initialFuncName, functionNames); if (choice == null) return; new SetTextJob(ni, "Function: " + choice); } private static void modArcFixAng(EditWindow wnd, NodeInst ni) { String initialMsg = Info.getValueOnNode(ni); boolean initialChoice = initialMsg.equalsIgnoreCase("yes"); boolean finalChoice = PromptAt.showPromptAt(wnd, ni, "Set whether this Arc Remains at a Fixed Angle", "Should instances of this arc be created with the 'fixed angle' constraint?", initialChoice); if (finalChoice != initialChoice) { new SetTextJob(ni, "Fixed-angle: " + (finalChoice ? "Yes" : "No")); } } private static void modArcWipes(EditWindow wnd, NodeInst ni) { String initialMsg = Info.getValueOnNode(ni); boolean initialChoice = initialMsg.equalsIgnoreCase("yes"); boolean finalChoice = PromptAt.showPromptAt(wnd, ni, "Set Whether this Arc Can Obscure a Pin Node", "Can this arc obscure a pin node (that is obscurable)?", initialChoice); if (finalChoice != initialChoice) { new SetTextJob(ni, "Wipes pins: " + (finalChoice ? "Yes" : "No")); } } private static void modArcExtension(EditWindow wnd, NodeInst ni) { String initialMsg = Info.getValueOnNode(ni); boolean initialChoice = initialMsg.equalsIgnoreCase("yes"); boolean finalChoice = PromptAt.showPromptAt(wnd, ni, "Set Extension Default", "Are new instances of this arc drawn with ends extended?", initialChoice); if (finalChoice != initialChoice) { new SetTextJob(ni, "Extend arcs: " + (finalChoice ? "Yes" : "No")); } } private static void modArcAngInc(EditWindow wnd, NodeInst ni) { String initialMsg = Info.getValueOnNode(ni); String newInc = PromptAt.showPromptAt(w
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -