Back to index

texmacs  1.0.7.15
pdf_renderer.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : pdf_renderer.hpp
00004 * DESCRIPTION: Renderer for printing pdf graphics
00005 * COPYRIGHT  : (C) 2010  Massimiliano Gubinelli
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef PDF_RENDERER_H
00013 #define PDF_RENDERER_H
00014 
00015 #include "renderer.hpp"
00016 #include "gui.hpp"
00017 #include "hashmap.hpp"
00018 #include "url.hpp"
00019 
00020 class pdf_renderer_rep: public renderer_rep {
00021   static const int default_dpi= 72;
00022 
00023   url       pdf_file_name;
00024   int       dpi;
00025   int       nr_pages;
00026   string    page_type;
00027   bool      landscape;
00028   double    paper_w;
00029   double    paper_h;
00030 
00031   color     fg, bg;
00032   SI        lw;
00033   string    cfn;
00034   int       cfid;
00035 
00036   double p;
00037   double width, height;
00038 
00039   
00040   hashmap<string,int> tex_fonts;
00041   hashmap<string,int> image_resources;
00042   
00043   double to_x (SI x);
00044   double to_y (SI y);
00045   void init_page_size ();
00046   void select_color (color c);
00047   void select_line_width (SI w);
00048   void compile_glyph (scheme_tree t);
00049 
00050 public:
00051   pdf_renderer_rep (url pdf_file_name, int dpi, int nr_pages,
00052               string ptype, bool landsc, double paper_w, double paper_h);
00053   ~pdf_renderer_rep ();
00054   bool is_printer ();
00055   void next_page ();
00056 
00057   void  set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore= false);
00058   color get_color ();
00059   color get_background ();
00060   void  set_color (color c);
00061   void  set_background (color c);
00062   void  draw (int char_code, font_glyphs fn, SI x, SI y);
00063   void  set_line_style (SI w, int type=0, bool round=true);
00064   void  line (SI x1, SI y1, SI x2, SI y2);
00065   void  lines (array<SI> x, array<SI> y);
00066   void  clear (SI x1, SI y1, SI x2, SI y2);
00067   void  fill (SI x1, SI y1, SI x2, SI y2);
00068   void  arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00069   void  fill_arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00070   void  polygon (array<SI> x, array<SI> y, bool convex=true);
00071   void  xpm (url file_name, SI x, SI y);
00072   void  image (url u, SI w, SI h, SI x, SI y,
00073               double cx1, double cy1, double cx2, double cy2,
00074                int alpha);
00075 
00076   void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y);
00077   void new_shadow (renderer& ren);
00078   void delete_shadow (renderer& ren);
00079   void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00080   void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00081   void apply_shadow (SI x1, SI y1, SI x2, SI y2);
00082 };
00083 
00084 renderer pdf_renderer (url pdf_file_name, int dpi, int nr_pages= 1,
00085                 string page_type= "a4", bool landscape= false,
00086                 double paper_w= 21.0, double paper_h= 29.7);
00087 
00088 #endif // ifdef PDF_RENDERER_H