00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PDBLOCK_H
00021 #define PDBLOCK_H
00022
00023 #include "img.h"
00024 #include "strngs.h"
00025 #include "polyblk.h"
00026
00027 #include "hpddef.h"
00028
00029 class DLLSYM PDBLK;
00030
00031 CLISTIZEH (PDBLK)
00032 class DLLSYM PDBLK
00033 {
00034 friend class BLOCK_RECT_IT;
00035
00036 public:
00037 PDBLK() {
00038 hand_poly = NULL;
00039 index_ = 0;
00040 }
00041 PDBLK(
00042 inT16 xmin,
00043 inT16 ymin,
00044 inT16 xmax,
00045 inT16 ymax);
00046
00047 void set_sides(
00048 ICOORDELT_LIST *left,
00049 ICOORDELT_LIST *right);
00050
00051 ~PDBLK () {
00052 if (hand_poly) delete hand_poly;
00053 }
00054
00055 POLY_BLOCK *poly_block() {
00056 return hand_poly;
00057 }
00058 void set_poly_block(
00059 POLY_BLOCK *blk) {
00060 hand_poly = blk;
00061 }
00062 void bounding_box(
00063 ICOORD &bottom_left,
00064 ICOORD &top_right) const {
00065 bottom_left = box.botleft ();
00066 top_right = box.topright ();
00067 }
00068
00069 const TBOX &bounding_box() const {
00070 return box;
00071 }
00072
00073 int index() const {
00074 return index_;
00075 }
00076 void set_index(int value) {
00077 index_ = value;
00078 }
00079
00080 BOOL8 contains(
00081 ICOORD pt);
00082
00083 void move(
00084 const ICOORD vec);
00085
00086 void plot(
00087 ScrollView* window,
00088 inT32 serial,
00089 ScrollView::Color colour);
00090
00091 void show(
00092 IMAGE *image,
00093 ScrollView* window);
00094
00095 PDBLK & operator= (
00096 const PDBLK & source);
00097
00098 protected:
00099 POLY_BLOCK *hand_poly;
00100 ICOORDELT_LIST leftside;
00101 ICOORDELT_LIST rightside;
00102 TBOX box;
00103 int index_;
00104 };
00105
00106 class DLLSYM BLOCK_RECT_IT
00107 {
00108 public:
00109 BLOCK_RECT_IT(
00110 PDBLK *blkptr);
00111
00112
00113 NEWDELETE2 (BLOCK_RECT_IT) void set_to_block (
00114 PDBLK * blkptr);
00115
00116 void start_block();
00117
00118 void forward();
00119
00120 BOOL8 cycled_rects() {
00121 return left_it.cycled_list () && right_it.cycled_list ();
00122 }
00123
00124 void bounding_box(
00125 ICOORD &bleft,
00126 ICOORD &tright) {
00127
00128 bleft = ICOORD (left_it.data ()->x (), ymin);
00129
00130 tright = ICOORD (right_it.data ()->x (), ymax);
00131 }
00132
00133 private:
00134 inT16 ymin;
00135 inT16 ymax;
00136 PDBLK *block;
00137 ICOORDELT_IT left_it;
00138 ICOORDELT_IT right_it;
00139 };
00140
00141 class DLLSYM BLOCK_LINE_IT
00142 {
00143 public:
00144 BLOCK_LINE_IT (
00145 PDBLK * blkptr)
00146 :rect_it (blkptr) {
00147 block = blkptr;
00148 }
00149
00150
00151 NEWDELETE2 (BLOCK_LINE_IT) void set_to_block (
00152 PDBLK * blkptr) {
00153 block = blkptr;
00154
00155 rect_it.set_to_block (blkptr);
00156 }
00157
00158 inT16 get_line(
00159 inT16 y,
00160 inT16 &xext);
00161
00162 private:
00163 PDBLK * block;
00164 BLOCK_RECT_IT rect_it;
00165 };
00166
00167 int decreasing_top_order(
00168 const void *row1,
00169 const void *row2);
00170 #endif