All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
drawtord.cpp File Reference
#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

ScrollViewcreate_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 ScrollViewto_win = NULL
 

Macro Definition Documentation

#define EXTERN

Definition at line 33 of file drawtord.cpp.

#define TO_WIN_NAME   "Textord"

Definition at line 30 of file drawtord.cpp.

#define TO_WIN_XPOS   0

Definition at line 28 of file drawtord.cpp.

#define TO_WIN_YPOS   0

Definition at line 29 of file drawtord.cpp.

Function Documentation

void close_to_win ( )

Definition at line 56 of file drawtord.cpp.

56  {
57  // to_win is leaked, but this enables the user to view the contents.
58  if (to_win != NULL) {
59  to_win->Update();
60  }
61 }
static void Update()
Definition: scrollview.cpp:715
EXTERN ScrollView * to_win
Definition: drawtord.cpp:38
#define NULL
Definition: host.h:144
ScrollView* create_to_win ( ICOORD  page_tr)

Definition at line 47 of file drawtord.cpp.

47  {
48  if (to_win != NULL) return to_win;
50  page_tr.x() + 1, page_tr.y() + 1,
51  page_tr.x(), page_tr.y(), true);
52  return to_win;
53 }
#define TO_WIN_XPOS
Definition: drawtord.cpp:28
#define TO_WIN_NAME
Definition: drawtord.cpp:30
EXTERN ScrollView * to_win
Definition: drawtord.cpp:38
inT16 y() const
access_function
Definition: points.h:56
#define TO_WIN_YPOS
Definition: drawtord.cpp:29
inT16 x() const
access function
Definition: points.h:52
#define NULL
Definition: host.h:144
void draw_meanlines ( TO_BLOCK block,
float  gradient,
inT32  left,
ScrollView::Color  colour,
FCOORD  rotation 
)

Definition at line 210 of file drawtord.cpp.

216  {
217  FCOORD plot_pt; //point to plot
218  //rows
219  TO_ROW_IT row_it = block->get_rows ();
220  TO_ROW *row; //current row
221  BLOBNBOX_IT blob_it; //blobs
222  float right; //end of row
223  to_win->Pen(colour);
224  for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
225  row = row_it.data ();
226  blob_it.set_to_list (row->blob_list ());
227  blob_it.move_to_last ();
228  right = blob_it.data ()->bounding_box ().right ();
229  plot_pt =
230  FCOORD ((float) left,
231  gradient * left + row->parallel_c () + row->xheight);
232  plot_pt.rotate (rotation);
233  to_win->SetCursor(plot_pt.x (), plot_pt.y ());
234  plot_pt =
235  FCOORD ((float) right,
236  gradient * right + row->parallel_c () + row->xheight);
237  plot_pt.rotate (rotation);
238  to_win->DrawTo (plot_pt.x (), plot_pt.y ());
239  }
240 }
void Pen(Color color)
Definition: scrollview.cpp:726
float x() const
Definition: points.h:209
float parallel_c() const
Definition: blobbox.h:575
void DrawTo(int x, int y)
Definition: scrollview.cpp:531
void rotate(const FCOORD vec)
Definition: ipoints.h:471
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:595
EXTERN ScrollView * to_win
Definition: drawtord.cpp:38
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
TO_ROW_LIST * get_rows()
Definition: blobbox.h:700
float y() const
Definition: points.h:212
float xheight
Definition: blobbox.h:653
Definition: points.h:189
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.

172  {
173  inT32 line_index; //pixel coord
174  ScrollView::Color colour; //of histogram
175  float fleft = (float) xleft; //float version
176 
177  colour = ScrollView::WHITE;
178  to_win->Pen(colour);
179  to_win->SetCursor(fleft, (float) ybottom);
180  for (line_index = min_y; line_index <= max_y; line_index++) {
181  if (occupation[line_index - min_y] < thresholds[line_index - min_y]) {
182  if (colour != ScrollView::BLUE) {
183  colour = ScrollView::BLUE;
184  to_win->Pen(colour);
185  }
186  }
187  else {
188  if (colour != ScrollView::WHITE) {
189  colour = ScrollView::WHITE;
190  to_win->Pen(colour);
191  }
192  }
193  to_win->DrawTo(fleft + occupation[line_index - min_y] / 10.0, (float) line_index);
194  }
195  colour=ScrollView::STEEL_BLUE;
196  to_win->Pen(colour);
197  to_win->SetCursor(fleft, (float) ybottom);
198  for (line_index = min_y; line_index <= max_y; line_index++) {
199  to_win->DrawTo(fleft + thresholds[line_index - min_y] / 10.0, (float) line_index);
200  }
201 }
void Pen(Color color)
Definition: scrollview.cpp:726
void DrawTo(int x, int y)
Definition: scrollview.cpp:531
EXTERN ScrollView * to_win
Definition: drawtord.cpp:38
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
int inT32
Definition: host.h:102
void plot_box_list ( ScrollView win,
BLOBNBOX_LIST *  list,
ScrollView::Color  body_colour 
)

