|
tesseract 3.04.01
|
00001 /********************************************************************** 00002 * File: ocrrow.h (Formerly row.h) 00003 * Description: Code for the ROW class. 00004 * Author: Ray Smith 00005 * Created: Tue Oct 08 15:58:04 BST 1991 00006 * 00007 * (C) Copyright 1991, Hewlett-Packard Ltd. 00008 ** Licensed under the Apache License, Version 2.0 (the "License"); 00009 ** you may not use this file except in compliance with the License. 00010 ** You may obtain a copy of the License at 00011 ** http://www.apache.org/licenses/LICENSE-2.0 00012 ** Unless required by applicable law or agreed to in writing, software 00013 ** distributed under the License is distributed on an "AS IS" BASIS, 00014 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 ** See the License for the specific language governing permissions and 00016 ** limitations under the License. 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef OCRROW_H 00021 #define OCRROW_H 00022 00023 #include <stdio.h> 00024 00025 #include "quspline.h" 00026 #include "werd.h" 00027 00028 class TO_ROW; 00029 00030 struct PARA; 00031 00032 class ROW:public ELIST_LINK 00033 { 00034 friend void tweak_row_baseline(ROW *, double, double); 00035 public: 00036 ROW() { 00037 } //empty constructor 00038 ROW( //constructor 00039 inT32 spline_size, //no of segments 00040 inT32 *xstarts, //segment boundaries 00041 double *coeffs, //coefficients //ascender size 00042 float x_height, 00043 float ascenders, 00044 float descenders, //descender size 00045 inT16 kern, //char gap 00046 inT16 space); //word gap 00047 ROW( //constructor 00048 TO_ROW *row, //textord row 00049 inT16 kern, //char gap 00050 inT16 space); //word gap 00051 00052 WERD_LIST *word_list() { //get words 00053 return &words; 00054 } 00055 00056 float base_line( //compute baseline 00057 float xpos) const { //at the position 00058 //get spline value 00059 return (float) baseline.y (xpos); 00060 } 00061 float x_height() const { //return x height 00062 return xheight; 00063 } 00064 void set_x_height(float new_xheight) { // set x height 00065 xheight = new_xheight; 00066 } 00067 inT32 kern() const { //return kerning 00068 return kerning; 00069 } 00070 float body_size() const { //return body size 00071 return bodysize; 00072 } 00073 void set_body_size(float new_size) { // set body size 00074 bodysize = new_size; 00075 } 00076 inT32 space() const { //return spacing 00077 return spacing; 00078 } 00079 float ascenders() const { //return size 00080 return ascrise; 00081 } 00082 float descenders() const { //return size 00083 return descdrop; 00084 } 00085 TBOX bounding_box() const { //return bounding box 00086 return bound_box; 00087 } 00088 // Returns the bounding box including the desired combination of upper and 00089 // lower noise/diacritic elements. 00090 TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const; 00091 00092 void set_lmargin(inT16 lmargin) { 00093 lmargin_ = lmargin; 00094 } 00095 void set_rmargin(inT16 rmargin) { 00096 rmargin_ = rmargin; 00097 } 00098 inT16 lmargin() const { 00099 return lmargin_; 00100 } 00101 inT16 rmargin() const { 00102 return rmargin_; 00103 } 00104 00105 void set_has_drop_cap(bool has) { 00106 has_drop_cap_ = has; 00107 } 00108 bool has_drop_cap() const { 00109 return has_drop_cap_; 00110 } 00111 00112 void set_para(PARA *p) { 00113 para_ = p; 00114 } 00115 PARA *para() const { 00116 return para_; 00117 } 00118 00119 void recalc_bounding_box(); //recalculate BB 00120 00121 void move( // reposition row 00122 const ICOORD vec); // by vector 00123 00124 void print( //print 00125 FILE *fp); //file to print on 00126 00127 #ifndef GRAPHICS_DISABLED 00128 void plot( //draw one 00129 ScrollView* window, //window to draw in 00130 ScrollView::Color colour); //uniform colour 00131 void plot( //draw one 00132 ScrollView* window); //in rainbow colours 00133 00134 void plot_baseline( //draw the baseline 00135 ScrollView* window, //window to draw in 00136 ScrollView::Color colour) { //colour to draw 00137 //draw it 00138 baseline.plot (window, colour); 00139 } 00140 #endif // GRAPHICS_DISABLED 00141 ROW& operator= (const ROW & source); 00142 00143 private: 00144 inT32 kerning; //inter char gap 00145 inT32 spacing; //inter word gap 00146 TBOX bound_box; //bounding box 00147 float xheight; //height of line 00148 float ascrise; //size of ascenders 00149 float descdrop; //-size of descenders 00150 float bodysize; //CJK character size. (equals to 00151 //xheight+ascrise by default) 00152 WERD_LIST words; //words 00153 QSPLINE baseline; //baseline spline 00154 00155 // These get set after blocks have been determined. 00156 bool has_drop_cap_; 00157 inT16 lmargin_; // Distance to left polyblock margin. 00158 inT16 rmargin_; // Distance to right polyblock margin. 00159 00160 // This gets set during paragraph analysis. 00161 PARA *para_; // Paragraph of which this row is part. 00162 }; 00163 00164 ELISTIZEH (ROW) 00165 #endif