ccstruct/pageblk.h

Go to the documentation of this file.
00001 
00017 #ifndef           PAGEBLK_C
00018 #define           PAGEBLK_C
00019 
00020 #include "elst.h"
00021 #include "txtregn.h"
00022 #include "bits16.h"
00023 
00024 #include          "hpddef.h"     //must be last (handpd.dll)
00025 
00032 enum PB_TYPE
00033 {
00034   PB_TEXT,
00035   PB_RULES,
00036   PB_GRAPHICS,
00037   PB_IMAGE,
00038   PB_SCRIBBLE,
00039   PB_WEIRD
00040 };
00041 
00042 class DLLSYM PAGE_BLOCK;         //forward decl
00043 class DLLSYM TEXT_BLOCK;         //forward decl
00044 class DLLSYM GRAPHICS_BLOCK;     //forward decl
00045 class DLLSYM RULE_BLOCK;         //forward decl
00046 class DLLSYM IMAGE_BLOCK;        //forward decl
00047 class DLLSYM SCRIBBLE_BLOCK;     //forward decl
00048 class DLLSYM WEIRD_BLOCK;        //forward decl
00049 
00050 ELISTIZEH_S (PAGE_BLOCK)
00051 
00052 
00063 class DLLSYM PAGE_BLOCK:public ELIST_LINK, public POLY_BLOCK
00064 {
00065   public:
00066     PAGE_BLOCK() { 
00067     }                            //empty constructor
00068     PAGE_BLOCK(  //simple constructor
00069                ICOORDELT_LIST *points,
00070                PB_TYPE type,
00071                PAGE_BLOCK_LIST *child);
00072 
00073     PAGE_BLOCK(  //simple constructor
00074                ICOORDELT_LIST *points,
00075                PB_TYPE type);
00076 
00077     ~PAGE_BLOCK () {             //destructor
00078     }
00079 
00080     void add_a_child(PAGE_BLOCK *newchild); 
00081 
00082     PB_TYPE type() {  //get type
00083       return pb_type;
00084     }
00085 
00086     PAGE_BLOCK_LIST *child() {  //get children
00087       return &children;
00088     }
00089 
00090     void rotate(  //rotate it
00091                 FCOORD rotation);
00092     void move(                //move it
00093               ICOORD shift);  //vector
00094 
00095     void basic_plot(WINDOW window, COLOUR colour); 
00096 
00097     void plot(WINDOW window, COLOUR colour); 
00098 
00099     void show_attrs(DEBUG_WIN *debug); 
00100 
00101     NEWDELETE2 (PAGE_BLOCK) void pb_delete ();
00102 
00103     void serialise(FILE *f); 
00104 
00105     static PAGE_BLOCK *de_serialise(FILE *f); 
00106 
00107     void prep_serialise() {  //set ptrs to counts
00108       POLY_BLOCK::prep_serialise(); 
00109       children.prep_serialise ();
00110     }
00111 
00112     void dump(  //write external bits
00113               FILE *f) {
00114       POLY_BLOCK::dump(f); 
00115       children.dump (f);
00116     }
00117 
00118     void de_dump(  //read external bits
00119                  FILE *f) {
00120       POLY_BLOCK::de_dump(f); 
00121       children.de_dump (f);
00122     }
00123 
00124    /*
00125    PAGE_BLOCK_LIST cannot be de-serialised by the normal mechanism, 
00126    use read_poly_blocks or the code therein
00127    */
00128     void serialise_asc(  //serialise to ascii
00129                        FILE *f);
00130     void internal_serialise_asc(  //serialise to ascii
00131                                 FILE *f);
00132     void de_serialise_asc(  //serialise from ascii
00133                           FILE *f);
00134                                  //make one from ascii
00135     static PAGE_BLOCK *new_de_serialise_asc(FILE *f); 
00136 
00137   private:
00138     PB_TYPE pb_type;
00139     PAGE_BLOCK_LIST children;
00140 };
00141 
00142 DLLSYM void show_all_in(PAGE_BLOCK *pblock,
00143                         POLY_BLOCK *show_area,
00144                         DEBUG_WIN *f);
00145 
00146 DLLSYM void delete_all_in(PAGE_BLOCK *pblock, POLY_BLOCK *delete_area); 
00147 
00148 DLLSYM PAGE_BLOCK *smallest_containing(PAGE_BLOCK *pblock, POLY_BLOCK *other); 
00149 
00156 class DLLSYM TEXT_BLOCK:public PAGE_BLOCK
00157 {
00158   public:
00159     TEXT_BLOCK() { 
00160     }                            //empty constructor
00161     TEXT_BLOCK(ICOORDELT_LIST *points); 
00162 
00163     TEXT_BLOCK (ICOORDELT_LIST * points, BOOL8 backg[NUM_BACKGROUNDS]);
00164 
00165                                  //get children
00166     TEXT_REGION_LIST *regions() { 
00167       return &text_regions;
00168     }
00169 
00170     INT32 nregions() { 
00171       return text_regions.length ();
00172     }
00173 
00174     void add_a_region(TEXT_REGION *newchild); 
00175 
00176     void rotate(  //rotate it
00177                 FCOORD rotation);
00178     void move(                //move it
00179               ICOORD shift);  //vector
00180 
00181     void plot(WINDOW window,
00182               COLOUR colour,
00183               COLOUR region_colour,
00184               COLOUR subregion_colour);
00185 
00186     void set_attrs (BOOL8 backg[NUM_BACKGROUNDS]);
00187 
00188     void show_attrs(DEBUG_WIN *debug); 
00189 
00190     void prep_serialise() {  //set ptrs to counts
00191       PAGE_BLOCK::prep_serialise(); 
00192       text_regions.prep_serialise ();
00193     }
00194 
00195     void dump(  //write external bits
00196               FILE *f) {
00197       PAGE_BLOCK::dump(f); 
00198       text_regions.dump (f);
00199     }
00200 
00201     void de_dump(  //read external bits
00202                  FILE *f) {
00203       PAGE_BLOCK::de_dump(f); 
00204       text_regions.de_dump (f);
00205     }
00206 
00207                                  //serialise to ascii
00208     make_serialise (TEXT_BLOCK) void serialise_asc (
00209       FILE * f);
00210     void de_serialise_asc(  //serialise from ascii
00211                           FILE *f);
00212 
00213   private:
00215     BITS16 background;
00217     TEXT_REGION_LIST text_regions;
00218 };
00219 
00220 DLLSYM void delete_all_tr_in(TEXT_BLOCK *tblock, POLY_BLOCK *delete_area); 
00221 
00222 DLLSYM void show_all_tr_in(TEXT_BLOCK *tblock,
00223                            POLY_BLOCK *show_area,
00224                            DEBUG_WIN *f);
00225 
00230 class DLLSYM RULE_BLOCK:public PAGE_BLOCK
00231 {
00232   public:
00233     RULE_BLOCK() { 
00234     }                            //empty constructor
00235     RULE_BLOCK(ICOORDELT_LIST *points, INT8 sing, INT8 colo); 
00236 
00237     void set_attrs(INT8 sing, INT8 colo); 
00238 
00239     void show_attrs(DEBUG_WIN *debug); 
00240 
00241                                  //serialise to ascii
00242     make_serialise (RULE_BLOCK) void serialise_asc (
00243       FILE * f);
00244     void de_serialise_asc(  //serialise from ascii
00245                           FILE *f);
00246 
00247   private:
00249     INT8 multiplicity;
00251     INT8 colour;
00252 };
00253 
00258 class DLLSYM GRAPHICS_BLOCK:public PAGE_BLOCK
00259 {
00260   public:
00261     GRAPHICS_BLOCK() { 
00262     }                            //empty constructor
00263     GRAPHICS_BLOCK (ICOORDELT_LIST * points,
00264       BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg);
00265 
00266     void set_attrs (BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg);
00267 
00268     void show_attrs(DEBUG_WIN *debug); 
00269 
00270                                  //serialise to ascii
00271     make_serialise (GRAPHICS_BLOCK) void serialise_asc (
00272       FILE * f);
00273     void de_serialise_asc(  //serialise from ascii
00274                           FILE *f);
00275 
00276   private:
00278     BITS16 background;
00280     INT8 foreground;
00281 };
00282 
00289 class DLLSYM IMAGE_BLOCK:public PAGE_BLOCK
00290 {
00291   public:
00292     IMAGE_BLOCK() { 
00293     }                            //empty constructor
00294     IMAGE_BLOCK(ICOORDELT_LIST *points, INT8 colo, INT8 qual); 
00295 
00296     void set_attrs(INT8 colo, INT8 qual); 
00297 
00298     void show_attrs(DEBUG_WIN *debug); 
00299 
00300                                  //serialise to ascii
00301     make_serialise (IMAGE_BLOCK) void serialise_asc (
00302       FILE * f);
00303     void de_serialise_asc(  //serialise from ascii
00304                           FILE *f);
00305 
00306   private:
00308     INT8 colour;
00310     INT8 quality;
00311 
00312 };
00313 
00320 class DLLSYM SCRIBBLE_BLOCK:public PAGE_BLOCK
00321 {
00322   public:
00323     SCRIBBLE_BLOCK() { 
00324     }                            //empty constructor
00325     SCRIBBLE_BLOCK (ICOORDELT_LIST * points,
00326       BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg);
00327 
00328     void set_attrs (BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg);
00329 
00330     void show_attrs(DEBUG_WIN *debug); 
00331 
00332                                  //serialise to ascii
00333     make_serialise (SCRIBBLE_BLOCK) void serialise_asc (
00334       FILE * f);
00335     void de_serialise_asc(  //serialise from ascii
00336                           FILE *f);
00337 
00338   private:
00340     BITS16 background;
00342     INT8 foreground;
00343 };
00344 
00351 class DLLSYM WEIRD_BLOCK:public PAGE_BLOCK
00352 {
00353   public:
00354     WEIRD_BLOCK() { 
00355     }                            //empty constructor
00356     WEIRD_BLOCK(ICOORDELT_LIST *points, INT32 id_no); 
00357 
00358     void set_id(INT32 id_no); 
00359 
00360     void show_attrs(DEBUG_WIN *debug); 
00361 
00362     void set_id_no(INT32 new_id) { 
00363       id_number = new_id;
00364     }
00365 
00366     void plot(WINDOW window, COLOUR colour); 
00367 
00368     INT32 id_no() { 
00369       return id_number;
00370     }
00371 
00372                                  //serialise to ascii
00373     make_serialise (WEIRD_BLOCK) void serialise_asc (
00374       FILE * f);
00375     void de_serialise_asc(  //serialise from ascii
00376                           FILE *f);
00377 
00378   private:
00380     INT32 id_number;
00381 
00382 };
00383 
00384 void print_background(DEBUG_WIN *f, BITS16 background); 
00385 #endif

Generated on Wed Feb 28 19:49:08 2007 for Tesseract by  doxygen 1.5.1