plotter.h 112 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* This is "plotter.h", the public header file for the C++ Plotter class
  16. provided by GNU libplotter, a shared class library for 2-dimensional
  17. vector graphics.
  18. This file should be included by any code that uses the Plotter class.
  19. If the Plotter class was installed without X Window System support, be
  20. sure to do "#define X_DISPLAY_MISSING" before including this file.
  21. From the base Plotter class, the BitmapPlotter, MetaPlotter, TekPlotter,
  22. ReGISPlotter, HPGLPlotter, FigPlotter, CGMPlotter, PSPlotter, AIPlotter,
  23. SVGPlotter, GIFPlotter, PNMPlotter, PNGPlotter, and XDrawablePlotter
  24. classes are derived. The PNMPlotter and PNGPlotter classes are derived
  25. from the BitmapPlotter class, the PCLPlotter class is derived from the
  26. HPGLPlotter class, and the XPlotter class is derived from the
  27. XDrawablePlotter class. */
  28. /* If NOT_LIBPLOTTER is defined, this file magically becomes an internal
  29. header file used in GNU libplot, the C version of libplotter. libplot
  30. has its own public header file, called "plot.h". */
  31. /* Implementation note: In libplot, a Plotter is a typedef'd structure
  32. rather than a class instance. Because of the need to support both
  33. libplot and libplotter, i.e. C and C++, all data members of derived
  34. Plotter classes are declared in this file twice: once in the Plotter
  35. structure (for C), and once in each derived class declaration (for C++). */
  36. #ifndef _PLOTTER_H_
  37. #define _PLOTTER_H_ 1
  38. /***********************************************************************/
  39. /* Version of GNU libplot/libplotter which this header file accompanies.
  40. This information is included beginning with version 4.0.
  41. The PL_LIBPLOT_VER_STRING macro is compiled into the library, as
  42. `pl_libplot_ver'. The PL_LIBPLOT_VER macro is not compiled into it.
  43. Both are available to applications that include this header file. */
  44. #define PL_LIBPLOT_VER_STRING "4.4"
  45. #define PL_LIBPLOT_VER 404
  46. extern const char pl_libplot_ver[8]; /* need room for 99.99aa */
  47. /***********************************************************************/
  48. /* If we're supporting X, include X-related header files needed by the
  49. class definition. */
  50. #ifndef X_DISPLAY_MISSING
  51. #include <X11/Xlib.h>
  52. #include <X11/Intrinsic.h>
  53. #endif /* not X_DISPLAY_MISSING */
  54. /* Include stdio and iostream support if this is libplotter rather than
  55. libplot. */
  56. #ifndef NOT_LIBPLOTTER
  57. #include <cstdio>
  58. #include <iostream>
  59. using namespace std;
  60. #endif
  61. /* THE GLOBAL VARIABLES IN GNU LIBPLOTTER */
  62. /* There are two; both are user-settable error handlers. */
  63. #ifndef NOT_LIBPLOTTER
  64. extern int (*pl_libplotter_warning_handler) (const char *msg);
  65. extern int (*pl_libplotter_error_handler) (const char *msg);
  66. #endif
  67. /***********************************************************************/
  68. /* Structures for points. */
  69. typedef struct
  70. {
  71. double x, y;
  72. } plPoint;
  73. typedef struct
  74. {
  75. int x, y;
  76. } plIntPoint;
  77. /* Structures for paths, as painted by any Plotter. */
  78. /* Normally, a simple path is a sequence of contiguous line segments,
  79. circular arc segments, elliptic arc segments, quadratic Bezier segments,
  80. or cubic Bezier segments. All Plotters support line segments, but many
  81. Plotters don't support the other types of segment. Some Plotters also
  82. support (closed) simple paths that are single circles, ellipses, or
  83. "boxes" (rectangles aligned with the coordinate axes).
  84. A simple path that is a sequence of segments is represented internally
  85. as a list of plPathSegments. Each contains a single endpoint (x,y), and
  86. specifies how to get there (e.g., via a pen-up motion, which is used for
  87. the first point in a path, or via a line segment, or a curve defined by
  88. control points).
  89. A well-formed simple path of this `segment list' type has the form:
  90. { moveto { line | arc | ellarc | quad | cubic }* { closepath }? } */
  91. /* Allowed values for the path segment type field. */
  92. typedef enum
  93. {
  94. S_MOVETO, S_LINE, S_ARC, S_ELLARC, S_QUAD, S_CUBIC, S_CLOSEPATH
  95. } plPathSegmentType;
  96. /* Structure for a path segment. */
  97. typedef struct
  98. {
  99. plPathSegmentType type;
  100. plPoint p; /* endpoint of segment */
  101. plPoint pc; /* intermediate control point (if any) */
  102. plPoint pd; /* additional control point (S_CUBIC only) */
  103. } plPathSegment;
  104. /* Allowed values for the path type field in a plPath (see below). */
  105. typedef enum
  106. {
  107. PATH_SEGMENT_LIST, /* the default kind */
  108. PATH_CIRCLE, PATH_ELLIPSE, PATH_BOX /* supported by some Plotters */
  109. } plPathType;
  110. /* Structure for a simple path. The default kind of simple path is a list
  111. of segments. However, a simple path may also be a circle, ellipse, or
  112. box, which some Plotter support as primitive drawing elements, at least
  113. under some circumstances. Other Plotters automatically flatten these
  114. built-in primitives into segment lists. The advisory `primitive' flag
  115. is set to `true' to indicate that a segment list is in fact such a
  116. flattened object. */
  117. typedef struct
  118. {
  119. plPathType type; /* PATH_{SEGMENT_LIST,CIRCLE,ELLIPSE,BOX} */
  120. double llx, lly, urx, ury; /* bounding box */
  121. /* simple path of segment list type */
  122. plPathSegment *segments; /* list of path segments */
  123. int num_segments; /* number of segments in list */
  124. int segments_len; /* length of buffer for list storage (bytes) */
  125. bool primitive; /* advisory (see above; some Plotters use it)*/
  126. /* simple path of built-in primitive type (circle/ellipse/box) */
  127. plPoint pc; /* CIRCLE/ELLIPSE: center */
  128. double radius; /* CIRCLE: radius */
  129. double rx, ry; /* ELLIPSE: semi-axes */
  130. double angle; /* ELLIPSE: angle of first axis */
  131. plPoint p0, p1; /* BOX: opposite vertices */
  132. bool clockwise; /* CIRCLE/ELLIPSE/BOX: clockwise? */
  133. } plPath;
  134. /* An integer counterpart to plPathSegment, used by some Plotters during
  135. the mapping of segment-list paths to the device frame. This shouldn't
  136. be defined here, since it's so Plotter-specific. */
  137. typedef struct
  138. {
  139. plPathSegmentType type;
  140. plIntPoint p; /* endpoint of segment */
  141. plIntPoint pc; /* intermediate control point (if any) */
  142. plIntPoint pd; /* additional control point (S_CUBIC only) */
  143. double angle; /* subtended angle (for S_ARC, if used) */
  144. } plIntPathSegment;
  145. /* Values for the parameters `allowed_{arc|ellarc|quad|cubic}_scaling' of
  146. any Plotter. Those parameters specify which sorts of user frame ->
  147. device frame affine transformation are allowed, if an arc or Bezier that
  148. is part of a path is to be placed in the path buffer's segment list as a
  149. single segment, rather than approximated as a polyline.
  150. These are also the possible values for the parameters
  151. allowed_{circle|ellipse|box}_scaling' of any Plotter, which specify
  152. whether any circle/ellipse/box should be placed in the path buffer as a
  153. primitive, rather than split into arc segments or line segments and
  154. placed in the segment list.
  155. The reason for extensively parametrizing the internal operation of any
  156. Plotter (i.e. restricting what gets placed in its path buffer) is that
  157. for many Plotters, the Plotter-specific operation _paint_path(), which
  158. is called by endpath(), can't handle arbitrary drawing primitives,
  159. because the Plotter's output format doesn't support them.
  160. The values AS_UNIFORM and AS_AXES_PRESERVED aren't used for Beziers, but
  161. they're used for the other primitives. Also, insofar as ellipses go, a
  162. value of AS_AXES_PRESERVED for the allowed scaling is intepreted as
  163. meaning that not only should the affine map preserve coordinate axes,
  164. but the ellipse itself, to be placed in the path buffer, should have its
  165. major and minor axes aligned with the coordinate axes. See g_ellipse.c. */
  166. typedef enum
  167. {
  168. AS_NONE, /* primitive not supported at all */
  169. AS_UNIFORM, /* supported only if transf. is uniform */
  170. AS_AXES_PRESERVED, /* supported only if transf. preserves axes */
  171. AS_ANY /* supported irrespective of transformation */
  172. } plScalingType;
  173. /**********************************************************************/
  174. /* Structures for colors (we don't fully distinguish between 24-bit color
  175. and 48-bit color, though we should). */
  176. /* RGB */
  177. typedef struct
  178. {
  179. int red;
  180. int green;
  181. int blue;
  182. } plColor;
  183. /* BitmapPlotters (including PNMPlotters and PNGPlotters, which are
  184. derived) and GIFPlotters use the libxmi scan-conversion library, which
  185. is compiled into libplot/libplotter. libxmi writes into a pixmap that
  186. is made up of the following type of pixel. We use a struct containing a
  187. union, so that the compiled-in libxmi can be used both by GIF Plotters
  188. (in which pixel values are color indices) and by BitmapPlotters (in
  189. which pixel values are 24-bit RGB values). We distinguish them by the
  190. `type' field. */
  191. #define MI_PIXEL_TYPE struct \
  192. { \
  193. unsigned char type; \
  194. union \
  195. { \
  196. unsigned char index; \
  197. unsigned char rgb[3]; \
  198. } u; \
  199. }
  200. /* values for the `type' field */
  201. #define MI_PIXEL_INDEX_TYPE 0
  202. #define MI_PIXEL_RGB_TYPE 1
  203. #define MI_SAME_PIXEL(pixel1,pixel2) \
  204. (((pixel1).type == MI_PIXEL_INDEX_TYPE \
  205. && (pixel2).type == MI_PIXEL_INDEX_TYPE \
  206. && (pixel1).u.index == (pixel2).u.index) \
  207. || \
  208. ((pixel1).type == MI_PIXEL_RGB_TYPE \
  209. && (pixel2).type == MI_PIXEL_RGB_TYPE \
  210. && (pixel1).u.rgb[0] == (pixel2).u.rgb[0] \
  211. && (pixel1).u.rgb[1] == (pixel2).u.rgb[1] \
  212. && (pixel1).u.rgb[2] == (pixel2).u.rgb[2]))
  213. /**********************************************************************/
  214. /* Structure used for characterizing a page type (e.g. "letter", "a4"; see
  215. our database of known page types in g_pagetype.h). Any Plotter includes
  216. a pointer to one of these.
  217. For all `physical' Plotters, i.e. those with a page type determined by
  218. the PAGESIZE parameter, we map the window that the user specifies by
  219. invoking space(), to a viewport whose default size is fixed and
  220. Plotter-independent. E.g., for any Plotter for which PAGESIZE is
  221. "letter", the default viewport is a square of size 8.0in x 8.0in.
  222. All physical Plotters position this default viewport at the center of
  223. the page, except that HPGLPlotters don't know exactly where the origin
  224. of the device coordinate system is. PCLPlotters do, though, when
  225. they're emitting HP-GL/2 code (there's a field in the struct that
  226. specifies that, see below). See comments in g_pagetype.h. */
  227. typedef struct
  228. {
  229. const char *name; /* official name, e.g. "a" */
  230. const char *alt_name; /* alternative name if any, e.g. "letter" */
  231. const char *fig_name; /* name used in Fig format (case-sensitive) */
  232. bool metric; /* metric vs. Imperial, advisory only */
  233. double xsize, ysize; /* width, height in inches */
  234. double default_viewport_size; /* size of default square viewport, in inches*/
  235. double pcl_hpgl2_xorigin; /* origin for HP-GL/2-in-PCL5 plotting */
  236. double pcl_hpgl2_yorigin;
  237. double hpgl2_plot_length; /* plot length (for HP-GL/2 roll plotters) */
  238. } plPageData;
  239. /* Structure in which the user->NDC and user->device affine coordinate
  240. transformations are stored. Any drawing state includes one of these
  241. structures. The user->NDC transformation is a bit more fundamental,
  242. since it's used as an attribute of all objects that get drawn.
  243. The user->device transformation is the product of the user->NDC
  244. transformation and the NDC->device transformation (stored in the Plotter
  245. itself, since it never changes after being initialized at Plotter
  246. creation time). The reason we precompute the user->device
  247. transformation and store it here is that we use it so frequently. */
  248. typedef struct
  249. {
  250. /* the user->NDC transformation */
  251. double m_user_to_ndc[6]; /* 1. a linear transformation (4 elements) */
  252. /* 2. a translation (2 elements) */
  253. /* the user->device transformation, precomputed for convenience */
  254. double m[6];
  255. /* data on user->device map, also precomputed for convenience */
  256. bool uniform; /* transf. scaling is uniform? */
  257. bool axes_preserved; /* transf. preserves axis directions? */
  258. bool nonreflection; /* transf. doesn't involve a reflection? */
  259. } plTransform;
  260. /**********************************************************************/
  261. /* Drawing state structure. Includes drawing attributes, and the state of
  262. any uncompleted path object. When open, i.e., when drawing a page of
  263. graphics, any Plotter maintains a stack of these things. Many of the
  264. data members are device-dependent, i.e., specific to individual derived
  265. Plotter classes, but it's more efficient to keep them here, in a single
  266. structure. The device-independent data members are listed first. */
  267. typedef struct plDrawStateStruct
  268. {
  269. /***************** DEVICE-INDEPENDENT PART ***************************/
  270. /* graphics cursor position */
  271. plPoint pos; /* graphics cursor position in user space */
  272. /* affine transformation from user coordinates to normalized device
  273. coordinates, and also to actual device coordinates (precomputed) */
  274. plTransform transform; /* see definition of structure above */
  275. /* the compound path being drawn, if any */
  276. plPath *path; /* simple path being drawn */
  277. plPath **paths; /* previously drawn simple paths */
  278. int num_paths; /* number of previously drawn simple paths */
  279. plPoint start_point; /* starting point (used by closepath()) */
  280. /* modal drawing attributes */
  281. /* 1. path-related attributes */
  282. const char *fill_rule; /* fill rule */
  283. int fill_rule_type; /* one of PL_FILL_*, determined by fill rule */
  284. const char *line_mode; /* line mode */
  285. int line_type; /* one of PL_L_*, determined by line mode */
  286. bool points_are_connected; /* if not set, path displayed as points */
  287. const char *cap_mode; /* cap mode */
  288. int cap_type; /* one of PL_CAP_*, determined by cap mode */
  289. const char *join_mode; /* join mode */
  290. int join_type; /* one of PL_JOIN_*, determined by join mode */
  291. double miter_limit; /* miter limit for line joins */
  292. double line_width; /* width of lines in user coordinates */
  293. bool line_width_is_default; /* line width is (Plotter-specific) default? */
  294. double device_line_width; /* line width in device coordinates */
  295. int quantized_device_line_width; /* line width, quantized to integer */
  296. const double *dash_array; /* array of dash on/off lengths (nonnegative)*/
  297. int dash_array_len; /* length of same */
  298. double dash_offset; /* offset distance into dash array (`phase') */
  299. bool dash_array_in_effect; /* dash array should override line mode? */
  300. int pen_type; /* pen type (0 = no pen, 1 = pen) */
  301. int fill_type; /* fill type (0 = no fill, 1 = fill, ...) */
  302. int orientation; /* orientation of circles etc.(1=c'clockwise)*/
  303. /* 2. text-related attributes */
  304. const char *font_name; /* font name */
  305. double font_size; /* font size in user coordinates */
  306. bool font_size_is_default; /* font size is (Plotter-specific) default? */
  307. double text_rotation; /* degrees counterclockwise, for labels */
  308. const char *true_font_name; /* true font name (as retrieved) */
  309. double true_font_size; /* true font size (as retrieved) */
  310. double font_ascent; /* font ascent (as retrieved) */
  311. double font_descent; /* font descent (as retrieved) */
  312. double font_cap_height; /* font capital height (as received) */
  313. int font_type; /* PL_F_{HERSHEY|POSTSCRIPT|PCL|STICK|OTHER} */
  314. int typeface_index; /* typeface index (in g_fontdb.h table) */
  315. int font_index; /* font index, within typeface */
  316. bool font_is_iso8859_1; /* whether font uses iso8859_1 encoding */
  317. /* 3. color attributes (fgcolor and fillcolor are path-related; fgcolor
  318. affects other primitives too) */
  319. plColor fgcolor; /* foreground color, i.e., pen color */
  320. plColor fillcolor_base; /* fill color (not affected by fill_type) */
  321. plColor fillcolor; /* fill color (takes fill_type into account) */
  322. plColor bgcolor; /* background color for graphics display */
  323. bool bgcolor_suppressed; /* no actual background color? */
  324. /* default values for certain attributes, used when an out-of-range value
  325. is requested (these two are special because they're set by fsetmatrix()) */
  326. double default_line_width; /* width of lines in user coordinates */
  327. double default_font_size; /* font size in user coordinates */
  328. /****************** DEVICE-DEPENDENT PART ***************************/
  329. /* elements specific to the HPGL Plotter drawing state */
  330. double hpgl_pen_width; /* pen width (frac of diag dist betw P1,P2) */
  331. /* elements specific to the Fig Plotter drawing state */
  332. int fig_font_point_size; /* font size in fig's idea of points */
  333. int fig_fill_level; /* fig's fill level */
  334. int fig_fgcolor; /* fig's foreground color */
  335. int fig_fillcolor; /* fig's fill color */
  336. /* elements specific to the PS Plotter drawing state */
  337. double ps_fgcolor_red; /* RGB for fgcolor, each in [0.0,1.0] */
  338. double ps_fgcolor_green;
  339. double ps_fgcolor_blue;
  340. double ps_fillcolor_red; /* RGB for fillcolor, each in [0.0,1.0] */
  341. double ps_fillcolor_green;
  342. double ps_fillcolor_blue;
  343. int ps_idraw_fgcolor; /* index of idraw fgcolor in table */
  344. int ps_idraw_bgcolor; /* index of idraw bgcolor in table */
  345. int ps_idraw_shading; /* index of idraw shading in table */
  346. /* elements specific to the GIF Plotter drawing state */
  347. plColor i_pen_color; /* pen color (24-bit RGB) */
  348. plColor i_fill_color; /* fill color (24-bit RGB) */
  349. plColor i_bg_color; /* background color (24-bit RGB) */
  350. unsigned char i_pen_color_index; /* pen color index */
  351. unsigned char i_fill_color_index; /* fill color index */
  352. unsigned char i_bg_color_index; /* bg color index */
  353. bool i_pen_color_status; /* foreground color index is genuine? */
  354. bool i_fill_color_status; /* fill color index is genuine? */
  355. bool i_bg_color_status; /* background color index is genuine? */
  356. #ifndef X_DISPLAY_MISSING
  357. /* elements specific to the X Drawable Plotter drawing state */
  358. unsigned int x_font_pixel_size; /* pixel size according to server */
  359. XFontStruct *x_font_struct; /* font structure (used in x_text.c) */
  360. const unsigned char *x_label; /* label (hint to _x_retrieve_font()) */
  361. GC x_gc_fg; /* graphics context, for drawing */
  362. GC x_gc_fill; /* graphics context, for filling */
  363. GC x_gc_bg; /* graphics context, for erasing */
  364. plColor x_current_fgcolor; /* pen color stored in GC (48-bit RGB) */
  365. plColor x_current_fillcolor; /* fill color stored in GC (48-bit RGB) */
  366. plColor x_current_bgcolor; /* bg color stored in GC (48-bit RGB) */
  367. unsigned long x_gc_fgcolor; /* color stored in drawing GC (pixel value) */
  368. unsigned long x_gc_fillcolor; /* color stored in filling GC (pixel value) */
  369. unsigned long x_gc_bgcolor; /* color stored in erasing GC (pixel value) */
  370. bool x_gc_fgcolor_status; /* pixel value in drawing GC is genuine? */
  371. bool x_gc_fillcolor_status; /* pixel value in filling GC is genuine? */
  372. bool x_gc_bgcolor_status; /* pixel value in erasing GC is genuine? */
  373. int x_gc_line_style; /* line style stored in drawing GC */
  374. int x_gc_cap_style; /* cap style stored in drawing GC */
  375. int x_gc_join_style; /* join style stored in drawing GC */
  376. int x_gc_line_width; /* line width stored in drawing GC */
  377. const char *x_gc_dash_list; /* dash list stored in drawing GC */
  378. int x_gc_dash_list_len; /* length of dash list stored in drawing GC */
  379. int x_gc_dash_offset; /* offset into dash sequence, in drawing GC */
  380. int x_gc_fill_rule; /* fill rule stored in filling GC */
  381. #endif /* not X_DISPLAY_MISSING */
  382. /* pointer to previous drawing state */
  383. struct plDrawStateStruct *previous;
  384. } plDrawState;
  385. /**********************************************************************/
  386. /* An output buffer that may easily be resized. Used by most Plotters that
  387. do not do real-time output, to store device code for all graphical
  388. objects plotted on a page, and page-specific data such as the bounding
  389. box and `fonts used' information. (See e.g. g_outbuf.c.) Plotters that
  390. wait until they are deleted before outputing graphics, e.g. PSPlotters
  391. and CGMPlotters, maintain not just one of these things but rather a
  392. linked list, one output buffer per page. */
  393. /* NUM_PS_FONTS and NUM_PCL_FONTS should agree with the number of fonts of
  394. each type in g_fontdb.c. These are also defined in libplot/extern.h. */
  395. #define NUM_PS_FONTS 35
  396. #define NUM_PCL_FONTS 45
  397. typedef struct plOutbufStruct
  398. {
  399. /* if non-NULL, a plOutbuf containing a page header */
  400. struct plOutbufStruct *header;
  401. /* if non-NULL, a plOutbuf containing a page trailer */
  402. struct plOutbufStruct *trailer;
  403. /* device code for the graphics on the page */
  404. char *base; /* start of buffer */
  405. unsigned long len; /* size of buffer */
  406. char *point; /* current point (high-water mark) */
  407. char *reset_point; /* point below which contents are frozen */
  408. unsigned long contents; /* size of contents */
  409. unsigned long reset_contents; /* size of frozen contents if any */
  410. /* page-specific information that some Plotters generate and use (this is
  411. starting to look like a Christmas tree...) */
  412. double xrange_min; /* bounding box, in device coordinates */
  413. double xrange_max;
  414. double yrange_min;
  415. double yrange_max;
  416. bool ps_font_used[NUM_PS_FONTS]; /* PS fonts used on page */
  417. bool pcl_font_used[NUM_PCL_FONTS]; /* PCL fonts used on page */
  418. plColor bg_color; /* background color for the page */
  419. bool bg_color_suppressed; /* background color is "none"? */
  420. /* a hook for Plotters to hang other page-specific data */
  421. void * extra;
  422. /* pointer to previous Outbuf in page list if any */
  423. struct plOutbufStruct *next;
  424. } plOutbuf;
  425. /* Each Plotter caches the color names that have previously been mapped to
  426. RGB triples via libplot's colorname database (see g_colorname.h).
  427. For the cache, a linked list is currently used. */
  428. typedef struct
  429. {
  430. const char *name;
  431. unsigned char red;
  432. unsigned char green;
  433. unsigned char blue;
  434. } plColorNameInfo;
  435. typedef struct plCachedColorNameInfoStruct
  436. {
  437. const plColorNameInfo *info;
  438. struct plCachedColorNameInfoStruct *next;
  439. } plCachedColorNameInfo;
  440. typedef struct
  441. {
  442. plCachedColorNameInfo *cached_colors; /* head of linked list */
  443. } plColorNameCache;
  444. #ifndef X_DISPLAY_MISSING
  445. /* Each X DrawablePlotter (or X Plotter) keeps track of which fonts have
  446. been request from an X server, in any connection, by constructing a
  447. linked list of these records. A linked list is good enough if we don't
  448. have huge numbers of font changes. */
  449. typedef struct plXFontRecordStruct
  450. {
  451. char *x_font_name; /* font name, preferably an XLFD name */
  452. XFontStruct *x_font_struct; /* font structure */
  453. unsigned int x_font_pixel_size;
  454. unsigned int x_font_cap_height;
  455. bool x_font_is_iso8859_1;
  456. bool subset; /* did we retrieve a subset of the font? */
  457. unsigned char subset_vector[32]; /* 256-bit vector, 1 bit per font char */
  458. struct plXFontRecordStruct *next; /* most recently retrieved font */
  459. } plXFontRecord;
  460. /* Allocated color cells are kept track of similarly */
  461. typedef struct plColorRecordStruct
  462. {
  463. XColor rgb; /* RGB value and pixel value (if any) */
  464. bool allocated; /* pixel value successfully allocated? */
  465. int frame_number; /* frame that cell was most recently used in*/
  466. int page_number; /* page that cell was most recently used in*/
  467. struct plColorRecordStruct *next; /* most recently retrieved color cell */
  468. } plColorRecord;
  469. #endif /* not X_DISPLAY_MISSING */
  470. /***********************************************************************/
  471. /* The Plotter class, and also its derived classes (in libplotter). In
  472. libplot, a Plotter is a struct, and there are no derived classes; the
  473. data members of the derived classes are located inside the Plotter
  474. structure. */
  475. /* A few miscellaneous constants that appear in the declaration of the
  476. Plotter class (should be moved elsewhere if possible). */
  477. /* Number of recognized Plotter parameters (see g_params2.c). */
  478. #define NUM_PLOTTER_PARAMETERS 33
  479. /* Maximum number of pens, or logical pens, for an HP-GL/2 device. Some
  480. such devices permit as many as 256, but all should permit at least 32.
  481. Our pen numbering will range over 0..HPGL2_MAX_NUM_PENS-1. */
  482. #define HPGL2_MAX_NUM_PENS 32
  483. /* Maximum number of non-builtin colors that can be specified in an xfig
  484. input file. See also FIG_NUM_STD_COLORS, defined in
  485. libplot/extern.h. */
  486. #define FIG_MAX_NUM_USER_COLORS 512
  487. /* Supported Plotter types. These values are used in a `tag field', in
  488. libplot but not libplotter. (C++ doesn't have such things, at least it
  489. didn't until RTTI was invented :-)). */
  490. #ifdef NOT_LIBPLOTTER
  491. typedef enum
  492. {
  493. PL_GENERIC, /* instance of base Plotter class */
  494. PL_BITMAP, /* bitmap class, derived from by PNM and PNG */
  495. PL_META, /* GNU graphics metafile */
  496. PL_TEK, /* Tektronix 4014 with EGM */
  497. PL_REGIS, /* ReGIS (remote graphics instruction set) */
  498. PL_HPGL, /* HP-GL and HP-GL/2 */
  499. PL_PCL, /* PCL 5 (i.e. HP-GL/2 w/ header, trailer) */
  500. PL_FIG, /* xfig 3.2 */
  501. PL_CGM, /* CGM (Computer Graphics Metafile) */
  502. PL_PS, /* Postscript, with idraw support */
  503. PL_AI, /* Adobe Illustrator 5 (or 3) */
  504. PL_SVG, /* Scalable Vector Graphics */
  505. PL_GIF, /* GIF 87a or 89a */
  506. PL_PNM /* Portable Anymap Format (PBM/PGM/PPM) */
  507. #ifdef INCLUDE_PNG_SUPPORT
  508. , PL_PNG /* PNG: Portable Network Graphics */
  509. #endif
  510. #ifndef X_DISPLAY_MISSING
  511. , PL_X11_DRAWABLE /* X11 Drawable */
  512. , PL_X11 /* X11 (pops up, manages own window[s]) */
  513. #endif
  514. } plPlotterTag;
  515. #endif /* NOT_LIBPLOTTER */
  516. /* Types of Plotter output model. The `output_model' data element in any
  517. Plotter class specifies the output model, and the libplot machinery
  518. takes it from there. In particular, plOutbuf structures (one per page)
  519. are maintained if necessary, and written out at the appropriate time.
  520. Note: in the PAGES_ALL_AT_ONCE, OUTPUT_VIA_CUSTOM_ROUTINES* cases, the
  521. Plotter is responsible for managing its own output. In the
  522. PAGES_ALL_AT_ONCE case, libplot maintains not just one but an entire
  523. linked list of plOutbuf's, to be scanned over by the derived Plotter at
  524. deletion time. */
  525. typedef enum
  526. {
  527. PL_OUTPUT_NONE,
  528. /* No output at all; Plotter is used primarily for subclassing. E.g.,
  529. generic and Bitmap Plotters. */
  530. PL_OUTPUT_ONE_PAGE,
  531. /* Plotter produces at most one page of output (the first), and uses
  532. libplot's builtin plOutbuf-based output mechanism. The first page,
  533. which is written to a plOutbuf, is written out by the first invocation
  534. of closepl(), and all later pages are ignored. E.g., Fig,
  535. Illustrator, and SVG Plotters. */
  536. PL_OUTPUT_ONE_PAGE_AT_A_TIME,
  537. /* Plotter produces any number of pages of output, and uses libplot's
  538. builtin plOutbuf-based output mechanism. Each page is written out as
  539. soon as closepl() is called on it. E.g., HP-GL/PCL Plotters. */
  540. PL_OUTPUT_PAGES_ALL_AT_ONCE,
  541. /* Plotter produces any number of pages of output, and uses libplot's
  542. builtin plOutbuf-based output mechanism. But pages are written out
  543. only when the Plotter is deleted, i.e., when the internal terminate()
  544. function is called. (Actually, it's the generic-class terminate(),
  545. which any derived-class terminate() calls, that does it.) Because all
  546. pages need to be stored, a linked list of plOutbuf's is created, one
  547. per page. E.g., PS and CGM Plotters. */
  548. PL_OUTPUT_VIA_CUSTOM_ROUTINES,
  549. /* Plotter uses its own output routines to write one or possibly more
  550. pages to its output stream, as whole pages (i.e., when closepl() is
  551. called). It doesn't use libplot's plOutbuf-based output routines.
  552. E.g., PNM, GIF, and PNG Plotters (all of which output only 1 page). */
  553. PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME,
  554. /* Plotter uses its own output routines to write to its output stream, in
  555. real time. It doesn't use libplot's plOutbuf-based output routines.
  556. E.g., Metafile, Tektronix, and ReGIS Plotters. */
  557. PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM
  558. /* Plotter uses its own output routines to write to something other than
  559. an output stream, which must presumably be passed to it as a Plotter
  560. parameter. May or may not plot in real time. E.g., X Drawable and X
  561. Plotters (both of which plot in real time). */
  562. } plPlotterOutputModel;
  563. /* Plotter data. These data members of any Plotter object are stuffed into
  564. a single struct, for convenience. Most of them are initialized by the
  565. initialize() method, and don't change thereafter. So they're really
  566. parameters: they define the functioning of any Plotter.
  567. A few of these, e.g. the `page' member, do change at later times. But
  568. it's the core Plotter code that changes them; not the device-specific
  569. drivers. They're flagged by D: (i.e. dynamic), in their description. */
  570. typedef struct
  571. {
  572. /* data members (a great many!) which are really Plotter parameters */
  573. #ifdef NOT_LIBPLOTTER
  574. /* tag field */
  575. plPlotterTag type; /* Plotter type: one of PL_* defined above */
  576. #endif /* NOT_LIBPLOTTER */
  577. /* low-level I/O issues */
  578. plPlotterOutputModel output_model;/* one of PL_OUTPUT_* (see above) */
  579. FILE *infp; /* stdio-style input stream if any */
  580. FILE *outfp; /* stdio-style output stream if any */
  581. FILE *errfp; /* stdio-style error stream if any */
  582. #ifndef NOT_LIBPLOTTER
  583. istream *instream; /* C++-style input stream if any */
  584. ostream *outstream; /* C++-style output stream if any */
  585. ostream *errstream; /* C++-style error stream if any */
  586. #endif /* not NOT_LIBPLOTTER */
  587. /* device driver parameters (i.e., instance copies of class variables) */
  588. void * params[NUM_PLOTTER_PARAMETERS];
  589. /* (mostly) user-queryable capabilities: 0/1/2 = no/yes/maybe */
  590. int have_wide_lines;
  591. int have_dash_array;
  592. int have_solid_fill;
  593. int have_odd_winding_fill;
  594. int have_nonzero_winding_fill;
  595. int have_settable_bg;
  596. int have_escaped_string_support; /* can plot labels containing escapes? */
  597. int have_ps_fonts;
  598. int have_pcl_fonts;
  599. int have_stick_fonts;
  600. int have_extra_stick_fonts;
  601. int have_other_fonts;
  602. /* text and font-related parameters (internal, not queryable by user) */
  603. int default_font_type; /* PL_F_{HERSHEY|POSTSCRIPT|PCL|STICK} */
  604. bool pcl_before_ps; /* PCL fonts searched first? (if applicable) */
  605. bool have_horizontal_justification; /*device can justify text horizontally?*/
  606. bool have_vertical_justification; /* device can justify text vertically? */
  607. bool kern_stick_fonts; /* device kerns variable-width HP vector fonts?*/
  608. bool issue_font_warning; /* issue warning on font substitution? */
  609. /* path-related parameters (also internal) */
  610. int max_unfilled_path_length; /* user-settable, for unfilled polylines */
  611. bool have_mixed_paths; /* can mix arcs/Beziers and lines in paths? */
  612. plScalingType allowed_arc_scaling; /* scaling allowed for circular arcs */
  613. plScalingType allowed_ellarc_scaling; /* scaling allowed for elliptic arcs */
  614. plScalingType allowed_quad_scaling; /*scaling allowed for quadratic Beziers*/
  615. plScalingType allowed_cubic_scaling; /* scaling allowed for cubic Beziers */
  616. plScalingType allowed_box_scaling; /* scaling allowed for boxes */
  617. plScalingType allowed_circle_scaling; /* scaling allowed for circles */
  618. plScalingType allowed_ellipse_scaling; /* scaling allowed for ellipses */
  619. /* color-related parameters (also internal) */
  620. bool emulate_color; /* emulate color by grayscale? */
  621. /* cache of previously retrieved color names (used for speed) */
  622. plColorNameCache *color_name_cache;/* pointer to color name cache */
  623. /* info on the device coordinate frame (ranges for viewport in terms of
  624. native device coordinates, etc.; note that if flipped_y=true, then
  625. jmax<jmin or ymax<ymin) */
  626. int display_model_type; /* one of DISP_MODEL_{PHYSICAL,VIRTUAL} */
  627. int display_coors_type; /* one of DISP_DEVICE_COORS_{REAL, etc.} */
  628. bool flipped_y; /* y increases downward? */
  629. int imin, imax, jmin, jmax; /* ranges, if virtual with integer coors */
  630. double xmin, xmax, ymin, ymax; /* ranges, if physical with real coors */
  631. /* low-level page and viewport information, if display is physical.
  632. Final six parameters are in terms of inches, and can be specified by
  633. setting the PAGESIZE Plotter parameter. */
  634. const plPageData *page_data; /* page dimensions and other characteristics */
  635. double viewport_xsize, viewport_ysize; /* viewport dimensions (inches) */
  636. double viewport_xorigin, viewport_yorigin; /* viewport origin (inches) */
  637. double viewport_xoffset, viewport_yoffset; /* viewport origin offset */
  638. /* affine transformation from NDC to device coordinates */
  639. double m_ndc_to_device[6]; /* 1. a linear transformation (4 elements)
  640. 2. a translation (2 elements) */
  641. /* dynamic data members, which are updated during Plotter operation, unlike
  642. the many data members above */
  643. bool open; /* D: whether or not Plotter is open */
  644. bool opened; /* D: whether or not Plotter has been opened */
  645. int page_number; /* D: number of times it has been opened */
  646. bool fontsize_invoked; /* D: fontsize() invoked on this page? */
  647. bool linewidth_invoked; /* D: linewidth() invoked on this page? */
  648. int frame_number; /* D: number of frame in page */
  649. /* whether warning messages have been issued */
  650. bool font_warning_issued; /* D: issued warning on font substitution */
  651. bool pen_color_warning_issued; /* D: issued warning on name substitution */
  652. bool fill_color_warning_issued; /* D: issued warning on name substitution */
  653. bool bg_color_warning_issued; /* D: issued warning on name substitution */
  654. /* pointers to output buffers, containing graphics code */
  655. plOutbuf *page; /* D: output buffer for current page */
  656. plOutbuf *first_page; /* D: first page (if a linked list is kept) */
  657. } plPlotterData;
  658. /* The macro Q___ is used for declaring Plotter methods (as function
  659. pointers for libplot, and as function members of the Plotter class, for
  660. libplotter). QQ___ is used for declaring PlotterParams methods. It is
  661. the same as Q___, but does not declare the function members as virtual
  662. (the PlotterParams class is not derived from). */
  663. #ifdef Q___
  664. #undef Q___
  665. #endif
  666. #ifdef NOT_LIBPLOTTER
  667. #define Q___(rettype,f) rettype (*f)
  668. #define QQ___(rettype,f) rettype (*f)
  669. #else /* LIBPLOTTER */
  670. #define Q___(rettype,f) virtual rettype f
  671. #define QQ___(rettype,f) rettype f
  672. #endif
  673. /* Methods of the Plotter class (and derived classes) all have a hidden
  674. argument, called `this', which is a pointer to the invoking Plotter
  675. instance. That's a standard C++ convention. In libplot, we must pass
  676. such a pointer explicitly, as an extra argument; we call it `_plotter'.
  677. In libplotter, each occurrence of `_plotter' in the body of a Plotter
  678. method is mapped to `this'.
  679. Since the same code is used for both libplot and libplotter, we use a
  680. macro, R___() or S___(), in the declaration and the definition of each
  681. Plotter method. In libplotter, they elide their arguments. But in
  682. libplot, they do not; also, R___() appends a comma.
  683. Methods of the PlotterParams helper class are handled similarly. In
  684. libplot, each of them has an extra argument, `_plotter_params'. This is
  685. arranged via R___() or S___(). In libplotter, each occurrence of
  686. `_plotter_params' in the body of a PlotterParams method is mapped to
  687. `this'. */
  688. #ifdef NOT_LIBPLOTTER
  689. #define R___(arg1) arg1,
  690. #define S___(arg1) arg1
  691. #else /* LIBPLOTTER */
  692. #define _plotter this
  693. #define _plotter_params this
  694. #define R___(arg1)
  695. #define S___(arg1)
  696. #endif
  697. /* The PlotterParams class (or struct) definition. This is a helper class.
  698. Any instance of it holds parameters that are used when instantiating the
  699. Plotter class. */
  700. #ifndef NOT_LIBPLOTTER
  701. class PlotterParams
  702. #else
  703. typedef struct plPlotterParamsStruct /* this tag is used only by libplot */
  704. #endif
  705. {
  706. #ifndef NOT_LIBPLOTTER
  707. public:
  708. /* PlotterParams CTORS AND DTOR; copy constructor, assignment operator */
  709. PlotterParams ();
  710. ~PlotterParams ();
  711. PlotterParams (const PlotterParams& oldPlotterParams);
  712. PlotterParams& operator= (const PlotterParams& oldPlotterParams);
  713. #endif
  714. /* PLOTTERPARAMS PUBLIC METHODS */
  715. QQ___(int,setplparam) (R___(struct plPlotterParamsStruct *_plotter_params) const char *parameter, void * value);
  716. /* PUBLIC DATA: user-specified (recognized) Plotter parameters */
  717. void * plparams[NUM_PLOTTER_PARAMETERS];
  718. }
  719. #ifdef NOT_LIBPLOTTER
  720. PlotterParams;
  721. #else /* not NOT_LIBPLOTTER */
  722. ;
  723. #endif /* not NOT_LIBPLOTTER */
  724. /* The Plotter class (or struct) definition. There are many members! */
  725. #ifndef NOT_LIBPLOTTER
  726. class Plotter
  727. #else
  728. typedef struct plPlotterStruct /* this tag is used only by libplot */
  729. #endif
  730. {
  731. #ifndef NOT_LIBPLOTTER
  732. private:
  733. /* disallow copying and assignment */
  734. Plotter (const Plotter& oldplotter);
  735. Plotter& operator= (const Plotter& oldplotter);
  736. /* Private functions related to the drawing of text strings in Hershey
  737. fonts (all defined in g_alab_her.c). In libplot they're declared in
  738. libplot/extern.h. */
  739. double _g_alabel_hershey (const unsigned char *s, int x_justify, int y_justify);
  740. double _g_flabelwidth_hershey (const unsigned char *s);
  741. void _g_draw_hershey_glyph (int num, double charsize, int type, bool oblique);
  742. void _g_draw_hershey_penup_stroke (double dx, double dy, double charsize, bool oblique);
  743. void _g_draw_hershey_string (const unsigned short *string);
  744. void _g_draw_hershey_stroke (bool pendown, double deltax, double deltay);
  745. /* Other private functions (a mixed bag). In libplot they're declared
  746. in libplot/extern.h. */
  747. double _g_render_non_hershey_string (const char *s, bool do_render, int x_justify, int y_justify);
  748. double _g_render_simple_string (const unsigned char *s, bool do_render, int h_just, int v_just);
  749. unsigned short * _g_controlify (const unsigned char *);
  750. void _g_copy_params_to_plotter (const PlotterParams *params);
  751. void _g_create_first_drawing_state (void);
  752. void _g_delete_first_drawing_state (void);
  753. void _g_free_params_in_plotter (void);
  754. void _g_maybe_replace_arc (void);
  755. void _g_set_font (void);
  756. public:
  757. /* PLOTTER CTORS (old-style, not thread-safe) */
  758. Plotter (FILE *infile, FILE *outfile, FILE *errfile);
  759. Plotter (FILE *outfile);
  760. Plotter (istream& in, ostream& out, ostream& err);
  761. Plotter (ostream& out);
  762. Plotter ();
  763. /* PLOTTER CTORS (new-style, thread-safe) */
  764. Plotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  765. Plotter (FILE *outfile, PlotterParams &params);
  766. Plotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  767. Plotter (ostream& out, PlotterParams &params);
  768. Plotter (PlotterParams &params);
  769. /* PLOTTER DTOR */
  770. virtual ~Plotter ();
  771. /* PLOTTER PUBLIC METHOD (static, used by old [non-thread-safe] bindings) */
  772. static int parampl (const char *parameter, void * value);
  773. /* PLOTTER PUBLIC METHODS.
  774. The methods in the libplotter API. (In libplot, these methods are
  775. declared not here, but in extern.h.)
  776. Note that in the body of the code, these Plotter methods appear under
  777. the names _API_alabel() etc. Via #define's in extern.h, they're
  778. renamed as _pl_alable_r() etc. in libplot, and as Plotter::alabel
  779. etc. in libplotter. */
  780. int alabel (int x_justify, int y_justify, const char *s);
  781. int arc (int xc, int yc, int x0, int y0, int x1, int y1);
  782. int arcrel (int dxc, int dyc, int dx0, int dy0, int dx1, int dy1);
  783. int bezier2 (int x0, int y0, int x1, int y1, int x2, int y2);
  784. int bezier2rel (int dx0, int dy0, int dx1, int dy1, int dx2, int dy2);
  785. int bezier3 (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
  786. int bezier3rel (int dx0, int dy0, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
  787. int bgcolor (int red, int green, int blue);
  788. int bgcolorname (const char *name);
  789. int box (int x0, int y0, int x1, int y1);
  790. int boxrel (int dx0, int dy0, int dx1, int dy1);
  791. int capmod (const char *s);
  792. int circle (int x, int y, int r);
  793. int circlerel (int dx, int dy, int r);
  794. int closepath (void);
  795. int closepl (void);
  796. int color (int red, int green, int blue);
  797. int colorname (const char *name);
  798. int cont (int x, int y);
  799. int contrel (int dx, int dy);
  800. int ellarc (int xc, int yc, int x0, int y0, int x1, int y1);
  801. int ellarcrel (int dxc, int dyc, int dx0, int dy0, int dx1, int dy1);
  802. int ellipse (int x, int y, int rx, int ry, int angle);
  803. int ellipserel (int dx, int dy, int rx, int ry, int angle);
  804. int endpath (void);
  805. int endsubpath (void);
  806. int erase (void);
  807. int farc (double xc, double yc, double x0, double y0, double x1, double y1);
  808. int farcrel (double dxc, double dyc, double dx0, double dy0, double dx1, double dy1);
  809. int fbezier2 (double x0, double y0, double x1, double y1, double x2, double y2);
  810. int fbezier2rel (double dx0, double dy0, double dx1, double dy1, double dx2, double dy2);
  811. int fbezier3 (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3);
  812. int fbezier3rel (double dx0, double dy0, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
  813. int fbox (double x0, double y0, double x1, double y1);
  814. int fboxrel (double dx0, double dy0, double dx1, double dy1);
  815. int fcircle (double x, double y, double r);
  816. int fcirclerel (double dx, double dy, double r);
  817. int fconcat (double m0, double m1, double m2, double m3, double m4, double m5);
  818. int fcont (double x, double y);
  819. int fcontrel (double dx, double dy);
  820. int fellarc (double xc, double yc, double x0, double y0, double x1, double y1);
  821. int fellarcrel (double dxc, double dyc, double dx0, double dy0, double dx1, double dy1);
  822. int fellipse (double x, double y, double rx, double ry, double angle);
  823. int fellipserel (double dx, double dy, double rx, double ry, double angle);
  824. double ffontname (const char *s);
  825. double ffontsize (double size);
  826. int fillcolor (int red, int green, int blue);
  827. int fillcolorname (const char *name);
  828. int fillmod (const char *s);
  829. int filltype (int level);
  830. double flabelwidth (const char *s);
  831. int fline (double x0, double y0, double x1, double y1);
  832. int flinedash (int n, const double *dashes, double offset);
  833. int flinerel (double dx0, double dy0, double dx1, double dy1);
  834. int flinewidth (double size);
  835. int flushpl (void);
  836. int fmarker (double x, double y, int type, double size);
  837. int fmarkerrel (double dx, double dy, int type, double size);
  838. int fmiterlimit (double limit);
  839. int fmove (double x, double y);
  840. int fmoverel (double dx, double dy);
  841. int fontname (const char *s);
  842. int fontsize (int size);
  843. int fpoint (double x, double y);
  844. int fpointrel (double dx, double dy);
  845. int frotate (double theta);
  846. int fscale (double x, double y);
  847. int fsetmatrix (double m0, double m1, double m2, double m3, double m4, double m5);
  848. int fspace (double x0, double y0, double x1, double y1);
  849. int fspace2 (double x0, double y0, double x1, double y1, double x2, double y2);
  850. double ftextangle (double angle);
  851. int ftranslate (double x, double y);
  852. int havecap (const char *s);
  853. int joinmod (const char *s);
  854. int label (const char *s);
  855. int labelwidth (const char *s);
  856. int line (int x0, int y0, int x1, int y1);
  857. int linedash (int n, const int *dashes, int offset);
  858. int linemod (const char *s);
  859. int linerel (int dx0, int dy0, int dx1, int dy1);
  860. int linewidth (int size);
  861. int marker (int x, int y, int type, int size);
  862. int markerrel (int dx, int dy, int type, int size);
  863. int move (int x, int y);
  864. int moverel (int dx, int dy);
  865. int openpl (void);
  866. int orientation (int direction);
  867. FILE* outfile (FILE* newstream); /* OBSOLESCENT */
  868. int pencolor (int red, int green, int blue);
  869. int pencolorname (const char *name);
  870. int pentype (int level);
  871. int point (int x, int y);
  872. int pointrel (int dx, int dy);
  873. int restorestate (void);
  874. int savestate (void);
  875. int space (int x0, int y0, int x1, int y1);
  876. int space2 (int x0, int y0, int x1, int y1, int x2, int y2);
  877. int textangle (int angle);
  878. /* Undocumented public methods that provide access to the font tables
  879. within libplot/libplotter. They're used by the graphics programs in
  880. the plotutils package, to display lists of font names. In libplot
  881. they're declared in libplot/extern.h, rather than here. */
  882. void *_get_hershey_font_info (void);
  883. void *_get_ps_font_info (void);
  884. void *_get_pcl_font_info (void);
  885. void *_get_stick_font_info (void);
  886. protected:
  887. #endif /* not NOT_LIBPLOTTER */
  888. /* PLOTTER PROTECTED METHODS. All virtual, i.e. they're allowed to be
  889. Plotter-specific; the generic versions of these do nothing and are
  890. overridden in derived classes, to define what a Plotter does. */
  891. /* Initialization (after creation) and termination (before deletion).
  892. These are exceptions to the above rule: they're effectively
  893. constructors and destructors, so even in the generic Plotter class,
  894. they do useful work. In derived classes they should always invoke
  895. their base counterparts. */
  896. Q___(void,initialize) (S___(struct plPlotterStruct *_plotter));
  897. Q___(void,terminate) (S___(struct plPlotterStruct *_plotter));
  898. /* Internal page-related methods, called by the API methods openpl(),
  899. erase() and closepl(). `true' return value indicates operation
  900. performed successfully. */
  901. Q___(bool,begin_page) (S___(struct plPlotterStruct *_plotter));
  902. Q___(bool,erase_page) (S___(struct plPlotterStruct *_plotter));
  903. Q___(bool,end_page) (S___(struct plPlotterStruct *_plotter));
  904. /* Internal `push state' method, called by the API method savestate().
  905. This is used by a very few types of Plotter to create or initialize
  906. Plotter-specific fields in a newly created drawing state. Most
  907. Plotters don't override the generic version, which simply copies such
  908. Plotter-specific fields. */
  909. Q___(void,push_state) (S___(struct plPlotterStruct *_plotter));
  910. /* Internal `pop state' method, called by the API method restorestate().
  911. This is used by a very few types of Plotter to delete or tear down
  912. Plotter-specific fields in a drawing state about to be destroyed.
  913. Most Plotters don't override the generic version, which does nothing
  914. to such fields. */
  915. Q___(void,pop_state) (S___(struct plPlotterStruct *_plotter));
  916. /* Internal `paint path' method, called when the API method endpath() is
  917. invoked, to draw any path that has been built up in a Plotter's
  918. drawing state. It should paint a single simple path. The generic
  919. version of course does nothing. */
  920. Q___(void,paint_path) (S___(struct plPlotterStruct *_plotter));
  921. /* Another internal method, called by endpath() first, if the path to
  922. paint is compound rather than simple. If the Plotter can paint the
  923. compound path, this should return `true'; if `false' is returned,
  924. endpath() will paint using compound path emulation instead. The
  925. generic version does nothing, but returns `true'. */
  926. Q___(bool,paint_paths) (S___(struct plPlotterStruct *_plotter));
  927. /* Support for flushing out the path buffer when it gets too long. In
  928. any Plotter, this predicate is evaluated after any path element is
  929. added to the path buffer, provided (1) the path buffer has become
  930. greater than or equal to the `max_unfilled_path_length' Plotter
  931. parameter, and (2) the path isn't to be filled. In most Plotters,
  932. including generic Plotters, this simply returns `true', to indicate
  933. that the path should be flushed out by invoking endpath(). But in
  934. Plotters that plot in real time under some circumstances (see below),
  935. this normally returns `false' under those circumstances. */
  936. Q___(bool,path_is_flushable) (S___(struct plPlotterStruct *_plotter));
  937. /* Support for real-time plotting, if desired. An internal `prepaint
  938. segments' method, called not when a path is finished by endpath()
  939. being called, but rather when any single segment is added to it. (Or
  940. when several segments, obtained by polygonalizing a higher-level
  941. primitive, are added to it.) Only in Plotters that plot in real time
  942. (by definition!) is this not a no-op. */
  943. Q___(void,maybe_prepaint_segments) (R___(struct plPlotterStruct *_plotter) int prev_num_segments);
  944. /* Internal `draw marker' method, called when the API method marker() is
  945. invoked. Only a very few types of Plotter use this. Return value
  946. should indicate whether the marker was drawn; `false' means that a
  947. generic drawing routine, which creates a marker from other libplot
  948. primitives, should be used. (Yes, some Plotter output formats support
  949. some types of marker but not others!). The generic version does nothing,
  950. but returns `false'. */
  951. Q___(bool,paint_marker) (R___(struct plPlotterStruct *_plotter) int type, double size);
  952. /* Internal `draw point' method, called when the API method point() is
  953. invoked. There's no standard definition of a `point', so Plotters are
  954. free to implement this as they see fit. */
  955. Q___(void,paint_point) (S___(struct plPlotterStruct *_plotter));
  956. /* Internal, Plotter-specific versions of the `alabel' and `flabelwidth'
  957. methods, which are applied to single-line text strings in a single
  958. font (no escape sequences, etc.). The API methods alabel and
  959. flabelwidth are wrappers around these.
  960. The argument h_just specifies the justification to be used when
  961. rendering (PL_JUST_LEFT, PL_JUST_RIGHT, or PL_JUST_CENTER). If a
  962. display device provides low-level support for non-default
  963. (i.e. non-left) justification, the Plotter's
  964. have_horizontal_justification flag (see below) should be set.
  965. Similarly, v_just specifies vertical justification (PL_JUST_TOP,
  966. PL_JUST_HALF, PL_JUST_BASE, PL_JUST_BOTTOM, or PL_JUST_CAP). */
  967. /* The first of these is special, for use by Metafile Plotters only. Any
  968. Metafile Plotter has low-level support for drawing labels that include
  969. any of our many escape sequences. (Actually, a Metafile Plotter just
  970. dumps them to the output stream, unchanged. :-)). So the Metafile
  971. Plotter class has a special _m_paint_text_string_with_escapes method.
  972. In all other Plotters, the paint_text_string_with_escapes method
  973. should be set to the dummy _g_paint_text_string_with_escapes method,
  974. which does nothing; it'll never be invoked. Our code recognizes that
  975. a Metafile Plotter is special by looking at the Plotter's
  976. `have_escaped_string_support' capability, which is `1' for a Metafile
  977. Plotter and `0' for all others. */
  978. Q___(void,paint_text_string_with_escapes) (R___(struct plPlotterStruct *_plotter) const unsigned char *s, int x_justify, int y_justify);
  979. Q___(double,paint_text_string) (R___(struct plPlotterStruct *_plotter) const unsigned char *s, int h_just, int v_just);
  980. Q___(double,get_text_width) (R___(struct plPlotterStruct *_plotter) const unsigned char *s);
  981. /* Low-level, Plotter-specific `retrieve font' function; called by the
  982. internal _set_font() function, which in turn is called by the API
  983. methods alabel() and labelwidth(), and by the API methods
  984. fontname()/fontsize()/textwidth(), but only because they need to
  985. return a font size. retrieve_font() is called only if the
  986. user-specified font is a non-Hershey font. If it returns false, a
  987. default font, e.g., a Hershey font, will be substituted. */
  988. Q___(bool,retrieve_font) (S___(struct plPlotterStruct *_plotter));
  989. /* Internal `flush output' method, called by the API method flushpl().
  990. This is called only if the Plotter does its own output, i.e., does not
  991. write to an output stream. I.e., only if the Plotter's `output_model'
  992. data element is PL_OUTPUT_VIA_CUSTOM_ROUTINES_TO_NON_STREAM. Return
  993. value indicates whether flushing worked. */
  994. Q___(bool,flush_output) (S___(struct plPlotterStruct *_plotter));
  995. /* error handlers */
  996. Q___(void,warning) (R___(struct plPlotterStruct *_plotter) const char *msg);
  997. Q___(void,error) (R___(struct plPlotterStruct *_plotter) const char *msg);
  998. /* PLOTTER DATA MEMBERS (not specific to any one device driver). These
  999. are protected rather than private, so they can be accessed by derived
  1000. classes. */
  1001. /* Basic data members: many parameters affecting Plotter operation, which
  1002. are set by the initialize() method and not changed thereafter, plus a
  1003. few (e.g., pointers to plOutbuf's for holding graphics code) which may
  1004. change at later times. */
  1005. plPlotterData *data;
  1006. /* drawing state stack (pointer to top) */
  1007. plDrawState *drawstate;
  1008. #ifdef NOT_LIBPLOTTER
  1009. /* PLOTTER DATA MEMBERS (device driver-specific). */
  1010. /* In libplot, they appear here, i.e., in the Plotter struct. But in
  1011. libplotter, they don't appear here, i.e. they don't appear in the base
  1012. Plotter class: they appear, more logically, as private or protected
  1013. data members of the appropriate derived classes (for the definitions
  1014. of which, see further below in this file). */
  1015. /* Some of these are constant over the usable lifetime of the Plotter,
  1016. and are set, at latest, in the first call to begin_page(). They are
  1017. just parameters. Other data members may change, since they represent
  1018. our knowledge of the display device's internal state. Each of the
  1019. latter is flagged by "D:" (i.e. "dynamic") in its comment line. */
  1020. /* data members specific to Bitmap Plotters */
  1021. void * b_arc_cache_data; /* pointer to cache (used by miPolyArc_r) */
  1022. int b_xn, b_yn; /* bitmap dimensions */
  1023. void * b_painted_set; /* D: libxmi's canvas (a (miPaintedSet *)) */
  1024. void * b_canvas; /* D: libxmi's canvas (a (miCanvas *)) */
  1025. /* data members specific to Metafile Plotters */
  1026. /* 0. parameters */
  1027. bool meta_portable_output; /* portable, not binary output format? */
  1028. /* 1. dynamic attributes, general */
  1029. plPoint meta_pos; /* graphics cursor position */
  1030. bool meta_position_is_unknown; /* position is unknown? */
  1031. double meta_m_user_to_ndc[6]; /* user->NDC transformation matrix */
  1032. /* 2. dynamic attributes, path-related */
  1033. int meta_fill_rule_type; /* one of PL_FILL_*, determined by fill rule */
  1034. int meta_line_type; /* one of PL_L_*, determined by line mode */
  1035. bool meta_points_are_connected; /* if not set, path displayed as points */
  1036. int meta_cap_type; /* one of PL_CAP_*, determined by cap mode */
  1037. int meta_join_type; /* one of PL_JOIN_*, determined by join mode */
  1038. double meta_miter_limit; /* miter limit for line joins */
  1039. double meta_line_width; /* width of lines in user coordinates */
  1040. bool meta_line_width_is_default; /* line width is default value? */
  1041. const double *meta_dash_array; /* array of dash on/off lengths(nonnegative)*/
  1042. int meta_dash_array_len; /* length of same */
  1043. double meta_dash_offset; /* offset distance into dash array (`phase') */
  1044. bool meta_dash_array_in_effect; /* dash array should override line mode? */
  1045. int meta_pen_type; /* pen type (0 = no pen, 1 = pen) */
  1046. int meta_fill_type; /* fill type (0 = no fill, 1 = fill, ...) */
  1047. int meta_orientation; /* orientation of circles etc.(1=c'clockwise)*/
  1048. /* 3. dynamic attributes, text-related */
  1049. const char *meta_font_name; /* font name */
  1050. double meta_font_size; /* font size in user coordinates */
  1051. bool meta_font_size_is_default; /* font size is Plotter default? */
  1052. double meta_text_rotation; /* degrees counterclockwise, for labels */
  1053. /* 4. dynamic color attributes (fgcolor and fillcolor are path-related;
  1054. fgcolor affects other primitives too) */
  1055. plColor meta_fgcolor; /* foreground color, i.e., pen color */
  1056. plColor meta_fillcolor_base; /* fill color */
  1057. plColor meta_bgcolor; /* background color for graphics display */
  1058. /* data members specific to Tektronix Plotters */
  1059. int tek_display_type; /* which sort of Tektronix? (one of TEK_DPY_*) */
  1060. int tek_mode; /* D: one of TEK_MODE_* */
  1061. int tek_line_type; /* D: one of PL_L_* */
  1062. bool tek_mode_is_unknown; /* D: tek mode unknown? */
  1063. bool tek_line_type_is_unknown; /* D: tek line type unknown? */
  1064. int tek_kermit_fgcolor; /* D: kermit's foreground color */
  1065. int tek_kermit_bgcolor; /* D: kermit's background color */
  1066. bool tek_position_is_unknown; /* D: cursor position is unknown? */
  1067. plIntPoint tek_pos; /* D: Tektronix cursor position */
  1068. /* data members specific to ReGIS Plotters */
  1069. plIntPoint regis_pos; /* D: ReGIS graphics cursor position */
  1070. bool regis_position_is_unknown; /* D: graphics cursor position is unknown? */
  1071. int regis_line_type; /* D: native ReGIS line type */
  1072. bool regis_line_type_is_unknown; /* D: ReGIS line type is unknown? */
  1073. int regis_fgcolor; /* D: ReGIS foreground color, in range 0..7 */
  1074. int regis_bgcolor; /* D: ReGIS background color, in range 0..7 */
  1075. bool regis_fgcolor_is_unknown; /* D: foreground color unknown? */
  1076. bool regis_bgcolor_is_unknown; /* D: background color unknown? */
  1077. /* data members specific to HP-GL (and PCL) Plotters */
  1078. int hpgl_version; /* version: 0=HP-GL, 1=HP7550A, 2=HP-GL/2 */
  1079. int hpgl_rotation; /* rotation angle (0, 90, 180, or 270) */
  1080. double hpgl_plot_length; /* plot length (for HP-GL/2 roll plotters) */
  1081. plPoint hpgl_p1; /* scaling point P1 in native HP-GL coors */
  1082. plPoint hpgl_p2; /* scaling point P2 in native HP-GL coors */
  1083. bool hpgl_have_screened_vectors; /* can shade pen marks? (HP-GL/2 only) */
  1084. bool hpgl_have_char_fill; /* can shade char interiors? (HP-GL/2 only) */
  1085. bool hpgl_can_assign_colors; /* can assign pen colors? (HP-GL/2 only) */
  1086. bool hpgl_use_opaque_mode; /* pen marks sh'd be opaque? (HP-GL/2 only) */
  1087. plColor hpgl_pen_color[HPGL2_MAX_NUM_PENS]; /* D: color array for pens */
  1088. int hpgl_pen_defined[HPGL2_MAX_NUM_PENS];/*D:0=none,1=soft-defd,2=hard-defd*/
  1089. int hpgl_pen; /* D: number of currently selected pen */
  1090. int hpgl_free_pen; /* D: pen to be assigned a color next */
  1091. bool hpgl_bad_pen; /* D: bad pen (advisory, see h_color.c) */
  1092. bool hpgl_pendown; /* D: pen down rather than up? */
  1093. double hpgl_pen_width; /* D: pen width(frac of diag dist betw P1,P2)*/
  1094. int hpgl_line_type; /* D: line type(HP-GL numbering,solid = -100)*/
  1095. int hpgl_cap_style; /* D: cap style for lines (HP-GL/2 numbering)*/
  1096. int hpgl_join_style; /* D: join style for lines(HP-GL/2 numbering)*/
  1097. double hpgl_miter_limit; /* D: miterlimit for line joins(HP-GL/2 only)*/
  1098. int hpgl_pen_type; /* D: sv type (e.g. HPGL_PEN_{SOLID|SHADED}) */
  1099. double hpgl_pen_option1; /* D: used for some screened vector types */
  1100. double hpgl_pen_option2; /* D: used for some screened vector types */
  1101. int hpgl_fill_type; /* D: fill type (one of FILL_SOLID_UNI etc.) */
  1102. double hpgl_fill_option1; /* D: used for some fill types */
  1103. double hpgl_fill_option2; /* D: used for some fill types */
  1104. int hpgl_char_rendering_type; /* D: character rendering type (fill/edge) */
  1105. int hpgl_symbol_set; /* D: encoding, 14=ISO-Latin-1 (HP-GL/2 only)*/
  1106. int hpgl_spacing; /* D: fontspacing,0=fixed,1=not(HP-GL/2 only)*/
  1107. int hpgl_posture; /* D: posture,0=uprite,1=italic(HP-GL/2 only)*/
  1108. int hpgl_stroke_weight; /* D: weight,0=normal,3=bold,..(HP-GL/2only)*/
  1109. int hpgl_pcl_typeface; /* D: PCL typeface, see g_fontdb.c (HP-GL/2) */
  1110. int hpgl_charset_lower; /* D: HP lower-half charset no. (pre-HP-GL/2)*/
  1111. int hpgl_charset_upper; /* D: HP upper-half charset no. (pre-HP-GL/2)*/
  1112. double hpgl_rel_char_height; /* D: char ht., % of p2y-p1y (HP-GL/2 only) */
  1113. double hpgl_rel_char_width; /* D: char width, % of p2x-p1x (HP-GL/2 only)*/
  1114. double hpgl_rel_label_rise; /* D: label rise, % of p2y-p1y (HP-GL/2 only)*/
  1115. double hpgl_rel_label_run; /* D: label run, % of p2x-p1x (HP-GL/2 only) */
  1116. double hpgl_tan_char_slant; /* D: tan of character slant (HP-GL/2 only)*/
  1117. bool hpgl_position_is_unknown; /* D: HP-GL[/2] cursor position is unknown? */
  1118. plIntPoint hpgl_pos; /* D: cursor position (integer HP-GL coors) */
  1119. /* data members specific to Fig Plotters */
  1120. int fig_drawing_depth; /* D: fig's curr value for `depth' attribute */
  1121. int fig_num_usercolors; /* D: number of colors currently defined */
  1122. long int fig_usercolors[FIG_MAX_NUM_USER_COLORS]; /* D: colors we've def'd */
  1123. bool fig_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  1124. /* data members specific to CGM Plotters */
  1125. int cgm_encoding; /* CGM_ENCODING_{BINARY,CHARACTER,CLEAR_TEXT}*/
  1126. int cgm_max_version; /* upper bound on CGM version number */
  1127. int cgm_version; /* D: CGM version for file (1, 2, 3, or 4) */
  1128. int cgm_profile; /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1129. int cgm_need_color; /* D: non-monochrome? */
  1130. int cgm_page_version; /* D: CGM version for current page */
  1131. int cgm_page_profile; /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1132. bool cgm_page_need_color; /* D: current page is non-monochrome? */
  1133. plColor cgm_line_color; /* D: line pen color (24-bit or 48-bit RGB) */
  1134. plColor cgm_edge_color; /* D: edge pen color (24-bit or 48-bit RGB) */
  1135. plColor cgm_fillcolor; /* D: fill color (24-bit or 48-bit RGB) */
  1136. plColor cgm_marker_color; /* D: marker pen color (24-bit or 48-bit RGB)*/
  1137. plColor cgm_text_color; /* D: text pen color (24-bit or 48-bit RGB) */
  1138. plColor cgm_bgcolor; /* D: background color (24-bit or 48-bit RGB)*/
  1139. bool cgm_bgcolor_suppressed; /* D: background color suppressed? */
  1140. int cgm_line_type; /* D: one of CGM_L_{SOLID, etc.} */
  1141. double cgm_dash_offset; /* D: offset into dash array (`phase') */
  1142. int cgm_join_style; /* D: join style for lines (CGM numbering)*/
  1143. int cgm_cap_style; /* D: cap style for lines (CGM numbering)*/
  1144. int cgm_dash_cap_style; /* D: dash cap style for lines(CGM numbering)*/
  1145. int cgm_line_width; /* D: line width in CGM coordinates */
  1146. int cgm_interior_style; /* D: one of CGM_INT_STYLE_{EMPTY, etc.} */
  1147. int cgm_edge_type; /* D: one of CGM_L_{SOLID, etc.} */
  1148. double cgm_edge_dash_offset; /* D: offset into dash array (`phase') */
  1149. int cgm_edge_join_style; /* D: join style for edges (CGM numbering)*/
  1150. int cgm_edge_cap_style; /* D: cap style for edges (CGM numbering)*/
  1151. int cgm_edge_dash_cap_style; /* D: dash cap style for edges(CGM numbering)*/
  1152. int cgm_edge_width; /* D: edge width in CGM coordinates */
  1153. bool cgm_edge_is_visible; /* D: filled regions have edges? */
  1154. double cgm_miter_limit; /* D: CGM's miter limit */
  1155. int cgm_marker_type; /* D: one of CGM_M_{DOT, etc.} */
  1156. int cgm_marker_size; /* D: marker size in CGM coordinates */
  1157. int cgm_char_height; /* D: character height */
  1158. int cgm_char_base_vector_x; /* D: character base vector */
  1159. int cgm_char_base_vector_y;
  1160. int cgm_char_up_vector_x; /* D: character up vector */
  1161. int cgm_char_up_vector_y;
  1162. int cgm_horizontal_text_alignment; /* D: one of CGM_ALIGN_* */
  1163. int cgm_vertical_text_alignment; /* D: one of CGM_ALIGN_* */
  1164. int cgm_font_id; /* D: PS font in range 0..34 */
  1165. int cgm_charset_lower; /* D: lower charset (index into defined list)*/
  1166. int cgm_charset_upper; /* D: upper charset (index into defined list)*/
  1167. int cgm_restricted_text_type; /* D: one of CGM_RESTRICTED_TEXT_TYPE_* */
  1168. /* data members specific to Illustrator Plotters */
  1169. int ai_version; /* AI version 3 or AI version 5? */
  1170. double ai_pen_cyan; /* D: pen color (in CMYK space) */
  1171. double ai_pen_magenta;
  1172. double ai_pen_yellow;
  1173. double ai_pen_black;
  1174. double ai_fill_cyan; /* D: fill color (in CMYK space) */
  1175. double ai_fill_magenta;
  1176. double ai_fill_yellow;
  1177. double ai_fill_black;
  1178. bool ai_cyan_used; /* D: C, M, Y, K have been used? */
  1179. bool ai_magenta_used;
  1180. bool ai_yellow_used;
  1181. bool ai_black_used;
  1182. int ai_cap_style; /* D: cap style for lines (PS numbering) */
  1183. int ai_join_style; /* D: join style for lines (PS numbering) */
  1184. double ai_miter_limit; /* D: miterlimit for line joins */
  1185. int ai_line_type; /* D: one of PL_L_* */
  1186. double ai_line_width; /* D: line width in printer's points */
  1187. int ai_fill_rule_type; /* D: fill rule (AI_FILL_{ODD|NONZERO}_WINDING) */
  1188. /* data members specific to SVG Plotters */
  1189. double s_matrix[6]; /* D: default transformation matrix for page */
  1190. bool s_matrix_is_unknown; /* D: matrix has not yet been set? */
  1191. bool s_matrix_is_bogus; /* D: matrix has been set, but is bogus? */
  1192. plColor s_bgcolor; /* D: background color (RGB) */
  1193. bool s_bgcolor_suppressed; /* D: background color suppressed? */
  1194. /* data members specific to PNM Plotters (derived from Bitmap Plotters) */
  1195. bool n_portable_output; /* portable, not binary output format? */
  1196. #ifdef INCLUDE_PNG_SUPPORT
  1197. /* data members specific to PNG Plotters (derived from Bitmap Plotters) */
  1198. bool z_interlace; /* interlaced PNG? */
  1199. bool z_transparent; /* transparent PNG? */
  1200. plColor z_transparent_color; /* if so, transparent color (24-bit RGB) */
  1201. #endif /* INCLUDE_PNG_SUPPORT */
  1202. /* data members specific to GIF Plotters */
  1203. int i_xn, i_yn; /* bitmap dimensions */
  1204. int i_num_pixels; /* total pixels (used by scanner) */
  1205. bool i_animation; /* animated (multi-image) GIF? */
  1206. int i_iterations; /* number of times GIF should be looped */
  1207. int i_delay; /* delay after image, in 1/100 sec units */
  1208. bool i_interlace; /* interlaced GIF? */
  1209. bool i_transparent; /* transparent GIF? */
  1210. plColor i_transparent_color; /* if so, transparent color (24-bit RGB) */
  1211. void * i_arc_cache_data; /* pointer to cache (used by miPolyArc_r) */
  1212. int i_transparent_index; /* D: transparent color index (if any) */
  1213. void * i_painted_set; /* D: libxmi's canvas (a (miPaintedSet *)) */
  1214. void * i_canvas; /* D: libxmi's canvas (a (miCanvas *)) */
  1215. plColor i_colormap[256]; /* D: frame colormap (containing 24-bit RGBs)*/
  1216. int i_num_color_indices; /* D: number of color indices allocated */
  1217. bool i_frame_nonempty; /* D: something drawn in current frame? */
  1218. int i_bit_depth; /* D: bit depth (ceil(log2(num_indices))) */
  1219. int i_pixels_scanned; /* D: number that scanner has scanned */
  1220. int i_pass; /* D: scanner pass (used if interlacing) */
  1221. plIntPoint i_hot; /* D: scanner hot spot */
  1222. plColor i_global_colormap[256]; /* D: colormap for first frame (stashed) */
  1223. int i_num_global_color_indices;/* D: number of indices in global colormap */
  1224. bool i_header_written; /* D: GIF header written yet? */
  1225. #ifndef X_DISPLAY_MISSING
  1226. /* data members specific to X Drawable Plotters and X Plotters */
  1227. Display *x_dpy; /* X display */
  1228. Visual *x_visual; /* X visual */
  1229. Drawable x_drawable1; /* an X drawable (e.g. a pixmap) */
  1230. Drawable x_drawable2; /* an X drawable (e.g. a window) */
  1231. Drawable x_drawable3; /* graphics buffer, if double buffering */
  1232. int x_double_buffering; /* double buffering type (if any) */
  1233. long int x_max_polyline_len; /* limit on polyline len (X display-specific)*/
  1234. plXFontRecord *x_fontlist; /* D: head of list of retrieved X fonts */
  1235. plColorRecord *x_colorlist; /* D: head of list of retrieved X color cells*/
  1236. Colormap x_cmap; /* D: colormap */
  1237. int x_cmap_type; /* D: colormap type (orig./copied/bad) */
  1238. bool x_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  1239. bool x_bg_color_warning_issued; /* D: issued warning on bg color */
  1240. int x_paint_pixel_count; /* D: times point() is invoked to set a pixel*/
  1241. /* additional data members specific to X Plotters */
  1242. XtAppContext y_app_con; /* application context */
  1243. Widget y_toplevel; /* toplevel widget */
  1244. Widget y_canvas; /* Label widget */
  1245. Drawable y_drawable4; /* used for server-side double buffering */
  1246. bool y_auto_flush; /* do an XFlush() after each drawing op? */
  1247. bool y_vanish_on_delete; /* window(s) disappear on Plotter deletion? */
  1248. pid_t *y_pids; /* D: list of pids of forked-off processes */
  1249. int y_num_pids; /* D: number of pids in list */
  1250. int y_event_handler_count; /* D: times that event handler is invoked */
  1251. #endif /* not X_DISPLAY_MISSING */
  1252. #endif /* NOT_LIBPLOTTER */
  1253. #ifndef NOT_LIBPLOTTER
  1254. /* STATIC DATA MEMBERS, protected, which are defined in g_defplot.c. (In
  1255. libplot, these variables are globals, rather than static members of
  1256. the Plotter class. That's arranged by #ifdef's in libplot/extern.h.) */
  1257. /* These maintain a sparse array of pointers to Plotter instances. */
  1258. static Plotter **_plotters; /* D: sparse array of Plotter instances */
  1259. static int _plotters_len; /* D: length of sparse array */
  1260. /* This stores the global Plotter parameters used by the old,
  1261. non-thread-safe C++ binding (the user specifies them with
  1262. Plotter::parampl). */
  1263. static PlotterParams *_old_api_global_plotter_params;
  1264. #endif /* not NOT_LIBPLOTTER */
  1265. /* PLOTTER PROTECTED FUNCTIONS. In libplotter they're declared here, as
  1266. protected members of the base Plotter class. (In libplot they're
  1267. declared in libplot/extern.h.) Since they're protected, derived
  1268. classes can access them, i.e. call them. */
  1269. #ifndef NOT_LIBPLOTTER
  1270. void _flush_plotter_outstreams (void);
  1271. #endif /* NOT_LIBPLOTTER */
  1272. }
  1273. #ifdef NOT_LIBPLOTTER
  1274. Plotter;
  1275. #else /* not NOT_LIBPLOTTER */
  1276. ;
  1277. #endif /* not NOT_LIBPLOTTER */
  1278. #undef Q___
  1279. #ifndef NOT_LIBPLOTTER
  1280. /****************** DERIVED CLASSES (libplotter only) ********************/
  1281. /* The derived Plotter classes extensively override the generic Plotter
  1282. methods; the non-private ones, at least. Note that in libplot, this
  1283. overriding is accomplished differently: `derived' Plotter structs are
  1284. initialized to contain function pointers that may point to the
  1285. non-generic methods. The files ?_defplot.c contain the structures
  1286. which, in libplot, are used to initialize the function-pointer part of
  1287. the derived Plotter structs.
  1288. The device-specific data members which, in libplot, all appear in every
  1289. Plotter struct, are in libplotter spread among the derived Plotter
  1290. classes, as they logically should be. */
  1291. /* The MetaPlotter class, which produces GNU metafile output */
  1292. class MetaPlotter : public Plotter
  1293. {
  1294. private:
  1295. /* disallow copying and assignment */
  1296. MetaPlotter (const MetaPlotter& oldplotter);
  1297. MetaPlotter& operator= (const MetaPlotter& oldplotter);
  1298. public:
  1299. /* ctors (old-style, not thread-safe) */
  1300. MetaPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1301. MetaPlotter (FILE *outfile);
  1302. MetaPlotter (istream& in, ostream& out, ostream& err);
  1303. MetaPlotter (ostream& out);
  1304. MetaPlotter ();
  1305. /* ctors (new-style, thread-safe) */
  1306. MetaPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1307. MetaPlotter (FILE *outfile, PlotterParams &params);
  1308. MetaPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1309. MetaPlotter (ostream& out, PlotterParams &params);
  1310. MetaPlotter (PlotterParams &params);
  1311. /* dtor */
  1312. virtual ~MetaPlotter ();
  1313. protected:
  1314. /* protected methods (overriding Plotter methods) */
  1315. bool begin_page (void);
  1316. bool end_page (void);
  1317. bool erase_page (void);
  1318. bool paint_marker (int type, double size);
  1319. bool paint_paths (void);
  1320. bool path_is_flushable (void);
  1321. void paint_text_string_with_escapes (const unsigned char *s, int h_just, int v_just);
  1322. void initialize (void);
  1323. void maybe_prepaint_segments (int prev_num_segments);
  1324. void paint_path (void);
  1325. void paint_point (void);
  1326. void terminate (void);
  1327. /* MetaPlotter-specific internal functions */
  1328. void _m_emit_integer (int x);
  1329. void _m_emit_float (double x);
  1330. void _m_emit_op_code (int c);
  1331. void _m_emit_string (const char *s);
  1332. void _m_emit_terminator (void);
  1333. void _m_paint_path_internal (const plPath *path);
  1334. void _m_set_attributes (unsigned int mask);
  1335. /* MetaPlotter-specific data members */
  1336. /* 0. parameters */
  1337. bool meta_portable_output; /* portable, not binary output format? */
  1338. /* 1. dynamic attributes, general */
  1339. plPoint meta_pos; /* graphics cursor position */
  1340. bool meta_position_is_unknown; /* position is unknown? */
  1341. double meta_m_user_to_ndc[6]; /* user->NDC transformation matrix */
  1342. /* 2. dynamic attributes, path-related */
  1343. int meta_fill_rule_type; /* one of PL_FILL_*, determined by fill rule */
  1344. int meta_line_type; /* one of L_*, determined by line mode */
  1345. bool meta_points_are_connected; /* if not set, path displayed as points */
  1346. int meta_cap_type; /* one of PL_CAP_*, determined by cap mode */
  1347. int meta_join_type; /* one of PL_JOIN_*, determined by join mode */
  1348. double meta_miter_limit; /* miter limit for line joins */
  1349. double meta_line_width; /* width of lines in user coordinates */
  1350. bool meta_line_width_is_default; /* line width is default value? */
  1351. const double *meta_dash_array; /* array of dash on/off lengths(nonnegative)*/
  1352. int meta_dash_array_len; /* length of same */
  1353. double meta_dash_offset; /* offset distance into dash array (`phase') */
  1354. bool meta_dash_array_in_effect; /* dash array should override line mode? */
  1355. int meta_pen_type; /* pen type (0 = no pen, 1 = pen) */
  1356. int meta_fill_type; /* fill type (0 = no fill, 1 = fill, ...) */
  1357. int meta_orientation; /* orientation of circles etc.(1=c'clockwise)*/
  1358. /* 3. dynamic attributes, text-related */
  1359. const char *meta_font_name; /* font name */
  1360. double meta_font_size; /* font size in user coordinates */
  1361. bool meta_font_size_is_default; /* font size is Plotter default? */
  1362. double meta_text_rotation; /* degrees counterclockwise, for labels */
  1363. /* 4. dynamic color attributes (fgcolor and fillcolor are path-related;
  1364. fgcolor affects other primitives too) */
  1365. plColor meta_fgcolor; /* foreground color, i.e., pen color */
  1366. plColor meta_fillcolor_base; /* fill color */
  1367. plColor meta_bgcolor; /* background color for graphics display */
  1368. };
  1369. /* The BitmapPlotter class, from which PNMPlotter and PNGPlotter are derived */
  1370. class BitmapPlotter : public Plotter
  1371. {
  1372. private:
  1373. /* disallow copying and assignment */
  1374. BitmapPlotter (const BitmapPlotter& oldplotter);
  1375. BitmapPlotter& operator= (const BitmapPlotter& oldplotter);
  1376. public:
  1377. /* ctors (old-style, not thread-safe) */
  1378. BitmapPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1379. BitmapPlotter (FILE *outfile);
  1380. BitmapPlotter (istream& in, ostream& out, ostream& err);
  1381. BitmapPlotter (ostream& out);
  1382. BitmapPlotter ();
  1383. /* ctors (new-style, thread-safe) */
  1384. BitmapPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1385. BitmapPlotter (FILE *outfile, PlotterParams &params);
  1386. BitmapPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1387. BitmapPlotter (ostream& out, PlotterParams &params);
  1388. BitmapPlotter (PlotterParams &params);
  1389. /* dtor */
  1390. virtual ~BitmapPlotter ();
  1391. protected:
  1392. /* protected methods (overriding Plotter methods) */
  1393. bool begin_page (void);
  1394. bool erase_page (void);
  1395. bool end_page (void);
  1396. void paint_point (void);
  1397. void initialize (void);
  1398. void terminate (void);
  1399. void paint_path (void);
  1400. bool paint_paths (void);
  1401. /* internal functions that are overridden in derived classes (crocks) */
  1402. virtual int _maybe_output_image (void);
  1403. /* BitmapPlotter-specific internal functions */
  1404. void _b_delete_image (void);
  1405. void _b_draw_elliptic_arc (plPoint p0, plPoint p1, plPoint pc);
  1406. void _b_draw_elliptic_arc_2 (plPoint p0, plPoint p1, plPoint pc);
  1407. void _b_draw_elliptic_arc_internal (int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange);
  1408. void _b_new_image (void);
  1409. /* BitmapPlotter-specific data members */
  1410. void * b_arc_cache_data; /* pointer to cache (used by miPolyArc_r) */
  1411. int b_xn, b_yn; /* bitmap dimensions */
  1412. void * b_painted_set; /* D: libxmi's canvas (a (miPaintedSet *)) */
  1413. void * b_canvas; /* D: libxmi's canvas (a (miCanvas *)) */
  1414. };
  1415. /* The TekPlotter class, which produces Tektronix output */
  1416. class TekPlotter : public Plotter
  1417. {
  1418. private:
  1419. /* disallow copying and assignment */
  1420. TekPlotter (const TekPlotter& oldplotter);
  1421. TekPlotter& operator= (const TekPlotter& oldplotter);
  1422. public:
  1423. /* ctors (old-style, not thread-safe) */
  1424. TekPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1425. TekPlotter (FILE *outfile);
  1426. TekPlotter (istream& in, ostream& out, ostream& err);
  1427. TekPlotter (ostream& out);
  1428. TekPlotter ();
  1429. /* ctors (new-style, thread-safe) */
  1430. TekPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1431. TekPlotter (FILE *outfile, PlotterParams &params);
  1432. TekPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1433. TekPlotter (ostream& out, PlotterParams &params);
  1434. TekPlotter (PlotterParams &params);
  1435. /* dtor */
  1436. virtual ~TekPlotter ();
  1437. protected:
  1438. /* protected methods (overriding Plotter methods) */
  1439. bool begin_page (void);
  1440. bool erase_page (void);
  1441. bool end_page (void);
  1442. bool path_is_flushable (void);
  1443. void paint_point (void);
  1444. void initialize (void);
  1445. void terminate (void);
  1446. void maybe_prepaint_segments (int prev_num_segments);
  1447. /* TekPlotter-specific internal functions */
  1448. void _t_set_attributes (void);
  1449. void _t_set_bg_color (void);
  1450. void _t_set_pen_color (void);
  1451. void _t_tek_mode (int newmode);
  1452. void _t_tek_move (int xx, int yy);
  1453. void _t_tek_vector (int xx, int yy);
  1454. void _t_tek_vector_compressed (int xx, int yy, int oldxx, int oldyy, bool force);
  1455. /* TekPlotter-specific data members */
  1456. int tek_display_type; /* which sort of Tektronix? (one of TEK_DPY_*) */
  1457. int tek_mode; /* D: one of TEK_MODE_* */
  1458. int tek_line_type; /* D: one of PL_L_* */
  1459. bool tek_mode_is_unknown; /* D: tek mode unknown? */
  1460. bool tek_line_type_is_unknown; /* D: tek line type unknown? */
  1461. int tek_kermit_fgcolor; /* D: kermit's foreground color */
  1462. int tek_kermit_bgcolor; /* D: kermit's background color */
  1463. bool tek_position_is_unknown; /* D: cursor position is unknown? */
  1464. plIntPoint tek_pos; /* D: Tektronix cursor position */
  1465. };
  1466. /* The ReGISPlotter class, which produces ReGIS output */
  1467. class ReGISPlotter : public Plotter
  1468. {
  1469. private:
  1470. /* disallow copying and assignment */
  1471. ReGISPlotter (const ReGISPlotter& oldplotter);
  1472. ReGISPlotter& operator= (const ReGISPlotter& oldplotter);
  1473. public:
  1474. /* ctors (old-style, not thread-safe) */
  1475. ReGISPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1476. ReGISPlotter (FILE *outfile);
  1477. ReGISPlotter (istream& in, ostream& out, ostream& err);
  1478. ReGISPlotter (ostream& out);
  1479. ReGISPlotter ();
  1480. /* ctors (new-style, thread-safe) */
  1481. ReGISPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1482. ReGISPlotter (FILE *outfile, PlotterParams &params);
  1483. ReGISPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1484. ReGISPlotter (ostream& out, PlotterParams &params);
  1485. ReGISPlotter (PlotterParams &params);
  1486. /* dtor */
  1487. virtual ~ReGISPlotter ();
  1488. protected:
  1489. /* protected methods (overriding Plotter methods) */
  1490. bool begin_page (void);
  1491. bool erase_page (void);
  1492. bool end_page (void);
  1493. void paint_point (void);
  1494. bool path_is_flushable (void);
  1495. void initialize (void);
  1496. void terminate (void);
  1497. void maybe_prepaint_segments (int prev_num_segments);
  1498. void paint_path (void);
  1499. bool paint_paths (void);
  1500. /* ReGISPlotter-specific internal functions */
  1501. void _r_set_attributes (void);
  1502. void _r_set_bg_color (void);
  1503. void _r_set_fill_color (void);
  1504. void _r_set_pen_color (void);
  1505. void _r_regis_move (int xx, int yy);
  1506. /* ReGISPlotter-specific data members */
  1507. plIntPoint regis_pos; /* D: ReGIS graphics cursor position */
  1508. bool regis_position_is_unknown; /* D: graphics cursor position is unknown? */
  1509. int regis_line_type; /* D: native ReGIS line type */
  1510. bool regis_line_type_is_unknown; /* D: ReGIS line type is unknown? */
  1511. int regis_fgcolor; /* D: ReGIS foreground color, in range 0..7 */
  1512. int regis_bgcolor; /* D: ReGIS background color, in range 0..7 */
  1513. bool regis_fgcolor_is_unknown; /* D: foreground color unknown? */
  1514. bool regis_bgcolor_is_unknown; /* D: background color unknown? */
  1515. };
  1516. /* The HPGLPlotter class, which produces HP-GL or HP-GL/2 output */
  1517. class HPGLPlotter : public Plotter
  1518. {
  1519. private:
  1520. /* disallow copying and assignment */
  1521. HPGLPlotter (const HPGLPlotter& oldplotter);
  1522. HPGLPlotter& operator= (const HPGLPlotter& oldplotter);
  1523. public:
  1524. /* ctors (old-style, not thread-safe) */
  1525. HPGLPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1526. HPGLPlotter (FILE *outfile);
  1527. HPGLPlotter (istream& in, ostream& out, ostream& err);
  1528. HPGLPlotter (ostream& out);
  1529. HPGLPlotter ();
  1530. /* ctors (new-style, thread-safe) */
  1531. HPGLPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1532. HPGLPlotter (FILE *outfile, PlotterParams &params);
  1533. HPGLPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1534. HPGLPlotter (ostream& out, PlotterParams &params);
  1535. HPGLPlotter (PlotterParams &params);
  1536. /* dtor */
  1537. virtual ~HPGLPlotter ();
  1538. protected:
  1539. /* protected methods (overriding Plotter methods, overridden in
  1540. PCLPlotter class */
  1541. void initialize (void);
  1542. void terminate (void);
  1543. /* protected methods (overriding Plotter methods) */
  1544. bool begin_page (void);
  1545. bool erase_page (void);
  1546. bool end_page (void);
  1547. void paint_point (void);
  1548. void paint_path (void);
  1549. bool paint_paths (void);
  1550. double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1551. /* internal functions that are overridden in the PCLPlotter class */
  1552. virtual void _maybe_switch_to_hpgl (void);
  1553. virtual void _maybe_switch_from_hpgl (void);
  1554. /* other HPGLPlotter-specific internal functions */
  1555. bool _h_hpgl2_maybe_update_font (void);
  1556. bool _h_hpgl_maybe_update_font (void);
  1557. bool _h_parse_pen_string (const char *pen_s);
  1558. int _h_hpgl_pseudocolor (int red, int green, int blue, bool restrict_white);
  1559. void _h_set_attributes (void);
  1560. void _h_set_fill_color (bool force_pen_color);
  1561. void _h_set_font (void);
  1562. void _h_set_pen_color (int hpgl_object_type);
  1563. void _h_set_position (void);
  1564. void _h_hpgl_shaded_pseudocolor (int red, int green, int blue, int *pen, double *shading);
  1565. void _h_set_hpgl_fill_type (int fill_type, double option1, double option2);
  1566. void _h_set_hpgl_pen_type (int pen_type, double option1, double option2);
  1567. void _h_set_hpgl_pen (int pen);
  1568. /* HPGLPlotter-specific data members */
  1569. int hpgl_version; /* version: 0=HP-GL, 1=HP7550A, 2=HP-GL/2 */
  1570. int hpgl_rotation; /* rotation angle (0, 90, 180, or 270) */
  1571. double hpgl_plot_length; /* plot length (for HP-GL/2 roll plotters) */
  1572. plPoint hpgl_p1; /* scaling point P1 in native HP-GL coors */
  1573. plPoint hpgl_p2; /* scaling point P2 in native HP-GL coors */
  1574. bool hpgl_have_screened_vectors; /* can shade pen marks? (HP-GL/2 only) */
  1575. bool hpgl_have_char_fill; /* can shade char interiors? (HP-GL/2 only) */
  1576. bool hpgl_can_assign_colors; /* can assign pen colors? (HP-GL/2 only) */
  1577. bool hpgl_use_opaque_mode; /* pen marks sh'd be opaque? (HP-GL/2 only) */
  1578. plColor hpgl_pen_color[HPGL2_MAX_NUM_PENS]; /* D: color array for pens */
  1579. int hpgl_pen_defined[HPGL2_MAX_NUM_PENS];/*D:0=none,1=soft-defd,2=hard-defd*/
  1580. int hpgl_pen; /* D: number of currently selected pen */
  1581. int hpgl_free_pen; /* D: pen to be assigned a color next */
  1582. bool hpgl_bad_pen; /* D: bad pen (advisory, see h_color.c) */
  1583. bool hpgl_pendown; /* D: pen down rather than up? */
  1584. double hpgl_pen_width; /* D: pen width(frac of diag dist betw P1,P2)*/
  1585. int hpgl_line_type; /* D: line type(HP-GL numbering,solid = -100)*/
  1586. int hpgl_cap_style; /* D: cap style for lines (HP-GL/2 numbering)*/
  1587. int hpgl_join_style; /* D: join style for lines(HP-GL/2 numbering)*/
  1588. double hpgl_miter_limit; /* D: miterlimit for line joins(HP-GL/2 only)*/
  1589. int hpgl_pen_type; /* D: sv type (e.g. HPGL_PEN_{SOLID|SHADED}) */
  1590. double hpgl_pen_option1; /* D: used for some screened vector types */
  1591. double hpgl_pen_option2; /* D: used for some screened vector types */
  1592. int hpgl_fill_type; /* D: fill type (one of FILL_SOLID_UNI etc.) */
  1593. double hpgl_fill_option1; /* D: used for some fill types */
  1594. double hpgl_fill_option2; /* D: used for some fill types */
  1595. int hpgl_char_rendering_type; /* D: character rendering type (fill/edge) */
  1596. int hpgl_symbol_set; /* D: encoding, 14=ISO-Latin-1 (HP-GL/2 only)*/
  1597. int hpgl_spacing; /* D: fontspacing,0=fixed,1=not(HP-GL/2 only)*/
  1598. int hpgl_posture; /* D: posture,0=uprite,1=italic(HP-GL/2 only)*/
  1599. int hpgl_stroke_weight; /* D: weight,0=normal,3=bold,..(HP-GL/2only)*/
  1600. int hpgl_pcl_typeface; /* D: typeface, see g_fontdb.c (HP-GL/2) */
  1601. int hpgl_charset_lower; /* D: HP lower-half charset no. (pre-HP-GL/2)*/
  1602. int hpgl_charset_upper; /* D: HP upper-half charset no. (pre-HP-GL/2)*/
  1603. double hpgl_rel_char_height; /* D: char ht., % of p2y-p1y (HP-GL/2 only) */
  1604. double hpgl_rel_char_width; /* D: char width, % of p2x-p1x (HP-GL/2 only)*/
  1605. double hpgl_rel_label_rise; /* D: label rise, % of p2y-p1y (HP-GL/2 only)*/
  1606. double hpgl_rel_label_run; /* D: label run, % of p2x-p1x (HP-GL/2 only) */
  1607. double hpgl_tan_char_slant; /* D: tan of character slant (HP-GL/2 only)*/
  1608. bool hpgl_position_is_unknown; /* D: HP-GL[/2] cursor position is unknown? */
  1609. plIntPoint hpgl_pos; /* D: cursor position (integer HP-GL coors) */
  1610. };
  1611. /* The PCLPlotter class, which produces PCL 5 output */
  1612. class PCLPlotter : public HPGLPlotter
  1613. {
  1614. private:
  1615. /* disallow copying and assignment */
  1616. PCLPlotter (const PCLPlotter& oldplotter);
  1617. PCLPlotter& operator= (const PCLPlotter& oldplotter);
  1618. public:
  1619. /* ctors (old-style, not thread-safe) */
  1620. PCLPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1621. PCLPlotter (FILE *outfile);
  1622. PCLPlotter (istream& in, ostream& out, ostream& err);
  1623. PCLPlotter (ostream& out);
  1624. PCLPlotter ();
  1625. /* ctors (new-style, thread-safe) */
  1626. PCLPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1627. PCLPlotter (FILE *outfile, PlotterParams &params);
  1628. PCLPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1629. PCLPlotter (ostream& out, PlotterParams &params);
  1630. PCLPlotter (PlotterParams &params);
  1631. /* dtor */
  1632. virtual ~PCLPlotter ();
  1633. protected:
  1634. /* protected methods (overriding HPGLPlotter methods) */
  1635. void initialize (void);
  1636. void terminate (void);
  1637. /* internal functions that override HPGLPlotter internal functions */
  1638. void _maybe_switch_to_hpgl (void);
  1639. void _maybe_switch_from_hpgl (void);
  1640. };
  1641. /* The FigPlotter class, which produces Fig-format output for xfig */
  1642. class FigPlotter : public Plotter
  1643. {
  1644. private:
  1645. /* disallow copying and assignment */
  1646. FigPlotter (const FigPlotter& oldplotter);
  1647. FigPlotter& operator= (const FigPlotter& oldplotter);
  1648. public:
  1649. /* ctors (old-style, not thread-safe) */
  1650. FigPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1651. FigPlotter (FILE *outfile);
  1652. FigPlotter (istream& in, ostream& out, ostream& err);
  1653. FigPlotter (ostream& out);
  1654. FigPlotter ();
  1655. /* ctors (new-style, thread-safe) */
  1656. FigPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1657. FigPlotter (FILE *outfile, PlotterParams &params);
  1658. FigPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1659. FigPlotter (ostream& out, PlotterParams &params);
  1660. FigPlotter (PlotterParams &params);
  1661. /* dtor */
  1662. virtual ~FigPlotter ();
  1663. protected:
  1664. /* protected methods (overriding Plotter methods) */
  1665. bool begin_page (void);
  1666. bool erase_page (void);
  1667. bool end_page (void);
  1668. void paint_point (void);
  1669. void initialize (void);
  1670. void terminate (void);
  1671. void paint_path (void);
  1672. bool paint_paths (void);
  1673. double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1674. bool retrieve_font (void);
  1675. /* FigPlotter-specific internal functions */
  1676. int _f_fig_color (int red, int green, int blue);
  1677. void _f_compute_line_style (int *style, double *spacing);
  1678. void _f_draw_arc_internal (double xc, double yc, double x0, double y0, double x1, double y1);
  1679. void _f_draw_box_internal (plPoint p0, plPoint p1);
  1680. void _f_draw_ellipse_internal (double x, double y, double rx, double ry, double angle, int subtype);
  1681. void _f_set_fill_color (void);
  1682. void _f_set_pen_color (void);
  1683. /* FigPlotter-specific data members */
  1684. int fig_drawing_depth; /* D: fig's curr value for `depth' attribute */
  1685. int fig_num_usercolors; /* D: number of colors currently defined */
  1686. long int fig_usercolors[FIG_MAX_NUM_USER_COLORS]; /* D: colors we've def'd */
  1687. bool fig_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  1688. };
  1689. /* The CGMPlotter class, which produces CGM (Computer Graphics Metafile)
  1690. output */
  1691. class CGMPlotter : public Plotter
  1692. {
  1693. private:
  1694. /* disallow copying and assignment */
  1695. CGMPlotter (const CGMPlotter& oldplotter);
  1696. CGMPlotter& operator= (const CGMPlotter& oldplotter);
  1697. public:
  1698. /* ctors (old-style, not thread-safe) */
  1699. CGMPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1700. CGMPlotter (FILE *outfile);
  1701. CGMPlotter (istream& in, ostream& out, ostream& err);
  1702. CGMPlotter (ostream& out);
  1703. CGMPlotter ();
  1704. /* ctors (new-style, thread-safe) */
  1705. CGMPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1706. CGMPlotter (FILE *outfile, PlotterParams &params);
  1707. CGMPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1708. CGMPlotter (ostream& out, PlotterParams &params);
  1709. CGMPlotter (PlotterParams &params);
  1710. /* dtor */
  1711. virtual ~CGMPlotter ();
  1712. protected:
  1713. /* protected methods (overriding Plotter methods) */
  1714. bool begin_page (void);
  1715. bool erase_page (void);
  1716. bool end_page (void);
  1717. void paint_point (void);
  1718. void initialize (void);
  1719. void terminate (void);
  1720. void paint_path (void);
  1721. bool paint_marker (int type, double size);
  1722. bool paint_paths (void);
  1723. double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1724. /* internal functions */
  1725. void _c_set_attributes (int cgm_object_type);
  1726. void _c_set_bg_color (void);
  1727. void _c_set_fill_color (int cgm_object_type);
  1728. void _c_set_pen_color (int cgm_object_type);
  1729. /* CGMPlotter-specific data members */
  1730. int cgm_encoding; /* CGM_ENCODING_{BINARY,CHARACTER,CLEAR_TEXT}*/
  1731. int cgm_max_version; /* upper bound on CGM version number */
  1732. int cgm_version; /* D: CGM version for file (1, 2, 3, or 4) */
  1733. int cgm_profile; /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1734. int cgm_need_color; /* D: non-monochrome? */
  1735. int cgm_page_version; /* D: CGM version for current page */
  1736. int cgm_page_profile; /* D: CGM_PROFILE_{WEB,MODEL,NONE} */
  1737. bool cgm_page_need_color; /* D: current page is non-monochrome? */
  1738. plColor cgm_line_color; /* D: line pen color (24-bit or 48-bit RGB) */
  1739. plColor cgm_edge_color; /* D: edge pen color (24-bit or 48-bit RGB) */
  1740. plColor cgm_fillcolor; /* D: fill color (24-bit or 48-bit RGB) */
  1741. plColor cgm_marker_color; /* D: marker pen color (24-bit or 48-bit RGB)*/
  1742. plColor cgm_text_color; /* D: text pen color (24-bit or 48-bit RGB) */
  1743. plColor cgm_bgcolor; /* D: background color (24-bit or 48-bit RGB)*/
  1744. bool cgm_bgcolor_suppressed; /* D: background color suppressed? */
  1745. int cgm_line_type; /* D: one of CGM_L_{SOLID, etc.} */
  1746. double cgm_dash_offset; /* D: offset into dash array (`phase') */
  1747. int cgm_join_style; /* D: join style for lines (CGM numbering)*/
  1748. int cgm_cap_style; /* D: cap style for lines (CGM numbering)*/
  1749. int cgm_dash_cap_style; /* D: dash cap style for lines(CGM numbering)*/
  1750. int cgm_line_width; /* D: line width in CGM coordinates */
  1751. int cgm_interior_style; /* D: one of CGM_INT_STYLE_{EMPTY, etc.} */
  1752. int cgm_edge_type; /* D: one of CGM_L_{SOLID, etc.} */
  1753. double cgm_edge_dash_offset; /* D: offset into dash array (`phase') */
  1754. int cgm_edge_join_style; /* D: join style for edges (CGM numbering)*/
  1755. int cgm_edge_cap_style; /* D: cap style for edges (CGM numbering)*/
  1756. int cgm_edge_dash_cap_style; /* D: dash cap style for edges(CGM numbering)*/
  1757. int cgm_edge_width; /* D: edge width in CGM coordinates */
  1758. bool cgm_edge_is_visible; /* D: filled regions have edges? */
  1759. double cgm_miter_limit; /* D: CGM's miter limit */
  1760. int cgm_marker_type; /* D: one of CGM_M_{DOT, etc.} */
  1761. int cgm_marker_size; /* D: marker size in CGM coordinates */
  1762. int cgm_char_height; /* D: character height */
  1763. int cgm_char_base_vector_x; /* D: character base vector */
  1764. int cgm_char_base_vector_y;
  1765. int cgm_char_up_vector_x; /* D: character up vector */
  1766. int cgm_char_up_vector_y;
  1767. int cgm_horizontal_text_alignment; /* D: one of CGM_ALIGN_* */
  1768. int cgm_vertical_text_alignment; /* D: one of CGM_ALIGN_* */
  1769. int cgm_font_id; /* D: PS font in range 0..34 */
  1770. int cgm_charset_lower; /* D: lower charset (index into defined list)*/
  1771. int cgm_charset_upper; /* D: upper charset (index into defined list)*/
  1772. int cgm_restricted_text_type; /* D: one of CGM_RESTRICTED_TEXT_TYPE_* */
  1773. };
  1774. /* The PSPlotter class, which produces idraw-editable PS output */
  1775. class PSPlotter : public Plotter
  1776. {
  1777. private:
  1778. /* disallow copying and assignment */
  1779. PSPlotter (const PSPlotter& oldplotter);
  1780. PSPlotter& operator= (const PSPlotter& oldplotter);
  1781. public:
  1782. /* ctors (old-style, not thread-safe) */
  1783. PSPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1784. PSPlotter (FILE *outfile);
  1785. PSPlotter (istream& in, ostream& out, ostream& err);
  1786. PSPlotter (ostream& out);
  1787. PSPlotter ();
  1788. /* ctors (new-style, thread-safe) */
  1789. PSPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1790. PSPlotter (FILE *outfile, PlotterParams &params);
  1791. PSPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1792. PSPlotter (ostream& out, PlotterParams &params);
  1793. PSPlotter (PlotterParams &params);
  1794. /* dtor */
  1795. virtual ~PSPlotter ();
  1796. protected:
  1797. /* protected methods (overriding Plotter methods) */
  1798. bool begin_page (void);
  1799. bool erase_page (void);
  1800. bool end_page (void);
  1801. void paint_point (void);
  1802. void initialize (void);
  1803. void terminate (void);
  1804. void paint_path (void);
  1805. bool paint_paths (void);
  1806. double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1807. /* PSPlotter-specific internal functions */
  1808. double _p_emit_common_attributes (void);
  1809. void _p_compute_idraw_bgcolor (void);
  1810. void _p_fellipse_internal (double x, double y, double rx, double ry, double angle, bool circlep);
  1811. void _p_set_fill_color (void);
  1812. void _p_set_pen_color (void);
  1813. };
  1814. /* The AIPlotter class, which produces output editable by Adobe Illustrator */
  1815. class AIPlotter : public Plotter
  1816. {
  1817. private:
  1818. /* disallow copying and assignment */
  1819. AIPlotter (const AIPlotter& oldplotter);
  1820. AIPlotter& operator= (const AIPlotter& oldplotter);
  1821. public:
  1822. /* ctors (old-style, not thread-safe) */
  1823. AIPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1824. AIPlotter (FILE *outfile);
  1825. AIPlotter (istream& in, ostream& out, ostream& err);
  1826. AIPlotter (ostream& out);
  1827. AIPlotter ();
  1828. /* ctors (new-style, thread-safe) */
  1829. AIPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1830. AIPlotter (FILE *outfile, PlotterParams &params);
  1831. AIPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1832. AIPlotter (ostream& out, PlotterParams &params);
  1833. AIPlotter (PlotterParams &params);
  1834. /* dtor */
  1835. virtual ~AIPlotter ();
  1836. protected:
  1837. /* protected methods (overriding Plotter methods) */
  1838. bool begin_page (void);
  1839. bool erase_page (void);
  1840. bool end_page (void);
  1841. void paint_point (void);
  1842. void initialize (void);
  1843. void terminate (void);
  1844. void paint_path (void);
  1845. bool paint_paths (void);
  1846. double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1847. /* internal functions */
  1848. void _a_set_attributes (void);
  1849. void _a_set_fill_color (bool force_pen_color);
  1850. void _a_set_pen_color (void);
  1851. /* AIPlotter-specific data members */
  1852. int ai_version; /* AI3 or AI5? */
  1853. double ai_pen_cyan; /* D: pen color (in CMYK space) */
  1854. double ai_pen_magenta;
  1855. double ai_pen_yellow;
  1856. double ai_pen_black;
  1857. double ai_fill_cyan; /* D: fill color (in CMYK space) */
  1858. double ai_fill_magenta;
  1859. double ai_fill_yellow;
  1860. double ai_fill_black;
  1861. bool ai_cyan_used; /* D: C, M, Y, K have been used? */
  1862. bool ai_magenta_used;
  1863. bool ai_yellow_used;
  1864. bool ai_black_used;
  1865. int ai_cap_style; /* D: cap style for lines (PS numbering)*/
  1866. int ai_join_style; /* D: join style for lines(PS numbering)*/
  1867. double ai_miter_limit; /* D: miterlimit for line joins */
  1868. int ai_line_type; /* D: one of PL_L_* */
  1869. double ai_line_width; /* D: line width in printer's points */
  1870. int ai_fill_rule_type; /* D: fill rule (AI_FILL_{ODD|NONZERO}_WINDING) */
  1871. };
  1872. /* The SVGPlotter class, which produces SVG output for the Web */
  1873. class SVGPlotter : public Plotter
  1874. {
  1875. private:
  1876. /* disallow copying and assignment */
  1877. SVGPlotter (const SVGPlotter& oldplotter);
  1878. SVGPlotter& operator= (const SVGPlotter& oldplotter);
  1879. public:
  1880. /* ctors (old-style, not thread-safe) */
  1881. SVGPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1882. SVGPlotter (FILE *outfile);
  1883. SVGPlotter (istream& in, ostream& out, ostream& err);
  1884. SVGPlotter (ostream& out);
  1885. SVGPlotter ();
  1886. /* ctors (new-style, thread-safe) */
  1887. SVGPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1888. SVGPlotter (FILE *outfile, PlotterParams &params);
  1889. SVGPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1890. SVGPlotter (ostream& out, PlotterParams &params);
  1891. SVGPlotter (PlotterParams &params);
  1892. /* dtor */
  1893. virtual ~SVGPlotter ();
  1894. protected:
  1895. /* protected methods (overriding Plotter methods) */
  1896. bool begin_page (void);
  1897. bool erase_page (void);
  1898. bool end_page (void);
  1899. void paint_point (void);
  1900. void initialize (void);
  1901. void terminate (void);
  1902. void paint_path (void);
  1903. bool paint_paths (void);
  1904. double paint_text_string (const unsigned char *s, int h_just, int v_just);
  1905. /* SVGPlotter-specific internal functions */
  1906. void _s_set_matrix (const double m_local[6]);
  1907. /* SVGPlotter-specific data members */
  1908. double s_matrix[6]; /* D: default transformation matrix for page */
  1909. bool s_matrix_is_unknown; /* D: matrix has not yet been set? */
  1910. bool s_matrix_is_bogus; /* D: matrix has been set, but is bogus? */
  1911. plColor s_bgcolor; /* D: background color (RGB) */
  1912. bool s_bgcolor_suppressed; /* D: background color suppressed? */
  1913. };
  1914. /* The PNMPlotter class, which produces PBM/PGM/PPM output; derived from
  1915. the BitmapPlotter class */
  1916. class PNMPlotter : public BitmapPlotter
  1917. {
  1918. private:
  1919. /* disallow copying and assignment */
  1920. PNMPlotter (const PNMPlotter& oldplotter);
  1921. PNMPlotter& operator= (const PNMPlotter& oldplotter);
  1922. public:
  1923. /* ctors (old-style, not thread-safe) */
  1924. PNMPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1925. PNMPlotter (FILE *outfile);
  1926. PNMPlotter (istream& in, ostream& out, ostream& err);
  1927. PNMPlotter (ostream& out);
  1928. PNMPlotter ();
  1929. /* ctors (new-style, thread-safe) */
  1930. PNMPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1931. PNMPlotter (FILE *outfile, PlotterParams &params);
  1932. PNMPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1933. PNMPlotter (ostream& out, PlotterParams &params);
  1934. PNMPlotter (PlotterParams &params);
  1935. /* dtor */
  1936. virtual ~PNMPlotter ();
  1937. protected:
  1938. /* protected methods (overriding BitmapPlotter methods) */
  1939. void initialize (void);
  1940. void terminate (void);
  1941. /* internal functions that override BitmapPlotter functions (crocks) */
  1942. int _maybe_output_image (void);
  1943. /* other PNMPlotter-specific internal functions */
  1944. void _n_write_pnm (void);
  1945. void _n_write_pbm (void);
  1946. void _n_write_pgm (void);
  1947. void _n_write_ppm (void);
  1948. /* PNMPlotter-specific data members */
  1949. bool n_portable_output; /* portable, not binary output format? */
  1950. };
  1951. #ifdef INCLUDE_PNG_SUPPORT
  1952. /* The PNGPlotter class, which produces PNG output; derived from the
  1953. BitmapPlotter class */
  1954. class PNGPlotter : public BitmapPlotter
  1955. {
  1956. private:
  1957. /* disallow copying and assignment */
  1958. PNGPlotter (const PNGPlotter& oldplotter);
  1959. PNGPlotter& operator= (const PNGPlotter& oldplotter);
  1960. public:
  1961. /* ctors (old-style, not thread-safe) */
  1962. PNGPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1963. PNGPlotter (FILE *outfile);
  1964. PNGPlotter (istream& in, ostream& out, ostream& err);
  1965. PNGPlotter (ostream& out);
  1966. PNGPlotter ();
  1967. /* ctors (new-style, thread-safe) */
  1968. PNGPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  1969. PNGPlotter (FILE *outfile, PlotterParams &params);
  1970. PNGPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  1971. PNGPlotter (ostream& out, PlotterParams &params);
  1972. PNGPlotter (PlotterParams &params);
  1973. /* dtor */
  1974. virtual ~PNGPlotter ();
  1975. protected:
  1976. /* protected methods (overriding BitmapPlotter methods) */
  1977. void initialize (void);
  1978. void terminate (void);
  1979. /* internal functions that override BitmapPlotter functions (crocks) */
  1980. int _maybe_output_image (void);
  1981. /* PNGPlotter-specific data members */
  1982. bool z_interlace; /* interlaced PNG? */
  1983. bool z_transparent; /* transparent PNG? */
  1984. plColor z_transparent_color; /* if so, transparent color (24-bit RGB) */
  1985. };
  1986. #endif /* INCLUDE_PNG_SUPPORT */
  1987. /* The GIFPlotter class, which produces pseudo-GIF output */
  1988. class GIFPlotter : public Plotter
  1989. {
  1990. private:
  1991. /* disallow copying and assignment */
  1992. GIFPlotter (const GIFPlotter& oldplotter);
  1993. GIFPlotter& operator= (const GIFPlotter& oldplotter);
  1994. public:
  1995. /* ctors (old-style, not thread-safe) */
  1996. GIFPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  1997. GIFPlotter (FILE *outfile);
  1998. GIFPlotter (istream& in, ostream& out, ostream& err);
  1999. GIFPlotter (ostream& out);
  2000. GIFPlotter ();
  2001. /* ctors (new-style, thread-safe) */
  2002. GIFPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  2003. GIFPlotter (FILE *outfile, PlotterParams &params);
  2004. GIFPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  2005. GIFPlotter (ostream& out, PlotterParams &params);
  2006. GIFPlotter (PlotterParams &params);
  2007. /* dtor */
  2008. virtual ~GIFPlotter ();
  2009. protected:
  2010. /* protected methods (overriding Plotter methods) */
  2011. bool begin_page (void);
  2012. bool erase_page (void);
  2013. bool end_page (void);
  2014. void paint_point (void);
  2015. void initialize (void);
  2016. void terminate (void);
  2017. void paint_path (void);
  2018. bool paint_paths (void);
  2019. /* GIFPlotter-specific internal functions */
  2020. unsigned char _i_new_color_index (int red, int green, int blue);
  2021. int _i_scan_pixel (void);
  2022. void _i_delete_image (void);
  2023. void _i_draw_elliptic_arc (plPoint p0, plPoint p1, plPoint pc);
  2024. void _i_draw_elliptic_arc_2 (plPoint p0, plPoint p1, plPoint pc);
  2025. void _i_draw_elliptic_arc_internal (int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange);
  2026. void _i_new_image (void);
  2027. void _i_set_bg_color (void);
  2028. void _i_set_fill_color (void);
  2029. void _i_set_pen_color (void);
  2030. void _i_start_scan (void);
  2031. void _i_write_gif_header (void);
  2032. void _i_write_gif_image (void);
  2033. void _i_write_gif_trailer (void);
  2034. void _i_write_short_int (unsigned int i);
  2035. /* GIFPlotter-specific data members */
  2036. int i_xn, i_yn; /* bitmap dimensions */
  2037. int i_num_pixels; /* total pixels (used by scanner) */
  2038. bool i_animation; /* animated (multi-image) GIF? */
  2039. int i_iterations; /* number of times GIF should be looped */
  2040. int i_delay; /* delay after image, in 1/100 sec units */
  2041. bool i_interlace; /* interlaced GIF? */
  2042. bool i_transparent; /* transparent GIF? */
  2043. plColor i_transparent_color; /* if so, transparent color (24-bit RGB) */
  2044. void * i_arc_cache_data; /* pointer to cache (used by miPolyArc_r) */
  2045. int i_transparent_index; /* D: transparent color index (if any) */
  2046. void * i_painted_set; /* D: libxmi's canvas (a (miPaintedSet *)) */
  2047. void * i_canvas; /* D: libxmi's canvas (a (miCanvas *)) */
  2048. plColor i_colormap[256]; /* D: frame colormap (containing 24-bit RGBs)*/
  2049. int i_num_color_indices; /* D: number of color indices allocated */
  2050. bool i_frame_nonempty; /* D: something drawn in current frame? */
  2051. int i_bit_depth; /* D: bit depth (ceil(log2(num_indices))) */
  2052. int i_pixels_scanned; /* D: number that scanner has scanned */
  2053. int i_pass; /* D: scanner pass (used if interlacing) */
  2054. plIntPoint i_hot; /* D: scanner hot spot */
  2055. plColor i_global_colormap[256]; /* D: colormap for first frame (stashed) */
  2056. int i_num_global_color_indices;/* D: number of indices in global colormap */
  2057. bool i_header_written; /* D: GIF header written yet? */
  2058. };
  2059. #ifndef X_DISPLAY_MISSING
  2060. /* The XDrawablePlotter class, which draws into one or two X drawables */
  2061. class XDrawablePlotter : public Plotter
  2062. {
  2063. private:
  2064. /* disallow copying and assignment */
  2065. XDrawablePlotter (const XDrawablePlotter& oldplotter);
  2066. XDrawablePlotter& operator= (const XDrawablePlotter& oldplotter);
  2067. public:
  2068. /* ctors (old-style, not thread-safe) */
  2069. XDrawablePlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2070. XDrawablePlotter (FILE *outfile);
  2071. XDrawablePlotter (istream& in, ostream& out, ostream& err);
  2072. XDrawablePlotter (ostream& out);
  2073. XDrawablePlotter ();
  2074. /* ctors (new-style, thread-safe) */
  2075. XDrawablePlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  2076. XDrawablePlotter (FILE *outfile, PlotterParams &params);
  2077. XDrawablePlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  2078. XDrawablePlotter (ostream& out, PlotterParams &params);
  2079. XDrawablePlotter (PlotterParams &params);
  2080. /* dtor */
  2081. virtual ~XDrawablePlotter ();
  2082. protected:
  2083. /* protected methods (overriding Plotter methods) */
  2084. bool begin_page (void);
  2085. bool erase_page (void);
  2086. bool end_page (void);
  2087. bool flush_output (void);
  2088. bool path_is_flushable (void);
  2089. void push_state (void);
  2090. void pop_state (void);
  2091. void paint_point (void);
  2092. void initialize (void);
  2093. void terminate (void);
  2094. void paint_path (void);
  2095. bool paint_paths (void);
  2096. void maybe_prepaint_segments (int prev_num_segments);
  2097. double paint_text_string (const unsigned char *s, int h_just, int v_just);
  2098. double get_text_width (const unsigned char *s);
  2099. bool retrieve_font (void);
  2100. /* internal functions that are overridden in the XPlotter class (crocks) */
  2101. virtual void _maybe_get_new_colormap (void);
  2102. virtual void _maybe_handle_x_events (void);
  2103. /* other XDrawablePlotter-specific internal functions */
  2104. bool _x_retrieve_color (XColor *rgb_ptr);
  2105. bool _x_select_font_carefully (const char *name, const unsigned char *s, bool subsetting);
  2106. bool _x_select_xlfd_font_carefully (const char *x_name, const char *x_name_alt, const char *x_name_alt2, const char *x_name_alt3);
  2107. void _x_add_gcs_to_first_drawing_state (void);
  2108. void _x_delete_gcs_from_first_drawing_state (void);
  2109. void _x_draw_elliptic_arc (plPoint p0, plPoint p1, plPoint pc);
  2110. void _x_draw_elliptic_arc_2 (plPoint p0, plPoint p1, plPoint pc);
  2111. void _x_draw_elliptic_arc_internal (int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange);
  2112. void _x_set_attributes (int x_gc_type);
  2113. void _x_set_bg_color (void);
  2114. void _x_set_fill_color (void);
  2115. void _x_set_pen_color (void);
  2116. /* XDrawablePlotter-specific data members */
  2117. Display *x_dpy; /* X display */
  2118. Visual *x_visual; /* X visual */
  2119. Drawable x_drawable1; /* an X drawable (e.g. a pixmap) */
  2120. Drawable x_drawable2; /* an X drawable (e.g. a window) */
  2121. Drawable x_drawable3; /* graphics buffer, if double buffering */
  2122. int x_double_buffering; /* double buffering type (if any) */
  2123. long int x_max_polyline_len; /* limit on polyline len (X display-specific)*/
  2124. plXFontRecord *x_fontlist; /* D: head of list of retrieved X fonts */
  2125. plColorRecord *x_colorlist; /* D: head of list of retrieved X color cells*/
  2126. Colormap x_cmap; /* D: colormap (dynamic only for XPlotters) */
  2127. int x_cmap_type; /* D: colormap type (orig./copied/bad) */
  2128. bool x_colormap_warning_issued; /* D: issued warning on colormap filling up*/
  2129. bool x_bg_color_warning_issued; /* D: issued warning on bg color */
  2130. int x_paint_pixel_count; /* D: times point() is invoked to set a pixel*/
  2131. };
  2132. /* The XPlotter class, which pops up a window and draws into it */
  2133. class XPlotter : public XDrawablePlotter
  2134. {
  2135. private:
  2136. /* disallow copying and assignment */
  2137. XPlotter (const XPlotter& oldplotter);
  2138. XPlotter& operator= (const XPlotter& oldplotter);
  2139. public:
  2140. /* ctors (old-style, not thread-safe) */
  2141. XPlotter (FILE *infile, FILE *outfile, FILE *errfile);
  2142. XPlotter (FILE *outfile);
  2143. XPlotter (istream& in, ostream& out, ostream& err);
  2144. XPlotter (ostream& out);
  2145. XPlotter ();
  2146. /* ctors (new-style, thread-safe) */
  2147. XPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &params);
  2148. XPlotter (FILE *outfile, PlotterParams &params);
  2149. XPlotter (istream& in, ostream& out, ostream& err, PlotterParams &params);
  2150. XPlotter (ostream& out, PlotterParams &params);
  2151. XPlotter (PlotterParams &params);
  2152. /* dtor */
  2153. virtual ~XPlotter ();
  2154. protected:
  2155. /* protected methods (overriding XDrawablePlotter methods) */
  2156. bool begin_page (void);
  2157. bool erase_page (void);
  2158. bool end_page (void);
  2159. void initialize (void);
  2160. void terminate (void);
  2161. /* internal functions that override XDrawablePlotter functions (crocks) */
  2162. void _maybe_get_new_colormap (void);
  2163. void _maybe_handle_x_events (void);
  2164. /* other XPlotter-specific internal functions */
  2165. void _y_set_data_for_quitting (void);
  2166. /* XPlotter-specific data members (non-static) */
  2167. XtAppContext y_app_con; /* application context */
  2168. Widget y_toplevel; /* toplevel widget */
  2169. Widget y_canvas; /* Label widget */
  2170. Drawable y_drawable4; /* used for server-side double buffering */
  2171. bool y_auto_flush; /* do an XFlush() after each drawing op? */
  2172. bool y_vanish_on_delete; /* window(s) disappear on Plotter deletion? */
  2173. pid_t *y_pids; /* D: list of pids of forked-off processes */
  2174. int y_num_pids; /* D: number of pids in list */
  2175. int y_event_handler_count; /* D: times that event handler is invoked */
  2176. /* XPlotter-specific data members (static) */
  2177. static XPlotter **_xplotters; /* D: sparse array of XPlotter instances */
  2178. static int _xplotters_len; /* D: length of sparse array */
  2179. };
  2180. #endif /* not X_DISPLAY_MISSING */
  2181. #endif /* not NOT_LIBPLOTTER */
  2182. /***********************************************************************/
  2183. /* Useful definitions, included in both plot.h and plotter.h. */
  2184. #ifndef _PL_LIBPLOT_USEFUL_DEFS
  2185. #define _PL_LIBPLOT_USEFUL_DEFS 1
  2186. /* Symbol types for the marker() function, extending over the range 0..31.
  2187. (1 through 5 are the same as in the GKS [Graphical Kernel System].)
  2188. These are now defined as enums rather than ints. Cast them to ints if
  2189. necessary. */
  2190. enum
  2191. { M_NONE, M_DOT, M_PLUS, M_ASTERISK, M_CIRCLE, M_CROSS,
  2192. M_SQUARE, M_TRIANGLE, M_DIAMOND, M_STAR, M_INVERTED_TRIANGLE,
  2193. M_STARBURST, M_FANCY_PLUS, M_FANCY_CROSS, M_FANCY_SQUARE,
  2194. M_FANCY_DIAMOND, M_FILLED_CIRCLE, M_FILLED_SQUARE, M_FILLED_TRIANGLE,
  2195. M_FILLED_DIAMOND, M_FILLED_INVERTED_TRIANGLE, M_FILLED_FANCY_SQUARE,
  2196. M_FILLED_FANCY_DIAMOND, M_HALF_FILLED_CIRCLE, M_HALF_FILLED_SQUARE,
  2197. M_HALF_FILLED_TRIANGLE, M_HALF_FILLED_DIAMOND,
  2198. M_HALF_FILLED_INVERTED_TRIANGLE, M_HALF_FILLED_FANCY_SQUARE,
  2199. M_HALF_FILLED_FANCY_DIAMOND, M_OCTAGON, M_FILLED_OCTAGON
  2200. };
  2201. /* ONE-BYTE OPERATION CODES FOR GNU METAFILE FORMAT. These are now defined
  2202. as enums rather than ints. Cast them to ints if necessary.
  2203. There are 85 currently recognized op codes. The first 10 date back to
  2204. Unix plot(5) format. */
  2205. enum
  2206. {
  2207. /* 10 op codes for primitive graphics operations, as in Unix plot(5) format. */
  2208. O_ARC = 'a',
  2209. O_CIRCLE = 'c',
  2210. O_CONT = 'n',
  2211. O_ERASE = 'e',
  2212. O_LABEL = 't',
  2213. O_LINEMOD = 'f',
  2214. O_LINE = 'l',
  2215. O_MOVE = 'm',
  2216. O_POINT = 'p',
  2217. O_SPACE = 's',
  2218. /* 42 op codes that are GNU extensions */
  2219. O_ALABEL = 'T',
  2220. O_ARCREL = 'A',
  2221. O_BEZIER2 = 'q',
  2222. O_BEZIER2REL = 'r',
  2223. O_BEZIER3 = 'y',
  2224. O_BEZIER3REL = 'z',
  2225. O_BGCOLOR = '~',
  2226. O_BOX = 'B', /* not an op code in Unix plot(5) */
  2227. O_BOXREL = 'H',
  2228. O_CAPMOD = 'K',
  2229. O_CIRCLEREL = 'G',
  2230. O_CLOSEPATH = 'k',
  2231. O_CLOSEPL = 'x', /* not an op code in Unix plot(5) */
  2232. O_COMMENT = '#',
  2233. O_CONTREL = 'N',
  2234. O_ELLARC = '?',
  2235. O_ELLARCREL = '/',
  2236. O_ELLIPSE = '+',
  2237. O_ELLIPSEREL = '=',
  2238. O_ENDPATH = 'E',
  2239. O_ENDSUBPATH = ']',
  2240. O_FILLTYPE = 'L',
  2241. O_FILLCOLOR = 'D',
  2242. O_FILLMOD = 'g',
  2243. O_FONTNAME = 'F',
  2244. O_FONTSIZE = 'S',
  2245. O_JOINMOD = 'J',
  2246. O_LINEDASH = 'd',
  2247. O_LINEREL = 'I',
  2248. O_LINEWIDTH = 'W',
  2249. O_MARKER = 'Y',
  2250. O_MARKERREL = 'Z',
  2251. O_MOVEREL = 'M',
  2252. O_OPENPL = 'o', /* not an op code in Unix plot(5) */
  2253. O_ORIENTATION = 'b',
  2254. O_PENCOLOR = '-',
  2255. O_PENTYPE = 'h',
  2256. O_POINTREL = 'P',
  2257. O_RESTORESTATE= 'O',
  2258. O_SAVESTATE = 'U',
  2259. O_SPACE2 = ':',
  2260. O_TEXTANGLE = 'R',
  2261. /* 30 floating point counterparts to many of the above. They are not even
  2262. slightly mnemonic. */
  2263. O_FARC = '1',
  2264. O_FARCREL = '2',
  2265. O_FBEZIER2 = '`',
  2266. O_FBEZIER2REL = '\'',
  2267. O_FBEZIER3 = ',',
  2268. O_FBEZIER3REL = '.',
  2269. O_FBOX = '3',
  2270. O_FBOXREL = '4',
  2271. O_FCIRCLE = '5',
  2272. O_FCIRCLEREL = '6',
  2273. O_FCONT = ')',
  2274. O_FCONTREL = '_',
  2275. O_FELLARC = '}',
  2276. O_FELLARCREL = '|',
  2277. O_FELLIPSE = '{',
  2278. O_FELLIPSEREL = '[',
  2279. O_FFONTSIZE = '7',
  2280. O_FLINE = '8',
  2281. O_FLINEDASH = 'w',
  2282. O_FLINEREL = '9',
  2283. O_FLINEWIDTH = '0',
  2284. O_FMARKER = '!',
  2285. O_FMARKERREL = '@',
  2286. O_FMOVE = '$',
  2287. O_FMOVEREL = '%',
  2288. O_FPOINT = '^',
  2289. O_FPOINTREL = '&',
  2290. O_FSPACE = '*',
  2291. O_FSPACE2 = ';',
  2292. O_FTEXTANGLE = '(',
  2293. /* 3 op codes for floating point operations with no integer counterpart */
  2294. O_FCONCAT = '\\',
  2295. O_FMITERLIMIT = 'i',
  2296. O_FSETMATRIX = 'j'
  2297. };
  2298. #endif /* not _PL_LIBPLOT_USEFUL_DEFS */
  2299. /***********************************************************************/
  2300. #endif /* not _PLOTTER_H_ */