From 404629e49f5212551fd0548e006d52e0ed2a000d Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sun, 26 Aug 2018 22:36:15 -0400 Subject: [PATCH] Added new option "port" for the "labels" statement in cifinput. This allows text appearing on a specific GDS layer:purpose pair to be interpreted as a port. This does not quite match the intended behavior of such layers, since it is implied that any layer geometry coincident with the text should form the area of the port, which is not (yet) handled. Also, it is presumably implied that the port order matches the order in which text appears in the GDS stream, but magic does not preserve this order when re-writing any GDS output. --- calma/CalmaRdpt.c | 39 ++++++++++++++++++++++++++++----------- cif/CIFrdtech.c | 16 +++++++++++++--- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/calma/CalmaRdpt.c b/calma/CalmaRdpt.c index 5b9c7d8b..d156b6cc 100644 --- a/calma/CalmaRdpt.c +++ b/calma/CalmaRdpt.c @@ -631,6 +631,8 @@ calmaElementPath() } } +typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType; + /* * ---------------------------------------------------------------------------- * @@ -853,16 +855,9 @@ calmaElementText() else { int flags, i; + Label *lab; - /* Find the style layer record corresponding to the label type */ - layer = -1; - for (i = 0; i < cifCurReadStyle->crs_nLayers; i++) - if (cifCurReadStyle->crs_layers[i]->crl_magicType == type) { - layer = i; - break; - } - - if (layer >= 0 && cifCurReadStyle->crs_labelSticky[layer]) + if (cifnum >= 0 && (cifCurReadStyle->crs_labelSticky[cifnum] != LABEL_TYPE_NONE)) flags = LABEL_STICKY; else if (cifCurReadStyle->crs_flags & CRF_NO_RECONNECT_LABELS) flags = LABEL_STICKY; @@ -870,10 +865,32 @@ calmaElementText() flags = 0; if (font < 0) - DBPutLabel(cifReadCellDef, &r, pos, textbody, type, flags); + lab = DBPutLabel(cifReadCellDef, &r, pos, textbody, type, flags); else - DBPutFontLabel(cifReadCellDef, &r, font, size, angle, + lab = DBPutFontLabel(cifReadCellDef, &r, font, size, angle, &GeoOrigin, pos, textbody, type, flags); + + if ((lab != NULL) && (cifnum >= 0) && + ((cifCurReadStyle->crs_labelSticky[cifnum] == LABEL_TYPE_PORT))) + { + Label *sl; + int idx; + + /* No port information can be encoded in the GDS file, so */ + /* assume defaults, and assume that the port order is the */ + /* order in which labels arrive in the GDS stream. */ + + i = -1; + for (sl = cifReadCellDef->cd_labels; sl != NULL; sl = sl->lab_next) + { + idx = sl->lab_flags & PORT_NUM_MASK; + if (idx > i) i = idx; + } + i++; + lab->lab_flags |= (PORT_NUM_MASK & i); + lab->lab_flags |= PORT_DIR_NORTH | PORT_DIR_SOUTH | + PORT_DIR_EAST | PORT_DIR_WEST; + } } /* done with textbody */ diff --git a/cif/CIFrdtech.c b/cif/CIFrdtech.c index 71dbaa27..0ec99571 100644 --- a/cif/CIFrdtech.c +++ b/cif/CIFrdtech.c @@ -62,6 +62,9 @@ CIFOp *cifCurReadOp; /* Last geometric operation seen. */ void cifReadStyleInit(); void CIFReadLoadStyle(); +/* Label types used by the "labels" statement option */ +typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType; + /* * ---------------------------------------------------------------------------- * @@ -365,7 +368,7 @@ cifReadStyleInit() for (i = 0; i < MAXCIFRLAYERS; i++) { cifCurReadStyle->crs_labelLayer[i] = TT_SPACE; - cifCurReadStyle->crs_labelSticky[i] = FALSE; + cifCurReadStyle->crs_labelSticky[i] = LABEL_TYPE_NONE; cifCurReadStyle->crs_layers[i] = NULL; } } @@ -465,6 +468,7 @@ CIFReadTechLine(sectionName, argc, argv) CalmaLayerType clt; int calmaLayers[CALMA_LAYER_MAX], calmaTypes[CALMA_LAYER_MAX]; int nCalmaLayers, nCalmaTypes, l, t, j; + int calmaLabelType = LABEL_TYPE_NONE; if (argc <= 0) return TRUE; else if (argc >= 2) l = strlen(argv[1]); @@ -848,7 +852,13 @@ CIFReadTechLine(sectionName, argc, argv) { if (argc == 3) { - if (strcmp(argv[2], "text")) + if (!strcmp(argv[2], "text")) + calmaLabelType = LABEL_TYPE_TEXT; + else if (!strcmp(argv[2], "sticky")) + calmaLabelType = LABEL_TYPE_TEXT; + else if (!strcmp(argv[2], "port")) + calmaLabelType = LABEL_TYPE_PORT; + else goto wrongNumArgs; } else @@ -862,7 +872,7 @@ CIFReadTechLine(sectionName, argc, argv) cifCurReadStyle->crs_labelLayer[i] = cifCurReadLayer->crl_magicType; if (argc == 3) - cifCurReadStyle->crs_labelSticky[i] = TRUE; + cifCurReadStyle->crs_labelSticky[i] = calmaLabelType; } } return TRUE;