From 925136c6526933167acf895c374f11c41620cf23 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 27 Aug 2018 10:57:51 -0400 Subject: [PATCH] Attempt at finishing the support of standard practices to define geometry attached to a label in GDS using specific layer:purpose pairs. The additional code maintains the order of ports when writing out text to GDS, and attempts to attach geometry to labels when the geometry is defined on the same layer:purpose pair as the text, and the cifinput style declares the purpose to be a port label. --- calma/CalmaRdpt.c | 35 ++++++++++++++++++++++++++++++++--- calma/CalmaWrite.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/calma/CalmaRdpt.c b/calma/CalmaRdpt.c index d156b6cc..ba421ac1 100644 --- a/calma/CalmaRdpt.c +++ b/calma/CalmaRdpt.c @@ -57,6 +57,8 @@ extern HashTable calmaDefInitHash; extern void calmaLayerError(); bool calmaReadPath(); +typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType; + /* * ---------------------------------------------------------------------------- * @@ -276,6 +278,35 @@ calmaElementBoundary() rp = CIFPolyToRects(pathheadp, plane, CIFPaintTable, (PaintUndoInfo *)NULL); CIFFreePath(pathheadp); + /* If the input layer is designated for ports by a "label" */ + /* statement in the cifinput section, then find any label */ + /* bounded by the path and attach the path to it. Note */ + /* that this assumes two things: (1) that labels can only */ + /* be attached to simple rectangles, and (2) that the */ + /* rectangle appears in the GDS stream after the label. If */ + /* either assumption is violated, this method needs to be */ + /* re-coded. */ + + if (rp != NULL) + { + if ((ciftype >= 0) && + ((cifCurReadStyle->crs_labelSticky[ciftype] == LABEL_TYPE_PORT))) + { + Label *lab; + TileType type; + + type = cifCurReadStyle->crs_labelLayer[ciftype]; + for (lab = cifReadCellDef->cd_labels; lab; lab = lab->lab_next) + { + if ((GEO_SURROUND(&lab->lab_rect, &rp->r_r)) && (lab->lab_type == type)) + { + lab->lab_rect = rp->r_r; /* Replace with larger rectangle */ + break; + } + } + } + } + /* Paint the rectangles (if any) */ for (; rp != NULL ; rp = rp->r_next) { @@ -631,8 +662,6 @@ calmaElementPath() } } -typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType; - /* * ---------------------------------------------------------------------------- * @@ -871,7 +900,7 @@ calmaElementText() &GeoOrigin, pos, textbody, type, flags); if ((lab != NULL) && (cifnum >= 0) && - ((cifCurReadStyle->crs_labelSticky[cifnum] == LABEL_TYPE_PORT))) + (cifCurReadStyle->crs_labelSticky[cifnum] == LABEL_TYPE_PORT)) { Label *sl; int idx; diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index f3d0e66b..29ad020c 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -881,11 +881,36 @@ calmaOutFunc(def, f, cliprect) (ClientData) &cos); } - /* Output labels */ + /* Output labels. Do this in two passes, first for non-port labels */ + /* while finding the highest-numbered port. Then output the port */ + /* labels (if any) in the order of the port index. */ + if (CalmaDoLabels) + { + int i, maxport = -1; + for (lab = def->cd_labels; lab; lab = lab->lab_next) - calmaWriteLabelFunc(lab, + { + if ((lab->lab_flags & PORT_DIR_MASK) == 0) + calmaWriteLabelFunc(lab, CIFCurStyle->cs_labelLayer[lab->lab_type], f); + else + { + if ((lab->lab_flags & PORT_NUM_MASK) > maxport) + maxport = lab->lab_flags & PORT_NUM_MASK; + } + } + if (maxport >= 0) + for (i = 0; i <= maxport; i++) + for (lab = def->cd_labels; lab; lab = lab->lab_next) + if (((lab->lab_flags & PORT_DIR_MASK) != 0) && + ((lab->lab_flags & PORT_NUM_MASK) == i)) + { + calmaWriteLabelFunc(lab, + CIFCurStyle->cs_labelLayer[lab->lab_type], f); + break; + } + } /* End of structure */ calmaOutRH(4, CALMA_ENDSTR, CALMA_NODATA, f);