00001
00020 #include "mfcpch.h"
00021 #include "ocrrow.h"
00022 #include "blobbox.h"
00023
00024 ELISTIZE_S (ROW)
00031 ROW::ROW (
00032 INT32 spline_size,
00033 INT32 * xstarts,
00034 double *coeffs,
00035 float x_height,
00036 float ascenders,
00037 float descenders,
00038 INT16 kern,
00039 INT16 space
00040 ):
00041 baseline(spline_size, xstarts, coeffs) {
00042 kerning = kern;
00043 spacing = space;
00044 xheight = x_height;
00045 ascrise = ascenders;
00046 descdrop = descenders;
00047 }
00048
00049
00056 ROW::ROW(
00057 TO_ROW *to_row,
00058 INT16 kern,
00059 INT16 space
00060 ) {
00061 kerning = kern;
00062 spacing = space;
00063 xheight = to_row->xheight;
00064 ascrise = to_row->ascrise;
00065 descdrop = to_row->descdrop;
00066 baseline = to_row->baseline;
00067 }
00068
00069
00073 void ROW::recalc_bounding_box() {
00074 WERD *word;
00075 WERD_IT it = &words;
00076 INT16 left;
00077 INT16 prev_left;
00078
00079 if (!it.empty ()) {
00080 word = it.data ();
00081 prev_left = word->bounding_box ().left ();
00082 it.forward ();
00083 while (!it.at_first ()) {
00084 word = it.data ();
00085 left = word->bounding_box ().left ();
00086 if (left < prev_left) {
00087 it.move_to_first ();
00088
00089 it.sort (word_comparator);
00090 break;
00091 }
00092 prev_left = left;
00093 it.forward ();
00094 }
00095 }
00096 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
00097 word = it.data ();
00098 if (it.at_first ())
00099 word->set_flag (W_BOL, TRUE);
00100 else
00101
00102 word->set_flag (W_BOL, FALSE);
00103 if (it.at_last ())
00104 word->set_flag (W_EOL, TRUE);
00105 else
00106
00107 word->set_flag (W_EOL, FALSE);
00108
00109 bound_box += word->bounding_box ();
00110 }
00111 }
00112
00113
00117 void ROW::move(
00118 const ICOORD vec
00119 ) {
00120 WERD_IT it(&words);
00121
00122 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
00123 it.data ()->move (vec);
00124
00125 bound_box.move (vec);
00126 baseline.move (vec);
00127 }
00128
00129
00133 void ROW::print(
00134 FILE *fp
00135 ) {
00136 tprintf ("Kerning= %d\n", kerning);
00137 tprintf ("Spacing= %d\n", spacing);
00138 bound_box.print ();
00139 tprintf ("Xheight= %f\n", xheight);
00140 tprintf ("Ascrise= %f\n", ascrise);
00141 tprintf ("Descdrop= %f\n", descdrop);
00142 }
00143
00144
00148 #ifndef GRAPHICS_DISABLED
00149 void ROW::plot(
00150 WINDOW window,
00151 COLOUR colour
00152 ) {
00153 WERD *word;
00154 WERD_IT it = &words;
00155
00156 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
00157 word = it.data ();
00158 word->plot (window, colour);
00159 }
00160 }
00161 #endif
00162
00166 #ifndef GRAPHICS_DISABLED
00167 void ROW::plot(
00168 WINDOW window
00169 ) {
00170 WERD *word;
00171 WERD_IT it = &words;
00172
00173 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
00174 word = it.data ();
00175 word->plot (window);
00176 }
00177 }
00178 #endif
00179
00183 ROW & ROW::operator= (
00184 const ROW & source
00185 ) {
00186 this->ELIST_LINK::operator= (source);
00187 kerning = source.kerning;
00188 spacing = source.spacing;
00189 xheight = source.xheight;
00190 ascrise = source.ascrise;
00191 descdrop = source.descdrop;
00192 if (!words.empty ())
00193 words.clear ();
00194 baseline = source.baseline;
00195 bound_box = source.bound_box;
00196 return *this;
00197 }