All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PDBLK Class Reference

page block More...

#include <pdblock.h>

Inheritance diagram for PDBLK:
BLOCK

Public Member Functions

 PDBLK ()
 empty constructor More...
 
 PDBLK (inT16 xmin, inT16 ymin, inT16 xmax, inT16 ymax)
 simple constructor More...
 
void set_sides (ICOORDELT_LIST *left, ICOORDELT_LIST *right)
 
 ~PDBLK ()
 destructor More...
 
POLY_BLOCKpoly_block () const
 
void set_poly_block (POLY_BLOCK *blk)
 set the poly block More...
 
void bounding_box (ICOORD &bottom_left, ICOORD &top_right) const
 get box More...
 
const TBOXbounding_box () const
 get real box More...
 
int index () const
 
void set_index (int value)
 
BOOL8 contains (ICOORD pt)
 is pt inside block More...
 
void move (const ICOORD vec)
 reposition block More...
 
Pix * render_mask (const FCOORD &rerotation, TBOX *mask_box)
 
void plot (ScrollView *window, inT32 serial, ScrollView::Color colour)
 
PDBLKoperator= (const PDBLK &source)
 

Protected Attributes

POLY_BLOCKhand_poly
 
ICOORDELT_LIST leftside
 
ICOORDELT_LIST rightside
 
TBOX box
 
int index_
 

Friends

class BLOCK_RECT_IT
 

Detailed Description

page block

Definition at line 32 of file pdblock.h.

Constructor & Destructor Documentation

PDBLK::PDBLK ( )
inline

empty constructor

Definition at line 38 of file pdblock.h.

38  {
39  hand_poly = NULL;
40  index_ = 0;
41  }
POLY_BLOCK * hand_poly
Definition: pdblock.h:111
#define NULL
Definition: host.h:144
int index_
Definition: pdblock.h:115
PDBLK::PDBLK ( inT16  xmin,
inT16  ymin,
inT16  xmax,
inT16  ymax 
)

simple constructor

Definition at line 38 of file pdblock.cpp.

41  : box (ICOORD (xmin, ymin), ICOORD (xmax, ymax)) {
42  //boundaries
43  ICOORDELT_IT left_it = &leftside;
44  ICOORDELT_IT right_it = &rightside;
45 
46  hand_poly = NULL;
47  left_it.set_to_list (&leftside);
48  right_it.set_to_list (&rightside);
49  //make default box
50  left_it.add_to_end (new ICOORDELT (xmin, ymin));
51  left_it.add_to_end (new ICOORDELT (xmin, ymax));
52  right_it.add_to_end (new ICOORDELT (xmax, ymin));
53  right_it.add_to_end (new ICOORDELT (xmax, ymax));
54  index_ = 0;
55 }
TBOX box
Definition: pdblock.h:114
POLY_BLOCK * hand_poly
Definition: pdblock.h:111
ICOORDELT_LIST rightside
Definition: pdblock.h:113
ICOORDELT_LIST leftside
Definition: pdblock.h:112
integer coordinate
Definition: points.h:30
#define NULL
Definition: host.h:144
int index_
Definition: pdblock.h:115
PDBLK::~PDBLK ( )
inline

destructor

Definition at line 55 of file pdblock.h.

55  {
56  if (hand_poly) delete hand_poly;
57  }
POLY_BLOCK * hand_poly
Definition: pdblock.h:111

Member Function Documentation

void PDBLK::bounding_box ( ICOORD bottom_left,
ICOORD top_right 
) const
inline

get box

Definition at line 67 of file pdblock.h.

68  { //topright
69  bottom_left = box.botleft ();
70  top_right = box.topright ();
71  }
TBOX box
Definition: pdblock.h:114
const ICOORD & botleft() const
Definition: rect.h:88
const ICOORD & topright() const
Definition: rect.h:100
const TBOX& PDBLK::bounding_box ( ) const
inline

get real box

Definition at line 73 of file pdblock.h.

73  {
74  return box;
75  }
TBOX box
Definition: pdblock.h:114
BOOL8 PDBLK::contains ( ICOORD  pt)

is pt inside block

Definition at line 86 of file pdblock.cpp.

88  {
89  BLOCK_RECT_IT it = this; //rectangle iterator
90  ICOORD bleft, tright; //corners of rectangle
91 
92  for (it.start_block (); !it.cycled_rects (); it.forward ()) {
93  //get rectangle
94  it.bounding_box (bleft, tright);
95  //inside rect
96  if (pt.x () >= bleft.x () && pt.x () <= tright.x ()
97  && pt.y () >= bleft.y () && pt.y () <= tright.y ())
98  return TRUE; //is inside
99  }
100  return FALSE; //not inside
101 }
void forward()
next rectangle
Definition: pdblock.cpp:313
void bounding_box(ICOORD &bleft, ICOORD &tright)
Definition: pdblock.h:143
BOOL8 cycled_rects()
test end
Definition: pdblock.h:136
inT16 y() const
access_function
Definition: points.h:56
integer coordinate
Definition: points.h:30
void start_block()
start iteration
Definition: pdblock.cpp:294
#define FALSE
Definition: capi.h:29
inT16 x() const
access function
Definition: points.h:52
#define TRUE
Definition: capi.h:28
int PDBLK::index ( ) const
inline

