ccstruct/txtregn.cpp

Go to the documentation of this file.
00001 
00020 #include          "mfcpch.h"
00021 #include          <ctype.h>
00022 #include          <math.h>
00023 #include          "txtregn.h"
00024 #include          "labls.h"
00025 
00026 #include          "hpddef.h"     //must be last (handpd.dll)
00027 
00030 ELISTIZE_S (TEXT_REGION) TEXT_REGION::TEXT_REGION (INT32 idno, ICOORDELT_LIST * points, TEXT_REGION_LIST * child):POLY_BLOCK (points,
00031 POLY_TEXT) {
00032   TEXT_REGION_IT
00033     c = &txt_regions;
00034 
00035   id_number = idno;
00036   txt_regions.clear ();
00037   c.move_to_first ();
00038   c.add_list_before (child);
00039 }
00040 
00041 
00044 TEXT_REGION::TEXT_REGION (INT32 idno, ICOORDELT_LIST * points):POLY_BLOCK (points,
00045 POLY_TEXT) {
00046   id_number = idno;
00047 
00048   txt_regions.clear ();
00049 }
00050 
00051 
00055 TEXT_REGION::TEXT_REGION (       //constructor
00056 INT32 idno, ICOORDELT_LIST * points, INT8 hor, INT8 tex, INT8 ser, INT8 pro, INT8 nor, INT8 upr, INT8 sol, INT8 bla, INT8 und, INT8 dro):POLY_BLOCK (points,
00057 POLY_TEXT) {
00058 
00059   id_number = idno;
00060   horizontal = hor;
00061   text = tex;
00062   serif = ser;
00063   proportional = pro;
00064   normal = nor;
00065   upright = upr;
00066   solid = sol;
00067   black = bla;
00068   underlined = und;
00069   dropcaps = dro;
00070 
00071   txt_regions.clear ();
00072 }
00073 
00074 
00077 void TEXT_REGION::set_attrs(INT8 hor,
00078                             INT8 tex,
00079                             INT8 ser,
00080                             INT8 pro,
00081                             INT8 nor,
00082                             INT8 upr,
00083                             INT8 sol,
00084                             INT8 bla,
00085                             INT8 und,
00086                             INT8 dro) {
00087 
00088   horizontal = hor;
00089   text = tex;
00090   serif = ser;
00091   proportional = pro;
00092   normal = nor;
00093   upright = upr;
00094   solid = sol;
00095   black = bla;
00096   underlined = und;
00097   dropcaps = dro;
00098 }
00099 
00100 
00101 #include          "hpddef.h"     //must be last (handpd.dll)
00102 
00106 void TEXT_REGION::show_attrs(  //Now uses tprintf instead
00107                              DEBUG_WIN *f) {
00108   TEXT_REGION_IT it = &txt_regions;
00109 
00110   if (id_number > -1) {
00111     f->
00112       dprintf
00113       ("Text region no. %d with attributes %s, %s, %s, %s, %s, %s, %s,  %s, %s, %s\n",
00114       id_number, tlabel[0][horizontal], tlabel[1][text],
00115       tlabel[2][serif], tlabel[3][proportional], tlabel[4][normal],
00116       tlabel[5][upright], tlabel[6][solid], tlabel[7][black],
00117       tlabel[8][underlined], tlabel[9][dropcaps]);
00118     if (!txt_regions.empty ()) {
00119       f->dprintf ("with text subregions\n");
00120       for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
00121         it.data ()->show_attrs (f);
00122       f->dprintf ("end of subregions\n");
00123     }
00124   }
00125   else
00126     f->
00127       dprintf
00128       ("Text subregion with attributes %s, %s, %s, %s, %s, %s, %s,   %s, %s, %s\n",
00129       tlabel[0][horizontal], tlabel[1][text], tlabel[2][serif],
00130       tlabel[3][proportional], tlabel[4][normal], tlabel[5][upright],
00131       tlabel[6][solid], tlabel[7][black], tlabel[8][underlined],
00132       tlabel[9][dropcaps]);
00133 }
00134 
00135 
00139 void TEXT_REGION::add_a_region(TEXT_REGION *newchild) { 
00140   TEXT_REGION_IT c = &txt_regions;
00141 
00142   c.move_to_first ();
00143   c.add_to_end (newchild);
00144 }
00145 
00146 
00150 void TEXT_REGION::rotate(  //cos,sin
00151                          FCOORD rotation) {
00152                                  //sub block iterator
00153   TEXT_REGION_IT child_it = &txt_regions;
00154   TEXT_REGION *child;            //child block
00155 
00156   for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
00157   child_it.forward ()) {
00158     child = child_it.data ();
00159     child->rotate (rotation);
00160   }
00161   POLY_BLOCK::rotate(rotation); 
00162 }
00163 
00164 
00168 void TEXT_REGION::move(ICOORD shift  //amount to move
00169                       ) {
00170                                  //sub block iterator
00171   TEXT_REGION_IT child_it = &txt_regions;
00172   TEXT_REGION *child;            //child block
00173 
00174   for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
00175   child_it.forward ()) {
00176     child = child_it.data ();
00177     child->move (shift);
00178   }
00179   POLY_BLOCK::move(shift); 
00180 }
00181 
00182 
00186 void TEXT_REGION::serialise_asc(         //convert to ascii
00187                                 FILE *f  //file to use
00188                                ) {
00189   ((POLY_BLOCK *) this)->serialise_asc (f);
00190   serialise_INT32(f, id_number);  //unique id
00191                                  //horizontal, vertical, skewed
00192   serialise_INT32(f, horizontal); 
00193   serialise_INT32(f, text);  //text, table, form
00194   serialise_INT32(f, serif);  //serif, sansserif
00195                                  //proportional, fixed
00196   serialise_INT32(f, proportional); 
00197   serialise_INT32(f, normal);  //normal, bold
00198   serialise_INT32(f, upright);  //upright, italic
00199   serialise_INT32(f, solid);  //solid, outline
00200   serialise_INT32(f, black);  //black, coloured, white,
00201                                  //not underlined, underlined
00202   serialise_INT32(f, underlined); 
00203   serialise_INT32(f, dropcaps);  //not dropcaps, dropcaps
00204 
00205   txt_regions.serialise_asc (f);
00206 }
00207 
00208 
00212 void TEXT_REGION::de_serialise_asc(         //convert from ascii
00213                                    FILE *f  //file to use
00214                                   ) {
00215   ((POLY_BLOCK *) this)->de_serialise_asc (f);
00216                                  //unique id
00217   id_number = de_serialise_INT32 (f);
00218                                  //horizontal, vertical, skewed
00219   horizontal = de_serialise_INT32 (f);
00220   text = de_serialise_INT32 (f); //text, table, form
00221   serif = de_serialise_INT32 (f);//serif, sansserif
00222                                  //proportional, fixed
00223   proportional = de_serialise_INT32 (f);
00224                                  //normal, bold
00225   normal = de_serialise_INT32 (f);
00226                                  //upright, italic
00227   upright = de_serialise_INT32 (f);
00228   solid = de_serialise_INT32 (f);//solid, outline
00229   black = de_serialise_INT32 (f);//black, coloured, white,
00230                                  //not underlined, underlined
00231   underlined = de_serialise_INT32 (f);
00232                                  //not dropcaps, dropcaps
00233   dropcaps = de_serialise_INT32 (f);
00234 
00235   txt_regions.de_serialise_asc (f);
00236 }

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