summaryrefslogtreecommitdiff
path: root/html/en/drv/cgm.html
blob: 17ca1412de23b001c6c467c494d5f5e27f87b1f0 (plain)
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
<!doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>CD_CGM</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<h2>CD_CGM - <em>Computer Graphics Metafile Driver </em>(cdcgm.h)</h2>

  <p>This driver allows generating a Computer Graphics Metafile, which is an ANSI standard for the persistent storage of 
  graphics primitives. The file usually has an extension .CGM.</p>

<h3>Use</h3>

  <p>The file file is created by means of a call to the function <font face="Courier">
  <a href="../func/init.html#cdCreateCanvas"><strong>cdCreateCanvas</strong></a>(CD_CGM, 
  Data)</font>, which <b>opens</b> the file and writes its header. Then, other functions in the CD library can be called 
  as usual. The <font face="Courier">Data</font> parameter string has the following format:</p>
  
    <pre><em>&quot;filename [widthxheight] [resolution] [-t] -p[precision]&quot; or in C style &quot;<strong><tt>%s %gx%g %g %s</tt></strong>&quot;</em></pre>
  
  <p>Only the parameter <font face="Courier">filename</font> is required. The filename must be inside double quotes (&quot;) 
  if it has spaces.<font face="Courier"> Width</font> and <font face="Courier">height</font> are provided in millimeters 
  (note the lowercase &quot;x&quot; between them), and their default value in pixels is <font face="Courier">INT_MAX</font> for 
  both dimensions. When the canvas' size is not specified, the VDC Extension saved to the file is the image's bounding 
  rectangle. The resolution is the number of pixels per millimeter; its default value is &quot;3.78 pixels/mm&quot; (96 DPI).
  <font face="Courier">Width</font>, <font face="Courier">height</font> and <font face="Courier">resolution</font> are 
  real values. <font face="Courier">Width</font>, <font face="Courier">height</font> and <font face="Courier">resolution</font> 
  are used only by <strong><font face="Courier">cdGetCanvasSize</font> </strong>and in pixel-millimeter conversion. 
  Parameter <font face="Courier">-t</font> modifies the codification. Parameter <font face="Courier">-p</font> specifies 
  the precision of integers, which can be 16 (default) or 32.</p>
  <p>Any amount of such canvases may exist simultaneously. It is important to note that a call to function
  <a href="../func/init.html#cdKillCanvas"><font face="Courier"><strong>
  cdKillCanvas</strong></font></a> is required to <b>close</b> the file properly.</p>
  <p><strong>Coding -</strong> The CGM format supports binary and text coding. If you are not sure what to do, use 
  binary coding, which is the default. Should you prefer text coding, add a &quot;<font face="Courier">-t</font>&quot; string to 
  the <font face="Courier">Data</font> parameter.</p>
  <p><strong>Precision of Coordinates -</strong> The primitives can use coordinates in real numbers. However, for 
  compatibility reasons, we use coordinates in integers.</p>

<h3>Behavior of Functions</h3>
<h4>Control&nbsp; </h4>
<ul>
  <li><a href="../func/control.html#cdClear"><font face="Courier"><strong>Clear</strong></font></a>: 
  does nothing.</li>
  <li><a href="../func/control.html#cdFlush"><font face="Courier"><strong>Flush</strong></font></a>: 
  creates a new image, preserving the previous one. The CGM format supports multiple images in a file.</li>
  <li><a href="../func/other.html#cdPlay"><font face="Courier"><strong>Play</strong></font></a>: 
  works with files created with text or binary coding. There are several callbacks for this driver. If one of the 
  callbacks returns a value different from zero, <font face="Courier">cdPlay</font>'s processing is interrupted. The 
  driver implements the callback <tt><strong><font face="Courier">CD_SIZECB</font> </strong></tt>and other callbacks 
  associated to CGM:<br>
  <tt><font face="Courier"><strong>CD_COUNTERCB</strong></font> - int(*cdcgmcountercb)(cdContext *driver, double 
  percent) - </tt>Executed for each header of CGM commands; returns the percentage (0-100%) of headers read.<br>
  <font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_SCLMDECB</span></strong></code></font><tt> - int(*cdcgmsclmdecb)(cdContext 
  *driver, short scl_mde, short *drw_mode, double *factor)</tt> <font face="Courier">-</font> Executed for the command 
  CGM SCALE MODE. Returns the current CGM scale mode and allows the callback to modify the scale mode used by the
  <font face="Courier">cdPlay</font> function <font face="Courier">(ABSTRACT=0, METRIC=1)</font>. Should you choose the 
  METRIC or ABSTRACT scale mode but the original scale mode is METRIC, you must provide the conversion factor in mm per 
  pixel.<br>
  <font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_VDCEXTCB</span></strong></code></font><tt> - int(*cdcgmvdcextcb)(cdContext 
  *driver, short type, void *xmn, void *ymn, void *xmx, void *ymx)</tt> <font face="Courier">-</font> Executed for the 
  CGM command CGM VDC EXTENT, returns the VDC SPACE. <br>
  <font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_BEGPICTCB</span></strong></code></font><tt> - int(*cdcgmbegpictcb)(cdContext 
  *driver, char *pict)</tt> <font face="Courier">-</font> Executed for the command BEGIN PICTURE, returns the string 
  that describes the image.<br>
  <font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_BEGPICTBCB</span></strong></code></font><tt> - int(*cdcgmbegpictbcb)(cdContext 
  *driver)</tt> <font face="Courier">-</font> Executed for the command BEGIN PICTURE BODY.<br>
  <font face="Times New Roman"><code><strong><span style="font-family: Courier">CD_CGMBEGMTFCB</span></strong></code></font> - <font face="Times New Roman"><code>
  int (*cdcgmbegmtfcb)(cdContext *driver, int *xmin, int *ymin, int *xmax, int *ymax)</code></font> - Executed for the 
  command BEGIN METAFILE, provides the drawing limits of the image in the file.</li>
