00001
00020 #ifndef PDBLOCK_H
00021 #define PDBLOCK_H
00022
00023 #include "img.h"
00024 #include "strngs.h"
00025 #include "pageblk.h"
00026
00027 #include "hpddef.h"
00028
00029 class DLLSYM PDBLK;
00030
00031 CLISTIZEH (PDBLK)
00036 class DLLSYM PDBLK
00037 {
00038 friend class BLOCK_RECT_IT;
00039
00040 friend void scan_hpd_blocks(const char *name,
00041 PAGE_BLOCK_LIST *page_blocks,
00042 INT32 &block_no,
00043 PDBLK_C_IT *block_it);
00044 friend BOOL8 read_vec_file(
00045 STRING name,
00046 INT32 xsize,
00047 INT32 ysize,
00048 PDBLK_CLIST *blocks);
00049 friend BOOL8 read_pd_file(
00050 STRING name,
00051 INT32 xsize,
00052 INT32 ysize,
00053 PDBLK_CLIST *blocks);
00054
00055 public:
00056 PDBLK() {
00057 hand_block = NULL;
00058 hand_poly = NULL;
00059 }
00060 PDBLK(
00061 INT16 xmin,
00062 INT16 ymin,
00063 INT16 xmax,
00064 INT16 ymax);
00065
00066 void set_sides(
00067 ICOORDELT_LIST *left,
00068 ICOORDELT_LIST *right);
00069
00070 ~PDBLK () {
00071 }
00072
00073 TEXT_REGION *text_region() {
00074 return hand_block;
00075 }
00076 POLY_BLOCK *poly_block() {
00077 return hand_poly;
00078 }
00079 void set_poly_block(
00080 POLY_BLOCK *blk) {
00081 hand_poly = blk;
00082 }
00083 void bounding_box(
00084 ICOORD &bottom_left,
00085 ICOORD &top_right) const {
00086 bottom_left = box.botleft ();
00087 top_right = box.topright ();
00088 }
00089
00090 const BOX &bounding_box() const {
00091 return box;
00092 }
00093
00094 BOOL8 contains(
00095 ICOORD pt);
00096
00097 void move(
00098 const ICOORD vec);
00099
00100 void plot(
00101 WINDOW window,
00102 INT32 serial,
00103 COLOUR colour);
00104
00105 void show(
00106 IMAGE *image,
00107 WINDOW window);
00108
00109 PDBLK & operator= (
00110 const PDBLK & source);
00111
00112 protected:
00114 TEXT_REGION * hand_block;
00116 POLY_BLOCK *hand_poly;
00118 ICOORDELT_LIST leftside;
00120 ICOORDELT_LIST rightside;
00122 BOX box;
00123 };
00124
00129 class DLLSYM BLOCK_RECT_IT
00130 {
00131 public:
00132 BLOCK_RECT_IT(
00133 PDBLK *blkptr);
00134
00135 NEWDELETE2 (BLOCK_RECT_IT) void set_to_block (
00136 PDBLK * blkptr);
00137
00138 void start_block();
00139
00140 void forward();
00141
00142 BOOL8 cycled_rects() {
00143 return left_it.cycled_list () && right_it.cycled_list ();
00144 }
00145
00146 void bounding_box(
00147 ICOORD &bleft,
00148 ICOORD &tright) {
00149 bleft = ICOORD (left_it.data ()->x (), ymin);
00150 tright = ICOORD (right_it.data ()->x (), ymax);
00151 }
00152
00153 private:
00155 INT16 ymin;
00157 INT16 ymax;
00159 PDBLK *block;
00161 ICOORDELT_IT left_it;
00163 ICOORDELT_IT right_it;
00164 };
00165
00170 class DLLSYM BLOCK_LINE_IT
00171 {
00172 public:
00173 BLOCK_LINE_IT (
00174 PDBLK * blkptr)
00175 :rect_it (blkptr) {
00176 block = blkptr;
00177 }
00178
00179 NEWDELETE2 (BLOCK_LINE_IT) void set_to_block (
00180 PDBLK * blkptr) {
00181 block = blkptr;
00182
00183 rect_it.set_to_block (blkptr);
00184 }
00185
00186 INT16 get_line(
00187 INT16 y,
00188 INT16 &xext);
00189
00190 private:
00192 PDBLK * block;
00194 BLOCK_RECT_IT rect_it;
00195 };
00196
00197 int decreasing_top_order(
00198 const void *row1,
00199 const void *row2);
00204 #endif