tesseract  4.00.00dev
ocrrow.h
Go to the documentation of this file.
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 
25 #include "quspline.h"
26 #include "werd.h"
27 
28 class TO_ROW;
29 
30 struct PARA;
31 
32 class ROW:public ELIST_LINK
33 {
34  friend void tweak_row_baseline(ROW *, double, double);
35  public:
36  ROW() {
37  } //empty constructor
38  ROW( //constructor
39  inT32 spline_size, //no of segments
40  inT32 *xstarts, //segment boundaries
41  double *coeffs, //coefficients //ascender size
42  float x_height,
43  float ascenders,
44  float descenders, //descender size
45  inT16 kern, //char gap
46  inT16 space); //word gap
47  ROW( //constructor
48  TO_ROW *row, //textord row
49  inT16 kern, //char gap
50  inT16 space); //word gap
51 
52  WERD_LIST *word_list() { //get words
53  return &words;
54  }
55 
56  float base_line( //compute baseline
57  float xpos) const { //at the position
58  //get spline value
59  return (float) baseline.y (xpos);
60  }
61  float x_height() const { //return x height
62  return xheight;
63  }
64  void set_x_height(float new_xheight) { // set x height
65  xheight = new_xheight;
66  }
67  inT32 kern() const { //return kerning
68  return kerning;
69  }
70  float body_size() const { //return body size
71  return bodysize;
72  }
73  void set_body_size(float new_size) { // set body size
74  bodysize = new_size;
75  }
76  inT32 space() const { //return spacing
77  return spacing;
78  }
79  float ascenders() const { //return size
80  return ascrise;
81  }
82  float descenders() const { //return size
83  return descdrop;
84  }
85  TBOX bounding_box() const { //return bounding box
86  return bound_box;
87  }
88  // Returns the bounding box including the desired combination of upper and
89  // lower noise/diacritic elements.
90  TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const;
91 
93  lmargin_ = lmargin;
94  }
96  rmargin_ = rmargin;
97  }
98  inT16 lmargin() const {
99  return lmargin_;
100  }
101  inT16 rmargin() const {
102  return rmargin_;
103  }
104 
105  void set_has_drop_cap(bool has) {
106  has_drop_cap_ = has;
107  }
108  bool has_drop_cap() const {
109  return has_drop_cap_;
110  }
111 
112  void set_para(PARA *p) {
113  para_ = p;
114  }
115  PARA *para() const {
116  return para_;
117  }
118 
119  void recalc_bounding_box(); //recalculate BB
120 
121  void move( // reposition row
122  const ICOORD vec); // by vector
123 
124  void print( //print
125  FILE *fp); //file to print on
126 
127  #ifndef GRAPHICS_DISABLED
128  void plot( //draw one
129  ScrollView* window, //window to draw in
130  ScrollView::Color colour); //uniform colour
131  void plot( //draw one
132  ScrollView* window); //in rainbow colours
133 
134  void plot_baseline( //draw the baseline
135  ScrollView* window, //window to draw in
136  ScrollView::Color colour) { //colour to draw
137  //draw it
138  baseline.plot (window, colour);
139  }
140  #endif // GRAPHICS_DISABLED
141  ROW& operator= (const ROW & source);
142 
143  private:
144  inT32 kerning; //inter char gap
145  inT32 spacing; //inter word gap
146  TBOX bound_box; //bounding box
147  float xheight; //height of line
148  float ascrise; //size of ascenders
149  float descdrop; //-size of descenders
150  float bodysize; //CJK character size. (equals to
151  //xheight+ascrise by default)
152  WERD_LIST words; //words
153  QSPLINE baseline; //baseline spline
154 
155  // These get set after blocks have been determined.
156  bool has_drop_cap_;
157  inT16 lmargin_; // Distance to left polyblock margin.
158  inT16 rmargin_; // Distance to right polyblock margin.
159 
160  // This gets set during paragraph analysis.
161  PARA *para_; // Paragraph of which this row is part.
162 };
163 
164 ELISTIZEH (ROW)
165 #endif
friend void tweak_row_baseline(ROW *, double, double)
Definition: tordmain.cpp:885
float body_size() const
Definition: ocrrow.h:70
int32_t inT32
Definition: host.h:38
ROW()
Definition: ocrrow.h:36
#define ELISTIZEH(CLASSNAME)
Definition: elst.h:948
void move(const ICOORD vec)
Definition: ocrrow.cpp:148
void set_has_drop_cap(bool has)
Definition: ocrrow.h:105
void plot(ScrollView *window, ScrollView::Color colour) const
Definition: quspline.cpp:363
ROW & operator=(const ROW &source)
Definition: ocrrow.cpp:226
WERD_LIST * word_list()
Definition: ocrrow.h:52
float x_height() const
Definition: ocrrow.h:61
void print(FILE *fp)
Definition: ocrrow.cpp:167
void set_para(PARA *p)
Definition: ocrrow.h:112
int16_t inT16
Definition: host.h:36
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
Definition: ocrrow.cpp:85
inT16 lmargin() const
Definition: ocrrow.h:98
inT16 rmargin() const
Definition: ocrrow.h:101
void set_rmargin(inT16 rmargin)
Definition: ocrrow.h:95
void plot_baseline(ScrollView *window, ScrollView::Color colour)
Definition: ocrrow.h:134
double y(double x) const
Definition: quspline.cpp:217
inT32 kern() const
Definition: ocrrow.h:67
void set_body_size(float new_size)
Definition: ocrrow.h:73
TBOX bounding_box() const
Definition: ocrrow.h:85
float ascenders() const
Definition: ocrrow.h:79
Definition: rect.h:30
Definition: ocrpara.h:29
void set_x_height(float new_xheight)
Definition: ocrrow.h:64
void plot(ScrollView *window, ScrollView::Color colour)
Definition: ocrrow.cpp:188
void set_lmargin(inT16 lmargin)
Definition: ocrrow.h:92
PARA * para() const
Definition: ocrrow.h:115
float base_line(float xpos) const
Definition: ocrrow.h:56
void recalc_bounding_box()
Definition: ocrrow.cpp:101
Definition: ocrrow.h:32
integer coordinate
Definition: points.h:30
float descenders() const
Definition: ocrrow.h:82
inT32 space() const
Definition: ocrrow.h:76
bool has_drop_cap() const
Definition: ocrrow.h:108