123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- #include "sys-defines.h"
- #include "extern.h"
- #include "xmi.h"
- static bool parse_bitmap_size (const char *bitmap_size_s, int *width, int *height);
- #ifndef LIBPLOTTER
- const Plotter _pl_i_default_plotter =
- {
-
- _pl_i_initialize, _pl_i_terminate,
-
- _pl_i_begin_page, _pl_i_erase_page, _pl_i_end_page,
-
- _pl_g_push_state, _pl_g_pop_state,
-
- _pl_i_paint_path, _pl_i_paint_paths, _pl_g_path_is_flushable, _pl_g_maybe_prepaint_segments,
-
- _pl_g_paint_marker, _pl_i_paint_point,
-
- _pl_g_paint_text_string_with_escapes, _pl_g_paint_text_string,
- _pl_g_get_text_width,
-
- _pl_g_retrieve_font,
-
- _pl_g_flush_output,
-
- _pl_g_warning,
- _pl_g_error,
- };
- #endif
- void
- _pl_i_initialize (S___(Plotter *_plotter))
- {
- #ifndef LIBPLOTTER
-
- _pl_g_initialize (S___(_plotter));
- #endif
-
- #ifndef LIBPLOTTER
-
- _plotter->data->type = PL_GIF;
- #endif
-
- _plotter->data->output_model = PL_OUTPUT_VIA_CUSTOM_ROUTINES;
-
- _plotter->data->have_wide_lines = 1;
- _plotter->data->have_dash_array = 1;
- _plotter->data->have_solid_fill = 1;
- _plotter->data->have_odd_winding_fill = 1;
- _plotter->data->have_nonzero_winding_fill = 1;
- _plotter->data->have_settable_bg = 1;
- _plotter->data->have_escaped_string_support = 0;
- _plotter->data->have_ps_fonts = 0;
- _plotter->data->have_pcl_fonts = 0;
- _plotter->data->have_stick_fonts = 0;
- _plotter->data->have_extra_stick_fonts = 0;
- _plotter->data->have_other_fonts = 0;
-
- _plotter->data->default_font_type = PL_F_HERSHEY;
- _plotter->data->pcl_before_ps = false;
- _plotter->data->have_horizontal_justification = false;
- _plotter->data->have_vertical_justification = false;
- _plotter->data->issue_font_warning = true;
-
- _plotter->data->have_mixed_paths = false;
- _plotter->data->allowed_arc_scaling = AS_AXES_PRESERVED;
- _plotter->data->allowed_ellarc_scaling = AS_AXES_PRESERVED;
- _plotter->data->allowed_quad_scaling = AS_NONE;
- _plotter->data->allowed_cubic_scaling = AS_NONE;
- _plotter->data->allowed_box_scaling = AS_NONE;
- _plotter->data->allowed_circle_scaling = AS_NONE;
- _plotter->data->allowed_ellipse_scaling = AS_AXES_PRESERVED;
-
- _plotter->data->display_model_type = (int)DISP_MODEL_VIRTUAL;
- _plotter->data->display_coors_type = (int)DISP_DEVICE_COORS_INTEGER_LIBXMI;
- _plotter->data->flipped_y = true;
- _plotter->data->imin = 0;
- _plotter->data->imax = 569;
- _plotter->data->jmin = 569;
- _plotter->data->jmax = 0;
- _plotter->data->xmin = 0.0;
- _plotter->data->xmax = 0.0;
- _plotter->data->ymin = 0.0;
- _plotter->data->ymax = 0.0;
- _plotter->data->page_data = (plPageData *)NULL;
-
-
- _plotter->i_xn = _plotter->data->imax + 1;
- _plotter->i_yn = _plotter->data->jmin + 1;
- _plotter->i_num_pixels = (_plotter->i_xn) * (_plotter->i_yn);
- _plotter->i_animation = true;
- _plotter->i_iterations = 0;
- _plotter->i_delay = 0;
- _plotter->i_interlace = false;
- _plotter->i_transparent = false;
- _plotter->i_transparent_color.red = 255;
- _plotter->i_transparent_color.green = 255;
- _plotter->i_transparent_color.blue = 255;
- _plotter->i_transparent_index = 0;
-
- _plotter->i_arc_cache_data = (void *)miNewEllipseCache ();
-
- _plotter->i_painted_set = (void *)NULL;
- _plotter->i_canvas = (void *)NULL;
-
- _plotter->i_num_color_indices = 0;
- _plotter->i_bit_depth = 0;
- _plotter->i_frame_nonempty = false;
- _plotter->i_pixels_scanned = 0;
- _plotter->i_pass = 0;
- _plotter->i_hot.x = 0;
- _plotter->i_hot.y = 0;
-
- _plotter->i_header_written = false;
-
-
- {
- const char *transparent_name_s;
- plColor color;
- transparent_name_s = (const char *)_get_plot_param (_plotter->data, "TRANSPARENT_COLOR");
- if (transparent_name_s
- && _string_to_color (transparent_name_s, &color, _plotter->data->color_name_cache))
-
- {
- _plotter->i_transparent = true;
- _plotter->i_transparent_color = color;
- }
- }
-
- {
- const char *interlace_s;
- interlace_s = (const char *)_get_plot_param (_plotter->data, "INTERLACE" );
- if (strcasecmp (interlace_s, "yes") == 0)
- _plotter->i_interlace = true;
- }
-
-
- {
- const char *animate_s;
- animate_s = (const char *)_get_plot_param (_plotter->data, "GIF_ANIMATION" );
- if (strcasecmp (animate_s, "no") == 0)
- _plotter->i_animation = false;
- }
-
-
- {
- const char *iteration_s;
- int num_iterations;
- iteration_s = (const char *)_get_plot_param (_plotter->data, "GIF_ITERATIONS" );
- if (sscanf (iteration_s, "%d", &num_iterations) > 0
- && num_iterations >= 0 && num_iterations <= 65535)
- _plotter->i_iterations = num_iterations;
- }
-
- {
- const char *delay_s;
- int delay;
- delay_s = (const char *)_get_plot_param (_plotter->data, "GIF_DELAY" );
- if (sscanf (delay_s, "%d", &delay) > 0
- && delay >= 0 && delay <= 65535)
- _plotter->i_delay = delay;
- }
-
- {
- const char *bitmap_size_s;
- int width = 1, height = 1;
-
- bitmap_size_s = (const char *)_get_plot_param (_plotter->data, "BITMAPSIZE");
- if (bitmap_size_s && parse_bitmap_size (bitmap_size_s, &width, &height)
-
- && width >= 1 && height >= 1
- && width <= 65535 && height <= 65535)
-
- {
- _plotter->data->imax = width - 1;
- _plotter->data->jmin = height - 1;
- _plotter->i_xn = width;
- _plotter->i_yn = height;
- _plotter->i_num_pixels = width * height;
- }
- }
-
- _compute_ndc_to_device_map (_plotter->data);
- }
- static bool
- parse_bitmap_size (const char *bitmap_size_s, int *width, int *height)
- {
- int local_width = 1, local_height = 1;
- if (bitmap_size_s
-
- && sscanf (bitmap_size_s, "%dx%d", &local_width, &local_height) == 2
- && local_width > 0 && local_height > 0)
- {
- *width = local_width;
- *height = local_height;
- return true;
- }
- else
- return false;
- }
- void
- _pl_i_terminate (S___(Plotter *_plotter))
- {
-
- miDeleteEllipseCache ((miEllipseCache *)_plotter->i_arc_cache_data);
- #ifndef LIBPLOTTER
-
- _pl_g_terminate (S___(_plotter));
- #endif
- }
- #ifdef LIBPLOTTER
- GIFPlotter::GIFPlotter (FILE *infile, FILE *outfile, FILE *errfile)
- :Plotter (infile, outfile, errfile)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (FILE *outfile)
- :Plotter (outfile)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (istream& in, ostream& out, ostream& err)
- : Plotter (in, out, err)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (ostream& out)
- : Plotter (out)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter ()
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (FILE *infile, FILE *outfile, FILE *errfile, PlotterParams ¶meters)
- :Plotter (infile, outfile, errfile, parameters)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (FILE *outfile, PlotterParams ¶meters)
- :Plotter (outfile, parameters)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (istream& in, ostream& out, ostream& err, PlotterParams ¶meters)
- : Plotter (in, out, err, parameters)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (ostream& out, PlotterParams ¶meters)
- : Plotter (out, parameters)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::GIFPlotter (PlotterParams ¶meters)
- : Plotter (parameters)
- {
- _pl_i_initialize ();
- }
- GIFPlotter::~GIFPlotter ()
- {
-
- if (_plotter->data->open)
- _API_closepl ();
- _pl_i_terminate ();
- }
- #endif
|