ccstruct/pageblk.cpp

Go to the documentation of this file.
00001 
00005 #include "mfcpch.h"
00006 #include          "pageblk.h"
00007 #include    <stdio.h>
00008 #include          <ctype.h>
00009 #include          <math.h>
00010 #ifdef __UNIX__
00011 #include          <unistd.h>
00012 #else
00013 #include          <io.h>
00014 #endif
00015 
00016 #include          "hpddef.h"     //must be last (handpd.dll)
00017 
00018 #define G_START 0
00019 #define I_START 1
00020 #define R_START 3
00021 #define S_START 5
00022 
00023 extern char blabel[NUM_BLOCK_ATTR][4][MAXLENGTH];
00024 extern char backlabel[NUM_BACKGROUNDS][MAXLENGTH];
00025 
00026 ELISTIZE_S (PAGE_BLOCK)
00032 void PAGE_BLOCK::pb_delete() { 
00033   switch (pb_type) {
00034     case PB_TEXT:
00035       delete ((TEXT_BLOCK *) this);
00036       break;
00037     case PB_GRAPHICS:
00038       delete ((GRAPHICS_BLOCK *) this);
00039       break;
00040     case PB_IMAGE:
00041       delete ((IMAGE_BLOCK *) this);
00042       break;
00043     case PB_RULES:
00044       delete ((RULE_BLOCK *) this);
00045       break;
00046     case PB_SCRIBBLE:
00047       delete ((SCRIBBLE_BLOCK *) this);
00048       break;
00049     case PB_WEIRD:
00050       delete ((WEIRD_BLOCK *) this);
00051       break;
00052     default:
00053       break;
00054   }
00055 }
00056 
00057 
00058 #define QUOTE_IT( parm ) #parm
00059 
00065 void PAGE_BLOCK::serialise(FILE *f) { 
00066 
00067   if (fwrite (&pb_type, sizeof (PB_TYPE), 1, f) != 1)
00068     WRITEFAILED.error (QUOTE_IT (PAGE_BLOCK::serialise), ABORT, NULL);
00069   switch (pb_type) {
00070     case PB_TEXT:
00071       ((TEXT_BLOCK *) this)->serialise (f);
00072       break;
00073     case PB_GRAPHICS:
00074       ((GRAPHICS_BLOCK *) this)->serialise (f);
00075       break;
00076     case PB_RULES:
00077       ((RULE_BLOCK *) this)->serialise (f);
00078       break;
00079     case PB_IMAGE:
00080       ((IMAGE_BLOCK *) this)->serialise (f);
00081       break;
00082     case PB_SCRIBBLE:
00083       ((SCRIBBLE_BLOCK *) this)->serialise (f);
00084       break;
00085     case PB_WEIRD:
00086       ((WEIRD_BLOCK *) this)->serialise (f);
00087       break;
00088     default:
00089       break;
00090   }
00091 }
00092 
00093 
00099 PAGE_BLOCK *PAGE_BLOCK::de_serialise(FILE *f) { 
00100   PB_TYPE type;
00101   TEXT_BLOCK *tblock;
00102   GRAPHICS_BLOCK *gblock;
00103   RULE_BLOCK *rblock;
00104   IMAGE_BLOCK *iblock;
00105   SCRIBBLE_BLOCK *sblock;
00106   WEIRD_BLOCK *wblock;
00107 
00108   if (fread ((void *) &type, sizeof (PB_TYPE), 1, f) != 1)
00109     WRITEFAILED.error (QUOTE_IT (PAGE_BLOCK::serialise), ABORT, NULL);
00110   switch (type) {
00111     case PB_TEXT:
00112       tblock = (TEXT_BLOCK *) alloc_struct (sizeof (TEXT_BLOCK));
00113       return tblock->de_serialise (f);
00114     case PB_GRAPHICS:
00115       gblock = (GRAPHICS_BLOCK *) alloc_struct (sizeof (GRAPHICS_BLOCK));
00116       return gblock->de_serialise (f);
00117     case PB_RULES:
00118       rblock = (RULE_BLOCK *) alloc_struct (sizeof (RULE_BLOCK));
00119       return rblock->de_serialise (f);
00120     case PB_IMAGE:
00121       iblock = (IMAGE_BLOCK *) alloc_struct (sizeof (IMAGE_BLOCK));
00122       return iblock->de_serialise (f);
00123     case PB_SCRIBBLE:
00124       sblock = (SCRIBBLE_BLOCK *) alloc_struct (sizeof (SCRIBBLE_BLOCK));
00125       return sblock->de_serialise (f);
00126     case PB_WEIRD:
00127       wblock = (WEIRD_BLOCK *) alloc_struct (sizeof (SCRIBBLE_BLOCK));
00128       return wblock->de_serialise (f);
00129     default:
00130       return NULL;
00131   }
00132 }
00133 
00134 
00140 void PAGE_BLOCK::serialise_asc(         //convert to ascii
00141                                FILE *f  //file to use
00142                               ) {
00143   serialise_INT32(f, pb_type); 
00144   switch (pb_type) {
00145     case PB_TEXT:
00146       ((TEXT_BLOCK *) this)->serialise_asc (f);
00147       break;
00148     case PB_GRAPHICS:
00149       ((GRAPHICS_BLOCK *) this)->serialise_asc (f);
00150       break;
00151     case PB_RULES:
00152       ((RULE_BLOCK *) this)->serialise_asc (f);
00153       break;
00154     case PB_IMAGE:
00155       ((IMAGE_BLOCK *) this)->serialise_asc (f);
00156       break;
00157     case PB_SCRIBBLE:
00158       ((SCRIBBLE_BLOCK *) this)->serialise_asc (f);
00159       break;
00160     case PB_WEIRD:
00161       ((WEIRD_BLOCK *) this)->serialise_asc (f);
00162       break;
00163     default:
00164       break;
00165   }
00166 }
00167 
00168 
00172 void PAGE_BLOCK::internal_serialise_asc(         //convert to ascii
00173                                         FILE *f  //file to use
00174                                        ) {
00175   ((POLY_BLOCK *) this)->serialise_asc (f);
00176   serialise_INT32(f, pb_type); 
00177   children.serialise_asc (f);
00178 }
00179 
00180 
00184 void PAGE_BLOCK::de_serialise_asc(         //convert from ascii
00185                                   FILE *f  //file to use
00186                                  ) {
00187   PAGE_BLOCK *page_block;        //new block for list
00188   INT32 len;                     /*length to retrive */
00189   PAGE_BLOCK_IT it;
00190 
00191   ((POLY_BLOCK *) this)->de_serialise_asc (f);
00192   pb_type = (PB_TYPE) de_serialise_INT32 (f);
00193   //      children.de_serialise_asc(f);
00194   len = de_serialise_INT32 (f);
00195   it.set_to_list (&children);
00196   for (; len > 0; len--) {
00197     page_block = new_de_serialise_asc (f);
00198     it.add_to_end (page_block);  /*put on the list */
00199   }
00200 }
00201 
00202 
00208 PAGE_BLOCK *PAGE_BLOCK::new_de_serialise_asc(         //convert from ascii
00209                                              FILE *f  //file to use
00210                                             ) {
00211   PB_TYPE type;
00212   TEXT_BLOCK *tblock;
00213   GRAPHICS_BLOCK *gblock;
00214   RULE_BLOCK *rblock;
00215   IMAGE_BLOCK *iblock;
00216   SCRIBBLE_BLOCK *sblock;
00217   WEIRD_BLOCK *wblock;
00218 
00219   type = (PB_TYPE) de_serialise_INT32 (f);
00220   switch (type) {
00221     case PB_TEXT:
00222       tblock = new TEXT_BLOCK;
00223       tblock->de_serialise_asc (f);
00224       return tblock;
00225     case PB_GRAPHICS:
00226       gblock = new GRAPHICS_BLOCK;
00227       gblock->de_serialise_asc (f);
00228       return gblock;
00229     case PB_RULES:
00230       rblock = new RULE_BLOCK;
00231       rblock->de_serialise_asc (f);
00232       return rblock;
00233     case PB_IMAGE:
00234       iblock = new IMAGE_BLOCK;
00235       iblock->de_serialise_asc (f);
00236       return iblock;
00237     case PB_SCRIBBLE:
00238       sblock = new SCRIBBLE_BLOCK;
00239       sblock->de_serialise_asc (f);
00240       return sblock;
00241     case PB_WEIRD:
00242       wblock = new WEIRD_BLOCK;
00243       wblock->de_serialise_asc (f);
00244       return wblock;
00245     default:
00246       return NULL;
00247   }
00248 }
00249 
00255 void PAGE_BLOCK::show_attrs(DEBUG_WIN *f) { 
00256   PAGE_BLOCK_IT it;
00257 
00258   switch (pb_type) {
00259     case PB_TEXT:
00260       ((TEXT_BLOCK *) this)->show_attrs (f);
00261       break;
00262     case PB_GRAPHICS:
00263       ((GRAPHICS_BLOCK *) this)->show_attrs (f);
00264       break;
00265     case PB_RULES:
00266       ((RULE_BLOCK *) this)->show_attrs (f);
00267       break;
00268     case PB_IMAGE:
00269       ((IMAGE_BLOCK *) this)->show_attrs (f);
00270       break;
00271     case PB_SCRIBBLE:
00272       ((SCRIBBLE_BLOCK *) this)->show_attrs (f);
00273       break;
00274     case PB_WEIRD:
00275       ((WEIRD_BLOCK *) this)->show_attrs (f);
00276       break;
00277     default:
00278       break;
00279   }
00280 
00281   if (!children.empty ()) {
00282     f->dprintf ("containing subblocks\n");
00283     it.set_to_list (&children);
00284     for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
00285       it.data ()->show_attrs (f);
00286     f->dprintf ("end of subblocks\n");
00287   }
00288 }
00289 
00290 
00294 PAGE_BLOCK::PAGE_BLOCK (ICOORDELT_LIST * points, PB_TYPE type, PAGE_BLOCK_LIST * child):POLY_BLOCK (points,
00295 POLY_PAGE) {
00296   PAGE_BLOCK_IT
00297     c = &children;
00298 
00299   pb_type = type;
00300   children.clear ();
00301   c.move_to_first ();
00302   c.add_list_before (child);
00303 }
00304 
00305 
00309 PAGE_BLOCK::PAGE_BLOCK (ICOORDELT_LIST * points, PB_TYPE type):POLY_BLOCK (points,
00310 POLY_PAGE) {
00311   pb_type = type;
00312   children.clear ();
00313 }
00314 
00315 
00319 void PAGE_BLOCK::add_a_child(PAGE_BLOCK *newchild) { 
00320   PAGE_BLOCK_IT c = &children;
00321 
00322   c.move_to_first ();
00323   c.add_to_end (newchild);
00324 }
00325 
00326 
00330 void PAGE_BLOCK::rotate(  //cos,sin
00331                         FCOORD rotation) {
00332                                  //sub block iterator
00333   PAGE_BLOCK_IT child_it = &children;
00334   PAGE_BLOCK *child;             //child block
00335 
00336   for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
00337   child_it.forward ()) {
00338     child = child_it.data ();
00339     child->rotate (rotation);
00340   }
00341   if (pb_type == PB_TEXT)
00342     ((TEXT_BLOCK *) this)->rotate (rotation);
00343   else
00344     POLY_BLOCK::rotate(rotation); 
00345 }
00346 
00347 
00351 void PAGE_BLOCK::move(ICOORD shift  //amount to move
00352                      ) {
00353                                  //sub block iterator
00354   PAGE_BLOCK_IT child_it = &children;
00355   PAGE_BLOCK *child;             //child block
00356 
00357   for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
00358   child_it.forward ()) {
00359     child = child_it.data ();
00360     child->move (shift);
00361   }
00362   if (pb_type == PB_TEXT)
00363     ((TEXT_BLOCK *) this)->move (shift);
00364   else
00365     POLY_BLOCK::move(shift); 
00366 }
00367 
00368 
00372 #ifndef GRAPHICS_DISABLED
00373 void PAGE_BLOCK::basic_plot(WINDOW window, COLOUR colour) { 
00374   PAGE_BLOCK_IT c = &children;
00375 
00376   POLY_BLOCK::plot (window, colour, 0);
00377 
00378   if (!c.empty ())
00379     for (c.mark_cycle_pt (); !c.cycled_list (); c.forward ())
00380       c.data ()->plot (window, colour);
00381 }
00382 
00383 
00389 void PAGE_BLOCK::plot(WINDOW window, COLOUR colour) { 
00390   TEXT_BLOCK *tblock;
00391   WEIRD_BLOCK *wblock;
00392 
00393   switch (pb_type) {
00394     case PB_TEXT:
00395       basic_plot(window, colour); 
00396       tblock = (TEXT_BLOCK *) this;
00397       tblock->plot (window, colour, REGION_COLOUR, SUBREGION_COLOUR);
00398       break;
00399     case PB_WEIRD:
00400       wblock = (WEIRD_BLOCK *) this;
00401       wblock->plot (window, colour);
00402       break;
00403     default:
00404       basic_plot(window, colour); 
00405       break;
00406   }
00407 }
00408 #endif
00409 
00413 void show_all_in(PAGE_BLOCK *pblock, POLY_BLOCK *show_area, DEBUG_WIN *f) { 
00414   PAGE_BLOCK_IT c;
00415   INT16 i, pnum;
00416 
00417   c.set_to_list (pblock->child ());
00418   pnum = pblock->child ()->length ();
00419   for (i = 0; i < pnum; i++, c.forward ()) {
00420     if (show_area->contains (c.data ()))
00421       c.data ()->show_attrs (f);
00422     else if (show_area->overlap (c.data ()))
00423       show_all_in (c.data (), show_area, f);
00424   }
00425 }
00426 
00427 
00431 void delete_all_in(PAGE_BLOCK *pblock, POLY_BLOCK *delete_area) { 
00432   PAGE_BLOCK_IT c;
00433   INT16 i, pnum;
00434 
00435   c.set_to_list (pblock->child ());
00436   pnum = pblock->child ()->length ();
00437   for (i = 0; i < pnum; i++, c.forward ()) {
00438     if (delete_area->contains (c.data ()))
00439       c.extract ()->pb_delete ();
00440     else if (delete_area->overlap (c.data ()))
00441       delete_all_in (c.data (), delete_area);
00442   }
00443 }
00444 
00445 
00449 PAGE_BLOCK *smallest_containing(PAGE_BLOCK *pblock, POLY_BLOCK *other) { 
00450   PAGE_BLOCK_IT c;
00451 
00452   c.set_to_list (pblock->child ());
00453   if (c.empty ())
00454     return (pblock);
00455 
00456   for (c.mark_cycle_pt (); !c.cycled_list (); c.forward ())
00457     if (c.data ()->contains (other))
00458       return (smallest_containing (c.data (), other));
00459 
00460   return (pblock);
00461 }
00462 
00463 
00467 TEXT_BLOCK::TEXT_BLOCK (ICOORDELT_LIST * points, BOOL8 backg[NUM_BACKGROUNDS]):PAGE_BLOCK (points,
00468 PB_TEXT) {
00469   int
00470     i;
00471 
00472   for (i = 0; i < NUM_BACKGROUNDS; i++)
00473     background.set_bit (i, backg[i]);
00474 
00475   text_regions.clear ();
00476 }
00477 
00478 
00479 void
00480 TEXT_BLOCK::set_attrs (BOOL8 backg[NUM_BACKGROUNDS]) {
00481   int i;
00482 
00483   for (i = 0; i < NUM_BACKGROUNDS; i++)
00484     background.set_bit (i, backg[i]);
00485 }
00486 
00487 
00491 void TEXT_BLOCK::add_a_region(TEXT_REGION *newchild) { 
00492   TEXT_REGION_IT c;
00493 
00494   c.set_to_list (&text_regions);
00495 
00496   c.move_to_first ();
00497   c.add_to_end (newchild);
00498 }
00499 
00500 
00504 void TEXT_BLOCK::rotate(  //cos,sin
00505                         FCOORD rotation) {
00506                                  //sub block iterator
00507   TEXT_REGION_IT child_it = &text_regions;
00508   TEXT_REGION *child;            //child block
00509 
00510   for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
00511   child_it.forward ()) {
00512     child = child_it.data ();
00513     child->rotate (rotation);
00514   }
00515   POLY_BLOCK::rotate(rotation); 
00516 }
00517 
00518 
00522 void TEXT_BLOCK::move(ICOORD shift  //amount to move
00523                      ) {
00524                                  //sub block iterator
00525   TEXT_REGION_IT child_it = &text_regions;
00526   TEXT_REGION *child;            //child block
00527 
00528   for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
00529   child_it.forward ()) {
00530     child = child_it.data ();
00531     child->move (shift);
00532   }
00533   POLY_BLOCK::move(shift); 
00534 }
00535 
00536 
00540 void TEXT_BLOCK::serialise_asc(         //convert to ascii
00541                                FILE *f  //file to use
00542                               ) {
00543   ((PAGE_BLOCK *) this)->internal_serialise_asc (f);
00544   serialise_INT32 (f, background.val);
00545   text_regions.serialise_asc (f);
00546 }
00547 
00548 
00552 void TEXT_BLOCK::de_serialise_asc(         //convert from ascii
00553                                   FILE *f  //file to use
00554                                  ) {
00555   ((PAGE_BLOCK *) this)->de_serialise_asc (f);
00556   background.val = de_serialise_INT32 (f);
00557   text_regions.de_serialise_asc (f);
00558 }
00559 
00560 
00564 #ifndef GRAPHICS_DISABLED
00565 void TEXT_BLOCK::plot(WINDOW window,
00566                       COLOUR colour,
00567                       COLOUR region_colour,
00568                       COLOUR subregion_colour) {
00569   TEXT_REGION_IT t = &text_regions, tc;
00570 
00571   PAGE_BLOCK::basic_plot(window, colour); 
00572 
00573   if (!t.empty ())
00574   for (t.mark_cycle_pt (); !t.cycled_list (); t.forward ()) {
00575     t.data ()->plot (window, region_colour, t.data ()->id_no ());
00576     tc.set_to_list (t.data ()->regions ());
00577     if (!tc.empty ())
00578       for (tc.mark_cycle_pt (); !tc.cycled_list (); tc.forward ())
00579         tc.data ()->plot (window, subregion_colour, -1);
00580   }
00581 }
00582 #endif
00583 
00584 
00588 void TEXT_BLOCK::show_attrs(DEBUG_WIN *f) { 
00589   TEXT_REGION_IT it;
00590 
00591   f->dprintf ("TEXT BLOCK\n");
00592   print_background(f, background); 
00593   if (!text_regions.empty ()) {
00594     f->dprintf ("containing text regions:\n");
00595     it.set_to_list (&text_regions);
00596     for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
00597       it.data ()->show_attrs (f);
00598     f->dprintf ("end of regions\n");
00599   }
00600 }
00601 
00602 
00608 DLLSYM void show_all_tr_in(TEXT_BLOCK *tblock,
00609                            POLY_BLOCK *show_area,
00610                            DEBUG_WIN *f) {
00611   TEXT_REGION_IT t, tc;
00612   INT16 i, tnum, j, ttnum;
00613 
00614   t.set_to_list (tblock->regions ());
00615   tnum = tblock->regions ()->length ();
00616   for (i = 0; i < tnum; i++, t.forward ()) {
00617     if (show_area->contains (t.data ()))
00618       t.data ()->show_attrs (f);
00619     else if (show_area->overlap (t.data ())) {
00620       tc.set_to_list (t.data ()->regions ());
00621       ttnum = t.data ()->regions ()->length ();
00622       for (j = 0; j < ttnum; j++, tc.forward ())
00623         if (show_area->contains (tc.data ()))
00624           tc.data ()->show_attrs (f);
00625     }
00626   }
00627 }
00628 
00629 
00635 void delete_all_tr_in(TEXT_BLOCK *tblock, POLY_BLOCK *delete_area) { 
00636   TEXT_REGION_IT t, tc;
00637   INT16 i, tnum, j, ttnum;
00638 
00639   t.set_to_list (tblock->regions ());
00640   tnum = tblock->regions ()->length ();
00641   for (i = 0; i < tnum; i++, t.forward ()) {
00642     if (delete_area->contains (t.data ()))
00643       delete (t.extract ());
00644     else if (delete_area->overlap (t.data ())) {
00645       tc.set_to_list (t.data ()->regions ());
00646       ttnum = t.data ()->regions ()->length ();
00647       for (j = 0; j < ttnum; j++, tc.forward ())
00648         if (delete_area->contains (tc.data ()))
00649           delete (tc.extract ());
00650     }
00651   }
00652 }
00653 
00654 
00658 RULE_BLOCK::RULE_BLOCK (ICOORDELT_LIST * points, INT8 sing, INT8 colo):PAGE_BLOCK (points,
00659 PB_RULES) {
00660   multiplicity = sing;
00661   colour = colo;
00662 }
00663 
00664 
00665 void RULE_BLOCK::set_attrs(INT8 sing, INT8 colo) { 
00666   multiplicity = sing;
00667   colour = colo;
00668 }
00669 
00670 
00674 void RULE_BLOCK::show_attrs(DEBUG_WIN *f) { 
00675   f->dprintf ("RULE BLOCK with attributes %s, %s\n",
00676     blabel[R_START][multiplicity], blabel[R_START + 1][colour]);
00677 }
00678 
00679 
00683 void RULE_BLOCK::serialise_asc(         //convert to ascii
00684                                FILE *f  //file to use
00685                               ) {
00686   ((PAGE_BLOCK *) this)->internal_serialise_asc (f);
00687   serialise_INT32(f, multiplicity); 
00688   serialise_INT32(f, colour); 
00689 }
00690 
00691 
00695 void RULE_BLOCK::de_serialise_asc(         //convert from ascii
00696                                   FILE *f  //file to use
00697                                  ) {
00698   ((PAGE_BLOCK *) this)->de_serialise_asc (f);
00699   multiplicity = de_serialise_INT32 (f);
00700   colour = de_serialise_INT32 (f);
00701 }
00702 
00703 
00707 GRAPHICS_BLOCK::GRAPHICS_BLOCK (ICOORDELT_LIST * points, BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg):PAGE_BLOCK (points,
00708 PB_GRAPHICS) {
00709   int
00710     i;
00711 
00712   for (i = 0; i < NUM_BACKGROUNDS; i++)
00713     background.set_bit (i, backg[i]);
00714 
00715   foreground = foreg;
00716 }
00717 
00718 
00719 void
00720 GRAPHICS_BLOCK::set_attrs (BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg) {
00721   int i;
00722 
00723   for (i = 0; i < NUM_BACKGROUNDS; i++)
00724     background.set_bit (i, backg[i]);
00725 
00726   foreground = foreg;
00727 }
00728 
00729 
00733 void GRAPHICS_BLOCK::show_attrs(DEBUG_WIN *f) { 
00734   f->dprintf ("GRAPHICS BLOCK with attribute %s\n",
00735     blabel[G_START][foreground]);
00736   print_background(f, background); 
00737 }
00738 
00739 
00743 void GRAPHICS_BLOCK::serialise_asc(         //convert to ascii
00744                                    FILE *f  //file to use
00745                                   ) {
00746   ((PAGE_BLOCK *) this)->internal_serialise_asc (f);
00747   serialise_INT32 (f, background.val);
00748   serialise_INT32(f, foreground); 
00749 }
00750 
00751 
00755 void GRAPHICS_BLOCK::de_serialise_asc(         //convert from ascii
00756                                       FILE *f  //file to use
00757                                      ) {
00758   ((PAGE_BLOCK *) this)->de_serialise_asc (f);
00759   background.val = de_serialise_INT32 (f);
00760   foreground = de_serialise_INT32 (f);
00761 }
00762 
00763 
00767 IMAGE_BLOCK::IMAGE_BLOCK (ICOORDELT_LIST * points, INT8 colo, INT8 qual):PAGE_BLOCK (points,
00768 PB_IMAGE) {
00769   colour = colo;
00770   quality = qual;
00771 }
00772 
00773 
00777 void IMAGE_BLOCK::set_attrs(INT8 colo, INT8 qual) { 
00778   colour = colo;
00779   quality = qual;
00780 }
00781 
00782 
00786 void IMAGE_BLOCK::show_attrs(DEBUG_WIN *f) { 
00787   f->dprintf ("IMAGE BLOCK with attributes %s, %s\n", blabel[I_START][colour],
00788     blabel[I_START + 1][quality]);
00789 }
00790 
00791 
00795 void IMAGE_BLOCK::serialise_asc(         //convert to ascii
00796                                 FILE *f  //file to use
00797                                ) {
00798   ((PAGE_BLOCK *) this)->internal_serialise_asc (f);
00799   serialise_INT32(f, colour); 
00800   serialise_INT32(f, quality); 
00801 }
00802 
00803 
00807 void IMAGE_BLOCK::de_serialise_asc(         //convert from ascii
00808                                    FILE *f  //file to use
00809                                   ) {
00810   ((PAGE_BLOCK *) this)->de_serialise_asc (f);
00811   colour = de_serialise_INT32 (f);
00812   quality = de_serialise_INT32 (f);
00813 }
00814 
00815 
00819 SCRIBBLE_BLOCK::SCRIBBLE_BLOCK (ICOORDELT_LIST * points, BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg):PAGE_BLOCK (points,
00820 PB_SCRIBBLE) {
00821   int
00822     i;
00823 
00824   for (i = 0; i < NUM_BACKGROUNDS; i++)
00825     background.set_bit (i, backg[i]);
00826 
00827   foreground = foreg;
00828 }
00829 
00830 
00831 void
00832 SCRIBBLE_BLOCK::set_attrs (BOOL8 backg[NUM_BACKGROUNDS], INT8 foreg) {
00833   int i;
00834 
00835   for (i = 0; i < NUM_BACKGROUNDS; i++)
00836     background.set_bit (i, backg[i]);
00837 
00838   foreground = foreg;
00839 }
00840 
00841 
00845 void SCRIBBLE_BLOCK::show_attrs(DEBUG_WIN *f) { 
00846   f->dprintf ("SCRIBBLE BLOCK with attributes %s\n",
00847     blabel[S_START][foreground]);
00848   print_background(f, background); 
00849 }
00850 
00851 
00855 void SCRIBBLE_BLOCK::serialise_asc(         //convert to ascii
00856                                    FILE *f  //file to use
00857                                   ) {
00858   ((PAGE_BLOCK *) this)->internal_serialise_asc (f);
00859   serialise_INT32 (f, background.val);
00860   serialise_INT32(f, foreground); 
00861 }
00862 
00863 
00867 void SCRIBBLE_BLOCK::de_serialise_asc(         //convert from ascii
00868                                       FILE *f  //file to use
00869                                      ) {
00870   ((PAGE_BLOCK *) this)->de_serialise_asc (f);
00871   background.val = de_serialise_INT32 (f);
00872   foreground = de_serialise_INT32 (f);
00873 }
00874 
00875 
00879 WEIRD_BLOCK::WEIRD_BLOCK (ICOORDELT_LIST * points, INT32 id_no):PAGE_BLOCK (points,
00880 PB_WEIRD) {
00881   id_number = id_no;
00882 }
00883 
00884 
00888 #ifndef GRAPHICS_DISABLED
00889 void WEIRD_BLOCK::plot(WINDOW window, COLOUR colour) { 
00890   PAGE_BLOCK_IT c = this->child ();
00891 
00892   POLY_BLOCK::plot(window, colour, id_number); 
00893 
00894   if (!c.empty ())
00895     for (c.mark_cycle_pt (); !c.cycled_list (); c.forward ())
00896       c.data ()->plot (window, colour);
00897 }
00898 #endif
00899 
00900 
00901 void WEIRD_BLOCK::set_id(INT32 id_no) { 
00902   id_number = id_no;
00903 }
00904 
00905 
00909 void WEIRD_BLOCK::show_attrs(DEBUG_WIN *f) { 
00910   f->dprintf ("WEIRD BLOCK with id number %d\n", id_number);
00911 }
00912 
00913 
00917 void WEIRD_BLOCK::serialise_asc(         //convert to ascii
00918                                 FILE *f  //file to use
00919                                ) {
00920   ((PAGE_BLOCK *) this)->internal_serialise_asc (f);
00921   serialise_INT32(f, id_number); 
00922 }
00923 
00924 
00928 void WEIRD_BLOCK::de_serialise_asc(         //convert from ascii
00929                                    FILE *f  //file to use
00930                                   ) {
00931   ((PAGE_BLOCK *) this)->de_serialise_asc (f);
00932   id_number = de_serialise_INT32 (f);
00933 }
00934 
00935 
00941 void print_background(DEBUG_WIN *f, BITS16 background) { 
00942   int i;
00943 
00944   f->dprintf ("Background is \n");
00945   for (i = 0; i < NUM_BACKGROUNDS; i++) {
00946     if (background.bit (i))
00947       f->dprintf ("%s, ", backlabel[i]);
00948   }
00949 
00950   f->dprintf ("\n");
00951 
00952 }

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