📄 edif.java
字号:
{ ArcInst ai = it.next(); writeSymbolArcInst(ai, GenMath.MATID); } // close figure setGraphic(EGUNKNOWN); blockClose("symbol"); } private void writeSymbol(PrimitiveNode pn, NodeInst ni) { if (pn == null) return; blockOpen("symbol"); egraphic_override = EGWIRE; egraphic = EGUNKNOWN; for(Iterator<PortProto> it = pn.getPorts(); it.hasNext(); ) { PortProto e = it.next(); blockOpen("portImplementation"); blockOpen("name"); blockPutIdentifier(makeToken(e.getName())); blockOpen("display"); blockOpen("figureGroupOverride"); blockPutIdentifier(getFigureGroupName(EGWIRE)); blockOpen("textHeight"); blockPutInteger(getTextHeight(null)); blockClose("figureGroupOverride"); Poly portPoly = ni.getShapeOfPort(e); //blockOpen("origin"); //writePoint(portPoly.getCenterX(), portPoly.getCenterY()); blockClose("name"); blockOpen("connectLocation"); writeSymbolPoly(portPoly, null, 1); // close figure setGraphic(EGUNKNOWN); blockClose("portImplementation"); } egraphic_override = EGUNKNOWN; Poly [] polys = pn.getTechnology().getShapeOfNode(ni); for (int i=0; i<polys.length; i++) { writeSymbolPoly(polys[i], null, 1); } // close figure setGraphic(EGUNKNOWN); blockClose("symbol"); } /** * Write a portImplementation node. * @param e * @param closeBlock true to close block, false to leave portImplementation block open */ private void writePortImplementation(Export e, boolean closeBlock) { blockOpen("portImplementation"); blockOpen("name"); blockPutIdentifier(makeToken(e.getName())); blockOpen("display"); blockOpen("figureGroupOverride"); blockPutIdentifier(getFigureGroupName(EGWIRE)); blockOpen("textHeight"); blockPutInteger(getTextHeight(e.getTextDescriptor(Export.EXPORT_NAME))); blockClose("figureGroupOverride"); blockOpen("origin"); Poly namePoly = e.getNamePoly(); writePoint(namePoly.getCenterX(), namePoly.getCenterY()); blockClose("name"); blockOpen("connectLocation"); Poly portPoly = e.getOriginalPort().getPoly(); egraphic_override = EGWIRE; egraphic = EGUNKNOWN; writeSymbolPoly(portPoly, null, 1); setGraphic(EGUNKNOWN); blockClose("connectLocation"); if (closeBlock) { blockClose("portImplementation"); } } /** * Method to output a specific symbol cell */ private void writeSymbolCell(NodeInst ni, AffineTransform prevtrans) { // make transformation matrix within the current nodeinst if (ni.getOrient().equals(Orientation.IDENT)) { writeSymbolNodeInst(ni, prevtrans); } else { AffineTransform localtran = ni.rotateOut(prevtrans); writeSymbolNodeInst(ni, localtran); } } /** * Method to symbol "ni" when transformed through "prevtrans". */ private void writeSymbolNodeInst(NodeInst ni, AffineTransform prevtrans) { NodeProto np = ni.getProto(); // primitive nodeinst: ask the technology how to draw it if (!ni.isCellInstance()) { Technology tech = np.getTechnology(); Poly [] polys = tech.getShapeOfNode(ni); int high = polys.length; // don't draw invisible pins int low = 0; if (np == Generic.tech().invisiblePinNode) low = 1; for (int j = low; j < high; j++) { // get description of this layer Poly poly = polys[j]; // draw the nodeinst poly.transform(prevtrans); // draw the nodeinst and restore the color // check for text ... boolean istext = false; if (poly.getStyle().isText()) { istext = true; // close the current figure ... setGraphic(EGUNKNOWN); blockOpen("annotate"); } writeSymbolPoly(poly, null, 1); if (istext) blockClose("annotate"); } } else { // transform into the nodeinst for display of its guts Cell subCell = (Cell)np; AffineTransform subrot = ni.translateOut(prevtrans); // see if there are displayable variables on the cell Poly[] varPolys = ni.getDisplayableVariables(ni.getBounds(), null, false); if (varPolys.length != 0) setGraphic(EGUNKNOWN); writeDisplayableVariables(varPolys, prevtrans); // search through cell for(Iterator<NodeInst> it = subCell.getNodes(); it.hasNext(); ) { NodeInst sNi = it.next(); writeSymbolCell(sNi, subrot); } for(Iterator<ArcInst> it = subCell.getArcs(); it.hasNext(); ) { ArcInst sAi = it.next(); writeSymbolArcInst(sAi, subrot); } } } /** * Method to draw an arcinst. Returns indicator of what else needs to * be drawn. Returns negative if display interrupted */ private void writeSymbolArcInst(ArcInst ai, AffineTransform trans) { // get the endpoints of the arcinst Point2D [] points = new Point2D[2]; points[0] = new Point2D.Double(ai.getTailLocation().getX(), ai.getTailLocation().getY()); points[1] = new Point2D.Double(ai.getHeadLocation().getX(), ai.getHeadLocation().getY()); // translate point if needed points[0] = equivs.translatePortConnection(points[0], ai.getTailPortInst()); points[1] = equivs.translatePortConnection(points[1], ai.getHeadPortInst()); Poly poly = new Poly(points); poly.setStyle(Poly.Type.OPENED); poly.transform(trans); writeSymbolPoly(poly, null, 1); // now get the variables int num = ai.numDisplayableVariables(false); if (num != 0) setGraphic(EGUNKNOWN); Poly [] varPolys = new Poly[num]; ai.addDisplayableVariables(ai.getBounds(), varPolys, 0, null, false); writeDisplayableVariables(varPolys, trans); } private void writeDisplayableVariables(Poly [] varPolys, AffineTransform prevtrans) { for(int i=0; i<varPolys.length; i++) { Poly varPoly = varPolys[i]; String name = null; String append = null; double scale = 1; DisplayedText dt = varPoly.getDisplayedText(); Variable var = null; if (dt != null) var = dt.getVariable(); if (var != null) { // see if there is a translation name = var.getTrueName(); EDIFEquiv.VariableEquivalence ve = equivs.getElectricVariableEquivalence(dt.getVariableKey().getName()); if (ve != null) { name = ve.externVarName; append = ve.appendElecOutput; scale = ve.scale; } } if (name == null) continue; if (prevtrans != null) varPoly.transform(prevtrans); // make sure poly type is some kind of text if (!varPoly.getStyle().isText() && var != null) { TextDescriptor td = var.getTextDescriptor(); if (td != null) { Poly.Type style = td.getPos().getPolyType(); varPoly.setStyle(style); } } if (varPoly.getString() == null && var != null) varPoly.setString(var.getObject().toString()); blockOpen("property"); blockPutIdentifier(name); blockOpen("string"); writeSymbolPoly(varPoly, append, scale); blockClose("property"); } } private void setGraphic(EGraphic type) { if (type == EGUNKNOWN) { // terminate the figure if (egraphic != EGUNKNOWN) blockClose("figure"); egraphic = EGUNKNOWN; } else if (egraphic_override == EGUNKNOWN) { // normal case if (type != egraphic) { // new egraphic type if (egraphic != EGUNKNOWN) blockClose("figure"); egraphic = type; blockOpen("figure"); blockPutIdentifier(getFigureGroupName(egraphic)); } } else if (egraphic != egraphic_override) { // override figure if (egraphic != EGUNKNOWN) blockClose("figure"); egraphic = egraphic_override; blockOpen("figure"); blockPutIdentifier(getFigureGroupName(egraphic)); } } /** * Method to write polys into EDIF syntax */ private void writeSymbolPoly(Poly obj, String append, double scale) { // now draw the polygon Poly.Type type = obj.getStyle(); Point2D [] points = obj.getPoints(); if (type == Poly.Type.CIRCLE || type == Poly.Type.DISC || type == Poly.Type.THICKCIRCLE) { setGraphic(EGART); double i = points[0].distance(points[1]); blockOpen("circle"); writePoint(points[0].getX() - i, points[0].getY()); writePoint(points[0].getX() + i, points[0].getY()); blockClose("circle"); return; } if (type == Poly.Type.CIRCLEARC || type == Poly.Type.THICKCIRCLEARC) { setGraphic(EGART); // arcs at [i] points [1+i] [2+i] clockwise if (points.length == 0) return; if ((points.length % 3) != 0) return; for (int i = 0; i < points.length; i += 3) { blockOpen("openShape"); blockOpen("curve"); blockOpen("arc"); writePoint(points[i + 1].getX(), points[i + 1].getY()); // calculate a point between the first and second point Point2D si = GenMath.computeArcCenter(points[i], points[i + 1], points[i + 2]); writePoint(si.getX(), si.getY()); writePoint(points[i + 2].getX(), points[i + 2].getY()); blockClose("openShape"); } return; } if (type == Poly.Type.FILLED || type == Poly.Type.CLOSED) { Rectangle2D bounds = obj.getBox(); if (bounds != null) { // simple rectangular box if (bounds.getWidth() == 0 && bounds.getHeight() == 0) { if (egraphic_override == EGUNKNOWN) return; setGraphic(EGART); blockOpen("dot"); writePoint(bounds.getCenterX(), bounds.getCenterY()); blockClose("dot"); } else { setGraphic(EGART); blockOpen("rectangle"); writePoint(bounds.getMinX(), bounds.getMinY()); writePoint(bounds.getMaxY(), bounds.getMaxY()); blockClose("rectangle"); } } else { setGraphic(EGART); blockOpen("path"); blockOpen("pointList"); for (int i = 0; i < points.length; i++) writePoint(points[i].getX(), points[i].getY()); if (points.length > 2) writePoint(points[0].getX(), points[0].getY()); blockClose("path"); } return; } if (type.isText()) { if (IOTool.isEDIFCadenceCompatibility() && obj.getDisplayedText() != null) { // Properties in Cadence do not have position info, Cadence // determines position automatically and cannot be altered by user. // There also does not seem to be any way to set the 'display' so // that it shows up on the instance String value = obj.getDisplayedText().getVariable().getPureValue(-1); if (scale != 1) { double scaled = TextUtils.atof(value); value = TextUtils.formatDouble(scaled * scale); } if (append != null) value += append; String str = convertElectricPropToCadence(value); str = str.replaceAll("\"", "%34%"); blockPutString(str); return; } Rectangle2D bounds = obj.getBounds2D(); setGraphic(EGUNKNOWN); blockOpen("stringDisplay"); String str = obj.getString().replaceAll("\"", "%34%"); if (append != null) str += append; blockPutString(str); blockOpen("display"); TextDescriptor td = obj.getTextDescriptor(); if (td != null) { blockOpen("figureGroupOverride"); blockPutIdentifier(getFigureGroupName(EGART)); // output the text height blockOpen("textHeight"); // 2 pixels = 0.0278 in or 36 double pixels per inch double height = getTextHeight(td); blockPutInteger(height); blockClose("figureGroupOverride"); } else { blockPutIdentifier(EGART.getText()); } if (type == Poly.Type.TEXTCENT) blockPut("justify", "CENTERCENTER"); else if (type == Poly.Type.TEXTTOP) blockPut("justify", "LOWERCENTER"); else if (type == Poly.Type.TEXTBOT) blockPut("justify", "UPPERCENTER"); else if (type == Poly.Type.TEXTLEFT) blockPut("justify", "CENTERRIGHT"); else if (type == Poly.Type.TEXTRIGHT) blockPut("justify", "CENTERLEFT"); else if (type == Poly.Type.TEXTTOPLEFT) blockPut("justify", "LOWERRIGHT"); else if (type == Poly.Type.TEXTBOTLEFT) blockPut("justify", "UPPERRIGHT"); else if (type == Poly.Type.TEXTTOPRIGHT) blockPut("justify", "LOWERLEFT"); else if (type == Poly.T
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -