r_defplot.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 file defines the initialization for any ReGISPlotter object,
  16. including both private data and public methods. There is a one-to-one
  17. correspondence between public methods and user-callable functions in the
  18. C API. */
  19. /* Note that ReGIS displays are rectangular, and wider than they are high.
  20. In terms of integer ReGIS coordinates a ReGIS display is a
  21. [0..767]x[0..479] rectangle, and we choose our viewport to be the square
  22. [144..623]x[0..479]. I.e. we define it to be a square, occupying the
  23. entire height of the display, and centered on the display. */
  24. #include "sys-defines.h"
  25. #include "extern.h"
  26. #ifndef LIBPLOTTER
  27. /* In libplot, this is the initialization for the function-pointer part of
  28. a ReGISPlotter struct. */
  29. const Plotter _pl_r_default_plotter =
  30. {
  31. /* initialization (after creation) and termination (before deletion) */
  32. _pl_r_initialize, _pl_r_terminate,
  33. /* page manipulation */
  34. _pl_r_begin_page, _pl_r_erase_page, _pl_r_end_page,
  35. /* drawing state manipulation */
  36. _pl_g_push_state, _pl_g_pop_state,
  37. /* internal path-painting methods (endpath() is a wrapper for the first) */
  38. _pl_r_paint_path, _pl_r_paint_paths, _pl_r_path_is_flushable, _pl_r_maybe_prepaint_segments,
  39. /* internal methods for drawing of markers and points */
  40. _pl_g_paint_marker, _pl_r_paint_point,
  41. /* internal methods that plot strings in Hershey, non-Hershey fonts */
  42. _pl_g_paint_text_string_with_escapes, _pl_g_paint_text_string,
  43. _pl_g_get_text_width,
  44. /* private low-level `retrieve font' method */
  45. _pl_g_retrieve_font,
  46. /* `flush output' method, called only if Plotter handles its own output */
  47. _pl_g_flush_output,
  48. /* error handlers */
  49. _pl_g_warning,
  50. _pl_g_error,
  51. };
  52. #endif /* not LIBPLOTTER */
  53. /* The private `initialize' method, which is invoked when a Plotter is
  54. created. It is used for such things as initializing capability flags
  55. from the values of class variables, allocating storage, etc. When this
  56. is invoked, _plotter points to the Plotter that has just been
  57. created. */
  58. void
  59. _pl_r_initialize (S___(Plotter *_plotter))
  60. {
  61. #ifndef LIBPLOTTER
  62. /* in libplot, manually invoke superclass initialization method */
  63. _pl_g_initialize (S___(_plotter));
  64. #endif
  65. /* override superclass initializations, as necessary */
  66. #ifndef LIBPLOTTER
  67. /* tag field, differs in derived classes */
  68. _plotter->data->type = PL_REGIS;
  69. #endif
  70. /* output model */
  71. _plotter->data->output_model = PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME;
  72. /* user-queryable capabilities: 0/1/2 = no/yes/maybe */
  73. _plotter->data->have_wide_lines = 0;
  74. _plotter->data->have_dash_array = 0;
  75. _plotter->data->have_solid_fill = 1;
  76. _plotter->data->have_odd_winding_fill = 1;
  77. _plotter->data->have_nonzero_winding_fill = 0;
  78. _plotter->data->have_settable_bg = 1;
  79. _plotter->data->have_escaped_string_support = 0;
  80. _plotter->data->have_ps_fonts = 0;
  81. _plotter->data->have_pcl_fonts = 0;
  82. _plotter->data->have_stick_fonts = 0;
  83. _plotter->data->have_extra_stick_fonts = 0;
  84. _plotter->data->have_other_fonts = 0;
  85. /* text and font-related parameters (internal, not queryable by user);
  86. note that we don't set kern_stick_fonts, because it was set by the
  87. superclass initialization (and it's irrelevant for this Plotter type,
  88. anyway) */
  89. _plotter->data->default_font_type = PL_F_HERSHEY;
  90. _plotter->data->pcl_before_ps = false;
  91. _plotter->data->have_horizontal_justification = false;
  92. _plotter->data->have_vertical_justification = false;
  93. _plotter->data->issue_font_warning = true;
  94. /* path-related parameters (also internal) */
  95. _plotter->data->max_unfilled_path_length = PL_MAX_UNFILLED_PATH_LENGTH;
  96. _plotter->data->have_mixed_paths = false;
  97. _plotter->data->allowed_arc_scaling = AS_NONE;
  98. _plotter->data->allowed_ellarc_scaling = AS_NONE;
  99. _plotter->data->allowed_quad_scaling = AS_NONE;
  100. _plotter->data->allowed_cubic_scaling = AS_NONE;
  101. _plotter->data->allowed_box_scaling = AS_NONE;
  102. _plotter->data->allowed_circle_scaling = AS_UNIFORM;
  103. _plotter->data->allowed_ellipse_scaling = AS_NONE;
  104. /* dimensions */
  105. _plotter->data->display_model_type = (int)DISP_MODEL_VIRTUAL;
  106. _plotter->data->display_coors_type = (int)DISP_DEVICE_COORS_INTEGER_NON_LIBXMI;
  107. _plotter->data->flipped_y = true;
  108. _plotter->data->imin = 144;
  109. _plotter->data->imax = 623;
  110. _plotter->data->jmin = 479;
  111. _plotter->data->jmax = 0; /* flipped y */
  112. _plotter->data->xmin = 0.0;
  113. _plotter->data->xmax = 0.0;
  114. _plotter->data->ymin = 0.0;
  115. _plotter->data->ymax = 0.0;
  116. _plotter->data->page_data = (plPageData *)NULL;
  117. /* compute the NDC to device-frame affine map, set it in Plotter */
  118. _compute_ndc_to_device_map (_plotter->data);
  119. /* initialize data members specific to this derived class */
  120. _plotter->regis_pos.x = 0; /* dummy */
  121. _plotter->regis_pos.y = 0; /* dummy */
  122. _plotter->regis_position_is_unknown = true;
  123. _plotter->regis_line_type = PL_L_SOLID; /* dummy */
  124. _plotter->regis_line_type_is_unknown = true;
  125. _plotter->regis_fgcolor = 0; /* dummy */
  126. _plotter->regis_bgcolor = 0; /* dummy */
  127. _plotter->regis_fgcolor_is_unknown = true;
  128. _plotter->regis_bgcolor_is_unknown = true;
  129. /* initialize certain data members from device driver parameters */
  130. }
  131. /* The private `terminate' method, which is invoked when a Plotter is
  132. deleted, provided that it is non-NULL. It may do such things as write
  133. to an output stream from internal storage, deallocate storage, etc.
  134. When this is invoked, _plotter points to the Plotter that is about to be
  135. deleted. */
  136. void
  137. _pl_r_terminate (S___(Plotter *_plotter))
  138. {
  139. #ifndef LIBPLOTTER
  140. /* invoke generic method, e.g. to deallocate instance-specific copies
  141. of class variables */
  142. _pl_g_terminate (S___(_plotter));
  143. #endif
  144. }
  145. #ifdef LIBPLOTTER
  146. ReGISPlotter::ReGISPlotter (FILE *infile, FILE *outfile, FILE *errfile)
  147. :Plotter (infile, outfile, errfile)
  148. {
  149. _pl_r_initialize ();
  150. }
  151. ReGISPlotter::ReGISPlotter (FILE *outfile)
  152. :Plotter (outfile)
  153. {
  154. _pl_r_initialize ();
  155. }
  156. ReGISPlotter::ReGISPlotter (istream& in, ostream& out, ostream& err)
  157. : Plotter (in, out, err)
  158. {
  159. _pl_r_initialize ();
  160. }
  161. ReGISPlotter::ReGISPlotter (ostream& out)
  162. : Plotter (out)
  163. {
  164. _pl_r_initialize ();
  165. }
  166. ReGISPlotter::ReGISPlotter ()
  167. {
  168. _pl_r_initialize ();
  169. }
  170. ReGISPlotter::ReGISPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &parameters)
  171. :Plotter (infile, outfile, errfile, parameters)
  172. {
  173. _pl_r_initialize ();
  174. }
  175. ReGISPlotter::ReGISPlotter (FILE *outfile, PlotterParams &parameters)
  176. :Plotter (outfile, parameters)
  177. {
  178. _pl_r_initialize ();
  179. }
  180. ReGISPlotter::ReGISPlotter (istream& in, ostream& out, ostream& err, PlotterParams &parameters)
  181. : Plotter (in, out, err, parameters)
  182. {
  183. _pl_r_initialize ();
  184. }
  185. ReGISPlotter::ReGISPlotter (ostream& out, PlotterParams &parameters)
  186. : Plotter (out, parameters)
  187. {
  188. _pl_r_initialize ();
  189. }
  190. ReGISPlotter::ReGISPlotter (PlotterParams &parameters)
  191. : Plotter (parameters)
  192. {
  193. _pl_r_initialize ();
  194. }
  195. ReGISPlotter::~ReGISPlotter ()
  196. {
  197. /* if luser left the Plotter open, close it */
  198. if (_plotter->data->open)
  199. _API_closepl ();
  200. _pl_r_terminate ();
  201. }
  202. #endif