1 /**************************************************************************** 2 Copyright (C) 1987-2015 by Jeffery P. Hansen 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 ****************************************************************************/ 18 #ifndef __print_h 19 #define __print_h 20 21 #define MODMAX 2048 /* Maximum number of modules in circuit */ 22 23 #define MODPGMAX 4 /* Maximum # of modules on a page */ 24 25 #define INCH(s) (72.0*(s)) 26 #define MM(s) (2.8346*(s)) 27 #define CM(s) (28.346*(s)) 28 29 #define PT2INCH(s) ((s)*0.01389) 30 #define PT2MM(s) ((s)*0.35278) 31 #define PT2CM(s) ((s)*0.035278) 32 33 #define YCONV(L,y) ((L)->l_ymax-(y)+(L)->l_ymin) 34 35 #define EPSF_MINX 10 36 #define EPSF_MINY 10 37 38 /* 39 Page metrics (in points unless otherwise state) 40 */ 41 #define PAGE_LMARGIN 25 /* Distance between edge of page and left edge of drawing */ 42 #define PAGE_RMARGIN 25 /* Distance between edge of page and right edge of drawing */ 43 #define PAGE_TMARGIN 25 /* Distance between edge of page and top edge of drawing */ 44 #define PAGE_BMARGIN 25 /* Distance between edge of page and bottom edge of drawing */ 45 #define PAGE_LBLOCK 60 /* Size of label block */ 46 #define PAGE_MODMARGIN 10 /* Margin around module */ 47 #define PAGE_OVERLAP 20 /* Portion of ciruit which overlaps on edges */ 48 49 /* 50 Font encoding vector ids 51 */ 52 #define PE_STANDARD 0 /* Standard encoding */ 53 #define PE_LATIN1 1 /* Latin1 encoding */ 54 55 56 /* 57 Page types 58 */ 59 #define PT_MODULE 0 /* Page with a single (or portion of a) module */ 60 #define PT_MOD4 1 /* Page with 4 modules */ 61 #define PT_INDEX 2 /* Index page */ 62 #define PT_GRAPH 3 /* Module hierarchy graph page */ 63 #define PT_TRACE 4 /* Scope trace page */ 64 65 /* 66 Paging styles 67 */ 68 #define PS_FIT 0 69 #define PS_PARTITION 1 70 71 /* 72 Layout for index pages 73 */ 74 #define PIDX_FONT 12 /* Font size for index */ 75 #define PIDX_LMARGIN 20 /* Space from left edge to text */ 76 #define PIDX_TMARGIN 20 /* Space from top edge to text baseline */ 77 #define PIDX_HDRSEP 20 /* Space from header baseline to first entry */ 78 #define PIDX_HDRLINEPOS 5 /* Position for header underline */ 79 #define PIDX_LINELEN 140 /* Length of header underline */ 80 #define PIDX_LINESEP 14 /* Space between lines */ 81 #define PIDX_PGCOLSEP 100 /* Space from module name to page number column */ 82 #define PIDX_COLSEP 150 /* Space to next column */ 83 84 /* 85 Trace metrics 86 */ 87 88 #define PTRC_TXTMARGIN 5 /* Distance from left edge to trace label */ 89 #define PTRC_LMARGIN 100 /* Distance from left edge to trace */ 90 #define PTRC_RMARGIN 10 /* Distance from right edge to trace */ 91 #define PTRC_TRHEIGHT 22 /* Height of a trace */ 92 #define PTRC_TRLOW 5 /* Position of low trace line */ 93 #define PTRC_TRMID 11 /* Position of middle trace line */ 94 #define PTRC_TRHIGH 17 /* Position of high trace line */ 95 #define PTRC_TMARGIN 10 /* Margin on top of page */ 96 #define PTRC_BMARGIN 10 /* Margin on bottom of page */ 97 #define PTRC_FONTSIZE 10 /* Size of labels */ 98 #define PTRC_SCBXHEIGHT 25 /* Height of the trace box */ 99 #define PTRC_SCHEIGHT 30 /* Height of the trace scale */ 100 #define PTRC_SCTICK 5 /* Length of scale tick */ 101 #define PTRC_SCLABPOS 18 /* Position of scale numbers */ 102 #define PTRC_HEXPOS 3 /* Offset for hex values in traces */ 103 104 typedef struct { 105 const char *po_title; 106 const char *po_cmd; 107 const char *po_file; 108 const char *po_paper; 109 const char *po_orient; 110 const char *po_style; 111 const char *po_select; 112 const char *po_modlist; 113 const char *po_epsf; 114 const char *po_index; 115 const char *po_graph; 116 const char *po_4up; 117 const char *po_isDuplex; 118 const char *po_start; 119 const char *po_end; 120 const char *po_scaleLength; 121 const char *po_incLib; 122 } GPrintOpt; 123 124 void GPrintOpt_init(GPrintOpt*); 125 void GPrintOpt_clDefault(GPrintOpt*); 126 void GPrintOpt_print(GPrintOpt*); 127 void GPrintOpt_tracePrint(GPrintOpt*); 128 129 typedef struct { 130 const char *ps_size; /* Name of size */ 131 const char *ps_tray; /* Name of tray */ 132 double ps_width; /* Width in points */ 133 double ps_height; /* Height in points */ 134 } PaperSize; 135 136 /* 137 A GModLayout specifies layout information for a module. Normally there is 138 one GModLayout per page, but if the 4-per-page option is enabled, there may 139 be up to 4 GModLayout per page. 140 */ 141 struct modlayout { 142 /* 143 Information about the module 144 */ 145 GModuleDef *l_mod; /* The module in this layout */ 146 int l_isSmall; /* Is this module 4-up-able */ 147 int l_xmin, l_xmax; /* The minimum and maximum X values (in pixels) */ 148 int l_ymin, l_ymax; /* The minimum and maximum Y values (in pixels) */ 149 150 /* 151 Where on the page is the circuit 152 */ 153 int l_xbase; /* The base x coordinate of the layout (in points) */ 154 int l_ybase; /* The base y coordinate of the layout (in points) */ 155 int l_width; /* The width of the layout (in points) */ 156 int l_height; /* The height of the layout (in points) */ 157 158 /* 159 Information about the partition if partitioned. 160 */ 161 int l_numRows; /* Total number of row partitions */ 162 int l_numCols; /* Total number of column partitions */ 163 int l_r,l_c; /* Position of this partition */ 164 int l_x,l_y; /* Base coordinates */ 165 int l_pWidth,l_pHeight; /* Width an height of this partition */ 166 167 }; 168 169 typedef struct { 170 int pg_num; /* Page number of this page */ 171 int pg_type; /* Type of page */ 172 int pg_nmod; /* Number of modules on this page */ 173 174 simtime_t pg_traceStart; /* Start time for traces on this page */ 175 simtime_t pg_traceEnd; /* End time for traces on this page */ 176 int pg_traceNum; /* Index of first trace on this page */ 177 178 GModLayout *pg_mods[MODPGMAX]; /* Module and layout data */ 179 } GPage; 180 181 typedef struct trace_info { 182 simtime_t ti_start; /* Starting epoch of trace */ 183 simtime_t ti_end; /* Ending epoch of trace */ 184 simtime_t ti_istart; /* Starting epoch of trace (rounded to interval) */ 185 simtime_t ti_iend; /* Ending epoch of trace (rounded to interval) */ 186 simtime_t ti_simEnd; /* Last simulated epoch */ 187 188 simtime_t ti_scaleLength; /* # of time units per line */ 189 190 simtime_t ti_interval; /* The interval for tick marks */ 191 simtime_t ti_epochsPerPage; /* Epochs per page */ 192 double ti_pointsPerEpoch; /* Points per epoch */ 193 194 int ti_tracesPerPage; /* Number of trace sets per page */ 195 int ti_pagesPerTrace; /* Number of pages per trace set */ 196 } GTraceInfo; 197 198 struct GPrint_str { 199 GPrintOpt p_opts; /* Raw printer options */ 200 int p_isFile; /* Output is to a file */ 201 FILE *p_f; /* File to print to */ 202 int p_orient; /* 0=portait, 1=landscape */ 203 int p_style; /* 0=scale, 1=partition */ 204 int p_isDuplex; /* Do double-sided printing */ 205 206 PaperSize *p_size; /* Page size */ 207 208 double p_width; /* Width of page */ 209 double p_height; /* Height of page */ 210 int p_isepsf; /* Output as EPSF document */ 211 212 double p_uWidth; /* Usable width */ 213 double p_uHeight; /* Usable height */ 214 215 GTraceInfo p_trace; /* Global data for traces */ 216 217 int p_numMods; /* Number of modules to print */ 218 GModLayout **p_mods; /* List of module layouts to print */ 219 220 int p_numPages; /* Number of pages */ 221 GPage **p_pages; /* List of pages to print */ 222 223 PHash p_genSymbols; /* Set of symbols that have been generated. */ 224 }; 225 226 GPage *new_GPage(int tp,int pn); 227 GPrint *new_GPrint(GPrintOpt *PO); 228 void GPrint_outputPreamble(GPrint *P,int do_gates); 229 void GPrint_outputPages(GPrint *P); 230 void GPrint_outputTrailer(GPrint *P); 231 void GPrint_printTracePage(GPrint *P,GPage *PG); 232 void delete_GPrint(GPrint *P); 233 234 extern PaperSize paperSizes[]; 235 236 void PSSetFont(GPrint *P,HtmlFont *F); 237 void PSDrawText(GPrint *P,HtmlFont *F,int x,int y,const char *text,int just); 238 int PSStringWidth(HtmlFont *F,const char *s,int len); /* Width of a postscript string in points. */ 239 240 241 242 243 #endif 244