1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>6. Output Files</TITLE>
<META NAME="description" CONTENT="6. Output Files">
<META NAME="keywords" CONTENT="TechDoc">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="TechDoc.css">
<LINK REL="next" HREF="developersguidenode8.html">
<LINK REL="previous" HREF="developersguidenode6.html">
<LINK REL="up" HREF="TechDoc.html">
<LINK REL="next" HREF="developersguidenode8.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html343"
HREF="developersguidenode8.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html340"
HREF="TechDoc.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html334"
HREF="developersguidenode6.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
<A NAME="tex2html342"
HREF="developersguidenode1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html344"
HREF="developersguidenode8.html">7. Compiling and Porting</A>
<B> Up:</B> <A NAME="tex2html341"
HREF="TechDoc.html">Toolkit for Conceptual Modeling</A>
<B> Previous:</B> <A NAME="tex2html335"
HREF="developersguidenode6.html">5. TCM Class Hierarchy</A>
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><strong>Subsections</strong></A>
<UL>
<LI><A NAME="tex2html345"
HREF="developersguidenode7.html#SECTION00710000000000000000">6.1 PostScript output</A>
<UL>
<LI><A NAME="tex2html346"
HREF="developersguidenode7.html#SECTION00711000000000000000">6.1.1 Plain PostScript</A>
<UL>
<LI><A NAME="tex2html347"
HREF="developersguidenode7.html#SECTION00711100000000000000">6.1.1.1 Header</A>
<LI><A NAME="tex2html348"
HREF="developersguidenode7.html#SECTION00711200000000000000">6.1.1.2 Pages</A>
</UL>
<LI><A NAME="tex2html349"
HREF="developersguidenode7.html#SECTION00712000000000000000">6.1.2 Encapsulated PostScript</A>
<LI><A NAME="tex2html350"
HREF="developersguidenode7.html#SECTION00713000000000000000">6.1.3 PSGrafport</A>
</UL>
<LI><A NAME="tex2html351"
HREF="developersguidenode7.html#SECTION00720000000000000000">6.2 TCM file format</A>
</UL>
<!--End of Table of Child-Links-->
<HR>
<H1><A NAME="SECTION00700000000000000000">
6. Output Files</A>
</H1>
<P>
<H1><A NAME="SECTION00710000000000000000">
6.1 PostScript output</A>
</H1>
<P>
This is a short description of the structure of the PostScript files that is
generated by the current version of TCM. This is not a lesson in programming
PostScript nor a detailed explanation of each possible PostScript expression
that could be generated by TCM. Instead, you are referred to the official
documentation like [<A
HREF="developersguidenode10.html#PostScriptTutorial">6</A>,<A
HREF="developersguidenode10.html#PostScriptRefMan">5</A>].
<P>
<H2><A NAME="SECTION00711000000000000000">
6.1.1 Plain PostScript</A>
</H2>
<P>
The PostScript output files for a TCM document have the following structure.
<P>
<H3><A NAME="SECTION00711100000000000000">
6.1.1.1 Header</A>
</H3>
The first part of the plain PostScript output consists of the following header:
<PRE>
%!PS-Adobe-1.0
%%Title: <name of document>
%%Creator: <tool+version>
%%CreationDate: <current date>
%%For: <login>
%%DocumentFonts: (atend)
%%Pages: (atend)
%%BoundingBox: (atend)
%%EndComments
/ISOLatin1Encoding[
...
] def
EndProlog
</PRE>
<P>
Lines that start with <code>%%</code> or <code>%!</code> are PostScript structuring commands.
The generated files conform to the PS-Adobe 1.0 file structuring conventions.
<TT>(atend)</TT> means that the value is determined in the rest of the program.
The ISOLatin1Encoding definition (whose body is not printed here
to save space) is necessary to make sure that the entire
ISO Latin-1 character set can be displayed.
<P>
<H3><A NAME="SECTION00711200000000000000">
6.1.1.2 Pages</A>
</H3>
<P>
Each page starts with a page setup followed by the page contents.
Example page setup:
<PRE>
%%Page: 1 2
12.8976 9.49604 translate
0.867470 0.867470 scale
0 948.736111 translate
1 -1 scale
1.000000 1.000000 scale
0.750000 setlinewidth
%%BeginPageSetup
gsave
-0.000000 -0.000000 translate
%%EndPageSetup
</PRE>The first line gives the current page label (1 in this example) and the total number of
pages (2). The next translate line moves the coordinate system to the drawable paper area.
Then the scale line scales X coordinates to PostScript points. The other translate and
scale lines change from X to the PostScript coordinate system (in portrait mode and with
scale factor 1.0). When the page would be written in LandScape and
with scale factor 1.5, those three lines would be:
<PRE>
90 rotate
1 -1 scale
1.5 1.5 scale
</PRE>
<P>
The setlinewidth line sets the width of the line a bit smaller than the
default, which is a bit too fat in comparison with the Xlib lines.
The lines between BeginPageSetup and EndPageSetup move the page (like it is
visible in the X window) that is going be written to the position of the
first page (in this case the translation is zero because the example
shows the first page).
<P>
After that, the lines of the current page are written
in rather ordinary PostScript prose (with <TT>newpath</TT>,
<TT>moveto</TT>, <TT>rlineto</TT>, <TT>closepath</TT> and <TT>stroke</TT> commands).
<P>
Strings are drawn in the following fashion: First the font is loaded when
that is not already done, e.g.:
<PRE>
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding ISOLatin1Encoding def
currentdict
end
/Helvetica-ISOLatin1Encoding exch definefont pop
</PRE>This loads the font family (in our case Helvetica ISO Latin1).
Then the string is positioned and drawn, e.g:
<PRE>
/Helvetica-ISOLatin1Encoding findfont
10 scalefont setfont
(foobar) stringwidth
pop 2 div neg
120 add 144 moveto
gsave
1 -1 scale
(foobar) show
grestore
</PRE>The above lines draw the string foobar in the just loaded font, centered
at position (120,144) with point size 10.
Each PostScript output page ends with:
<PRE>
grestore
showpage
%%PageTrailer
</PRE>
<P>
End finally the PostScript output ends with:
<PRE>
%%Trailer
%%EOF
</PRE>
<P>
<H2><A NAME="SECTION00712000000000000000">
6.1.2 Encapsulated PostScript</A>
</H2>
<P>
The first part of the EPS output consists of the following header.
<PRE>
%!PS-Adobe-3.0 EPSF-3.0
%%Title: <document name>
%%Creator: <tool+version>
%%CreationDate: <current date>
%%For: <login>
%%DocumentFonts: (atend)
%%Pages: 0
%%BoundingBox: llx lly urx ury
%%EndComments
/ISOLatin1Encoding[
] def
</PRE>The four numbers (llx lly urx ury) are the top left and bottom right coordinates
of the bounding box, i.e. the square area occupied by the drawing.
After the header the font is loaded, in the same way as in plain PostScript.
EPS does not have separate pages and hence does not need page setup lines.
The following lines are generated to change from X coordinates to EPS coordinates:
<P>
<PRE>
0.867470 0.867470 scale
0 85 2 mul 117 add 0.867470 div translate
1 -1 scale
%%EndProlog
</PRE>
<P>
0.867470 is the (fixed) factor of X coordinates/PS coordinates.
As a remark, I forgot the exact meaning of the second line, but is works
in any case.
After that the entire drawing is written as PostScript, the same way as it is done
with plain PostScript (but without page setups). The output ends with the same
two lines as plain PostScript.
<P>
<H2><A NAME="SECTION00713000000000000000">
6.1.3 PSGrafport</A>
</H2>
<P>
All PostScript generation is hidden in the <A NAME="tex2html165"
HREF="../sourcecode/PSGrafport.html"><TT>PSGrafport</TT></A>
class. It contains
the functions that write headers and page setup lines to the PostScript output file and
for each <A NAME="tex2html166"
HREF="../sourcecode/Grafport.html"><TT>Grafport</TT></A>
function
it contains a counterpart that writes a piece of
PostScript. For example <TT>Grafport</TT> has a
virtual function <TT>DrawRectangle(int x, int y, int width, int height)</TT> that draws
a rectangle to the Grafport. <TT>XGrafport</TT> implements this function as:
<PRE>
XDrawRectangle(display, window, xorGC, x, y, wd, ht);
</PRE>
I.e. it draws a rectangle on an X window. Whereas <TT>PSGrafport</TT> implements this
function with:
<PRE>
fprintf(fd, "newpath\n");
fprintf(fd, "%d %d moveto\n", x, y);
fprintf(fd, "%d 0 rlineto\n", wd);
fprintf(fd, "0 %d rlineto\n", ht);
fprintf(fd, "-%d 0 rlineto\n", wd);
fprintf(fd, "closepath\n");
fprintf(fd, "stroke\n");
</PRE>
I.e. it writes a PostScript fragment to the file that would result into
the printing of a rectangle.
<P>
To add another output format to TCM, you probably need only to make
another specialization of Grafport and implement each Grafport function in that
class to write a piece of output in that format.
For instance, for writing the Fig output (Produced by Xfig) we implemented
a <A NAME="tex2html167"
HREF="../sourcecode/FigGrafport.html">FigGrafport</A>
that writes
for every Draw-functions a part of Fig-format to file.
<P>
<H1><A NAME="SECTION00720000000000000000">
6.2 TCM file format</A>
</H1>
<P>
The TCM file format of the current version is described in full detail
in appendix B of the <A NAME="tex2html168"
HREF="../usersguide/index.html">User's guide</A>.
<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html343"
HREF="developersguidenode8.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html340"
HREF="TechDoc.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html334"
HREF="developersguidenode6.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
<A NAME="tex2html342"
HREF="developersguidenode1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html344"
HREF="developersguidenode8.html">7. Compiling and Porting</A>
<B> Up:</B> <A NAME="tex2html341"
HREF="TechDoc.html">Toolkit for Conceptual Modeling</A>
<B> Previous:</B> <A NAME="tex2html335"
HREF="developersguidenode6.html">5. TCM Class Hierarchy</A>
<!--End of Navigation Panel-->
<ADDRESS>
<I>Henk van de Zandschulp</I>
<BR><I>2003-01-07</I>
</ADDRESS>
</BODY>
</HTML>
|