Definition at line 70 of file drawtord.cpp.

74  {
75  BLOBNBOX_IT it = list; //iterator
76 
77  win->Pen(body_colour);
78  win->Brush(ScrollView::NONE);
79  for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
80  it.data ()->bounding_box ().plot (win);
81  }
82 }
void Pen(Color color)
Definition: scrollview.cpp:726
void Brush(Color color)
Definition: scrollview.cpp:732
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.

329  {
330  inT16 occupation; //occupied cells
331  TBOX word_box; //bounding box
332  FPSEGPT_LIST seg_list; //list of cuts
333  FPSEGPT_IT seg_it;
334  FPSEGPT *segpt; //current point
335 
336  if (pitsync_linear_version)
337  check_pitch_sync2 (blob_it, blob_count, pitch, 2, projection,
338  projection_left, projection_right,
339  projection_scale, occupation, &seg_list, 0, 0);
340  else
341  check_pitch_sync (blob_it, blob_count, pitch, 2, projection, &seg_list);
342  word_box = blob_it->data ()->bounding_box ();
343  for (; blob_count > 0; blob_count--)
344  word_box += box_next (blob_it);
345  seg_it.set_to_list (&seg_list);
346  for (seg_it.mark_cycle_pt (); !seg_it.cycled_list (); seg_it.forward ()) {
347  segpt = seg_it.data ();
348  if (segpt->faked) {
349  colour = ScrollView::WHITE;
350  win->Pen(colour); }
351  else {
352  win->Pen(colour); }
353  win->Line(segpt->position (), word_box.bottom (),segpt->position (), word_box.top ());
354  }
355 }
void Pen(Color color)
Definition: scrollview.cpp:726
BOOL8 faked
Definition: pitsync1.h:69
double check_pitch_sync(BLOBNBOX_IT *blob_it, inT16 blob_count, inT16 pitch, inT16 pitch_error, STATS *projection, FPSEGPT_LIST *seg_list)
Definition: pitsync1.cpp:148
inT16 bottom() const
Definition: rect.h:61
double check_pitch_sync2(BLOBNBOX_IT *blob_it, inT16 blob_count, inT16 pitch, inT16 pitch_error, STATS *projection, inT16 projection_left, inT16 projection_right, float projection_scale, inT16 &occupation_count, FPSEGPT_LIST *seg_list, inT16 start, inT16 end)
Definition: pithsync.cpp:298
TBOX box_next(BLOBNBOX_IT *it)
Definition: blobbox.cpp:629
Definition: rect.h:30
inT32 position()
Definition: pitsync1.h:49
inT16 top() const
Definition: rect.h:54
void Line(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:538
short inT16
Definition: host.h:100
void plot_fp_cells2 ( ScrollView win,
ScrollView::Color  colour,
TO_ROW row,
FPSEGPT_LIST *  seg_list 
)

Definition at line 364 of file drawtord.cpp.

369  {
370  TBOX word_box; //bounding box
371  FPSEGPT_IT seg_it = seg_list;
372  //blobs in row
373  BLOBNBOX_IT blob_it = row->blob_list ();
374  FPSEGPT *segpt; //current point
375 
376  word_box = blob_it.data ()->bounding_box ();
377  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();)
378  word_box += box_next (&blob_it);
379  for (seg_it.mark_cycle_pt (); !seg_it.cycled_list (); seg_it.forward ()) {
380  segpt = seg_it.data ();
381  if (segpt->faked) {
382  colour = ScrollView::WHITE;
383  win->Pen(colour); }
384  else {
385  win->Pen(colour); }
386  win->Line(segpt->position (), word_box.bottom (),segpt->position (), word_box.top ());
387  }
388 }
void Pen(Color color)
Definition: scrollview.cpp:726
BOOL8 faked
Definition: pitsync1.h:69
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:595
inT16 bottom() const
Definition: rect.h:61
TBOX box_next(BLOBNBOX_IT *it)
Definition: blobbox.cpp:629
Definition: rect.h:30
inT32 position()
Definition: pitsync1.h:49
inT16 top() const
Definition: rect.h:54
void Line(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:538
void plot_parallel_row ( TO_ROW row,
float  gradient,
inT32  left,
ScrollView::Color  colour,
FCOORD  rotation 
)

Definition at line 125 of file drawtord.cpp.

131  {
132  FCOORD plot_pt; //point to plot
133  //blobs
134  BLOBNBOX_IT it = row->blob_list ();
135  float fleft = (float) left; //floating version
136  float right; //end of row
137 
138  // left=it.data()->bounding_box().left();
139  it.move_to_last ();
140  right = it.data ()->bounding_box ().right ();
141  plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
142  to_win->Pen(colour);
143  plot_pt = FCOORD (fleft, gradient * left + row->max_y ());
144  plot_pt.rotate (rotation);
145  to_win->SetCursor(plot_pt.x (), plot_pt.y ());
146  plot_pt = FCOORD (fleft, gradient * left + row->min_y ());
147  plot_pt.rotate (rotation);
148  to_win->DrawTo(plot_pt.x (), plot_pt.y ());
149  plot_pt = FCOORD (fleft, gradient * left + row->parallel_c ());
150  plot_pt.rotate (rotation);
151  to_win->SetCursor(plot_pt.x (), plot_pt.y ());
152  plot_pt = FCOORD (right, gradient * right + row->parallel_c ());
153  plot_pt.rotate (rotation);
154  to_win->DrawTo(plot_pt.x (), plot_pt.y ());
155 }
void Pen(Color color)
Definition: scrollview.cpp:726
float x() const
Definition: points.h:209
float parallel_c() const
Definition: blobbox.h:575
void DrawTo(int x, int y)
Definition: scrollview.cpp:531
void rotate(const FCOORD vec)
Definition: ipoints.h:471
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:595
void plot_blob_list(ScrollView *win, BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour)
Definition: blobbox.cpp:1080
EXTERN ScrollView * to_win
Definition: drawtord.cpp:38
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
float y() const
Definition: points.h:212
float min_y() const
Definition: blobbox.h:557
Definition: points.h:189
float max_y() const
Definition: blobbox.h:554
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.

403  {
404  TBOX word_box; //bounding box
405  ICOORDELT_IT cell_it = cells;
406  //blobs in row
407  BLOBNBOX_IT blob_it = row->blob_list ();
408  ICOORDELT *cell; //current cell
409 
410  word_box = blob_it.data ()->bounding_box ();
411  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();)
412  word_box += box_next (&blob_it);
413  win->Pen(colour);
414  for (cell_it.mark_cycle_pt (); !cell_it.cycled_list (); cell_it.forward ()) {
415  cell = cell_it.data ();
416  win->Line(cell->x () + xshift, word_box.bottom (), cell->x () + xshift, word_box.top ());
417  }
418 }
void Pen(Color color)
Definition: scrollview.cpp:726
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:595
inT16 bottom() const
Definition: rect.h:61
TBOX box_next(BLOBNBOX_IT *it)
Definition: blobbox.cpp:629
inT16 x() const
access function
Definition: points.h:52
Definition: rect.h:30
inT16 top() const
Definition: rect.h:54
void Line(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:538
void plot_to_row ( TO_ROW row,
ScrollView::Color  colour,
FCOORD  rotation 
)

Definition at line 91 of file drawtord.cpp.

95  {
96  FCOORD plot_pt; //point to plot
97  //blobs
98  BLOBNBOX_IT it = row->blob_list ();
99  float left, right; //end of row
100 
101  if (it.empty ()) {
102  tprintf ("No blobs in row at %g\n", row->parallel_c ());
103  return;
104  }
105  left = it.data ()->bounding_box ().left ();
106  it.move_to_last ();
107  right = it.data ()->bounding_box ().right ();
108  plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
109  to_win->Pen(colour);
110  plot_pt = FCOORD (left, row->line_m () * left + row->line_c ());
111  plot_pt.rotate (rotation);
112  to_win->SetCursor(plot_pt.x (), plot_pt.y ());
113  plot_pt = FCOORD (right, row->line_m () * right + row->line_c ());
114  plot_pt.rotate (rotation);
115  to_win->DrawTo(plot_pt.x (), plot_pt.y ());
116 }
void Pen(Color color)
Definition: scrollview.cpp:726
float x() const
Definition: points.h:209
float parallel_c() const
Definition: blobbox.h:575
#define tprintf(...)
Definition: tprintf.h:31
void DrawTo(int x, int y)
Definition: scrollview.cpp:531
void rotate(const FCOORD vec)
Definition: ipoints.h:471
float line_c() const
Definition: blobbox.h:569
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:595
void plot_blob_list(ScrollView *win, BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour)
Definition: blobbox.cpp:1080
float line_m() const
Definition: blobbox.h:566
EXTERN ScrollView * to_win
Definition: drawtord.cpp:38
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
float y() const
Definition: points.h:212
Definition: points.h:189
void plot_word_decisions ( ScrollView win,
inT16  pitch,
TO_ROW row 
)

Definition at line 250 of file drawtord.cpp.

254  {
255  ScrollView::Color colour = ScrollView::MAGENTA; //current colour
256  ScrollView::Color rect_colour; //fuzzy colour
257  inT32 prev_x; //end of prev blob
258  inT16 blob_count; //blobs in word
259  BLOBNBOX *blob; //current blob
260  TBOX blob_box; //bounding box
261  //iterator
262  BLOBNBOX_IT blob_it = row->blob_list ();
263  BLOBNBOX_IT start_it = blob_it;//word start
264 
265  rect_colour = ScrollView::BLACK;
266  prev_x = -MAX_INT16;
267  blob_count = 0;
268  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
269  blob = blob_it.data ();
270  blob_box = blob->bounding_box ();
271  if (!blob->joined_to_prev ()
272  && blob_box.left () - prev_x > row->max_nonspace) {
273  if ((blob_box.left () - prev_x >= row->min_space
274  || blob_box.left () - prev_x > row->space_threshold)
275  && blob_count > 0) {
276  if (pitch > 0 && textord_show_fixed_cuts)
277  plot_fp_cells (win, colour, &start_it, pitch, blob_count,
278  &row->projection, row->projection_left,
279  row->projection_right,
281  blob_count = 0;
282  start_it = blob_it;
283  }
284  if (colour == ScrollView::MAGENTA)
285  colour = ScrollView::RED;
286  else
287  colour = (ScrollView::Color) (colour + 1);
288  if (blob_box.left () - prev_x < row->min_space) {
289  if (blob_box.left () - prev_x > row->space_threshold)
290  rect_colour = ScrollView::GOLDENROD;
291  else
292  rect_colour = ScrollView::CORAL;
293  //fill_color_index(win, rect_colour);
294  win->Brush(rect_colour);
295  win->Rectangle (prev_x, blob_box.bottom (),
296  blob_box.left (), blob_box.top ());
297  }
298  }
299  if (!blob->joined_to_prev())
300  prev_x = blob_box.right();
301  if (blob->cblob () != NULL)
302  blob->cblob ()->plot (win, colour, colour);
303  if (!blob->joined_to_prev() && blob->cblob() != NULL)
304  blob_count++;
305  }
306  if (pitch > 0 && textord_show_fixed_cuts && blob_count > 0)
307  plot_fp_cells (win, colour, &start_it, pitch, blob_count,
308  &row->projection, row->projection_left,
309  row->projection_right,
311 }
bool joined_to_prev() const
Definition: blobbox.h:241
inT32 min_space
Definition: blobbox.h:659
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: drawtord.cpp:320
inT16 projection_left
Definition: blobbox.h:644
inT16 right() const
Definition: rect.h:75
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:595
EXTERN double textord_projection_scale
Definition: topitch.cpp:57
inT16 left() const
Definition: rect.h:68
inT16 projection_right
Definition: blobbox.h:645
C_BLOB * cblob() const
Definition: blobbox.h:253
void Brush(Color color)
Definition: scrollview.cpp:732
EXTERN bool textord_show_fixed_cuts
Definition: drawtord.cpp:36
inT16 bottom() const
Definition: rect.h:61
inT32 max_nonspace
Definition: blobbox.h:660
STATS projection
Definition: blobbox.h:667
Definition: rect.h:30
#define MAX_INT16
Definition: host.h:119
void Rectangle(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:606
#define NULL
Definition: host.h:144
const TBOX & bounding_box() const
Definition: blobbox.h:215
float xheight
Definition: blobbox.h:653
inT16 top() const
Definition: rect.h:54
inT32 space_threshold
Definition: blobbox.h:661
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102
void plot(ScrollView *window, ScrollView::Color blob_colour, ScrollView::Color child_colour)
Definition: stepblob.cpp:532

Variable Documentation

EXTERN bool textord_show_fixed_cuts = FALSE

"Draw fixed pitch cell boundaries"

Definition at line 36 of file drawtord.cpp.

EXTERN ScrollView* to_win = NULL

Definition at line 38 of file drawtord.cpp.