Added a new cif/calma layer type "labellayer" that can be used to

tag geometry with a specific label which is the name of the layer.
This commit is contained in:
Tim Edwards 2021-11-16 10:58:18 -05:00
parent e8eb96103d
commit db6128232f
4 changed files with 157 additions and 8 deletions

View File

@ -72,6 +72,7 @@ extern int calmaWriteMarkFunc();
extern int calmaWritePaintFunc();
extern int calmaMergePaintFunc();
extern int calmaWriteUseFunc();
extern int calmaPaintLabelFunc();
extern void calmaWriteContacts();
extern void calmaDelContacts();
extern void calmaOutFunc();
@ -92,6 +93,7 @@ extern void calmaRemoveDegenerate();
typedef struct {
FILE *f; /* File stream for output */
Rect *area; /* Clipping area, in GDS coordinates */
int type; /* Layer index */
} calmaOutputStruct;
/*--------------------------------------------------------------*/
@ -1162,6 +1164,7 @@ calmaOutFunc(def, f, cliprect)
cos.f = f;
cos.area = (cliprect == &TiPlaneRect) ? NULL : cliprect;
cos.type = -1;
/* Output structure begin */
calmaOutRH(28, CALMA_BGNSTR, CALMA_I2, f);
@ -1227,13 +1230,19 @@ calmaOutFunc(def, f, cliprect)
layer = CIFCurStyle->cs_layers[type];
if (layer->cl_flags & CIF_TEMP) continue;
if (!CalmaIsValidLayer(layer->cl_calmanum)) continue;
cos.type = type;
calmaPaintLayerNumber = layer->cl_calmanum;
calmaPaintLayerType = layer->cl_calmatype;
DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
cliprect, &CIFSolidBits, (CalmaMergeTiles) ?
calmaMergePaintFunc : calmaWritePaintFunc,
(ClientData) &cos);
if (layer->cl_flags & CIF_LABEL)
DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
cliprect, &CIFSolidBits, calmaPaintLabelFunc,
(ClientData) &cos);
else
DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
cliprect, &CIFSolidBits, (CalmaMergeTiles) ?
calmaMergePaintFunc : calmaWritePaintFunc,
(ClientData) &cos);
}
/* Output labels. Do this in two passes, first for non-port labels */
@ -2867,6 +2876,73 @@ calmaWriteLabelFunc(lab, type, f)
}
}
/*
* ----------------------------------------------------------------------------
*
* calmaPaintLabelFunc --
*
* Filter function used to write out a single label corresponding to the
* area of a paint tile, and having a text matching the CIF layer name.
*
* Results:
* None.
*
* Side effects:
* Writes to the disk file.
*
* ----------------------------------------------------------------------------
*/
int
calmaPaintLabelFunc(tile, cos)
Tile *tile; /* Tile contains area for label. */
calmaOutputStruct *cos; /* File for output and clipping area */
{
FILE *f = cos->f;
Rect *clipArea = cos->area;
Rect r, r2;
Point p;
int len;
CIFLayer *layer = CIFCurStyle->cs_layers[cos->type];
if (IsSplit(tile)) return 0; /* Ignore non-Manhattan geometry */
if (!CalmaIsValidLayer(layer->cl_calmanum))
return;
TiToRect(tile, &r);
if (clipArea != NULL)
GeoClip(&r, clipArea);
r.r_xbot *= calmaPaintScale;
r.r_ybot *= calmaPaintScale;
r.r_xtop *= calmaPaintScale;
r.r_ytop *= calmaPaintScale;
calmaOutRH(4, CALMA_TEXT, CALMA_NODATA, f);
calmaOutRH(6, CALMA_LAYER, CALMA_I2, f);
calmaOutI2(layer->cl_calmanum, f);
calmaOutRH(6, CALMA_TEXTTYPE, CALMA_I2, f);
calmaOutI2(layer->cl_calmatype, f);
p.p_x = (r.r_xbot + r.r_xtop) * calmaWriteScale / 2;
p.p_y = (r.r_ybot + r.r_ytop) * calmaWriteScale / 2;
calmaOutRH(12, CALMA_XY, CALMA_I4, f);
calmaOutI4(p.p_x, f);
calmaOutI4(p.p_y, f);
/* Text of label is the CIF layer name */
calmaOutStringRecord(CALMA_STRING, layer->cl_name, f);
/* End of element */
calmaOutRH(4, CALMA_ENDEL, CALMA_NODATA, f);
return 0;
}
/*
* ----------------------------------------------------------------------------
*

View File

@ -226,9 +226,12 @@ typedef struct
*
* CIF_TEMP: Means that this is a temporary layer used to build
* up CIF information. It isn't output in the CIF file.
* CIF_LABEL: This layer is used to generate fixed labels in the
* output file.
*/
#define CIF_TEMP 1
#define CIF_LABEL 2
/* The following data structure describes a complete set of CIF
* layers. The number of CIF layers (MAXCIFLAYERS) must not be

View File

@ -804,7 +804,8 @@ CIFTechLine(sectionName, argc, argv)
if (CIFCurStyle->cs_status != TECH_PENDING) return TRUE;
newLayer = NULL;
if ((strcmp(argv[0], "templayer") == 0) || (strcmp(argv[0], "layer") == 0))
if ((strcmp(argv[0], "templayer") == 0) || (strcmp(argv[0], "layer") == 0) ||
(strcmp(argv[0], "labellayer") == 0))
{
if (CIFCurStyle->cs_nLayers == MAXCIFLAYERS)
{
@ -839,6 +840,8 @@ CIFTechLine(sectionName, argc, argv)
#endif
if (strcmp(argv[0], "templayer") == 0)
newLayer->cl_flags |= CIF_TEMP;
else if (strcmp(argv[0], "labellayer") == 0)
newLayer->cl_flags |= CIF_LABEL;
cifCurLayer = newLayer;
cifCurOp = NULL;
cifGotLabels = FALSE;

View File

@ -47,6 +47,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
extern int cifWriteInitFunc();
extern int cifWriteMarkFunc();
extern int cifWritePaintFunc();
extern int cifWriteLabelFunc();
extern int cifWriteUseFunc();
extern void cifOutPreamble();
extern void cifOut();
@ -394,9 +395,14 @@ cifOutFunc(def, f)
if (layer->cl_flags & CIF_TEMP) continue;
cifPaintLayerName = layer->cl_name;
cifPaintScale = 1;
(void) DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
&TiPlaneRect, &CIFSolidBits, cifWritePaintFunc,
(ClientData) f);
if (layer->cl_flags & CIF_LABEL)
DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
&TiPlaneRect, &CIFSolidBits, cifWriteLabelFunc,
(ClientData) f);
else
DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
&TiPlaneRect, &CIFSolidBits, cifWritePaintFunc,
(ClientData) f);
}
/* Output labels */
@ -553,6 +559,67 @@ cifWriteUseFunc(use, f)
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* cifWriteLabelFunc --
*
* Filter function used to write out a label corresponding to a
* single paint tile. The CIF layer name is used as the label to
* output.
*
* Results:
* Always return 0
*
* Side effects:
* Writes to the disk file.
*
* ----------------------------------------------------------------------------
*/
int
cifWriteLabelFunc(tile, f)
Tile *tile; /* Tile to be written out. */
FILE *f; /* File in which to write. */
{
Rect r;
int type;
Point center, size;
if (IsSplit(tile)) return 0; /* Ignore non-manhattan tiles */
if (cifPaintLayerName == NULL) return 0; /* Shouldn't happen */
TiToRect(tile, &r);
type = CIFCurStyle->cs_labelLayer[TiGetType(tile)];
center.p_x = r.r_xbot + r.r_xtop;
center.p_y = r.r_ybot + r.r_ytop;
center.p_x *= CIFCurStyle->cs_scaleFactor;
center.p_x /= CIFCurStyle->cs_reducer;
center.p_y *= CIFCurStyle->cs_scaleFactor;
center.p_y /= CIFCurStyle->cs_reducer;
if (CIFDoAreaLabels)
{
size.p_x = r.r_xtop - r.r_xbot;
size.p_y = r.r_ytop - r.r_ybot;
size.p_x *= 2 * CIFCurStyle->cs_scaleFactor;
size.p_x /= CIFCurStyle->cs_reducer;
size.p_y *= 2 * CIFCurStyle->cs_scaleFactor;
size.p_y /= CIFCurStyle->cs_reducer;
fprintf(f, "95 %s %d %d %d %d;\n",
cifPaintLayerName, size.p_x, size.p_y, center.p_x, center.p_y);
}
else
{
fprintf(f, "94 %s %d %d;\n",
cifPaintLayerName, center.p_x, center.p_y);
}
return 0;
}
/*
* ----------------------------------------------------------------------------
*