Modelib: PsFile.h Source File

Page principale | Hiérarchie des classes | Liste des composants | Liste des fichiers | Composants

# PsFile.h

    00001 #ifndef __PSFILE_H
    00002 #define __PSFILE_H
    00003
    00004 #include "Model.h"
    00005 #include <iostream>
    00006 #include <fstream>
    00007 #include <string>
    00008 #include <stdexcept>
    00009
    00016 class PSFile
    00017 {
    00018         std::string   nom;
    00019         std::ofstream psfile;
    00020
    00021         double hmin, hmax;
    00022         double vmin, vmax;
    00023         double xmin, xmax, xscale;
    00024         double ymin, ymax, yscale;
    00025
    00026         protected:
    00027
    00028         void aux_rectangle(
    00029     double xlo, double xhi,
    00030     double ylo, double yhi,
    00031     double gray,
    00032     char *op
    00033   );
    00034
    00035         void aux_polygon(
    00036     double x[], double y[],
    00037     int npoints,
    00038     double gray,
    00039     char *op
    00040   );
    00041
    00042         void aux_circle(
    00043     double xc, double yc, double radius,
    00044     double gray,
    00045     char *op
    00046   );
    00047
    00048         void aux_lune(
    00049     double xc, double yc, double radius, double tilt,
    00050     double gray,
    00051     char *op
    00052   );
    00053
    00054         void define_procs();
    00055         void define_caption_procs();
    00056
    00057         void save_scales(
    00058     double xmin, double xmax,
    00059     double ymin, double ymax,
    00060     double hmin, double hmax,
    00061     double vmin, double vmax
    00062   );
    00063
    00064         void setup_page_state( int xn, int yn);
    00065         void setup_caption_data();
    00066         void aux_end_page();
    00067
    00068         public:
    00069
    00070                 PSFile() {};
    00071                 PSFile(const std::string& _nom) : nom(_nom)
    00072                 {
    00073                         psfile.open(nom.c_str());
    00074                         if(!psfile.is_open())
    00075                          throw runtime_error("PSFile::PSFile() : I/O Error");
    00076                 begin_document ();
    00077                 begin_page(1,40,320,0,640, 20,300,750,750, 16 ,1);
    00078                 }
    00079
    00080                 ~PSFile()
    00081                 {
    00082                 end_page();
    00083                 end_document(1);
    00084                         psfile.close();
    00085                 }
    00086
    00087                 void close() {psfile.close();};
    00088
    00107                 void begin_figure (
    00108                 double xmin, double xmax,
    00109                 double ymin, double ymax,
    00110
    00111                 double hmin, double hmax,
    00112                 double vmin, double vmax,
    00113
    00114                 int xn, int yn
    00115         );
    00116
    00119                 void end_figure ();
    00120
    00134                 void begin_document ();
    00135
    00148                 void begin_page(
    00149                 int page,
    00150                 double xmin, double xmax,
    00151                 double ymin, double ymax,
    00152
    00153                     double hmin, double hmax,
    00154                 double vmin, double vmax,
    00155
    00156                 int xn, int yn
    00157                 );
    00158
    00161                 void end_page();
    00162
    00166                 void end_document (int npages);
    00167
    00171                 void begin_section (char *title);
    00172
    00176                 void end_section ();
    00177
    00182                 void set_pen (
    00183         double gray,
    00184         double width,
    00185         double dashlength,
    00186         double dashspace
    00187         );
    00188
    00192                 void draw_segment(
    00193         double xa, double ya,
    00194         double xb, double yb
    00195         );
    00196
    00200                 void draw_curve(
    00201         double xa, double ya,
    00202         double xb, double yb,
    00203         double xc, double yc,
    00204         double xd, double yd
    00205         );
    00206
    00210                 void draw_rectangle(
    00211         double xlo, double xhi,
    00212         double ylo, double yhi
    00213         );
    00214
    00218                 void fill_rectangle(
    00219         double xlo, double xhi,
    00220         double ylo, double yhi,
    00221         double gray
    00222         );
    00223
    00228                 void fill_and_draw_rectangle(
    00229         double xlo, double xhi,
    00230         double ylo, double yhi,
    00231         double gray
    00232         );
    00233
    00237                 void fill_circle(
    00238         double xc, double yc, double radius,
    00239         double gray
    00240         );
    00241
    00245                 void draw_circle(
    00246         double xc, double yc, double radius
    00247         );
    00248
    00253                 void fill_and_draw_circle(
    00254             double xc, double yc, double radius,
    00255             double gray
    00256           );
    00257
    00262                 void fill_and_draw_lune(
    00263         double xc, double yc, double radius, double tilt,
    00264         double gray
    00265         );
    00266
    00270                 void fill_polygon(
    00271         double x[], double y[],
    00272         int n,
    00273         double gray
    00274         );
    00275
    00280                 void draw_polygon(
    00281         double x[], double y[],
    00282                 int n
    00283         );
    00284
    00289                 void fill_and_draw_polygon(
    00290         double x[], double y[],
    00291         int n,
    00292         double gray
    00293         );
    00294
    00298                 void fill_triangle(
    00299         double xa, double ya,
    00300         double xb, double yb,
    00301         double xc, double yc,
    00302         double gray
    00303         );
    00304
    00309                 void fill_grid_cell(int xi, int yi, double gray);
    00310
    00315                 void draw_coord_line (char axis, double coord);
    00316
    00320                 void draw_grid_lines();
    00321
    00325         void set_label_font(char *font, float size);
    00326
    00334                 void put_label(
    00335         char *text,
    00336         double x, double y,
    00337         float xalign, float yalign
    00338         );
    00339
    00344                 void draw_frame ();
    00345
    00346
    00351                 void add_caption(char *txt);
    00352
    00353
    00360                 void put_text(char *text, char *newline);
    00361
    00365                 PSFile& operator<<(const std::string& str)
    00366                 {
    00367                         add_caption(const_cast<char*>(str.c_str()));
    00368                         return (*this);
    00369                 }
    00370
    00371                 PSFile& operator<<(const Model& m);
    00372 };
    00373
    00374 #endif