Definition at line 77 of file pdblock.h.

77  {
78  return index_;
79  }
int index_
Definition: pdblock.h:115
void PDBLK::move ( const ICOORD  vec)

reposition block

Definition at line 110 of file pdblock.cpp.

112  {
113  ICOORDELT_IT it(&leftside);
114 
115  for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
116  *(it.data ()) += vec;
117 
118  it.set_to_list (&rightside);
119 
120  for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
121  *(it.data ()) += vec;
122 
123  box.move (vec);
124 }
TBOX box
Definition: pdblock.h:114
ICOORDELT_LIST rightside
Definition: pdblock.h:113
ICOORDELT_LIST leftside
Definition: pdblock.h:112
void move(const ICOORD vec)
Definition: rect.h:153
PDBLK & PDBLK::operator= ( const PDBLK source)

assignment

Parameters
sourcefrom this

Definition at line 238 of file pdblock.cpp.

240  {
241  // this->ELIST_LINK::operator=(source);
242  if (!leftside.empty ())
243  leftside.clear ();
244  if (!rightside.empty ())
245  rightside.clear ();
246  leftside.deep_copy(&source.leftside, &ICOORDELT::deep_copy);
247  rightside.deep_copy(&source.rightside, &ICOORDELT::deep_copy);
248  box = source.box;
249  return *this;
250 }
TBOX box
Definition: pdblock.h:114
static ICOORDELT * deep_copy(const ICOORDELT *src)
Definition: points.h:180
ICOORDELT_LIST rightside
Definition: pdblock.h:113
ICOORDELT_LIST leftside
Definition: pdblock.h:112
void PDBLK::plot ( ScrollView window,
inT32  serial,
ScrollView::Color  colour 
)

draw histogram

Parameters
windowwindow to draw in
serialserial number
colourcolour to draw in

Definition at line 177 of file pdblock.cpp.

181  {
182  ICOORD startpt; //start of outline
183  ICOORD endpt; //end of outline
184  ICOORD prevpt; //previous point
185  ICOORDELT_IT it = &leftside; //iterator
186 
187  //set the colour
188  window->Pen(colour);
189  window->TextAttributes("Times", BLOCK_LABEL_HEIGHT, false, false, false);
190 
191  if (hand_poly != NULL) {
192  hand_poly->plot(window, serial);
193  } else if (!leftside.empty ()) {
194  startpt = *(it.data ()); //bottom left corner
195  // tprintf("Block %d bottom left is (%d,%d)\n",
196  // serial,startpt.x(),startpt.y());
197  char temp_buff[34];
198  #if defined(__UNIX__) || defined(MINGW)
199  sprintf(temp_buff, INT32FORMAT, serial);
200  #else
201  ultoa (serial, temp_buff, 10);
202  #endif
203  window->Text(startpt.x (), startpt.y (), temp_buff);
204 
205  window->SetCursor(startpt.x (), startpt.y ());
206  do {
207  prevpt = *(it.data ()); //previous point
208  it.forward (); //move to next point
209  //draw round corner
210  window->DrawTo(prevpt.x (), it.data ()->y ());
211  window->DrawTo(it.data ()->x (), it.data ()->y ());
212  }
213  while (!it.at_last ()); //until end of list
214  endpt = *(it.data ()); //end point
215 
216  //other side of boundary
217  window->SetCursor(startpt.x (), startpt.y ());
218  it.set_to_list (&rightside);
219  prevpt = startpt;
220  for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
221  //draw round corner
222  window->DrawTo(prevpt.x (), it.data ()->y ());
223  window->DrawTo(it.data ()->x (), it.data ()->y ());
224  prevpt = *(it.data ()); //previous point
225  }
226  //close boundary
227  window->DrawTo(endpt.x(), endpt.y());
228  }
229 }
void Pen(Color color)
Definition: scrollview.cpp:726
POLY_BLOCK * hand_poly
Definition: pdblock.h:111
void Text(int x, int y, const char *mystring)
Definition: scrollview.cpp:658
void DrawTo(int x, int y)
Definition: scrollview.cpp:531
#define INT32FORMAT
Definition: host.h:115
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
Definition: scrollview.cpp:641
ICOORDELT_LIST rightside
Definition: pdblock.h:113
ICOORDELT_LIST leftside
Definition: pdblock.h:112
inT16 y() const
access_function
Definition: points.h:56
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
integer coordinate
Definition: points.h:30
void plot(ScrollView *window, inT32 num)
Definition: polyblk.cpp:245
inT16 x() const
access function
Definition: points.h:52
#define BLOCK_LABEL_HEIGHT
Definition: pdblock.cpp:30
#define NULL
Definition: host.h:144
POLY_BLOCK* PDBLK::poly_block ( ) const
inline

