All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pdblock.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: pdblock.h (Formerly pdblk.h)
3  * Description: Page block class definition.
4  * Author: Ray Smith
5  * Created: Thu Mar 14 17:32:01 GMT 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 PDBLOCK_H
21 #define PDBLOCK_H
22 
23 #include "clst.h"
24 #include "strngs.h"
25 #include "polyblk.h"
26 
27 class DLLSYM PDBLK; //forward decl
28 struct Pix;
29 
32 class PDBLK
33 {
34  friend class BLOCK_RECT_IT; //< block iterator
35 
36  public:
38  PDBLK() {
39  hand_poly = NULL;
40  index_ = 0;
41  }
43  PDBLK(inT16 xmin, //< bottom left
44  inT16 ymin,
45  inT16 xmax, //< top right
46  inT16 ymax);
47 
51  void set_sides(ICOORDELT_LIST *left,
52  ICOORDELT_LIST *right);
53 
55  ~PDBLK () {
56  if (hand_poly) delete hand_poly;
57  }
58 
60  return hand_poly;
61  }
64  hand_poly = blk;
65  }
67  void bounding_box(ICOORD &bottom_left, //bottom left
68  ICOORD &top_right) const { //topright
69  bottom_left = box.botleft ();
70  top_right = box.topright ();
71  }
73  const TBOX &bounding_box() const {
74  return box;
75  }
76 
77  int index() const {
78  return index_;
79  }
80  void set_index(int value) {
81  index_ = value;
82  }
83 
85  BOOL8 contains(ICOORD pt);
86 
88  void move(const ICOORD vec); // by vector
89 
90  // Returns a binary Pix mask with a 1 pixel for every pixel within the
91  // block. Rotates the coordinate system by rerotation prior to rendering.
92  // If not NULL, mask_box is filled with the position box of the returned
93  // mask image.
94  Pix *render_mask(const FCOORD &rerotation, TBOX *mask_box);
95 
96  #ifndef GRAPHICS_DISABLED
97  void plot(ScrollView* window,
102  inT32 serial,
103  ScrollView::Color colour);
104  #endif // GRAPHICS_DISABLED
105 
108  PDBLK & operator= (const PDBLK & source);
109 
110  protected:
111  POLY_BLOCK *hand_poly; //< wierd as well
112  ICOORDELT_LIST leftside; //< left side vertices
113  ICOORDELT_LIST rightside; //< right side vertices
114  TBOX box; //< bounding box
115  int index_; //< Serial number of this block.
116 };
117 
118 class DLLSYM BLOCK_RECT_IT //rectangle iterator
119 {
120  public:
123  BLOCK_RECT_IT(PDBLK *blkptr);
124 
126  void set_to_block (
127  PDBLK * blkptr); //block to iterate
128 
130  void start_block();
131 
133  void forward();
134 
137  return left_it.cycled_list () && right_it.cycled_list ();
138  }
139 
143  void bounding_box(ICOORD &bleft,
144  ICOORD &tright) {
145  //bottom left
146  bleft = ICOORD (left_it.data ()->x (), ymin);
147  //top right
148  tright = ICOORD (right_it.data ()->x (), ymax);
149  }
150 
151  private:
152  inT16 ymin; //< bottom of rectangle
153  inT16 ymax; //< top of rectangle
154  PDBLK *block; //< block to iterate
155  ICOORDELT_IT left_it; //< boundary iterators
156  ICOORDELT_IT right_it;
157 };
158 
161 {
162  public:
165  BLOCK_LINE_IT (PDBLK * blkptr)
166  :rect_it (blkptr) {
167  block = blkptr; //remember block
168  }
169 
172  void set_to_block (PDBLK * blkptr) {
173  block = blkptr; //remember block
174  //set iterator
175  rect_it.set_to_block (blkptr);
176  }
177 
181  inT16 get_line(inT16 y,
182  inT16 &xext);
183 
184  private:
185  PDBLK * block; //< block to iterate
186  BLOCK_RECT_IT rect_it; //< rectangle iterator
187 };
188 
189 int decreasing_top_order(const void *row1,
190  const void *row2);
191 #endif
TBOX box
Definition: pdblock.h:114
#define CLISTIZEH(CLASSNAME)
Definition: clst.h:946
class DLLSYM PDBLK
Definition: pdblock.h:27
void bounding_box(ICOORD &bleft, ICOORD &tright)
Definition: pdblock.h:143
POLY_BLOCK * hand_poly
Definition: pdblock.h:111
BOOL8 cycled_rects()
test end
Definition: pdblock.h:136
PDBLK()
empty constructor
Definition: pdblock.h:38
void set_poly_block(POLY_BLOCK *blk)
set the poly block
Definition: pdblock.h:63
unsigned char BOOL8
Definition: host.h:113
rectangle iterator
Definition: pdblock.h:160
ICOORDELT_LIST rightside
Definition: pdblock.h:113
ICOORDELT_LIST leftside
Definition: pdblock.h:112
void set_to_block(PDBLK *blkptr)
Definition: pdblock.h:172
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:67
integer coordinate
Definition: points.h:30
~PDBLK()
destructor
Definition: pdblock.h:55
int decreasing_top_order(const void *row1, const void *row2)
Definition: ocrblock.cpp:71
Definition: rect.h:30
int index() const
Definition: pdblock.h:77
void set_index(int value)
Definition: pdblock.h:80
#define NULL
Definition: host.h:144
int index_
Definition: pdblock.h:115
const TBOX & bounding_box() const
get real box
Definition: pdblock.h:73
POLY_BLOCK * poly_block() const
Definition: pdblock.h:59
#define DLLSYM
Definition: platform.h:25
Definition: points.h:189
BLOCK_LINE_IT(PDBLK *blkptr)
Definition: pdblock.h:165
page block
Definition: pdblock.h:32
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102