</ul>
<h4>Coordinate System and Clipping</h4>
<ul>
  <li><a href="../func/coordinates.html#cdUpdateYAxis"><font face="Courier">
  <strong>UpdateYAxis</strong></font></a>: does nothing. The axis orientation is the same as the CD library.</li>
  <li><b>Complex Regions</b>: not supported.</li>
  <li><strong>Transformation Matrix</strong>: not supported.</li>
</ul>
<h4>Primitives</h4>
<ul>
  <li><a href="../func/lines.html#cdBegin"><font face="Courier"><strong>Begin</strong></font></a>: 
  if parameter <strong><tt>CD_CLIP</tt></strong> or <strong><tt>CD_BEZIER</tt></strong> are specified, does nothing.</li>
  <li><font face="Courier"><strong><a href="../func/marks.html#cdPixel">Pixel</a></strong></font>: 
  does not exist in CGM, is simulated using a mark with size 1.</li>
  <li><strong><font face="Courier"><a href="../func/filled.html#cdChord">Chord</a></font></strong>: 
  does nothing.</li>
  <li>Floating point primitives are supported.</li>
</ul>
<h4>Attributes </h4>
<ul>
  <li><a href="../func/attributes.html#cdWriteMode"><font face="Courier">
  <strong>
  WriteMode</strong></font></a>: does nothing, returns <font face="Courier">CD_REPLACE</font>.</li>
  <li><a href="../func/text.html#cdFontDim"><font face="Courier"><strong>FontDim</strong></font></a>: 
  is simulated.</li>
  <li><a href="../func/filled.html#cdFillMode"><font face="Courier"><strong>
  FillMode</strong></font></a>: does nothing.</li>
  <li><a href="../func/filled.html#cdLineCap"><font face="Courier"><strong>
  LineCap</strong></font></a>: does nothing.</li>
  <li><a href="../func/filled.html#cdLineJoin"><font face="Courier"><strong>
  LineJoin</strong></font></a>: does nothing.</li>
  <li><a href="../func/text.html#cdTextSize"><font face="Courier"><strong>
  TextSize</strong></font></a>: is simulated.</li>
  <li><a href="../func/text.html#cdTextOrientation"><font face="Courier">
  <strong>
  TextOrientation</strong></font></a>: does nothing.</li>
  <li><a href="../func/text.html#cdFont"><font face="Courier"><strong>Font</strong></font></a>: 
  see the table bellow for the generated font names. No other fonts are 
  supported.</li>
</ul>
<div align="center">
  <center>
  <table border="1" cellpadding="5">
    <caption style="text-align: center"><font size="4">Font Mapping</font></caption>
    <tr>
      <th rowspan="2">CD Fonts</th>
      <th colspan="4">Generated Font Names</th>
    </tr>
    <tr>
      <th>CD_PLAIN</th>
      <th>CD_BOLD</th>
      <th>CD_ITALIC</th>
      <th>CD_BOLD|CD_ITALIC</th>
    </tr>
    <tr>
      <td>&quot;System&quot;</td>
      <td>&quot;SYSTEM&quot;</td>
      <td>&quot;SYSTEM_BOLD&quot;</td>
      <td>&quot;SYSTEM_ITALIC&quot;</td>
      <td>&quot;SYSTEM_BOLDITALIC&quot;</td>
    </tr>
    <tr>
      <td>&quot;Courier&quot;</td>
      <td>&quot;COURIER&quot; </td>
      <td>&quot;COURIER_BOLD&quot; </td>
      <td>&quot;COURIER_ITALIC&quot; </td>
      <td>&quot;COURIER_BOLDITALIC&quot;</td>
    </tr>
    <tr>
      <td>&quot;Times&quot;</td>
      <td>&quot;TIMES_ROMAN&quot; </td>
      <td>&quot;TIMES_ROMAN_BOLD&quot;</td>
      <td>&quot;TIMES_ROMAN_ITALIC&quot;</td>
      <td>&quot;TIMES_ROMAN_BOLDITALIC&quot; </td>
    </tr>
    <tr>
      <td>&quot;Helvetica&quot;</td>
      <td>&quot;HELVETICA&quot; </td>
      <td>&quot;HELVETICA_BOLD&quot;</td>
      <td>&quot;HELVETICA_ITALIC&quot;</td>
      <td>&quot;HELVETICA_BOLDITALIC&quot;</td>
    </tr>
  </table>
  </center>
</div>
<h4>Colors </h4>
<ul>
  <li><a href="../func/color.html#cdGetColorPlanes"><font face="Courier">
  <strong>
  GetColorPlanes</strong></font></a>: returns 24.</li>
  <li><a href="../func/color.html#cdPalette"><font face="Courier"><strong>Palette</strong></font></a>: 
  does nothing. </li>
</ul>
<h4>Client Images&nbsp; </h4>
<ul>
  <li><a href="../func/client.html#cdGetImageRGB"><font face="Courier"><strong>
  GetImageRGB</strong></font></a>: does nothing.</li>
  <li><a href="../func/client.html#cdPutImageRGBA"><font face="Courier"><strong>
  PutImageRGBA</strong></font></a>: alpha is ignored.</li>
</ul>
<h4>Server Images</h4>
<ul>
  <li>All functions do nothing.</li>
</ul>

</body>

</html>