Definition at line 59 of file pdblock.h.

59  {
60  return hand_poly;
61  }
POLY_BLOCK * hand_poly
Definition: pdblock.h:111
Pix * PDBLK::render_mask ( const FCOORD rerotation,
TBOX mask_box 
)

Definition at line 128 of file pdblock.cpp.

128  {
129  TBOX rotated_box(box);
130  rotated_box.rotate(rerotation);
131  Pix* pix = pixCreate(rotated_box.width(), rotated_box.height(), 1);
132  if (hand_poly != NULL) {
133  // We are going to rotate, so get a deep copy of the points and
134  // make a new POLY_BLOCK with it.
135  ICOORDELT_LIST polygon;
136  polygon.deep_copy(hand_poly->points(), ICOORDELT::deep_copy);
137  POLY_BLOCK image_block(&polygon, hand_poly->isA());
138  image_block.rotate(rerotation);
139  // Block outline is a polygon, so use a PB_LINE_IT to get the
140  // rasterized interior. (Runs of interior pixels on a line.)
141  PB_LINE_IT *lines = new PB_LINE_IT(&image_block);
142  for (int y = box.bottom(); y < box.top(); ++y) {
143  ICOORDELT_LIST* segments = lines->get_line(y);
144  if (!segments->empty()) {
145  ICOORDELT_IT s_it(segments);
146  // Each element of segments is a start x and x size of the
147  // run of interior pixels.
148  for (s_it.mark_cycle_pt(); !s_it.cycled_list(); s_it.forward()) {
149  int start = s_it.data()->x();
150  int xext = s_it.data()->y();
151  // Set the run of pixels to 1.
152  pixRasterop(pix, start - rotated_box.left(),
153  rotated_box.height() - 1 - (y - rotated_box.bottom()),
154  xext, 1, PIX_SET, NULL, 0, 0);
155  }
156  }
157  delete segments;
158  }
159  delete lines;
160  } else {
161  // Just fill the whole block as there is only a bounding box.
162  pixRasterop(pix, 0, 0, rotated_box.width(), rotated_box.height(),
163  PIX_SET, NULL, 0, 0);
164  }
165  if (mask_box != NULL) *mask_box = rotated_box;
166  return pix;
167 }
TBOX box
Definition: pdblock.h:114
static ICOORDELT * deep_copy(const ICOORDELT *src)
Definition: points.h:180
POLY_BLOCK * hand_poly
Definition: pdblock.h:111
void rotate(FCOORD rotation)
Definition: polyblk.cpp:185
ICOORDELT_LIST * get_line(inT16 y)
Definition: polyblk.cpp:341
ICOORDELT_LIST * points()
Definition: polyblk.h:42
inT16 bottom() const
Definition: rect.h:61
Definition: rect.h:30
#define NULL
Definition: host.h:144
inT16 top() const
Definition: rect.h:54
PolyBlockType isA() const
Definition: polyblk.h:48
void PDBLK::set_index ( int  value)
inline

Definition at line 80 of file pdblock.h.

80  {
81  index_ = value;
82  }
int index_
Definition: pdblock.h:115
void PDBLK::set_poly_block ( POLY_BLOCK blk)
inline

set the poly block

Definition at line 63 of file pdblock.h.

63  {
64  hand_poly = blk;
65  }
POLY_BLOCK * hand_poly
Definition: pdblock.h:111
void PDBLK::set_sides ( ICOORDELT_LIST *  left,
ICOORDELT_LIST *  right 
)

set vertex lists

Parameters
leftlist of left vertices
rightlist of right vertices

Definition at line 64 of file pdblock.cpp.

67  {
68  //boundaries
69  ICOORDELT_IT left_it = &leftside;
70  ICOORDELT_IT right_it = &rightside;
71 
72  leftside.clear ();
73  left_it.move_to_first ();
74  left_it.add_list_before (left);
75  rightside.clear ();
76  right_it.move_to_first ();
77  right_it.add_list_before (right);
78 }
ICOORDELT_LIST rightside
Definition: pdblock.h:113
ICOORDELT_LIST leftside
Definition: pdblock.h:112

Friends And Related Function Documentation

friend class BLOCK_RECT_IT
friend

Definition at line 34 of file pdblock.h.

Member Data Documentation

TBOX PDBLK::box
protected

Definition at line 114 of file pdblock.h.

POLY_BLOCK* PDBLK::hand_poly
protected

Definition at line 111 of file pdblock.h.

int PDBLK::index_
protected

Definition at line 115 of file pdblock.h.

ICOORDELT_LIST PDBLK::leftside
protected

Definition at line 112 of file pdblock.h.

ICOORDELT_LIST PDBLK::rightside
protected

Definition at line 113 of file pdblock.h.


The documentation for this class was generated from the following files: