• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**********************************************************************
2  * File:        ocrrow.h  (Formerly row.h)
3  * Description: Code for the ROW class.
4  * Author:		Ray Smith
5  * Created:		Tue Oct 08 15:58:04 BST 1991
6  *
7  * (C) Copyright 1991, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef           OCRROW_H
21 #define           OCRROW_H
22 
23 #include          <stdio.h>
24 #include          "quspline.h"
25 #include          "werd.h"
26 
27 class TO_ROW;
28 
29 class ROW:public ELIST_LINK
30 {
31   friend void tweak_row_baseline(ROW *);
32   public:
ROW()33     ROW() {
34     }                            //empty constructor
35     ROW(                    //constructor
36         inT32 spline_size,  //no of segments
37         inT32 *xstarts,     //segment boundaries
38         double *coeffs,     //coefficients //ascender size
39         float x_height,
40         float ascenders,
41         float descenders,   //descender size
42         inT16 kern,         //char gap
43         inT16 space);       //word gap
44     ROW(               //constructor
45         TO_ROW *row,   //textord row
46         inT16 kern,    //char gap
47         inT16 space);  //word gap
48 
word_list()49     WERD_LIST *word_list() {  //get words
50       return &words;
51     }
52 
base_line(float xpos)53     float base_line(                     //compute baseline
54                     float xpos) const {  //at the position
55                                  //get spline value
56       return (float) baseline.y (xpos);
57     }
x_height()58     float x_height() const {  //return x height
59       return xheight;
60     }
set_x_height(float new_xheight)61     void set_x_height(float new_xheight) {  // set x height
62       xheight = new_xheight;
63     }
kern()64     inT32 kern() const {  //return kerning
65       return kerning;
66     }
space()67     inT32 space() const {  //return spacing
68       return spacing;
69     }
ascenders()70     float ascenders() const {  //return size
71       return ascrise;
72     }
descenders()73     float descenders() const {  //return size
74       return descdrop;
75     }
bounding_box()76     TBOX bounding_box() const {  //return bounding box
77       return bound_box;
78     }
79 
80     void recalc_bounding_box();  //recalculate BB
81 
82     void move(                    // reposition row
83               const ICOORD vec);  // by vector
84 
85     void print(            //print
86                FILE *fp);  //file to print on
87 
88     void plot(                 //draw one
89               ScrollView* window,   //window to draw in
90               ScrollView::Color colour);  //uniform colour
91     void plot(                 //draw one
92               ScrollView* window);  //in rainbow colours
93 
94 #ifndef GRAPHICS_DISABLED
plot_baseline(ScrollView * window,ScrollView::Color colour)95     void plot_baseline(                  //draw the baseline
96                        ScrollView* window,    //window to draw in
97                        ScrollView::Color colour) {  //colour to draw
98                                  //draw it
99       baseline.plot (window, colour);
100     }
101 #endif
102 
prep_serialise()103     void prep_serialise() {  //set ptrs to counts
104       words.prep_serialise ();
105       baseline.prep_serialise ();
106     }
107 
dump(FILE * f)108     void dump(  //write external bits
109               FILE *f) {
110       words.dump (f);
111       baseline.dump (f);
112     }
113 
de_dump(FILE * f)114     void de_dump(  //read external bits
115                  FILE *f) {
116       words.de_dump (f);
117       baseline.de_dump (f);
118     }
119 
120                                  //assignment
121     make_serialise (ROW) ROW & operator= (
122       const ROW & source);       //from this
123 
124   private:
125     inT32 kerning;               //inter char gap
126     inT32 spacing;               //inter word gap
127     TBOX bound_box;               //bounding box
128     float xheight;               //height of line
129     float ascrise;               //size of ascenders
130     float descdrop;              //-size of descenders
131     WERD_LIST words;             //words
132     QSPLINE baseline;            //baseline spline
133 };
134 
135 ELISTIZEH_S (ROW)
136 #endif
137