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.
This commit is contained in:
Tim Edwards 2018-08-26 22:36:15 -04:00
parent e073394430
commit 404629e49f
2 changed files with 41 additions and 14 deletions

View File

@ -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 */

View File

@ -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;