mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-10-06 18:02:52 +02:00
Added the ability to handle command option "cif list cover ..." to
provide a single decimal value back to the interpreter, without the additional diagnostic output.
This commit is contained in:
+21
-5
@@ -21,6 +21,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tcltk/tclmagic.h"
|
||||
#include "utils/magic.h"
|
||||
#include "utils/geometry.h"
|
||||
#include "tiles/tile.h"
|
||||
@@ -422,10 +423,11 @@ typedef struct {
|
||||
} coverstats;
|
||||
|
||||
void
|
||||
CIFCoverageLayer(rootDef, area, layer)
|
||||
CIFCoverageLayer(rootDef, area, layer, dolist)
|
||||
CellDef *rootDef; /* Def in which to compute CIF coverage */
|
||||
Rect *area; /* Area in which to compute coverage */
|
||||
char *layer; /* CIF layer for coverage computation. */
|
||||
bool dolist; /* If TRUE, report only the value, in decimal */
|
||||
{
|
||||
coverstats cstats;
|
||||
int i, scale;
|
||||
@@ -482,12 +484,26 @@ CIFCoverageLayer(rootDef, area, layer)
|
||||
atotal = (long long)(cstats.bounds.r_xtop - cstats.bounds.r_xbot);
|
||||
atotal *= (long long)(cstats.bounds.r_ytop - cstats.bounds.r_ybot);
|
||||
|
||||
TxPrintf("%s Area = %lld CIF units^2\n", doBox ? "Cursor Box" :
|
||||
if (dolist)
|
||||
{
|
||||
#ifdef MAGIC_WRAPPER
|
||||
Tcl_Obj *pobj;
|
||||
|
||||
pobj = Tcl_NewDoubleObj((double)fcover);
|
||||
Tcl_SetObjResult(magicinterp, pobj);
|
||||
#else
|
||||
TxPrintf("%g\n", fcover);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
TxPrintf("%s Area = %lld CIF units^2\n", doBox ? "Cursor Box" :
|
||||
"Cell", btotal);
|
||||
TxPrintf("Layer Bounding Area = %lld CIF units^2\n", atotal);
|
||||
TxPrintf("Layer Total Area = %lld CIF units^2\n", cstats.coverage);
|
||||
TxPrintf("Coverage in %s = %1.1f%%\n", doBox ? "box" :
|
||||
TxPrintf("Layer Bounding Area = %lld CIF units^2\n", atotal);
|
||||
TxPrintf("Layer Total Area = %lld CIF units^2\n", cstats.coverage);
|
||||
TxPrintf("Coverage in %s = %1.1f%%\n", doBox ? "box" :
|
||||
"cell", 100.0 * fcover);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
+3
-2
@@ -1304,6 +1304,7 @@ CmdCif(w, cmd)
|
||||
bool doforall = FALSE;
|
||||
float curscale;
|
||||
int argc = cmd->tx_argc;
|
||||
int argshift;
|
||||
char **argv = cmd->tx_argv;
|
||||
|
||||
static char *cmdCifWarnOptions[] = { "default", "none", "align",
|
||||
@@ -1459,10 +1460,10 @@ CmdCif(w, cmd)
|
||||
TxError("Box requested but no cursor box exists\n");
|
||||
return;
|
||||
}
|
||||
CIFCoverageLayer(rootDef, &box, argv[2]);
|
||||
CIFCoverageLayer(rootDef, &box, argv[2], dolist);
|
||||
}
|
||||
else if (argc == 3)
|
||||
CIFCoverageLayer(rootDef, &rootDef->cd_bbox, argv[2]);
|
||||
CIFCoverageLayer(rootDef, &rootDef->cd_bbox, argv[2], dolist);
|
||||
else
|
||||
goto wrongNumArgs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user