2020-08-08 15:47:34 +02:00
|
|
|
/* File: psprint.c
|
2020-10-12 13:13:31 +02:00
|
|
|
*
|
2020-08-08 15:47:34 +02:00
|
|
|
* This file is part of XSCHEM,
|
2020-10-12 13:13:31 +02:00
|
|
|
* a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit
|
2020-08-08 15:47:34 +02:00
|
|
|
* simulation.
|
2022-06-24 00:36:12 +02:00
|
|
|
* Copyright (C) 1998-2022 Stefan Frederik Schippers
|
2020-08-08 15:47:34 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "xschem.h"
|
2020-10-15 17:39:21 +02:00
|
|
|
#define X_TO_PS(x) ( (x+xctx->xorigin)* xctx->mooz )
|
|
|
|
|
#define Y_TO_PS(y) ( (y+xctx->yorigin)* xctx->mooz )
|
2020-08-08 15:47:34 +02:00
|
|
|
|
2021-01-07 04:33:19 +01:00
|
|
|
#if 0
|
2021-10-17 22:05:55 +02:00
|
|
|
* /* FIXME: overflow check. Not used, BTW */
|
|
|
|
|
* static char *strreplace(char s[], char token[], char replace[])
|
|
|
|
|
* {
|
|
|
|
|
* static char res[200];
|
|
|
|
|
* char *p1, *p2;
|
|
|
|
|
* int l;
|
|
|
|
|
*
|
|
|
|
|
* res[0] = '\0';
|
|
|
|
|
* l = strlen(token);
|
|
|
|
|
* p1 = p2 = s;
|
|
|
|
|
* while( (p2 = strstr(p1, token)) ) {
|
|
|
|
|
* strncat(res, p1, p2 - p1);
|
|
|
|
|
* strcat(res, replace);
|
|
|
|
|
* p1 = p2 = p2 + l;
|
|
|
|
|
* }
|
|
|
|
|
* strcat(res, p1);
|
|
|
|
|
* return res;
|
|
|
|
|
* }
|
2021-01-07 04:33:19 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
char *utf8_enc[]={
|
|
|
|
|
"/recodedict 24 dict def\n",
|
|
|
|
|
"/recode {recodedict begin /nco&na exch def\n",
|
|
|
|
|
"/nfnam exch def /basefontname exch def /basefontdict basefontname findfont def\n",
|
|
|
|
|
"/newfont basefontdict maxlength dict def basefontdict {exch dup /FID ne\n",
|
|
|
|
|
"{dup /Encoding eq {exch dup length array copy newfont 3 1 roll put} {exch\n",
|
|
|
|
|
"newfont 3 1 roll put} ifelse} {pop pop} ifelse } forall newfont\n",
|
|
|
|
|
"/FontName nfnam put nco&na aload pop nco&na length 2 idiv {newfont\n",
|
|
|
|
|
"/Encoding get 3 1 roll put} repeat nfnam newfont definefont pop end } def\n",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
char *utf8[]={
|
|
|
|
|
"/chararr [\n",
|
|
|
|
|
/* 0xC2 2-byte characters */
|
|
|
|
|
" 161 /exclamdown\n", " 162 /cent\n", " 163 /sterling\n", " 164 /currency\n",
|
|
|
|
|
" 165 /yen\n", " 166 /bar\n", " 167 /section\n", " 168 /dieresis\n",
|
|
|
|
|
" 169 /copyright\n", " 170 /ordfeminine\n", " 171 /guillemotleft\n", " 172 /logicalnot\n",
|
|
|
|
|
" 173 /emdash\n", " 174 /registered\n", " 175 /macron\n", " 176 /degree\n",
|
|
|
|
|
" 177 /plusminus\n", " 178 /twosuperior\n", " 179 /threesuperior\n", " 180 /acute\n",
|
|
|
|
|
" 181 /mu\n", " 182 /paragraph\n", " 183 /periodcentered\n", " 184 /cedilla\n",
|
|
|
|
|
" 185 /onesuperior\n", " 186 /ordmasculine\n", " 187 /guillemotright\n", " 188 /onequarter\n",
|
|
|
|
|
" 189 /onehalf\n", " 190 /threequarters\n", " 191 /questiondown\n",
|
|
|
|
|
/* 0xC3 2-byte characters */
|
|
|
|
|
" 192 /Agrave\n", " 193 /Aacute\n", " 194 /Acircumflex\n", " 195 /Atilde\n",
|
|
|
|
|
" 196 /Adieresis\n", " 197 /Aring\n", " 198 /AE\n", " 199 /Ccedilla\n",
|
|
|
|
|
" 200 /Egrave\n", " 201 /Eacute\n", " 202 /Ecircumflex\n", " 203 /Edieresis\n",
|
|
|
|
|
" 204 /Igrave\n", " 205 /Iacute\n", " 206 /Icircumflex\n", " 207 /Idieresis\n",
|
|
|
|
|
" 208 /Eth\n", " 209 /Ntilde\n", " 210 /Ograve\n", " 211 /Oacute\n",
|
|
|
|
|
" 212 /Ocircumflex\n", " 213 /Otilde\n", " 214 /Odieresis\n", " 215 /multiply\n",
|
|
|
|
|
" 216 /Oslash\n", " 217 /Ugrave\n", " 218 /Uacute\n", " 219 /Ucircumflex\n",
|
|
|
|
|
" 220 /Udieresis\n", " 221 /Yacute\n", " 222 /Thorn\n", " 223 /germandbls\n",
|
|
|
|
|
" 224 /agrave\n", " 225 /aacute\n", " 226 /acircumflex\n", " 227 /atilde\n",
|
|
|
|
|
" 228 /adieresis\n", " 229 /aring\n", " 230 /ae\n", " 231 /ccedilla\n",
|
|
|
|
|
" 232 /egrave\n", " 233 /eacute\n", " 234 /ecircumflex\n", " 235 /edieresis\n",
|
|
|
|
|
" 236 /igrave\n", " 237 /iacute\n", " 238 /icircumflex\n", " 239 /idieresis\n",
|
|
|
|
|
" 240 /eth\n", " 241 /ntilde\n", " 242 /ograve\n", " 243 /oacute\n",
|
|
|
|
|
" 244 /ocircumflex\n", " 245 /otilde\n", " 246 /odieresis\n", " 247 /divide\n",
|
|
|
|
|
" 248 /oslash\n", " 249 /ugrave\n", " 250 /uacute\n", " 251 /ucircumflex\n",
|
|
|
|
|
" 252 /udieresis\n", " 253 /yacute\n", " 254 /thorn\n", " 255 /ydieresis\n",
|
|
|
|
|
" ] def\n"};
|
|
|
|
|
|
2020-10-12 13:13:31 +02:00
|
|
|
static FILE *fd;
|
2020-08-08 15:47:34 +02:00
|
|
|
|
|
|
|
|
typedef struct {
|
2022-04-28 10:12:16 +02:00
|
|
|
unsigned int red;
|
|
|
|
|
unsigned int green;
|
|
|
|
|
unsigned int blue;
|
2020-08-08 15:47:34 +02:00
|
|
|
} Ps_color;
|
|
|
|
|
|
|
|
|
|
static Ps_color *ps_colors;
|
2021-01-07 04:33:19 +01:00
|
|
|
static char ps_font_name[80] = "Helvetica"; /* Courier Times Helvetica Symbol */
|
|
|
|
|
static char ps_font_family[80] = "Helvetica"; /* Courier Times Helvetica Symbol */
|
2020-08-08 15:47:34 +02:00
|
|
|
|
2020-12-16 18:30:33 +01:00
|
|
|
|
|
|
|
|
static void set_lw(void)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-10-17 00:53:19 +02:00
|
|
|
if(xctx->lw==0.0)
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g setlinewidth\n",0.5);
|
2020-08-08 15:47:34 +02:00
|
|
|
else
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g setlinewidth\n",xctx->lw/1.2);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void set_ps_colors(unsigned int pixel)
|
|
|
|
|
{
|
2020-10-12 13:13:31 +02:00
|
|
|
|
2020-12-16 18:56:38 +01:00
|
|
|
if(color_ps) fprintf(fd, "%g %g %g RGB\n",
|
2020-10-12 13:13:31 +02:00
|
|
|
(double)ps_colors[pixel].red/256.0, (double)ps_colors[pixel].green/256.0,
|
2020-08-08 15:47:34 +02:00
|
|
|
(double)ps_colors[pixel].blue/256.0);
|
2020-10-12 13:13:31 +02:00
|
|
|
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ps_xdrawarc(int layer, int fillarc, double x, double y, double r, double a, double b)
|
|
|
|
|
{
|
2022-08-28 23:50:57 +02:00
|
|
|
if(xctx->fill_pattern && xctx->fill_type[layer] && fillarc)
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g %g %g %g %g A %g %g LT C F S\n", x, y, r, -a, -a-b, x, y);
|
2020-08-08 15:47:34 +02:00
|
|
|
else
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g %g %g %g %g A S\n", x, y, r, -a, -a-b);
|
2020-10-12 13:13:31 +02:00
|
|
|
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-12 13:13:31 +02:00
|
|
|
static void ps_xdrawline(int layer, double x1, double y1, double x2,
|
2020-08-08 15:47:34 +02:00
|
|
|
double y2)
|
|
|
|
|
{
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%.6g %.6g %.6g %.6g L\n", x2, y2, x1, y1);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ps_xdrawpoint(int layer, double x1, double y1)
|
|
|
|
|
{
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g %g %g %g L\n", x1, y1,x1,y1);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ps_xfillrectange(int layer, double x1, double y1, double x2,
|
|
|
|
|
double y2)
|
|
|
|
|
{
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g %g %g %g R\n", x1,y1,x2-x1,y2-y1);
|
2021-11-16 22:28:10 +01:00
|
|
|
if( (xctx->fill_type[layer] == 1) && xctx->fill_pattern) {
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g %g %g %g RF\n", x1,y1,x2-x1,y2-y1);
|
2020-08-08 15:47:34 +02:00
|
|
|
/* fprintf(fd,"fill\n"); */
|
|
|
|
|
}
|
|
|
|
|
/*fprintf(fd,"stroke\n"); */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convex Nonconvex Complex */
|
|
|
|
|
#define Polygontype Nonconvex
|
2020-09-03 10:05:48 +02:00
|
|
|
static void ps_drawpolygon(int c, int what, double *x, double *y, int points, int poly_fill, int dash)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
double x1,y1,x2,y2;
|
|
|
|
|
double xx, yy;
|
2020-09-03 10:05:48 +02:00
|
|
|
double psdash;
|
2020-08-08 15:47:34 +02:00
|
|
|
int i;
|
|
|
|
|
polygon_bbox(x, y, points, &x1,&y1,&x2,&y2);
|
|
|
|
|
x1=X_TO_PS(x1);
|
|
|
|
|
y1=Y_TO_PS(y1);
|
|
|
|
|
x2=X_TO_PS(x2);
|
|
|
|
|
y2=Y_TO_PS(y2);
|
2020-12-02 15:10:47 +01:00
|
|
|
if( !rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) ) {
|
2020-08-08 15:47:34 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-15 17:39:21 +02:00
|
|
|
psdash = dash / xctx->zoom;
|
2020-09-03 10:05:48 +02:00
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash);
|
|
|
|
|
}
|
2020-08-08 15:47:34 +02:00
|
|
|
for(i=0;i<points; i++) {
|
|
|
|
|
xx = X_TO_PS(x[i]);
|
|
|
|
|
yy = Y_TO_PS(y[i]);
|
2020-12-16 18:30:33 +01:00
|
|
|
if(i==0) fprintf(fd, "NP\n%g %g MT\n", xx, yy);
|
|
|
|
|
else fprintf(fd, "%g %g LT\n", xx, yy);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2021-11-16 22:28:10 +01:00
|
|
|
if(xctx->fill_pattern && xctx->fill_type[c] && poly_fill) {
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "C F S\n");
|
2020-09-03 10:05:48 +02:00
|
|
|
} else {
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "S\n");
|
2020-09-03 10:05:48 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-12 13:13:31 +02:00
|
|
|
|
2020-09-03 10:05:48 +02:00
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[] 0 setdash\n");
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-09-03 10:05:48 +02:00
|
|
|
static void ps_filledrect(int gc, double rectx1,double recty1,double rectx2,double recty2, int dash)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
double x1,y1,x2,y2;
|
2020-09-03 10:05:48 +02:00
|
|
|
double psdash;
|
2020-08-08 15:47:34 +02:00
|
|
|
|
|
|
|
|
x1=X_TO_PS(rectx1);
|
|
|
|
|
y1=Y_TO_PS(recty1);
|
|
|
|
|
x2=X_TO_PS(rectx2);
|
|
|
|
|
y2=Y_TO_PS(recty2);
|
2020-12-02 15:10:47 +01:00
|
|
|
if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) )
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-10-15 17:39:21 +02:00
|
|
|
psdash = dash / xctx->zoom;
|
2020-09-03 10:05:48 +02:00
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash);
|
|
|
|
|
}
|
|
|
|
|
ps_xfillrectange(gc, x1,y1,x2,y2);
|
|
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[] 0 setdash\n");
|
|
|
|
|
}
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-03 10:05:48 +02:00
|
|
|
static void ps_drawarc(int gc, int fillarc, double x,double y,double r,double a, double b, int dash)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
double xx,yy,rr;
|
|
|
|
|
double x1, y1, x2, y2;
|
2020-09-03 10:05:48 +02:00
|
|
|
double psdash;
|
2020-08-08 15:47:34 +02:00
|
|
|
|
|
|
|
|
xx=X_TO_PS(x);
|
|
|
|
|
yy=Y_TO_PS(y);
|
2020-10-15 17:39:21 +02:00
|
|
|
rr=r*xctx->mooz;
|
2020-08-08 15:47:34 +02:00
|
|
|
arc_bbox(x, y, r, a, b, &x1,&y1,&x2,&y2);
|
|
|
|
|
x1=X_TO_PS(x1);
|
|
|
|
|
y1=Y_TO_PS(y1);
|
|
|
|
|
x2=X_TO_PS(x2);
|
|
|
|
|
y2=Y_TO_PS(y2);
|
|
|
|
|
|
2020-12-02 15:10:47 +01:00
|
|
|
if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) )
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-10-15 17:39:21 +02:00
|
|
|
psdash = dash / xctx->zoom;
|
2020-09-03 10:05:48 +02:00
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash);
|
|
|
|
|
}
|
|
|
|
|
ps_xdrawarc(gc, fillarc, xx, yy, rr, a, b);
|
|
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[] 0 setdash\n");
|
|
|
|
|
}
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-09-03 10:05:48 +02:00
|
|
|
static void ps_drawline(int gc, double linex1,double liney1,double linex2,double liney2, int dash)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
double x1,y1,x2,y2;
|
2020-09-03 10:05:48 +02:00
|
|
|
double psdash;
|
2020-08-08 15:47:34 +02:00
|
|
|
|
|
|
|
|
x1=X_TO_PS(linex1);
|
|
|
|
|
y1=Y_TO_PS(liney1);
|
|
|
|
|
x2=X_TO_PS(linex2);
|
|
|
|
|
y2=Y_TO_PS(liney2);
|
|
|
|
|
if( clip(&x1,&y1,&x2,&y2) )
|
|
|
|
|
{
|
2020-10-15 17:39:21 +02:00
|
|
|
psdash = dash / xctx->zoom;
|
2020-09-03 10:05:48 +02:00
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[%g %g] 0 setdash\n", psdash, psdash);
|
|
|
|
|
}
|
|
|
|
|
ps_xdrawline(gc, x1, y1, x2, y2);
|
|
|
|
|
if(dash) {
|
|
|
|
|
fprintf(fd, "[] 0 setdash\n");
|
|
|
|
|
}
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 18:30:33 +01:00
|
|
|
|
|
|
|
|
|
2020-12-23 05:07:39 +01:00
|
|
|
static void ps_draw_string_line(int layer, char *s, double x, double y, double size,
|
|
|
|
|
short rot, short flip, int lineno, double fontheight, double fontascent,
|
2022-04-28 00:00:51 +02:00
|
|
|
double fontdescent, int llength, int no_of_lines, double longest_line)
|
2020-12-16 18:30:33 +01:00
|
|
|
{
|
|
|
|
|
double ix, iy;
|
|
|
|
|
short rot1;
|
2022-04-27 13:18:45 +02:00
|
|
|
unsigned char c, offset;
|
|
|
|
|
double line_delta;
|
2020-12-16 18:30:33 +01:00
|
|
|
double lines;
|
|
|
|
|
set_ps_colors(layer);
|
|
|
|
|
if(s==NULL) return;
|
|
|
|
|
if(llength==0) return;
|
|
|
|
|
|
|
|
|
|
line_delta = lineno*fontheight;
|
2020-12-23 05:07:39 +01:00
|
|
|
lines = (no_of_lines-1)*fontheight;
|
2020-12-16 18:30:33 +01:00
|
|
|
|
|
|
|
|
ix=X_TO_PS(x);
|
|
|
|
|
iy=Y_TO_PS(y);
|
|
|
|
|
if(rot&1) {
|
|
|
|
|
rot1=3;
|
|
|
|
|
} else rot1=0;
|
|
|
|
|
|
|
|
|
|
if( rot==0 && flip==0) {iy+=line_delta+fontascent;}
|
|
|
|
|
else if(rot==1 && flip==0) {ix=ix-fontheight+fontascent-lines+line_delta;}
|
|
|
|
|
else if(rot==2 && flip==0) {iy=iy-fontheight-lines+line_delta+fontascent;}
|
|
|
|
|
else if(rot==3 && flip==0) {ix+=line_delta+fontascent;}
|
|
|
|
|
else if(rot==0 && flip==1) {iy+=line_delta+fontascent;}
|
|
|
|
|
else if(rot==1 && flip==1) {ix=ix-fontheight+line_delta-lines+fontascent;}
|
|
|
|
|
else if(rot==2 && flip==1) {iy=iy-fontheight-lines+line_delta+fontascent;}
|
|
|
|
|
else if(rot==3 && flip==1) {ix+=line_delta+fontascent;}
|
|
|
|
|
|
2020-12-23 02:59:44 +01:00
|
|
|
fprintf(fd, "GS\n");
|
2021-01-07 04:33:19 +01:00
|
|
|
fprintf(fd, "/%s", ps_font_family);
|
|
|
|
|
fprintf(fd, " FF\n");
|
2020-12-16 18:30:33 +01:00
|
|
|
fprintf(fd, "%g SCF\n", size * xctx->mooz);
|
|
|
|
|
fprintf(fd, "SF\n");
|
|
|
|
|
fprintf(fd, "NP\n");
|
|
|
|
|
fprintf(fd, "%g %g MT\n", ix, iy);
|
|
|
|
|
if(rot1) fprintf(fd, "%d rotate\n", rot1*90);
|
|
|
|
|
fprintf(fd, "1 -1 scale\n");
|
2020-12-17 02:49:37 +01:00
|
|
|
fprintf(fd, "(");
|
2021-01-07 04:33:19 +01:00
|
|
|
offset = 0;
|
|
|
|
|
while( (c = (unsigned char) *s) ) {
|
|
|
|
|
if(c > 127) {
|
|
|
|
|
if(c == 195) {offset = 64;s++; continue;}
|
|
|
|
|
if(c == 194) {s++; continue;}
|
|
|
|
|
fprintf(fd, "\\%03o", c + offset);
|
|
|
|
|
offset = 0;
|
|
|
|
|
} else
|
|
|
|
|
switch(c) {
|
2020-12-17 02:49:37 +01:00
|
|
|
case '(':
|
|
|
|
|
fputs("\\(", fd);
|
|
|
|
|
break;
|
|
|
|
|
case ')':
|
|
|
|
|
fputs("\\)", fd);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2021-01-07 04:33:19 +01:00
|
|
|
fputc(c, fd);
|
2020-12-17 02:49:37 +01:00
|
|
|
}
|
|
|
|
|
s++;
|
|
|
|
|
}
|
|
|
|
|
fprintf(fd, ")\n");
|
2020-12-16 18:30:33 +01:00
|
|
|
if (rot==1 && flip==0) {fprintf(fd, "dup SW pop neg 0 RMT\n");}
|
|
|
|
|
else if(rot==2 && flip==0) {fprintf(fd, "dup SW pop neg 0 RMT\n");}
|
|
|
|
|
else if(rot==0 && flip==1) {fprintf(fd, "dup SW pop neg 0 RMT\n");}
|
|
|
|
|
else if(rot==3 && flip==1) {fprintf(fd, "dup SW pop neg 0 RMT\n");}
|
|
|
|
|
|
|
|
|
|
fprintf(fd, "show\n");
|
|
|
|
|
fprintf(fd, "GR\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void ps_draw_string(int layer, const char *str, short rot, short flip, int hcenter, int vcenter,
|
|
|
|
|
double x,double y, double xscale, double yscale)
|
|
|
|
|
{
|
|
|
|
|
char *tt, *ss, *sss=NULL;
|
|
|
|
|
double textx1,textx2,texty1,texty2;
|
|
|
|
|
char c;
|
|
|
|
|
int lineno=0;
|
|
|
|
|
double size, height, ascent, descent;
|
2022-04-28 00:00:51 +02:00
|
|
|
int llength=0, no_of_lines;
|
|
|
|
|
double longest_line;
|
2020-12-23 05:07:39 +01:00
|
|
|
|
2022-01-19 10:44:15 +01:00
|
|
|
if(str==NULL) return;
|
2020-12-16 18:30:33 +01:00
|
|
|
size = xscale*53.;
|
|
|
|
|
height = size*xctx->mooz * 1.147; /* was 1.147 */
|
|
|
|
|
ascent = size*xctx->mooz * 0.808; /* was 0.908 */
|
|
|
|
|
descent = size*xctx->mooz * 0.219; /* was 0.219 */
|
|
|
|
|
|
2022-01-19 12:15:33 +01:00
|
|
|
#if HAS_CAIRO==1
|
2022-01-19 10:44:15 +01:00
|
|
|
if(!has_x)
|
|
|
|
|
text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter,
|
2020-12-23 05:07:39 +01:00
|
|
|
x,y, &textx1,&texty1,&textx2,&texty2, &no_of_lines, &longest_line);
|
2022-01-19 10:44:15 +01:00
|
|
|
else
|
|
|
|
|
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter,
|
|
|
|
|
x,y, &textx1,&texty1,&textx2,&texty2, &no_of_lines, &longest_line);
|
|
|
|
|
#else
|
|
|
|
|
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter,
|
|
|
|
|
x,y, &textx1,&texty1,&textx2,&texty2, &no_of_lines, &longest_line);
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-12-23 05:07:39 +01:00
|
|
|
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,
|
|
|
|
|
xctx->areay2,textx1,texty1,textx2,texty2)) {
|
2020-12-16 18:30:33 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(hcenter) {
|
|
|
|
|
if(rot == 0 && flip == 0 ) { x=textx1;}
|
|
|
|
|
if(rot == 1 && flip == 0 ) { y=texty1;}
|
|
|
|
|
if(rot == 2 && flip == 0 ) { x=textx2;}
|
|
|
|
|
if(rot == 3 && flip == 0 ) { y=texty2;}
|
|
|
|
|
if(rot == 0 && flip == 1 ) { x=textx2;}
|
|
|
|
|
if(rot == 1 && flip == 1 ) { y=texty2;}
|
|
|
|
|
if(rot == 2 && flip == 1 ) { x=textx1;}
|
|
|
|
|
if(rot == 3 && flip == 1 ) { y=texty1;}
|
|
|
|
|
}
|
|
|
|
|
if(vcenter) {
|
|
|
|
|
if(rot == 0 && flip == 0 ) { y=texty1;}
|
|
|
|
|
if(rot == 1 && flip == 0 ) { x=textx2;}
|
|
|
|
|
if(rot == 2 && flip == 0 ) { y=texty2;}
|
|
|
|
|
if(rot == 3 && flip == 0 ) { x=textx1;}
|
|
|
|
|
if(rot == 0 && flip == 1 ) { y=texty1;}
|
|
|
|
|
if(rot == 1 && flip == 1 ) { x=textx2;}
|
|
|
|
|
if(rot == 2 && flip == 1 ) { y=texty2;}
|
|
|
|
|
if(rot == 3 && flip == 1 ) { x=textx1;}
|
|
|
|
|
}
|
|
|
|
|
llength=0;
|
2020-12-17 02:01:38 +01:00
|
|
|
my_strdup2(54, &sss, str);
|
2020-12-16 18:30:33 +01:00
|
|
|
tt=ss=sss;
|
|
|
|
|
for(;;) {
|
|
|
|
|
c=*ss;
|
|
|
|
|
if(c=='\n' || c==0) {
|
|
|
|
|
*ss='\0';
|
2020-12-23 05:07:39 +01:00
|
|
|
ps_draw_string_line(layer, tt, x, y, size, rot, flip, lineno,
|
|
|
|
|
height, ascent, descent, llength, no_of_lines, longest_line);
|
2020-12-16 18:30:33 +01:00
|
|
|
lineno++;
|
|
|
|
|
if(c==0) break;
|
|
|
|
|
*ss='\n';
|
|
|
|
|
tt=ss+1;
|
|
|
|
|
llength=0;
|
|
|
|
|
} else {
|
|
|
|
|
llength++;
|
|
|
|
|
}
|
|
|
|
|
ss++;
|
|
|
|
|
}
|
2020-12-17 02:01:38 +01:00
|
|
|
my_free(53, &sss);
|
2020-12-16 18:30:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void old_ps_draw_string(int gctext, const char *str,
|
2020-12-05 03:16:01 +01:00
|
|
|
short rot, short flip, int hcenter, int vcenter,
|
2020-08-08 15:47:34 +02:00
|
|
|
double x1,double y1,
|
2020-10-12 13:13:31 +02:00
|
|
|
double xscale, double yscale)
|
2020-08-08 15:47:34 +02:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
double a,yy,curr_x1,curr_y1,curr_x2,curr_y2,rx1,rx2,ry1,ry2;
|
|
|
|
|
int pos=0,cc,pos2=0;
|
2022-04-28 00:00:51 +02:00
|
|
|
int i, no_of_lines;
|
|
|
|
|
double longest_line;
|
2020-08-08 15:47:34 +02:00
|
|
|
|
|
|
|
|
if(str==NULL) return;
|
2020-12-07 20:04:57 +01:00
|
|
|
#if HAS_CAIRO==1
|
2020-12-23 05:07:39 +01:00
|
|
|
text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter,
|
|
|
|
|
x1,y1, &rx1,&ry1,&rx2,&ry2, &no_of_lines, &longest_line);
|
2020-08-08 15:47:34 +02:00
|
|
|
#else
|
2020-12-23 05:07:39 +01:00
|
|
|
text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter,
|
2020-12-24 12:23:48 +01:00
|
|
|
x1,y1, &rx1,&ry1,&rx2,&ry2, &no_of_lines, &longest_line);
|
2020-08-08 15:47:34 +02:00
|
|
|
#endif
|
2021-11-10 13:43:08 +01:00
|
|
|
xscale*=tclgetdoublevar("nocairo_font_xscale");
|
|
|
|
|
yscale*=tclgetdoublevar("nocairo_font_yscale");
|
2020-08-08 15:47:34 +02:00
|
|
|
|
2020-12-02 15:10:47 +01:00
|
|
|
if(!textclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,rx1,ry1,rx2,ry2)) return;
|
2020-08-29 11:58:50 +02:00
|
|
|
set_ps_colors(gctext);
|
2020-08-08 15:47:34 +02:00
|
|
|
x1=rx1;y1=ry1;
|
|
|
|
|
if(rot&1) {y1=ry2;rot=3;}
|
|
|
|
|
else rot=0;
|
|
|
|
|
flip = 0; yy=y1;
|
|
|
|
|
while(str[pos2])
|
|
|
|
|
{
|
2020-11-13 12:54:07 +01:00
|
|
|
cc = (unsigned char)str[pos2++];
|
|
|
|
|
if(cc>127) cc= '?';
|
2020-10-12 13:13:31 +02:00
|
|
|
if(cc=='\n')
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
yy+=(FONTHEIGHT+FONTDESCENT+FONTWHITESPACE)*
|
|
|
|
|
yscale;
|
|
|
|
|
pos=0;
|
|
|
|
|
continue;
|
2020-10-12 13:13:31 +02:00
|
|
|
}
|
2020-08-08 15:47:34 +02:00
|
|
|
a = pos*(FONTWIDTH+FONTWHITESPACE);
|
|
|
|
|
for(i=0;i<character[cc][0]*4;i+=4)
|
|
|
|
|
{
|
|
|
|
|
curr_x1 = ( character[cc][i+1]+ a ) * xscale + x1;
|
|
|
|
|
curr_y1 = ( character[cc][i+2] ) * yscale+yy;
|
|
|
|
|
curr_x2 = ( character[cc][i+3]+ a ) * xscale + x1;
|
|
|
|
|
curr_y2 = ( character[cc][i+4] ) * yscale+yy;
|
2020-11-03 12:10:55 +01:00
|
|
|
ROTATION(rot, flip, x1,y1,curr_x1,curr_y1,rx1,ry1);
|
|
|
|
|
ROTATION(rot, flip, x1,y1,curr_x2,curr_y2,rx2,ry2);
|
2020-08-08 15:47:34 +02:00
|
|
|
ORDER(rx1,ry1,rx2,ry2);
|
2020-09-03 10:05:48 +02:00
|
|
|
ps_drawline(gctext, rx1, ry1, rx2, ry2, 0);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
pos++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ps_drawgrid()
|
|
|
|
|
{
|
|
|
|
|
double x,y;
|
|
|
|
|
double delta,tmp;
|
2021-11-10 13:43:08 +01:00
|
|
|
if( !tclgetboolvar("draw_grid")) return;
|
|
|
|
|
delta=tclgetdoublevar("cadgrid")* xctx->mooz;
|
2020-08-08 15:47:34 +02:00
|
|
|
while(delta<CADGRIDTHRESHOLD) delta*=CADGRIDMULTIPLY; /* <-- to be improved,but works */
|
2020-10-15 17:39:21 +02:00
|
|
|
x = xctx->xorigin* xctx->mooz;y = xctx->yorigin* xctx->mooz;
|
2020-08-08 15:47:34 +02:00
|
|
|
set_ps_colors(GRIDLAYER);
|
2020-12-02 15:10:47 +01:00
|
|
|
if(y>xctx->areay1 && y<xctx->areay2)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-12-02 15:10:47 +01:00
|
|
|
ps_xdrawline(GRIDLAYER,xctx->areax1+1,(int)y, xctx->areax2-1, (int)y);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2020-12-02 15:10:47 +01:00
|
|
|
if(x>xctx->areax1 && x<xctx->areax2)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-12-02 15:10:47 +01:00
|
|
|
ps_xdrawline(GRIDLAYER,(int)x,xctx->areay1+1, (int)x, xctx->areay2-1);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
set_ps_colors(GRIDLAYER);
|
2020-12-02 15:10:47 +01:00
|
|
|
tmp = floor((xctx->areay1+1)/delta)*delta-fmod(-xctx->yorigin* xctx->mooz,delta);
|
|
|
|
|
for(x=floor((xctx->areax1+1)/delta)*delta-fmod(-xctx->xorigin* xctx->mooz,delta);x<xctx->areax2;x+=delta)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-12-02 15:10:47 +01:00
|
|
|
for(y=tmp;y<xctx->areay2;y+=delta)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
ps_xdrawpoint(GRIDLAYER,(int)(x), (int)(y));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-30 19:06:22 +01:00
|
|
|
static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot, double xoffset, double yoffset)
|
2020-08-08 15:47:34 +02:00
|
|
|
/* draws current layer only, should be called within */
|
|
|
|
|
{ /* a "for(i=0;i<cadlayers;i++)" loop */
|
2022-03-01 19:36:08 +01:00
|
|
|
int j, hide = 0;
|
2020-08-08 15:47:34 +02:00
|
|
|
double x0,y0,x1,y1,x2,y2;
|
2020-12-05 03:16:01 +01:00
|
|
|
short flip;
|
|
|
|
|
int textlayer;
|
2020-10-12 13:13:31 +02:00
|
|
|
xLine line;
|
2021-12-19 01:28:39 +01:00
|
|
|
xRect rect;
|
2020-10-12 13:13:31 +02:00
|
|
|
xText text;
|
2020-08-08 15:47:34 +02:00
|
|
|
xArc arc;
|
2020-10-12 13:13:31 +02:00
|
|
|
xPoly polygon;
|
2020-12-16 18:30:33 +01:00
|
|
|
xSymbol *symptr;
|
|
|
|
|
char *textfont;
|
2022-03-09 00:29:16 +01:00
|
|
|
int show_hidden_texts = tclgetboolvar("show_hidden_texts");
|
2020-08-08 15:47:34 +02:00
|
|
|
|
2020-10-15 17:39:21 +02:00
|
|
|
if(xctx->inst[n].ptr == -1) return;
|
2021-11-16 22:28:10 +01:00
|
|
|
if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return;
|
2022-03-01 19:36:08 +01:00
|
|
|
if( (xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr &&
|
|
|
|
|
!strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (xctx->hide_symbols == 2) ) {
|
|
|
|
|
hide = 1;
|
|
|
|
|
} else {
|
|
|
|
|
hide = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-08 15:47:34 +02:00
|
|
|
if(layer==0)
|
|
|
|
|
{
|
2021-12-31 12:37:28 +01:00
|
|
|
x1=X_TO_PS(xctx->inst[n].x1);
|
|
|
|
|
x2=X_TO_PS(xctx->inst[n].x2);
|
|
|
|
|
y1=Y_TO_PS(xctx->inst[n].y1);
|
|
|
|
|
y2=Y_TO_PS(xctx->inst[n].y2);
|
|
|
|
|
if(OUTSIDE(x1,y1,x2,y2,xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2))
|
|
|
|
|
{
|
|
|
|
|
xctx->inst[n].flags|=1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else xctx->inst[n].flags&=~1;
|
|
|
|
|
|
|
|
|
|
/* pdfmarks, only if doing hierarchy print and if symbol has a subcircuit */
|
|
|
|
|
if(what != 7) {
|
|
|
|
|
if(!strcmp(get_tok_value((xctx->inst[n].ptr+ xctx->sym)->prop_ptr, "type", 0), "subcircuit")) {
|
|
|
|
|
fprintf(fd,
|
|
|
|
|
"[ "
|
|
|
|
|
"/Rect [ %g %g %g %g ] "
|
|
|
|
|
"/Border [0 0 0] "
|
|
|
|
|
"/Dest /%s "
|
|
|
|
|
"/Subtype /Link "
|
|
|
|
|
"/ANN pdfmark\n",
|
|
|
|
|
x1, y1, x2, y2,
|
|
|
|
|
add_ext(skip_dir(xctx->inst[n].name), ".sch"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2020-10-15 17:39:21 +02:00
|
|
|
else if(xctx->inst[n].flags&1)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
dbg(1, "draw_symbol(): skippinginst %d\n", n);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-10-15 17:39:21 +02:00
|
|
|
flip = xctx->inst[n].flip;
|
2020-08-08 15:47:34 +02:00
|
|
|
if(tmp_flip) flip = !flip;
|
2020-10-15 17:39:21 +02:00
|
|
|
rot = (xctx->inst[n].rot + rot ) & 0x3;
|
2020-10-12 13:13:31 +02:00
|
|
|
|
2020-10-15 17:39:21 +02:00
|
|
|
x0=xctx->inst[n].x0 + xoffset;
|
|
|
|
|
y0=xctx->inst[n].y0 + yoffset;
|
2020-12-16 18:30:33 +01:00
|
|
|
symptr = (xctx->inst[n].ptr+ xctx->sym);
|
2020-10-15 17:39:21 +02:00
|
|
|
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->lines[layer];j++)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-10-15 17:39:21 +02:00
|
|
|
line = ((xctx->inst[n].ptr+ xctx->sym)->line[layer])[j];
|
2020-11-03 12:10:55 +01:00
|
|
|
ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1);
|
|
|
|
|
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
|
2020-08-08 15:47:34 +02:00
|
|
|
ORDER(x1,y1,x2,y2);
|
2021-06-05 08:58:38 +02:00
|
|
|
ps_drawline(layer, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2020-10-15 17:39:21 +02:00
|
|
|
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->polygons[layer];j++)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-10-15 17:39:21 +02:00
|
|
|
polygon = ((xctx->inst[n].ptr+ xctx->sym)->poly[layer])[j];
|
2020-08-08 15:47:34 +02:00
|
|
|
{ /* scope block so we declare some auxiliary arrays for coord transforms. 20171115 */
|
|
|
|
|
int k;
|
|
|
|
|
double *x = my_malloc(309, sizeof(double) * polygon.points);
|
|
|
|
|
double *y = my_malloc(310, sizeof(double) * polygon.points);
|
|
|
|
|
for(k=0;k<polygon.points;k++) {
|
2020-11-03 12:10:55 +01:00
|
|
|
ROTATION(rot, flip, 0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
|
2020-08-08 15:47:34 +02:00
|
|
|
x[k]+= x0;
|
|
|
|
|
y[k] += y0;
|
|
|
|
|
}
|
2020-09-03 10:05:48 +02:00
|
|
|
ps_drawpolygon(layer, NOW, x, y, polygon.points, polygon.fill, polygon.dash);
|
2020-08-08 15:47:34 +02:00
|
|
|
my_free(876, &x);
|
|
|
|
|
my_free(877, &y);
|
|
|
|
|
}
|
2020-10-12 13:13:31 +02:00
|
|
|
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2020-10-15 17:39:21 +02:00
|
|
|
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->arcs[layer];j++)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
|
|
|
|
double angle;
|
2020-10-15 17:39:21 +02:00
|
|
|
arc = ((xctx->inst[n].ptr+ xctx->sym)->arc[layer])[j];
|
2020-08-08 15:47:34 +02:00
|
|
|
if(flip) {
|
|
|
|
|
angle = 270.*rot+180.-arc.b-arc.a;
|
|
|
|
|
} else {
|
|
|
|
|
angle = arc.a+rot*270.;
|
|
|
|
|
}
|
|
|
|
|
angle = fmod(angle, 360.);
|
|
|
|
|
if(angle<0.) angle+=360.;
|
2020-11-03 12:10:55 +01:00
|
|
|
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
|
2020-09-03 10:05:48 +02:00
|
|
|
ps_drawarc(layer, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2021-11-16 22:28:10 +01:00
|
|
|
if( xctx->enable_layer[layer] ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer];j++)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2021-12-19 01:28:39 +01:00
|
|
|
rect = ((xctx->inst[n].ptr+ xctx->sym)->rect[layer])[j];
|
|
|
|
|
ROTATION(rot, flip, 0.0,0.0,rect.x1,rect.y1,x1,y1);
|
|
|
|
|
ROTATION(rot, flip, 0.0,0.0,rect.x2,rect.y2,x2,y2);
|
2020-10-12 13:13:31 +02:00
|
|
|
RECTORDER(x1,y1,x2,y2);
|
2021-12-19 01:28:39 +01:00
|
|
|
ps_filledrect(layer, x0+x1, y0+y1, x0+x2, y0+y2, rect.dash);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2020-10-15 17:39:21 +02:00
|
|
|
if( (layer==TEXTWIRELAYER && !(xctx->inst[n].flags&2) ) ||
|
2021-11-16 22:28:10 +01:00
|
|
|
(xctx->sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) )
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-08-31 02:25:41 +02:00
|
|
|
const char *txtptr;
|
2020-10-15 17:39:21 +02:00
|
|
|
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->texts;j++)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-10-15 17:39:21 +02:00
|
|
|
text = (xctx->inst[n].ptr+ xctx->sym)->text[j];
|
|
|
|
|
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
2022-03-09 00:29:16 +01:00
|
|
|
if(!show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
|
2022-03-01 19:36:08 +01:00
|
|
|
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
|
2020-08-31 02:25:41 +02:00
|
|
|
txtptr= translate(n, text.txt_ptr);
|
2020-11-03 12:10:55 +01:00
|
|
|
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
2020-08-29 11:58:50 +02:00
|
|
|
textlayer = layer;
|
2020-12-22 18:31:08 +01:00
|
|
|
/* do not allow custom text color on PINLAYER hilighted instances */
|
2021-01-07 16:35:57 +01:00
|
|
|
if( !(xctx->inst[n].color == -PINLAYER)) {
|
2020-10-15 17:39:21 +02:00
|
|
|
textlayer = (xctx->inst[n].ptr+ xctx->sym)->text[j].layer;
|
2020-08-29 11:58:50 +02:00
|
|
|
if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer;
|
|
|
|
|
}
|
2020-12-22 18:31:08 +01:00
|
|
|
/* display PINLAYER colored instance texts even if PINLAYER disabled */
|
2021-11-16 22:28:10 +01:00
|
|
|
if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) {
|
2020-12-22 18:31:08 +01:00
|
|
|
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
|
|
|
|
|
my_snprintf(ps_font_name, S(ps_font_name), "Helvetica");
|
|
|
|
|
textfont = symptr->text[j].font;
|
|
|
|
|
if( (textfont && textfont[0])) {
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), textfont);
|
|
|
|
|
my_snprintf(ps_font_name, S(ps_font_name), textfont);
|
|
|
|
|
}
|
2021-01-07 04:33:19 +01:00
|
|
|
if( symptr->text[j].flags & TEXT_BOLD) {
|
|
|
|
|
if( (symptr->text[j].flags & TEXT_ITALIC) || (symptr->text[j].flags & TEXT_OBLIQUE) ) {
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-BoldOblique", ps_font_name);
|
|
|
|
|
} else {
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( symptr->text[j].flags & TEXT_ITALIC)
|
2020-12-22 18:31:08 +01:00
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
2021-01-07 04:33:19 +01:00
|
|
|
else if( symptr->text[j].flags & TEXT_OBLIQUE)
|
2020-12-22 18:31:08 +01:00
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
2020-12-16 18:30:33 +01:00
|
|
|
if(text_ps) {
|
|
|
|
|
ps_draw_string(textlayer, txtptr,
|
|
|
|
|
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
|
|
|
|
flip^text.flip, text.hcenter, text.vcenter,
|
|
|
|
|
x0+x1, y0+y1, text.xscale, text.yscale);
|
|
|
|
|
} else {
|
|
|
|
|
old_ps_draw_string(textlayer, txtptr,
|
|
|
|
|
(text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3,
|
|
|
|
|
flip^text.flip, text.hcenter, text.vcenter,
|
|
|
|
|
x0+x1, y0+y1, text.xscale, text.yscale);
|
|
|
|
|
}
|
2020-08-30 10:38:29 +02:00
|
|
|
}
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void fill_ps_colors()
|
|
|
|
|
{
|
|
|
|
|
char s[200]; /* overflow safe 20161122 */
|
|
|
|
|
unsigned int i,c;
|
2021-11-22 12:42:33 +01:00
|
|
|
/* if(debug_var>=1) {
|
|
|
|
|
* tcleval( "puts $ps_colors");
|
|
|
|
|
* }
|
|
|
|
|
*/
|
2020-08-08 15:47:34 +02:00
|
|
|
for(i=0;i<cadlayers;i++) {
|
2022-04-28 10:12:16 +02:00
|
|
|
my_snprintf(s, S(s), "lindex $ps_colors %u", i);
|
2020-08-08 15:47:34 +02:00
|
|
|
tcleval( s);
|
2020-08-16 03:34:45 +02:00
|
|
|
sscanf(tclresult(),"%x", &c);
|
2020-08-08 15:47:34 +02:00
|
|
|
ps_colors[i].red = (c & 0xff0000) >> 16;
|
|
|
|
|
ps_colors[i].green = (c & 0x00ff00) >> 8;
|
|
|
|
|
ps_colors[i].blue = (c & 0x0000ff);
|
|
|
|
|
}
|
2020-10-12 13:13:31 +02:00
|
|
|
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-22 01:28:19 +01:00
|
|
|
void create_ps(char **psfile, int what)
|
2021-01-28 23:09:37 +01:00
|
|
|
{
|
|
|
|
|
double dx, dy, scale, scaley;
|
|
|
|
|
int landscape=1;
|
2021-06-13 23:55:17 +02:00
|
|
|
static int numpages = 0;
|
2021-01-28 23:09:37 +01:00
|
|
|
double margin=10; /* in postscript points, (1/72)". No need to add margin as xschem zoom full already has margins.*/
|
|
|
|
|
|
|
|
|
|
/* Legal: 612 792 */
|
|
|
|
|
double pagex=842;/* a4, in postscript points, (1/72)" */
|
|
|
|
|
double pagey=595;/* a4, in postscript points, (1/72)" */
|
|
|
|
|
xRect boundbox;
|
|
|
|
|
int c,i, textlayer;
|
|
|
|
|
int old_grid;
|
2022-02-22 12:09:04 +01:00
|
|
|
const char *textfont;
|
2022-03-09 00:29:16 +01:00
|
|
|
int show_hidden_texts = tclgetboolvar("show_hidden_texts");
|
|
|
|
|
|
2021-06-13 23:55:17 +02:00
|
|
|
if(what & 1) { /* prolog */
|
|
|
|
|
numpages = 0;
|
|
|
|
|
if(!(fd = open_tmpfile("psplot_", psfile)) ) {
|
|
|
|
|
fprintf(errfp, "ps_draw(): can not create tmpfile %s\n", *psfile);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
|
|
|
|
ps_colors=my_calloc(311, cadlayers, sizeof(Ps_color));
|
|
|
|
|
if(ps_colors==NULL){
|
2021-11-29 17:29:09 +01:00
|
|
|
fprintf(errfp, "create_ps(): calloc error\n");
|
|
|
|
|
return;
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fill_ps_colors();
|
2021-11-10 13:43:08 +01:00
|
|
|
old_grid=tclgetboolvar("draw_grid");
|
|
|
|
|
tclsetvar("draw_grid", "0");
|
|
|
|
|
|
2021-01-28 23:09:37 +01:00
|
|
|
|
|
|
|
|
boundbox.x1 = xctx->areax1;
|
|
|
|
|
boundbox.x2 = xctx->areax2;
|
|
|
|
|
boundbox.y1 = xctx->areay1;
|
|
|
|
|
boundbox.y2 = xctx->areay2;
|
|
|
|
|
dx=boundbox.x2-boundbox.x1;
|
|
|
|
|
dy=boundbox.y2-boundbox.y1;
|
|
|
|
|
|
|
|
|
|
/* xschem window aspect ratio decides if portrait or landscape */
|
|
|
|
|
if(dy > dx) landscape = 0;
|
|
|
|
|
else landscape = 1;
|
|
|
|
|
if(!landscape) {
|
|
|
|
|
double tmp;
|
|
|
|
|
tmp = pagex;
|
|
|
|
|
pagex = pagey;
|
|
|
|
|
pagey = tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 23:55:17 +02:00
|
|
|
if(what & 1) {/* prolog */
|
|
|
|
|
dbg(1, "ps_draw(): bbox: x1=%g y1=%g x2=%g y2=%g\n", boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
|
|
|
|
|
fprintf(fd, "%%!PS-Adobe-3.0\n");
|
|
|
|
|
/* fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", landscape ? "a4land" : "a4", pagex, pagey); */
|
|
|
|
|
fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", "a4", pagex, pagey);
|
|
|
|
|
fprintf(fd, "%%%%PageOrientation: %s\n", landscape ? "Landscape" : "Portrait");
|
|
|
|
|
fprintf(fd, "%%%%Title: xschem plot\n");
|
|
|
|
|
fprintf(fd, "%%%%Creator: xschem\n");
|
|
|
|
|
fprintf(fd, "%%%%Pages: (atend)\n");
|
|
|
|
|
fprintf(fd, "%%%%EndComments\n");
|
|
|
|
|
fprintf(fd, "%%%%BeginProlog\n\n");
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < sizeof(utf8_enc)/sizeof(char *); i++) {
|
2021-10-27 10:12:16 +02:00
|
|
|
fprintf(fd, "%s", utf8_enc[i]);
|
2021-06-13 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
for(i = 0; i < sizeof(utf8)/sizeof(char *); i++) {
|
2021-10-27 10:12:16 +02:00
|
|
|
fprintf(fd, "%s", utf8[i]);
|
2021-06-13 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(fd, "/Times /Times chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Times-Bold /Times-Bold chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Times-Oblique /Times-Oblique chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Times-BoldOblique /Times-BoldOblique chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Helvetica /Helvetica chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Helvetica-Bold /Helvetica-Bold chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Helvetica-Oblique /Helvetica-Oblique chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Helvetica-BoldOblique /Helvetica-BoldOblique chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Courier /Courier chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Courier-Bold /Courier-Bold chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Courier-Oblique /Courier-Oblique chararr recode\n");
|
|
|
|
|
fprintf(fd, "/Courier-BoldOblique /Courier-BoldOblique chararr recode\n");
|
|
|
|
|
|
|
|
|
|
fprintf(fd,"/cm {28.346457 mul} bind def\n");
|
|
|
|
|
fprintf(fd,"/LT {lineto} bind def\n");
|
|
|
|
|
fprintf(fd,"/MT {moveto} bind def\n");
|
|
|
|
|
fprintf(fd,"/RMT {rmoveto} bind def\n");
|
|
|
|
|
fprintf(fd,"/L {moveto lineto stroke} bind def\n");
|
|
|
|
|
fprintf(fd,"/RGB {setrgbcolor} bind def\n");
|
|
|
|
|
fprintf(fd,"/FF {findfont} bind def\n");
|
|
|
|
|
fprintf(fd,"/SF {setfont} bind def\n");
|
|
|
|
|
fprintf(fd,"/SCF {scalefont} bind def\n");
|
|
|
|
|
fprintf(fd,"/SW {stringwidth} bind def\n");
|
|
|
|
|
fprintf(fd,"/GS {gsave} bind def\n");
|
|
|
|
|
fprintf(fd,"/GR {grestore} bind def\n");
|
|
|
|
|
fprintf(fd,"/NP {newpath} bind def\n");
|
|
|
|
|
fprintf(fd,"/A {arcn} bind def\n");
|
|
|
|
|
fprintf(fd,"/R {rectstroke} bind def\n");
|
|
|
|
|
fprintf(fd,"/S {stroke} bind def\n");
|
|
|
|
|
fprintf(fd,"/C {closepath} bind def\n");
|
|
|
|
|
fprintf(fd,"/F {fill} bind def\n");
|
|
|
|
|
fprintf(fd,"/RF {rectfill} bind def\n");
|
|
|
|
|
fprintf(fd, "%%%%EndProlog\n");
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-13 23:55:17 +02:00
|
|
|
|
|
|
|
|
if(what & 2) { /* page */
|
|
|
|
|
numpages++;
|
|
|
|
|
fprintf(fd, "%%%%BeginSetup\n");
|
|
|
|
|
fprintf(fd, "<< /PageSize [%g %g] /Orientation 0 >> setpagedevice\n", pagex, pagey);
|
|
|
|
|
fprintf(fd, "%%%%Page: %d %d\n\n", numpages, numpages);
|
|
|
|
|
fprintf(fd, "%%%%BeginPageSetup\n");
|
|
|
|
|
fprintf(fd, "%%%%EndPageSetup\n");
|
|
|
|
|
|
2021-12-30 17:15:50 +01:00
|
|
|
/* add small page title */
|
2021-12-30 19:06:22 +01:00
|
|
|
fprintf(fd, "/Helvetica FF 10 SCF SF NP 20 %g MT (%s) show\n", pagey - 20, xctx->current_name);
|
|
|
|
|
|
|
|
|
|
/* Add anchor for pdfmarks */
|
|
|
|
|
fprintf(fd,
|
|
|
|
|
"[ "
|
|
|
|
|
"/Dest /%s "
|
2021-12-31 11:58:28 +01:00
|
|
|
"/DEST pdfmark\n", get_cell_w_ext(xctx->current_name, 0));
|
2021-12-30 19:06:22 +01:00
|
|
|
|
2021-06-13 23:55:17 +02:00
|
|
|
scaley = scale = (pagey-2 * margin) / dy;
|
|
|
|
|
dbg(1, "scale=%g pagex=%g pagey=%g dx=%g dy=%g\n", scale, pagex, pagey, dx, dy);
|
|
|
|
|
if(dx * scale > (pagex - 2 * margin)) {
|
|
|
|
|
scale = (pagex - 2 * margin) / dx;
|
|
|
|
|
dbg(1, "scale=%g\n", scale);
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
2021-06-13 23:55:17 +02:00
|
|
|
fprintf(fd, "%g %g translate\n",
|
|
|
|
|
-scale * boundbox.x1 + margin, pagey - (scaley - scale) * dy - margin + scale * boundbox.y1);
|
|
|
|
|
fprintf(fd, "%g %g scale\n", scale, -scale);
|
|
|
|
|
fprintf(fd, "1 setlinejoin 1 setlinecap\n");
|
2021-12-30 17:15:50 +01:00
|
|
|
|
2021-06-13 23:55:17 +02:00
|
|
|
set_lw();
|
|
|
|
|
ps_drawgrid();
|
|
|
|
|
|
|
|
|
|
for(i=0;i<xctx->texts;i++)
|
|
|
|
|
{
|
|
|
|
|
textlayer = xctx->text[i].layer;
|
2022-03-09 00:29:16 +01:00
|
|
|
if(!show_hidden_texts && (xctx->text[i].flags & HIDE_TEXT)) continue;
|
2021-06-13 23:55:17 +02:00
|
|
|
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
|
|
|
|
|
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
|
|
|
|
|
my_snprintf(ps_font_name, S(ps_font_name), "Helvetica");
|
|
|
|
|
textfont = xctx->text[i].font;
|
|
|
|
|
if( (textfont && textfont[0])) {
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), textfont);
|
|
|
|
|
my_snprintf(ps_font_name, S(ps_font_name), textfont);
|
|
|
|
|
}
|
|
|
|
|
if( xctx->text[i].flags & TEXT_BOLD) {
|
|
|
|
|
if( (xctx->text[i].flags & TEXT_ITALIC) || (xctx->text[i].flags & TEXT_OBLIQUE) ) {
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-BoldOblique", ps_font_name);
|
|
|
|
|
} else {
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( xctx->text[i].flags & TEXT_ITALIC)
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
|
|
|
|
else if( xctx->text[i].flags & TEXT_OBLIQUE)
|
|
|
|
|
my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name);
|
|
|
|
|
|
|
|
|
|
if(text_ps) {
|
2022-02-22 12:09:04 +01:00
|
|
|
ps_draw_string(textlayer, xctx->text[i].txt_ptr,
|
2021-06-13 23:55:17 +02:00
|
|
|
xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
|
|
|
|
|
xctx->text[i].x0,xctx->text[i].y0,
|
|
|
|
|
xctx->text[i].xscale, xctx->text[i].yscale);
|
2021-01-28 23:09:37 +01:00
|
|
|
} else {
|
2022-02-22 12:09:04 +01:00
|
|
|
old_ps_draw_string(textlayer, xctx->text[i].txt_ptr,
|
2021-06-13 23:55:17 +02:00
|
|
|
xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
|
|
|
|
|
xctx->text[i].x0,xctx->text[i].y0,
|
|
|
|
|
xctx->text[i].xscale, xctx->text[i].yscale);
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-13 23:55:17 +02:00
|
|
|
for(c=0;c<cadlayers;c++)
|
2021-01-28 23:09:37 +01:00
|
|
|
{
|
2021-06-13 23:55:17 +02:00
|
|
|
set_ps_colors(c);
|
|
|
|
|
for(i=0;i<xctx->lines[c];i++)
|
|
|
|
|
ps_drawline(c, xctx->line[c][i].x1, xctx->line[c][i].y1,
|
|
|
|
|
xctx->line[c][i].x2, xctx->line[c][i].y2, xctx->line[c][i].dash);
|
|
|
|
|
for(i=0;i<xctx->rects[c];i++)
|
|
|
|
|
{
|
2021-12-30 17:15:50 +01:00
|
|
|
if(c != GRIDLAYER || !(xctx->rect[c][i].flags & 1) ) {
|
|
|
|
|
ps_filledrect(c, xctx->rect[c][i].x1, xctx->rect[c][i].y1,
|
|
|
|
|
xctx->rect[c][i].x2, xctx->rect[c][i].y2, xctx->rect[c][i].dash);
|
|
|
|
|
}
|
2021-06-13 23:55:17 +02:00
|
|
|
}
|
|
|
|
|
for(i=0;i<xctx->arcs[c];i++)
|
|
|
|
|
{
|
|
|
|
|
ps_drawarc(c, xctx->arc[c][i].fill, xctx->arc[c][i].x, xctx->arc[c][i].y,
|
|
|
|
|
xctx->arc[c][i].r, xctx->arc[c][i].a, xctx->arc[c][i].b, xctx->arc[c][i].dash);
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<xctx->polygons[c];i++) {
|
|
|
|
|
ps_drawpolygon(c, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points,
|
|
|
|
|
xctx->poly[c][i].fill, xctx->poly[c][i].dash);
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<xctx->instances;i++)
|
2021-12-30 19:06:22 +01:00
|
|
|
ps_draw_symbol(i,c,what,0,0,0.0,0.0);
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
2021-06-13 23:55:17 +02:00
|
|
|
set_ps_colors(WIRELAYER);
|
|
|
|
|
for(i=0;i<xctx->wires;i++)
|
2021-01-28 23:09:37 +01:00
|
|
|
{
|
2021-06-13 23:55:17 +02:00
|
|
|
ps_drawline(WIRELAYER, xctx->wire[i].x1,xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0);
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
2021-06-13 23:55:17 +02:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
double x1, y1, x2, y2;
|
2021-12-28 01:33:01 +01:00
|
|
|
Wireentry *wireptr;
|
2021-06-13 23:55:17 +02:00
|
|
|
int i;
|
2021-12-28 01:33:01 +01:00
|
|
|
Iterator_ctx ctx;
|
2021-06-13 23:55:17 +02:00
|
|
|
update_conn_cues(0, 0);
|
|
|
|
|
/* draw connecting dots */
|
|
|
|
|
x1 = X_TO_XSCHEM(xctx->areax1);
|
|
|
|
|
y1 = Y_TO_XSCHEM(xctx->areay1);
|
|
|
|
|
x2 = X_TO_XSCHEM(xctx->areax2);
|
|
|
|
|
y2 = Y_TO_XSCHEM(xctx->areay2);
|
|
|
|
|
for(init_wire_iterator(&ctx, x1, y1, x2, y2); ( wireptr = wire_iterator_next(&ctx) ) ;) {
|
|
|
|
|
i = wireptr->n;
|
2021-10-26 00:04:13 +02:00
|
|
|
if( xctx->wire[i].end1 >1 ) {
|
2021-06-13 23:55:17 +02:00
|
|
|
ps_drawarc(WIRELAYER, 1, xctx->wire[i].x1, xctx->wire[i].y1, cadhalfdotsize, 0, 360, 0);
|
|
|
|
|
}
|
2021-10-26 00:04:13 +02:00
|
|
|
if( xctx->wire[i].end2 >1 ) {
|
2021-06-13 23:55:17 +02:00
|
|
|
ps_drawarc(WIRELAYER, 1, xctx->wire[i].x2, xctx->wire[i].y2, cadhalfdotsize, 0, 360, 0);
|
|
|
|
|
}
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-07-14 01:43:29 +02:00
|
|
|
dbg(1, "ps_draw(): INT_WIDTH(lw)=%d plotfile=%s\n",INT_WIDTH(xctx->lw), xctx->plotfile);
|
2021-06-13 23:55:17 +02:00
|
|
|
fprintf(fd, "showpage\n\n");
|
|
|
|
|
}
|
|
|
|
|
if(what & 4) { /* trailer */
|
|
|
|
|
fprintf(fd, "%%%%trailer\n");
|
|
|
|
|
fprintf(fd, "%%%%Pages: %d\n", numpages);
|
|
|
|
|
fprintf(fd, "%%%%EOF\n");
|
|
|
|
|
fclose(fd);
|
2021-01-28 23:09:37 +01:00
|
|
|
}
|
2021-11-10 13:43:08 +01:00
|
|
|
tclsetboolvar("draw_grid", old_grid);
|
2021-01-28 23:09:37 +01:00
|
|
|
my_free(879, &ps_colors);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-13 23:55:17 +02:00
|
|
|
int ps_draw(int what)
|
2020-08-08 15:47:34 +02:00
|
|
|
{
|
2020-12-16 18:30:33 +01:00
|
|
|
char tmp[2*PATH_MAX+40];
|
2020-12-27 22:59:15 +01:00
|
|
|
static char lastdir[PATH_MAX] = "";
|
2021-01-28 23:09:37 +01:00
|
|
|
const char *r;
|
2021-06-13 23:55:17 +02:00
|
|
|
static char *psfile;
|
|
|
|
|
|
|
|
|
|
if(what & 1) { /* prolog */
|
|
|
|
|
if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir));
|
2021-12-05 15:31:26 +01:00
|
|
|
if(has_x && !xctx->plotfile[0]) {
|
2021-12-05 12:39:05 +01:00
|
|
|
tclvareval("tk_getSaveFile -title {Select destination file} -initialfile {",
|
2021-12-03 19:37:59 +01:00
|
|
|
get_cell(xctx->sch[xctx->currsch], 0) , ".pdf} -initialdir {", lastdir, "}", NULL);
|
2021-06-13 23:55:17 +02:00
|
|
|
r = tclresult();
|
|
|
|
|
if(r[0]) {
|
2021-07-14 01:43:29 +02:00
|
|
|
my_strncpy(xctx->plotfile, r, S(xctx->plotfile));
|
2021-12-05 12:39:05 +01:00
|
|
|
tclvareval("file dirname {", xctx->plotfile, "}", NULL);
|
2021-06-13 23:55:17 +02:00
|
|
|
my_strncpy(lastdir, tclresult(), S(lastdir));
|
|
|
|
|
}
|
|
|
|
|
else return 0;
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-13 23:55:17 +02:00
|
|
|
create_ps(&psfile, what);
|
|
|
|
|
if(what & 4) { /* trailer */
|
2021-07-14 01:43:29 +02:00
|
|
|
if(xctx->plotfile[0]) {
|
|
|
|
|
my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} {%s}", psfile, xctx->plotfile);
|
2021-06-13 23:55:17 +02:00
|
|
|
} else {
|
|
|
|
|
my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} plot.pdf", psfile);
|
|
|
|
|
}
|
2021-07-14 01:43:29 +02:00
|
|
|
my_strncpy(xctx->plotfile,"", S(xctx->plotfile));
|
2021-06-13 23:55:17 +02:00
|
|
|
tcleval( tmp);
|
|
|
|
|
Tcl_SetResult(interp,"",TCL_STATIC);
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
2021-06-13 23:55:17 +02:00
|
|
|
return 1;
|
2020-08-08 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
|