Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions | Variables
drawtord.cpp File Reference
`#include "mfcpch.h"`
`#include "pithsync.h"`
`#include "topitch.h"`
`#include "drawtord.h"`

Go to the source code of this file.

## Macros
#define | TO_WIN_XPOS 0
#define | TO_WIN_YPOS 0
#define | TO_WIN_NAME "Textord"
#define | EXTERN

## Functions
void | create_to_win (ICOORD page_tr)
void | close_to_win ()
void | plot_box_list (ScrollView *win, BLOBNBOX_LIST *list, ScrollView::Color body_colour)
void | plot_to_row (TO_ROW *row, ScrollView::Color colour, FCOORD rotation)
void | plot_parallel_row (TO_ROW *row, float gradient, inT32 left, ScrollView::Color colour, FCOORD rotation)
void | draw_occupation (inT32 xleft, inT32 ybottom, inT32 min_y, inT32 max_y, inT32 occupation[], inT32 thresholds[])
void | draw_meanlines (TO_BLOCK *block, float gradient, inT32 left, ScrollView::Color colour, FCOORD rotation)
void | plot_word_decisions (ScrollView *win, inT16 pitch, TO_ROW *row)
void | plot_fp_cells (ScrollView *win, ScrollView::Color colour, BLOBNBOX_IT *blob_it, inT16 pitch, inT16 blob_count, STATS *projection, inT16 projection_left, inT16 projection_right, float projection_scale)
void | plot_fp_cells2 (ScrollView *win, ScrollView::Color colour, TO_ROW *row, FPSEGPT_LIST *seg_list)
void | plot_row_cells (ScrollView *win, ScrollView::Color colour, TO_ROW *row, float xshift, ICOORDELT_LIST *cells)

## Variables
EXTERN bool | textord_show_fixed_cuts = FALSE
EXTERN ScrollView * | to_win = NULL

## Macro Definition Documentation

#define EXTERN

Definition at line 35 of file drawtord.cpp.

#define TO_WIN_NAME "Textord"

Definition at line 32 of file drawtord.cpp.

#define TO_WIN_XPOS 0

Definition at line 30 of file drawtord.cpp.

#define TO_WIN_YPOS 0

Definition at line 31 of file drawtord.cpp.

## Function Documentation

void close_to_win | ( |  | ) |

Definition at line 56 of file drawtord.cpp.

{
// to_win is leaked, but this enables the user to view the contents.
if (to_win != NULL) {
to_win->Update();
}
}

void create_to_win | ( | ICOORD | page_tr | ) |

Definition at line 49 of file drawtord.cpp.

{
to_win = new ScrollView(TO_WIN_NAME, TO_WIN_XPOS, TO_WIN_YPOS,
page_tr.x() + 1, page_tr.y() + 1,
page_tr.x(), page_tr.y(), true);
}

void draw_meanlines | ( | TO_BLOCK * | block,
|  | float | gradient,
|  | inT32 | left,
|  | ScrollView::Color | colour,
|  | FCOORD | rotation
| ) |  |

Definition at line 210 of file drawtord.cpp.

{
FCOORD plot_pt; //point to plot
//rows
TO_ROW_IT row_it = block->get_rows ();
TO_ROW *row; //current row
BLOBNBOX_IT blob_it; //blobs
float right; //end of row
to_win->Pen(colour);
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
blob_it.set_to_list (row->blob_list ());
blob_it.move_to_last ();
right = blob_it.data ()->bounding_box ().right ();
plot_pt =
FCOORD ((float) left,
gradient * left + row->parallel_c () + row->xheight);
plot_pt.rotate (rotation);
to_win->SetCursor(plot_pt.x (), plot_pt.y ());
plot_pt =
FCOORD ((float) right,
gradient * right + row->parallel_c () + row->xheight);
plot_pt.rotate (rotation);
to_win->DrawTo (plot_pt.x (), plot_pt.y ());
}
}

void draw_occupation | ( | inT32 | xleft,
|  | inT32 | ybottom,
|  | inT32 | min_y,
|  | inT32 | max_y,
|  | inT32 | occupation[],
|  | inT32 | thresholds[]
| ) |  |

Definition at line 166 of file drawtord.cpp.

{
inT32 line_index; //pixel coord
ScrollView::Color colour; //of histogram
float fleft = (float) xleft; //float version
colour = ScrollView::WHITE;
to_win->Pen(colour);
to_win->SetCursor(fleft, (float) ybottom);
for (line_index = min_y; line_index <= max_y; line_index++) {
if (occupation[line_index - min_y] < thresholds[line_index - min_y]) {
if (colour != ScrollView::BLUE) {
colour = ScrollView::BLUE;
to_win->Pen(colour);
}
}
else {
if (colour != ScrollView::WHITE) {
colour = ScrollView::WHITE;
to_win->Pen(colour);
}
}
to_win->DrawTo(fleft + occupation[line_index - min_y] / 10.0, (float) line_index);
}
colour=ScrollView::STEEL_BLUE;
to_win->Pen(colour);
to_win->SetCursor(fleft, (float) ybottom);
for (line_index = min_y; line_index <= max_y; line_index++) {
to_win->DrawTo(fleft + thresholds[line_index - min_y] / 10.0, (float) line_index);
}
}

void plot_box_list | ( | ScrollView * | win,
|  | BLOBNBOX_LIST * | list,
|  | ScrollView::Color | body_colour
| ) |  |

Definition at line 70 of file drawtord.cpp.

{
BLOBNBOX_IT it = list; //iterator
win->Pen(body_colour);
win->Brush(ScrollView::NONE);
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
it.data ()->bounding_box ().plot (win);
}
}

void plot_fp_cells | ( | ScrollView * | win,
|  | ScrollView::Color | colour,
|  | BLOBNBOX_IT * | blob_it,
|  | inT16 | pitch,
|  | inT16 | blob_count,
|  | STATS * | projection,
|  | inT16 | projection_left,
|  | inT16 | projection_right,
|  | float | projection_scale
| ) |  |

Definition at line 320 of file drawtord.cpp.

{
inT16 occupation; //occupied cells
TBOX word_box; //bounding box
FPSEGPT_LIST seg_list; //list of cuts
FPSEGPT_IT seg_it;
FPSEGPT *segpt; //current point
if (pitsync_linear_version)
check_pitch_sync2 (blob_it, blob_count, pitch, 2, projection,
projection_left, projection_right,
projection_scale, occupation, &seg_list, 0, 0);
else
check_pitch_sync (blob_it, blob_count, pitch, 2, projection, &seg_list);
word_box = blob_it->data ()->bounding_box ();
for (; blob_count > 0; blob_count--)
word_box += box_next (blob_it);
seg_it.set_to_list (&seg_list);
for (seg_it.mark_cycle_pt (); !seg_it.cycled_list (); seg_it.forward ()) {
segpt = seg_it.data ();
if (segpt->faked) {
colour = ScrollView::WHITE;
win->Pen(colour); }
else {
win->Pen(colour); }
win->Line(segpt->position (), word_box.bottom (),segpt->position (), word_box.top ());
}
}

void plot_fp_cells2 | ( | ScrollView * | win,
|  | ScrollView::Color | colour,
|  | TO_ROW * | row,
|  | FPSEGPT_LIST * | seg_list
| ) |  |

Definition at line 364 of file drawtord.cpp.

{
TBOX word_box; //bounding box
FPSEGPT_IT seg_it = seg_list;
//blobs in row
BLOBNBOX_IT blob_it = row->blob_list ();
FPSEGPT *segpt; //current point
word_box = blob_it.data ()->bounding_box ();
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();)
word_box += box_next (&blob_it);
for (seg_it.mark_cycle_pt (); !seg_it.cycled_list (); seg_it.forward ()) {
segpt = seg_it.data ();
if (segpt->faked) {
colour = ScrollView::WHITE;
win->Pen(colour); }
else {
win->Pen(colour); }
win->Line(segpt->position (), word_box.bottom (),segpt->position (), word_box.top ());
}
}

void plot_parallel_row | ( | TO_ROW * | row,
|  | float | gradient,
|  | inT32 | left,
|  | ScrollView::Color | colour,
|  | FCOORD | rotation
| ) |  |

Definition at line 125 of file drawtord.cpp.

{
FCOORD plot_pt; //point to plot
//blobs
BLOBNBOX_IT it = row->blob_list ();
float fleft = (float) left; //floating version
float right; //end of row
// left=it.data()->bounding_box().left();
it.move_to_last ();
right = it.data ()->bounding_box ().right ();
plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
to_win->Pen(colour);
plot_pt = FCOORD (fleft, gradient * left + row->max_y ());
plot_pt.rotate (rotation);
to_win->SetCursor(plot_pt.x (), plot_pt.y ());
plot_pt = FCOORD (fleft, gradient * left + row->min_y ());
plot_pt.rotate (rotation);
to_win->DrawTo(plot_pt.x (), plot_pt.y ());
plot_pt = FCOORD (fleft, gradient * left + row->parallel_c ());
plot_pt.rotate (rotation);
to_win->SetCursor(plot_pt.x (), plot_pt.y ());
plot_pt = FCOORD (right, gradient * right + row->parallel_c ());
plot_pt.rotate (rotation);
to_win->DrawTo(plot_pt.x (), plot_pt.y ());
}

void plot_row_cells | ( | ScrollView * | win,
|  | ScrollView::Color | colour,
|  | TO_ROW * | row,
|  | float | xshift,
|  | ICOORDELT_LIST * | cells
| ) |  |

Definition at line 397 of file drawtord.cpp.

{
TBOX word_box; //bounding box
ICOORDELT_IT cell_it = cells;
//blobs in row
BLOBNBOX_IT blob_it = row->blob_list ();
ICOORDELT *cell; //current cell
word_box = blob_it.data ()->bounding_box ();
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();)
word_box += box_next (&blob_it);
win->Pen(colour);
for (cell_it.mark_cycle_pt (); !cell_it.cycled_list (); cell_it.forward ()) {
cell = cell_it.data ();
win->Line(cell->x () + xshift, word_box.bottom (), cell->x () + xshift, word_box.top ());
}
}

void plot_to_row | ( | TO_ROW * | row,
|  | ScrollView::Color | colour,
|  | FCOORD | rotation
| ) |  |

Definition at line 91 of file drawtord.cpp.

{
FCOORD plot_pt; //point to plot
//blobs
BLOBNBOX_IT it = row->blob_list ();
float left, right; //end of row
if (it.empty ()) {
tprintf ("No blobs in row at %g\n", row->parallel_c ());
return;
}
left = it.data ()->bounding_box ().left ();
it.move_to_last ();
right = it.data ()->bounding_box ().right ();
plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
to_win->Pen(colour);
plot_pt = FCOORD (left, row->line_m () * left + row->line_c ());
plot_pt.rotate (rotation);
to_win->SetCursor(plot_pt.x (), plot_pt.y ());
plot_pt = FCOORD (right, row->line_m () * right + row->line_c ());
plot_pt.rotate (rotation);
to_win->DrawTo(plot_pt.x (), plot_pt.y ());
}

void plot_word_decisions | ( | ScrollView * | win,
|  | inT16 | pitch,
|  | TO_ROW * | row
| ) |  |

Definition at line 250 of file drawtord.cpp.

{
ScrollView::Color colour = ScrollView::MAGENTA; //current colour
ScrollView::Color rect_colour; //fuzzy colour
inT32 prev_x; //end of prev blob
inT16 blob_count; //blobs in word
BLOBNBOX *blob; //current blob
TBOX blob_box; //bounding box
//iterator
BLOBNBOX_IT blob_it = row->blob_list ();
BLOBNBOX_IT start_it = blob_it;//word start
rect_colour = ScrollView::BLACK;
prev_x = -MAX_INT16;
blob_count = 0;
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
blob = blob_it.data ();
blob_box = blob->bounding_box ();
if (!blob->joined_to_prev ()
&& blob_box.left () - prev_x > row->max_nonspace) {
if ((blob_box.left () - prev_x >= row->min_space
|| blob_box.left () - prev_x > row->space_threshold)
&& blob_count > 0) {
if (pitch > 0 && textord_show_fixed_cuts)
plot_fp_cells (win, colour, &start_it, pitch, blob_count,
&row->projection, row->projection_left,
row->projection_right,
row->xheight * textord_projection_scale);
blob_count = 0;
start_it = blob_it;
}
if (colour == ScrollView::MAGENTA)
colour = ScrollView::RED;
else
colour = (ScrollView::Color) (colour + 1);
if (blob_box.left () - prev_x < row->min_space) {
if (blob_box.left () - prev_x > row->space_threshold)
rect_colour = ScrollView::GOLDENROD;
else
rect_colour = ScrollView::CORAL;
//fill_color_index(win, rect_colour);
win->Brush(rect_colour);
win->Rectangle (prev_x, blob_box.bottom (),
blob_box.left (), blob_box.top ());
}
}
if (!blob->joined_to_prev())
prev_x = blob_box.right();
if (blob->cblob () != NULL)
blob->cblob ()->plot (win, colour, colour);
if (!blob->joined_to_prev() && blob->cblob() != NULL)
blob_count++;
}
if (pitch > 0 && textord_show_fixed_cuts && blob_count > 0)
plot_fp_cells (win, colour, &start_it, pitch, blob_count,
&row->projection, row->projection_left,
row->projection_right,
row->xheight * textord_projection_scale);
}

## Variable Documentation

EXTERN bool textord_show_fixed_cuts = FALSE

"Draw fixed pitch cell boundaries"

Definition at line 38 of file drawtord.cpp.

EXTERN ScrollView* to_win = NULL

Definition at line 40 of file drawtord.cpp.