23 #include "allheaders.h" 28 #include "config_auto.h" 31 #define BLOCK_LABEL_HEIGHT 150 //char height of block id 44 ICOORDELT_IT left_it = &leftside;
45 ICOORDELT_IT right_it = &rightside;
48 left_it.set_to_list (&leftside);
49 right_it.set_to_list (&rightside);
51 left_it.add_to_end (
new ICOORDELT (xmin, ymin));
52 left_it.add_to_end (
new ICOORDELT (xmin, ymax));
53 right_it.add_to_end (
new ICOORDELT (xmax, ymin));
54 right_it.add_to_end (
new ICOORDELT (xmax, ymax));
74 left_it.move_to_first ();
75 left_it.add_list_before (left);
77 right_it.move_to_first ();
78 right_it.add_list_before (right);
97 if (pt.
x () >= bleft.
x () && pt.
x () <= tright.
x ()
98 && pt.
y () >= bleft.
y () && pt.
y () <= tright.
y ())
116 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
117 *(it.data ()) += vec;
121 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
122 *(it.data ()) += vec;
131 rotated_box.
rotate(rerotation);
132 Pix* pix = pixCreate(rotated_box.
width(), rotated_box.
height(), 1);
136 ICOORDELT_LIST polygon;
139 image_block.
rotate(rerotation);
144 const std::unique_ptr< ICOORDELT_LIST> segments(
146 if (!segments->empty()) {
147 ICOORDELT_IT s_it(segments.get());
150 for (s_it.mark_cycle_pt(); !s_it.cycled_list(); s_it.forward()) {
151 int start = s_it.data()->x();
152 int xext = s_it.data()->y();
154 pixRasterop(pix, start - rotated_box.
left(),
156 xext, 1, PIX_SET, NULL, 0, 0);
163 pixRasterop(pix, 0, 0, rotated_box.
width(), rotated_box.
height(),
164 PIX_SET, NULL, 0, 0);
166 if (mask_box != NULL) *mask_box = rotated_box;
177 #ifndef GRAPHICS_DISABLED 195 startpt = *(it.data ());
199 #if defined(__UNIX__) || defined(MINGW) 200 snprintf(temp_buff,
sizeof(temp_buff),
"%" PRId32, serial);
202 ultoa (serial, temp_buff, 10);
204 window->
Text(startpt.
x (), startpt.
y (), temp_buff);
208 prevpt = *(it.data ());
211 window->
DrawTo(prevpt.
x (), it.data ()->y ());
212 window->
DrawTo(it.data ()->x (), it.data ()->y ());
214 while (!it.at_last ());
215 endpt = *(it.data ());
221 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
223 window->
DrawTo(prevpt.
x (), it.data ()->y ());
224 window->
DrawTo(it.data ()->x (), it.data ()->y ());
225 prevpt = *(it.data ());
228 window->
DrawTo(endpt.
x(), endpt.
y());
282 left_it.set_to_list (&blkptr->
leftside);
283 right_it.set_to_list (&blkptr->
rightside);
296 left_it.move_to_first ();
297 right_it.move_to_first ();
298 left_it.mark_cycle_pt ();
299 right_it.mark_cycle_pt ();
300 ymin = left_it.data ()->y ();
301 ymax = left_it.data_relative (1)->y ();
302 if (right_it.data_relative (1)->y () < ymax)
304 ymax = right_it.data_relative (1)->y ();
315 if (!left_it.empty ()) {
316 if (left_it.data_relative (1)->y () == ymax)
318 if (right_it.data_relative (1)->y () == ymax)
321 if (left_it.at_last () || right_it.at_last ()) {
322 left_it.move_to_first ();
323 right_it.move_to_first ();
325 ymin = left_it.data ()->y ();
331 ymax = left_it.data_relative (1)->y ();
332 if (right_it.data_relative (1)->y () < ymax)
334 ymax = right_it.data_relative (1)->y ();
354 if (y < bleft.
y () || y >= tright.
y ()) {
360 rect_it.bounding_box (bleft, tright);
362 if (y >= bleft.
y () && y < tright.
y ()) {
364 xext = tright.
x () - bleft.
x ();
367 for (rect_it.start_block (); !rect_it.cycled_rects (); rect_it.forward ()) {
369 rect_it.bounding_box (bleft, tright);
371 if (y >= bleft.
y () && y < tright.
y ()) {
373 xext = tright.
x () - bleft.
x ();
Pix * render_mask(const FCOORD &rerotation, TBOX *mask_box)
void plot(ScrollView *window, inT32 serial, ScrollView::Color colour)
const ERRCODE BADBLOCKLINE
BLOCK_RECT_IT(PDBLK *blkptr)
void DrawTo(int x, int y)
void bounding_box(ICOORD &bleft, ICOORD &tright)
inT16 x() const
access function
inT16 get_line(inT16 y, inT16 &xext)
void rotate(FCOORD rotation)
BOOL8 cycled_rects()
test end
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
PolyBlockType isA() const
const ERRCODE LOSTBLOCKLINE
void Text(int x, int y, const char *mystring)
BOOL8 contains(ICOORD pt)
is pt inside block
ICOORDELT_LIST * points()
void move(const ICOORD vec)
void forward()
next rectangle
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
static ICOORDELT * deep_copy(const ICOORDELT *src)
void SetCursor(int x, int y)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
void move(const ICOORD vec)
reposition block
void set_to_block(PDBLK *blkptr)
start (new) block
inT16 y() const
access_function
void rotate(const FCOORD &vec)
void start_block()
start iteration
void set_sides(ICOORDELT_LIST *left, ICOORDELT_LIST *right)
CLISTIZE(BLOCK_RES) ELISTIZE(ROW_RES) ELISTIZE(WERD_RES) static const double kStopperAmbiguityThresholdGain
#define BLOCK_LABEL_HEIGHT
ICOORDELT_LIST * get_line(inT16 y)
PDBLK & operator=(const PDBLK &source)
void plot(ScrollView *window, inT32 num)