Tesseract
3.02
|
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 class 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 00089 void set_lmargin(inT16 lmargin) { 00090 lmargin_ = lmargin; 00091 } 00092 void set_rmargin(inT16 rmargin) { 00093 rmargin_ = rmargin; 00094 } 00095 inT16 lmargin() const { 00096 return lmargin_; 00097 } 00098 inT16 rmargin() const { 00099 return rmargin_; 00100 } 00101 00102 void set_has_drop_cap(bool has) { 00103 has_drop_cap_ = has; 00104 } 00105 bool has_drop_cap() const { 00106 return has_drop_cap_; 00107 } 00108 00109 void set_para(PARA *p) { 00110 para_ = p; 00111 } 00112 PARA *para() const { 00113 return para_; 00114 } 00115 00116 void recalc_bounding_box(); //recalculate BB 00117 00118 void move( // reposition row 00119 const ICOORD vec); // by vector 00120 00121 void print( //print 00122 FILE *fp); //file to print on 00123 00124 void plot( //draw one 00125 ScrollView* window, //window to draw in 00126 ScrollView::Color colour); //uniform colour 00127 void plot( //draw one 00128 ScrollView* window); //in rainbow colours 00129 00130 #ifndef GRAPHICS_DISABLED 00131 void plot_baseline( //draw the baseline 00132 ScrollView* window, //window to draw in 00133 ScrollView::Color colour) { //colour to draw 00134 //draw it 00135 baseline.plot (window, colour); 00136 } 00137 #endif 00138 ROW& operator= (const ROW & source); 00139 00140 private: 00141 inT32 kerning; //inter char gap 00142 inT32 spacing; //inter word gap 00143 TBOX bound_box; //bounding box 00144 float xheight; //height of line 00145 float ascrise; //size of ascenders 00146 float descdrop; //-size of descenders 00147 float bodysize; //CJK character size. (equals to 00148 //xheight+ascrise by default) 00149 WERD_LIST words; //words 00150 QSPLINE baseline; //baseline spline 00151 00152 // These get set after blocks have been determined. 00153 bool has_drop_cap_; 00154 inT16 lmargin_; // Distance to left polyblock margin. 00155 inT16 rmargin_; // Distance to right polyblock margin. 00156 00157 // This gets set during paragraph analysis. 00158 PARA *para_; // Paragraph of which this row is part. 00159 }; 00160 00161 ELISTIZEH (ROW) 00162 #endif