Tesseract 3.01
/data/source/tesseract-ocr/ccstruct/ocrrow.h
Go to the documentation of this file.
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 #include          "quspline.h"
00025 #include          "werd.h"
00026 
00027 class TO_ROW;
00028 
00029 class ROW:public ELIST_LINK
00030 {
00031   friend void tweak_row_baseline(ROW *, double, double);
00032   public:
00033     ROW() {
00034     }                            //empty constructor
00035     ROW(                    //constructor
00036         inT32 spline_size,  //no of segments
00037         inT32 *xstarts,     //segment boundaries
00038         double *coeffs,     //coefficients //ascender size
00039         float x_height,
00040         float ascenders,
00041         float descenders,   //descender size
00042         inT16 kern,         //char gap
00043         inT16 space);       //word gap
00044     ROW(               //constructor
00045         TO_ROW *row,   //textord row
00046         inT16 kern,    //char gap
00047         inT16 space);  //word gap
00048 
00049     WERD_LIST *word_list() {  //get words
00050       return &words;
00051     }
00052 
00053     float base_line(                     //compute baseline
00054                     float xpos) const {  //at the position
00055                                  //get spline value
00056       return (float) baseline.y (xpos);
00057     }
00058     float x_height() const {  //return x height
00059       return xheight;
00060     }
00061     void set_x_height(float new_xheight) {  // set x height
00062       xheight = new_xheight;
00063     }
00064     inT32 kern() const {  //return kerning
00065       return kerning;
00066     }
00067     inT32 space() const {  //return spacing
00068       return spacing;
00069     }
00070     float ascenders() const {  //return size
00071       return ascrise;
00072     }
00073     float descenders() const {  //return size
00074       return descdrop;
00075     }
00076     TBOX bounding_box() const {  //return bounding box
00077       return bound_box;
00078     }
00079 
00080     void recalc_bounding_box();  //recalculate BB
00081 
00082     void move(                    // reposition row
00083               const ICOORD vec);  // by vector
00084 
00085     void print(            //print
00086                FILE *fp);  //file to print on
00087 
00088     void plot(                 //draw one
00089               ScrollView* window,   //window to draw in
00090               ScrollView::Color colour);  //uniform colour
00091     void plot(                 //draw one
00092               ScrollView* window);  //in rainbow colours
00093 
00094 #ifndef GRAPHICS_DISABLED
00095     void plot_baseline(                  //draw the baseline
00096                        ScrollView* window,    //window to draw in
00097                        ScrollView::Color colour) {  //colour to draw
00098                                  //draw it
00099       baseline.plot (window, colour);
00100     }
00101 #endif
00102     ROW& operator= (const ROW & source);
00103 
00104   private:
00105     inT32 kerning;               //inter char gap
00106     inT32 spacing;               //inter word gap
00107     TBOX bound_box;               //bounding box
00108     float xheight;               //height of line
00109     float ascrise;               //size of ascenders
00110     float descdrop;              //-size of descenders
00111     WERD_LIST words;             //words
00112     QSPLINE baseline;            //baseline spline
00113 };
00114 
00115 ELISTIZEH (ROW)
00116 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines