tesseract  5.0.0-alpha-619-ge9db
drawtord.h File Reference
#include "params.h"
#include "scrollview.h"
#include "pitsync1.h"
#include "blobbox.h"

Go to the source code of this file.

Macros

#define NO_SMD   "none"
 

Functions

ScrollViewcreate_to_win (ICOORD page_tr)
 
void close_to_win ()
 
void create_todebug_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_t left, ScrollView::Color colour, FCOORD rotation)
 
void draw_occupation (int32_t xleft, int32_t ybottom, int32_t min_y, int32_t max_y, int32_t occupation[], int32_t thresholds[])
 
void draw_meanlines (TO_BLOCK *block, float gradient, int32_t left, ScrollView::Color colour, FCOORD rotation)
 
void plot_word_decisions (ScrollView *win, int16_t pitch, TO_ROW *row)
 
void plot_fp_cells (ScrollView *win, ScrollView::Color colour, BLOBNBOX_IT *blob_it, int16_t pitch, int16_t blob_count, STATS *projection, int16_t projection_left, int16_t 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

bool textord_show_fixed_cuts = false
 
char * to_debugfile = DEBUG_WIN_NAME
 
char * to_smdfile = "none"
 
ScrollViewto_win
 
FILE * to_debug
 

Macro Definition Documentation

◆ NO_SMD

#define NO_SMD   "none"

Definition at line 26 of file drawtord.h.

Function Documentation

◆ close_to_win()

void close_to_win ( )

Definition at line 51 of file drawtord.cpp.

53  {
54  // to_win is leaked, but this enables the user to view the contents.
55  if (to_win != nullptr) {
56  to_win->Update();

◆ create_to_win()

ScrollView* create_to_win ( ICOORD  page_tr)

Definition at line 42 of file drawtord.cpp.

44  {
45  if (to_win != nullptr) return to_win;
47  page_tr.x() + 1, page_tr.y() + 1,
48  page_tr.x(), page_tr.y(), true);

◆ create_todebug_win()

void create_todebug_win ( )

◆ draw_meanlines()

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

Definition at line 200 of file drawtord.cpp.

213  {
214  FCOORD plot_pt; //point to plot
215  //rows
216  TO_ROW_IT row_it = block->get_rows ();
217  TO_ROW *row; //current row
218  BLOBNBOX_IT blob_it; //blobs
219  float right; //end of row
220  to_win->Pen(colour);
221  for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
222  row = row_it.data ();
223  blob_it.set_to_list (row->blob_list ());
224  blob_it.move_to_last ();
225  right = blob_it.data ()->bounding_box ().right ();
226  plot_pt =
227  FCOORD (static_cast<float>(left),
228  gradient * left + row->parallel_c () + row->xheight);
229  plot_pt.rotate (rotation);
230  to_win->SetCursor(plot_pt.x (), plot_pt.y ());

◆ draw_occupation()

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

Definition at line 157 of file drawtord.cpp.

169  {
170  int32_t line_index; //pixel coord
171  ScrollView::Color colour; //of histogram
172  auto fleft = static_cast<float>(xleft); //float version
173 
174  colour = ScrollView::WHITE;
175  to_win->Pen(colour);
176  to_win->SetCursor(fleft, static_cast<float>(ybottom));
177  for (line_index = min_y; line_index <= max_y; line_index++) {
178  if (occupation[line_index - min_y] < thresholds[line_index - min_y]) {
179  if (colour != ScrollView::BLUE) {
180  colour = ScrollView::BLUE;
181  to_win->Pen(colour);
182  }
183  }
184  else {
185  if (colour != ScrollView::WHITE) {
186  colour = ScrollView::WHITE;
187  to_win->Pen(colour);
188  }
189  }
190  to_win->DrawTo(fleft + occupation[line_index - min_y] / 10.0, static_cast<float>(line_index));
191  }
192  colour=ScrollView::STEEL_BLUE;

◆ plot_box_list()

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

Definition at line 64 of file drawtord.cpp.

71  {
72  BLOBNBOX_IT it = list; //iterator
73 
74  win->Pen(body_colour);
75  win->Brush(ScrollView::NONE);
76  for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {

◆ plot_fp_cells()

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

Definition at line 308 of file drawtord.cpp.

326  {
327  int16_t occupation; //occupied cells
328  TBOX word_box; //bounding box
329  FPSEGPT_LIST seg_list; //list of cuts
330  FPSEGPT_IT seg_it;
331  FPSEGPT *segpt; //current point
332 
333  if (pitsync_linear_version)
334  check_pitch_sync2 (blob_it, blob_count, pitch, 2, projection,
335  projection_left, projection_right,
336  projection_scale, occupation, &seg_list, 0, 0);
337  else
338  check_pitch_sync (blob_it, blob_count, pitch, 2, projection, &seg_list);
339  word_box = blob_it->data ()->bounding_box ();
340  for (; blob_count > 0; blob_count--)
341  word_box += box_next (blob_it);
342  seg_it.set_to_list (&seg_list);
343  for (seg_it.mark_cycle_pt (); !seg_it.cycled_list (); seg_it.forward ()) {

◆ plot_fp_cells2()

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

Definition at line 351 of file drawtord.cpp.

366  {
367  TBOX word_box; //bounding box
368  FPSEGPT_IT seg_it = seg_list;
369  //blobs in row
370  BLOBNBOX_IT blob_it = row->blob_list ();
371  FPSEGPT *segpt; //current point
372 
373  word_box = blob_it.data ()->bounding_box ();
374  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();)
375  word_box += box_next (&blob_it);

◆ plot_parallel_row()

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

Definition at line 117 of file drawtord.cpp.

128  {
129  FCOORD plot_pt; //point to plot
130  //blobs
131  BLOBNBOX_IT it = row->blob_list ();
132  auto fleft = static_cast<float>(left); //floating version
133  float right; //end of row
134 
135  // left=it.data()->bounding_box().left();
136  it.move_to_last ();
137  right = it.data ()->bounding_box ().right ();
138  plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
139  to_win->Pen(colour);
140  plot_pt = FCOORD (fleft, gradient * left + row->max_y ());
141  plot_pt.rotate (rotation);
142  to_win->SetCursor(plot_pt.x (), plot_pt.y ());
143  plot_pt = FCOORD (fleft, gradient * left + row->min_y ());
144  plot_pt.rotate (rotation);
145  to_win->DrawTo(plot_pt.x (), plot_pt.y ());
146  plot_pt = FCOORD (fleft, gradient * left + row->parallel_c ());
147  plot_pt.rotate (rotation);

◆ plot_row_cells()

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

Definition at line 383 of file drawtord.cpp.

400  {
401  TBOX word_box; //bounding box
402  ICOORDELT_IT cell_it = cells;
403  //blobs in row
404  BLOBNBOX_IT blob_it = row->blob_list ();

◆ plot_to_row()

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

Definition at line 84 of file drawtord.cpp.

92  {
93  FCOORD plot_pt; //point to plot
94  //blobs
95  BLOBNBOX_IT it = row->blob_list ();
96  float left, right; //end of row
97 
98  if (it.empty ()) {
99  tprintf ("No blobs in row at %g\n", row->parallel_c ());
100  return;
101  }
102  left = it.data ()->bounding_box ().left ();
103  it.move_to_last ();
104  right = it.data ()->bounding_box ().right ();
105  plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
106  to_win->Pen(colour);
107  plot_pt = FCOORD (left, row->line_m () * left + row->line_c ());
108  plot_pt.rotate (rotation);
109  to_win->SetCursor(plot_pt.x (), plot_pt.y ());

◆ plot_word_decisions()

void plot_word_decisions ( ScrollView win,
int16_t  pitch,
TO_ROW row 
)

Definition at line 239 of file drawtord.cpp.

251  {
252  ScrollView::Color colour = ScrollView::MAGENTA; //current colour
253  ScrollView::Color rect_colour; //fuzzy colour
254  int32_t prev_x; //end of prev blob
255  int16_t blob_count; //blobs in word
256  BLOBNBOX *blob; //current blob
257  TBOX blob_box; //bounding box
258  //iterator
259  BLOBNBOX_IT blob_it = row->blob_list ();
260  BLOBNBOX_IT start_it = blob_it;//word start
261 
262  rect_colour = ScrollView::BLACK;
263  prev_x = -INT16_MAX;
264  blob_count = 0;
265  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
266  blob = blob_it.data ();
267  blob_box = blob->bounding_box ();
268  if (!blob->joined_to_prev ()
269  && blob_box.left () - prev_x > row->max_nonspace) {
270  if ((blob_box.left () - prev_x >= row->min_space
271  || blob_box.left () - prev_x > row->space_threshold)
272  && blob_count > 0) {
273  if (pitch > 0 && textord_show_fixed_cuts)
274  plot_fp_cells (win, colour, &start_it, pitch, blob_count,
275  &row->projection, row->projection_left,
276  row->projection_right,
278  blob_count = 0;
279  start_it = blob_it;
280  }
281  if (colour == ScrollView::MAGENTA)
282  colour = ScrollView::RED;
283  else
284  colour = static_cast<ScrollView::Color>(colour + 1);
285  if (blob_box.left () - prev_x < row->min_space) {
286  if (blob_box.left () - prev_x > row->space_threshold)
287  rect_colour = ScrollView::GOLDENROD;
288  else
289  rect_colour = ScrollView::CORAL;
290  //fill_color_index(win, rect_colour);
291  win->Brush(rect_colour);
292  win->Rectangle (prev_x, blob_box.bottom (),
293  blob_box.left (), blob_box.top ());
294  }
295  }
296  if (!blob->joined_to_prev())
297  prev_x = blob_box.right();
298  if (blob->cblob () != nullptr)
299  blob->cblob ()->plot (win, colour, colour);
300  if (!blob->joined_to_prev() && blob->cblob() != nullptr)

Variable Documentation

◆ textord_show_fixed_cuts

bool textord_show_fixed_cuts = false

"Draw fixed pitch cell boundaries"

Definition at line 32 of file drawtord.cpp.

◆ to_debug

FILE* to_debug

◆ to_debugfile

char* to_debugfile = DEBUG_WIN_NAME

"Name of debugfile"

◆ to_smdfile

char* to_smdfile = "none"

"Name of SMD file"

◆ to_win

ScrollView* to_win

Definition at line 34 of file drawtord.cpp.

TO_ROW::min_space
int32_t min_space
Definition: blobbox.h:662
ScrollView
Definition: scrollview.h:97
ScrollView::Brush
void Brush(Color color)
Definition: scrollview.cpp:723
check_pitch_sync2
double check_pitch_sync2(BLOBNBOX_IT *blob_it, int16_t blob_count, int16_t pitch, int16_t pitch_error, STATS *projection, int16_t projection_left, int16_t projection_right, float projection_scale, int16_t &occupation_count, FPSEGPT_LIST *seg_list, int16_t start, int16_t end)
Definition: pithsync.cpp:286
textord_projection_scale
double textord_projection_scale
Definition: topitch.cpp:51
TO_WIN_NAME
#define TO_WIN_NAME
Definition: drawtord.cpp:28
FCOORD::y
float y() const
Definition: points.h:209
TO_ROW::line_m
float line_m() const
Definition: blobbox.h:570
FCOORD::x
float x() const
Definition: points.h:206
plot_fp_cells
void plot_fp_cells(ScrollView *win, ScrollView::Color colour, BLOBNBOX_IT *blob_it, int16_t pitch, int16_t blob_count, STATS *projection, int16_t projection_left, int16_t projection_right, float projection_scale)
Definition: drawtord.cpp:308
TO_ROW::max_y
float max_y() const
Definition: blobbox.h:558
TO_ROW::projection_left
int16_t projection_left
Definition: blobbox.h:647
TBOX::top
int16_t top() const
Definition: rect.h:57
ScrollView::STEEL_BLUE
Definition: scrollview.h:118
TO_ROW::projection_right
int16_t projection_right
Definition: blobbox.h:648
textord_show_fixed_cuts
bool textord_show_fixed_cuts
Definition: drawtord.cpp:32
ScrollView::BROWN
Definition: scrollview.h:120
TO_WIN_XPOS
#define TO_WIN_XPOS
Definition: drawtord.cpp:26
ScrollView::NONE
Definition: scrollview.h:101
ScrollView::Pen
void Pen(Color color)
Definition: scrollview.cpp:717
ScrollView::DrawTo
void DrawTo(int x, int y)
Definition: scrollview.cpp:524
ICOORD::x
int16_t x() const
access function
Definition: points.h:51
FCOORD
Definition: points.h:187
BLOBNBOX
Definition: blobbox.h:142
ScrollView::BLUE
Definition: scrollview.h:108
check_pitch_sync
double check_pitch_sync(BLOBNBOX_IT *blob_it, int16_t blob_count, int16_t pitch, int16_t pitch_error, STATS *projection, FPSEGPT_LIST *seg_list)
Definition: pitsync1.cpp:138
TO_WIN_YPOS
#define TO_WIN_YPOS
Definition: drawtord.cpp:27
ScrollView::BLACK
Definition: scrollview.h:102
TO_ROW::projection
STATS projection
Definition: blobbox.h:670
ScrollView::MAGENTA
Definition: scrollview.h:109
BLOBNBOX::joined_to_prev
bool joined_to_prev() const
Definition: blobbox.h:255
TO_ROW::parallel_c
float parallel_c() const
Definition: blobbox.h:579
TBOX::bottom
int16_t bottom() const
Definition: rect.h:64
ScrollView::WHITE
Definition: scrollview.h:103
TO_ROW::xheight
float xheight
Definition: blobbox.h:656
FCOORD::rotate
void rotate(const FCOORD vec)
Definition: points.h:736
TO_ROW::line_c
float line_c() const
Definition: blobbox.h:573
ScrollView::RED
Definition: scrollview.h:104
BLOBNBOX::bounding_box
const TBOX & bounding_box() const
Definition: blobbox.h:229
TO_BLOCK::get_rows
TO_ROW_LIST * get_rows()
Definition: blobbox.h:703
TO_ROW::space_threshold
int32_t space_threshold
Definition: blobbox.h:664
TO_ROW::max_nonspace
int32_t max_nonspace
Definition: blobbox.h:663
box_next
TBOX box_next(BLOBNBOX_IT *it)
Definition: blobbox.cpp:629
ScrollView::GOLDENROD
Definition: scrollview.h:123
TBOX::left
int16_t left() const
Definition: rect.h:71
TO_ROW::min_y
float min_y() const
Definition: blobbox.h:561
TBOX::right
int16_t right() const
Definition: rect.h:78
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34
TO_ROW
Definition: blobbox.h:543
ScrollView::Update
static void Update()
Definition: scrollview.cpp:708
ScrollView::SetCursor
void SetCursor(int x, int y)
Definition: scrollview.cpp:518
FPSEGPT
Definition: pitsync1.h:31
ScrollView::CORAL
Definition: scrollview.h:119
ScrollView::Color
Color
Definition: scrollview.h:100
BLOBNBOX::cblob
C_BLOB * cblob() const
Definition: blobbox.h:267
ScrollView::Rectangle
void Rectangle(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:599
to_win
ScrollView * to_win
Definition: drawtord.cpp:34
C_BLOB::plot
void plot(ScrollView *window, ScrollView::Color blob_colour, ScrollView::Color child_colour)
Definition: stepblob.cpp:523
plot_blob_list
void plot_blob_list(ScrollView *win, BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour)
Definition: blobbox.cpp:1068
TO_ROW::blob_list
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:599
ICOORD::y
int16_t y() const
access_function
Definition: points.h:55
TBOX
Definition: rect.h:33