• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**********************************************************************
2  * File:        normalis.h  (Formerly denorm.h)
3  * Description: Code for the DENORM class.
4  * Author:		Ray Smith
5  * Created:		Thu Apr 23 09:22:43 BST 1992
6  *
7  * (C) Copyright 1992, 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           NORMALIS_H
21 #define           NORMALIS_H
22 
23 #include          <stdio.h>
24 
25 class ROW;                       //forward decl
26 class BLOCK;
27 
28 class DENORM_SEG
29 {
30   public:
DENORM_SEG()31     DENORM_SEG() {
32     }                            //empty
33 
34     inT32 xstart;                //start of segment
35     inT32 ycoord;                //y at segment
36     float scale_factor;          //for this segment
37 };
38 
39 class DENORM
40 {
41   public:
DENORM()42     DENORM() {  //constructor
43       source_row = NULL;
44       x_centre = 0.0f;
45       scale_factor = 1.0f;
46       segments = 0;
47       segs = NULL;
48       base_is_row = TRUE;
49       m = c = 0;
50       block_ = NULL;
51     }
DENORM(float x,float scaling,ROW * src)52     DENORM(          //constructor
53            float x,  //from same pieces
54            float scaling,
55            ROW *src) {
56       x_centre = x;              //just copy
57       scale_factor = scaling;
58       source_row = src;
59       segments = 0;
60       segs = NULL;
61       base_is_row = TRUE;
62       m = c = 0;
63       block_ = NULL;
64     }
65     DENORM(                      //constructor
66            float x,              //from same pieces
67            float scaling,
68            double line_m,        //default line //no of segments
69            double line_c,
70            inT16 seg_count,
71            DENORM_SEG *seg_pts,  //actual segments
72            BOOL8 using_row,      //as baseline
73            ROW *src);
74     DENORM(const DENORM &);
75     DENORM & operator= (const DENORM &);
~DENORM()76     ~DENORM () {
77       if (segments > 0)
78         delete[]segs;
79     }
80 
origin()81     float origin() const {  //get x centre
82       return x_centre;
83     }
scale()84     float scale() const {  //get scale
85       return scale_factor;
86     }
row()87     ROW *row() const {  //get row
88       return source_row;
89     }
block()90     const BLOCK* block() const {
91       return block_;
92     }
set_block(const BLOCK * block)93     void set_block(const BLOCK* block) {
94       block_ = block;
95     }
96     float x(  //convert an xcoord
97             float src_x) const;
98     float y(                    //convert a ycoord
99             float src_y,        //coord to convert
100             float src_centre) const;  //normed x centre
101     float scale_at_x(  // Return scaling at this coord.
102             float src_x) const;
103     float yshift_at_x(  // Return yshift at this coord.
104             float src_x) const;
105 
106   private:
107     const DENORM_SEG *binary_search_segment(float src_x) const;
108 
109     BOOL8 base_is_row;           //using row baseline?
110     inT16 segments;              //no of segments
111     double c, m;                 //baseline
112     float x_centre;              //middle of word
113     float scale_factor;          //scaling
114     ROW *source_row;             //row it came from
115     DENORM_SEG *segs;            //array of segments
116     const BLOCK* block_;         // Block the word came from.
117 };
118 #endif
119