t_defplot.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 TekPlotter 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 Tektronix displays are rectangular, and wider than they are
  20. high: the aspect ratio is approximately 4:3. In terms of integer
  21. Tektronix coordinates the Tektronix display is a [0..4095]x[0..3119]
  22. rectangle, and we choose our viewport to be the square
  23. [488..3607]x[0..3119]. I.e. we define it to be a square, occupying the
  24. entire height of the display, and centered on the display. */
  25. #include "sys-defines.h"
  26. #include "extern.h"
  27. #ifndef LIBPLOTTER
  28. /* In libplot, this is the initialization for the function-pointer part of
  29. a TekPlotter struct. */
  30. const Plotter _pl_t_default_plotter =
  31. {
  32. /* initialization (after creation) and termination (before deletion) */
  33. _pl_t_initialize, _pl_t_terminate,
  34. /* page manipulation */
  35. _pl_t_begin_page, _pl_t_erase_page, _pl_t_end_page,
  36. /* drawing state manipulation */
  37. _pl_g_push_state, _pl_g_pop_state,
  38. /* internal path-painting methods (endpath() is a wrapper for the first) */
  39. _pl_g_paint_path, _pl_g_paint_paths, _pl_t_path_is_flushable, _pl_t_maybe_prepaint_segments,
  40. /* internal methods for drawing of markers and points */
  41. _pl_g_paint_marker, _pl_t_paint_point,
  42. /* internal methods that plot strings in Hershey, non-Hershey fonts */
  43. _pl_g_paint_text_string_with_escapes, _pl_g_paint_text_string,
  44. _pl_g_get_text_width,
  45. /* private low-level `retrieve font' method */
  46. _pl_g_retrieve_font,
  47. /* `flush output' method, called only if Plotter handles its own output */
  48. _pl_g_flush_output,
  49. /* error handlers */
  50. _pl_g_warning,
  51. _pl_g_error,
  52. };
  53. #endif /* not LIBPLOTTER */
  54. /* The private `initialize' method, which is invoked when a Plotter is
  55. created. It is used for such things as initializing capability flags
  56. from the values of class variables, allocating storage, etc. When this
  57. is invoked, _plotter points to the Plotter that has just been
  58. created. */
  59. void
  60. _pl_t_initialize (S___(Plotter *_plotter))
  61. {
  62. #ifndef LIBPLOTTER
  63. /* in libplot, manually invoke superclass initialization method */
  64. _pl_g_initialize (S___(_plotter));
  65. #endif
  66. /* override superclass initializations, as necessary */
  67. #ifndef LIBPLOTTER
  68. /* tag field, differs in derived classes */
  69. _plotter->data->type = PL_TEK;
  70. #endif
  71. /* output model */
  72. _plotter->data->output_model = PL_OUTPUT_VIA_CUSTOM_ROUTINES_IN_REAL_TIME;
  73. /* user-queryable capabilities: 0/1/2 = no/yes/maybe */
  74. _plotter->data->have_wide_lines = 0;
  75. _plotter->data->have_dash_array = 0;
  76. _plotter->data->have_solid_fill = 0;
  77. _plotter->data->have_odd_winding_fill = 1;
  78. _plotter->data->have_nonzero_winding_fill = 1;
  79. _plotter->data->have_settable_bg = 0;
  80. _plotter->data->have_escaped_string_support = 0;
  81. _plotter->data->have_ps_fonts = 0;
  82. _plotter->data->have_pcl_fonts = 0;
  83. _plotter->data->have_stick_fonts = 0;
  84. _plotter->data->have_extra_stick_fonts = 0;
  85. _plotter->data->have_other_fonts = 0;
  86. /* text and font-related parameters (internal, not queryable by user);
  87. note that we don't set kern_stick_fonts, because it was set by the
  88. superclass initialization (and it's irrelevant for this Plotter type,
  89. anyway) */
  90. _plotter->data->default_font_type = PL_F_HERSHEY;
  91. _plotter->data->pcl_before_ps = false;
  92. _plotter->data->have_horizontal_justification = false;
  93. _plotter->data->have_vertical_justification = false;
  94. _plotter->data->issue_font_warning = true;
  95. /* path-related parameters (also internal) */
  96. _plotter->data->max_unfilled_path_length = PL_MAX_UNFILLED_PATH_LENGTH;
  97. _plotter->data->have_mixed_paths = false;
  98. _plotter->data->allowed_arc_scaling = AS_NONE;
  99. _plotter->data->allowed_ellarc_scaling = AS_NONE;
  100. _plotter->data->allowed_quad_scaling = AS_NONE;
  101. _plotter->data->allowed_cubic_scaling = AS_NONE;
  102. _plotter->data->allowed_box_scaling = AS_NONE;
  103. _plotter->data->allowed_circle_scaling = AS_NONE;
  104. _plotter->data->allowed_ellipse_scaling = AS_NONE;
  105. /* dimensions */
  106. _plotter->data->display_model_type = (int)DISP_MODEL_VIRTUAL;
  107. _plotter->data->display_coors_type = (int)DISP_DEVICE_COORS_INTEGER_NON_LIBXMI;
  108. _plotter->data->flipped_y = false;
  109. _plotter->data->imin = 488;
  110. _plotter->data->imax = 3607;
  111. _plotter->data->jmin = 0;
  112. _plotter->data->jmax = 3119;
  113. _plotter->data->xmin = 0.0;
  114. _plotter->data->xmax = 0.0;
  115. _plotter->data->ymin = 0.0;
  116. _plotter->data->ymax = 0.0;
  117. _plotter->data->page_data = (plPageData *)NULL;
  118. /* compute the NDC to device-frame affine map, set it in Plotter */
  119. _compute_ndc_to_device_map (_plotter->data);
  120. /* initialize data members specific to this derived class */
  121. _plotter->tek_display_type = TEK_DPY_GENERIC;
  122. _plotter->tek_mode = TEK_MODE_ALPHA;
  123. _plotter->tek_line_type = PL_L_SOLID;
  124. _plotter->tek_mode_is_unknown = true;
  125. _plotter->tek_line_type_is_unknown = true;
  126. _plotter->tek_kermit_fgcolor = -1; /* nonsensical value; means `unknown' */
  127. _plotter->tek_kermit_bgcolor = -1; /* same */
  128. _plotter->tek_position_is_unknown = true;
  129. _plotter->tek_pos.x = 0;
  130. _plotter->tek_pos.y = 0;
  131. /* initialize certain data members from device driver parameters */
  132. /* determine Tek display type (xterm(1) / kermit(1) / generic Tektronix);
  133. there are so many possible termcap/terminfo names out there that we
  134. key only on an initial substring */
  135. {
  136. const char* term_type;
  137. term_type = (const char *)_get_plot_param (_plotter->data, "TERM");
  138. if (term_type != NULL)
  139. {
  140. if (strncmp (term_type, "xterm", 5) == 0
  141. || strncmp (term_type, "nxterm", 6) == 0
  142. || strncmp (term_type, "kterm", 5) == 0)
  143. _plotter->tek_display_type = TEK_DPY_XTERM;
  144. else if (strncmp (term_type, "ansi.sys", 8) == 0
  145. || strncmp (term_type, "nansi.sys", 9) == 0
  146. || strncmp (term_type, "ansisys", 7) == 0 /* undocumented */
  147. || strncmp (term_type, "kermit", 6) == 0)
  148. _plotter->tek_display_type = TEK_DPY_KERMIT;
  149. else
  150. _plotter->tek_display_type = TEK_DPY_GENERIC;
  151. }
  152. else
  153. _plotter->tek_display_type = TEK_DPY_GENERIC; /* default value */
  154. }
  155. }
  156. /* The private `terminate' method, which is invoked when a Plotter is
  157. deleted, provided that it is non-NULL. It may do such things as write
  158. to an output stream from internal storage, deallocate storage, etc.
  159. When this is invoked, _plotter points to the Plotter that is about to be
  160. deleted. */
  161. void
  162. _pl_t_terminate (S___(Plotter *_plotter))
  163. {
  164. #ifndef LIBPLOTTER
  165. /* in libplot, manually invoke superclass termination method */
  166. _pl_g_terminate (S___(_plotter));
  167. #endif
  168. }
  169. #ifdef LIBPLOTTER
  170. TekPlotter::TekPlotter (FILE *infile, FILE *outfile, FILE *errfile)
  171. :Plotter (infile, outfile, errfile)
  172. {
  173. _pl_t_initialize ();
  174. }
  175. TekPlotter::TekPlotter (FILE *outfile)
  176. :Plotter (outfile)
  177. {
  178. _pl_t_initialize ();
  179. }
  180. TekPlotter::TekPlotter (istream& in, ostream& out, ostream& err)
  181. : Plotter (in, out, err)
  182. {
  183. _pl_t_initialize ();
  184. }
  185. TekPlotter::TekPlotter (ostream& out)
  186. : Plotter (out)
  187. {
  188. _pl_t_initialize ();
  189. }
  190. TekPlotter::TekPlotter ()
  191. {
  192. _pl_t_initialize ();
  193. }
  194. TekPlotter::TekPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams &parameters)
  195. :Plotter (infile, outfile, errfile, parameters)
  196. {
  197. _pl_t_initialize ();
  198. }
  199. TekPlotter::TekPlotter (FILE *outfile, PlotterParams &parameters)
  200. :Plotter (outfile, parameters)
  201. {
  202. _pl_t_initialize ();
  203. }
  204. TekPlotter::TekPlotter (istream& in, ostream& out, ostream& err, PlotterParams &parameters)
  205. : Plotter (in, out, err, parameters)
  206. {
  207. _pl_t_initialize ();
  208. }
  209. TekPlotter::TekPlotter (ostream& out, PlotterParams &parameters)
  210. : Plotter (out, parameters)
  211. {
  212. _pl_t_initialize ();
  213. }
  214. TekPlotter::TekPlotter (PlotterParams &parameters)
  215. : Plotter (parameters)
  216. {
  217. _pl_t_initialize ();
  218. }
  219. TekPlotter::~TekPlotter ()
  220. {
  221. _pl_t_terminate ();
  222. }
  223. #endif