tesseract  4.0.0-1-g2a2b
pgedit.cpp File Reference
#include "pgedit.h"
#include <cctype>
#include <cmath>
#include "blread.h"
#include "control.h"
#include "paramsd.h"
#include "pageres.h"
#include "tordmain.h"
#include "scrollview.h"
#include "svmnode.h"
#include "statistc.h"
#include "tesseractclass.h"
#include "werdit.h"

Go to the source code of this file.

Classes

class  BlnEventHandler
 

Namespaces

 tesseract
 

Macros

#define ASC_HEIGHT   (2 * kBlnBaselineOffset + kBlnXHeight)
 
#define X_HEIGHT   (kBlnBaselineOffset + kBlnXHeight)
 
#define BL_HEIGHT   kBlnBaselineOffset
 
#define DESC_HEIGHT   0
 
#define MAXSPACING   128 /*max expected spacing in pix */
 

Enumerations

enum  CMD_EVENTS {
  NULL_CMD_EVENT, CHANGE_DISP_CMD_EVENT, DUMP_WERD_CMD_EVENT, SHOW_POINT_CMD_EVENT,
  SHOW_BLN_WERD_CMD_EVENT, DEBUG_WERD_CMD_EVENT, BLAMER_CMD_EVENT, BOUNDING_BOX_CMD_EVENT,
  CORRECT_TEXT_CMD_EVENT, POLYGONAL_CMD_EVENT, BL_NORM_CMD_EVENT, BITMAP_CMD_EVENT,
  IMAGE_CMD_EVENT, BLOCKS_CMD_EVENT, BASELINES_CMD_EVENT, UNIFORM_DISP_CMD_EVENT,
  REFRESH_CMD_EVENT, QUIT_CMD_EVENT, RECOG_WERDS, RECOG_PSEUDO,
  SHOW_BLOB_FEATURES, SHOW_SUBSCRIPT_CMD_EVENT, SHOW_SUPERSCRIPT_CMD_EVENT, SHOW_ITALIC_CMD_EVENT,
  SHOW_BOLD_CMD_EVENT, SHOW_UNDERLINE_CMD_EVENT, SHOW_FIXEDPITCH_CMD_EVENT, SHOW_SERIF_CMD_EVENT,
  SHOW_SMALLCAPS_CMD_EVENT, SHOW_DROPCAPS_CMD_EVENT
}
 
enum  ColorationMode {
  CM_RAINBOW, CM_SUBSCRIPT, CM_SUPERSCRIPT, CM_ITALIC,
  CM_BOLD, CM_UNDERLINE, CM_FIXEDPITCH, CM_SERIF,
  CM_SMALLCAPS, CM_DROPCAPS
}
 

Functions

ScrollViewbln_word_window_handle ()
 
void build_image_window (int width, int height)
 
void pgeditor_msg (const char *msg)
 
void pgeditor_show_point (SVEvent *event)
 
void show_point (PAGE_RES *page_res, float x, float y)
 

Variables

const ERRCODE EMPTYBLOCKLIST = "No blocks to edit"
 
BITS16 word_display_mode
 
BOOL8 display_image = FALSE
 
BOOL8 display_blocks = FALSE
 
BOOL8 display_baselines = FALSE
 
PAGE_REScurrent_page_res = nullptr
 
char * editor_image_win_name = "EditorImage"
 
int editor_image_xpos = 590
 
int editor_image_ypos = 10
 
int editor_image_menuheight = 50
 
int editor_image_word_bb_color = ScrollView::BLUE
 
int editor_image_blob_bb_color = ScrollView::YELLOW
 
int editor_image_text_color = ScrollView::WHITE
 
char * editor_dbwin_name = "EditorDBWin"
 
int editor_dbwin_xpos = 50
 
int editor_dbwin_ypos = 500
 
int editor_dbwin_height = 24
 
int editor_dbwin_width = 80
 
char * editor_word_name = "BlnWords"
 
int editor_word_xpos = 60
 
int editor_word_ypos = 510
 
int editor_word_height = 240
 
int editor_word_width = 655
 
char * editor_debug_config_file = ""
 

Macro Definition Documentation

◆ ASC_HEIGHT

#define ASC_HEIGHT   (2 * kBlnBaselineOffset + kBlnXHeight)

Definition at line 42 of file pgedit.cpp.

◆ BL_HEIGHT

#define BL_HEIGHT   kBlnBaselineOffset

Definition at line 44 of file pgedit.cpp.

◆ DESC_HEIGHT

#define DESC_HEIGHT   0

Definition at line 45 of file pgedit.cpp.

◆ MAXSPACING

#define MAXSPACING   128 /*max expected spacing in pix */

Definition at line 46 of file pgedit.cpp.

◆ X_HEIGHT

#define X_HEIGHT   (kBlnBaselineOffset + kBlnXHeight)

Definition at line 43 of file pgedit.cpp.

Enumeration Type Documentation

◆ CMD_EVENTS

enum CMD_EVENTS
Enumerator
NULL_CMD_EVENT 
CHANGE_DISP_CMD_EVENT 
DUMP_WERD_CMD_EVENT 
SHOW_POINT_CMD_EVENT 
SHOW_BLN_WERD_CMD_EVENT 
DEBUG_WERD_CMD_EVENT 
BLAMER_CMD_EVENT 
BOUNDING_BOX_CMD_EVENT 
CORRECT_TEXT_CMD_EVENT 
POLYGONAL_CMD_EVENT 
BL_NORM_CMD_EVENT 
BITMAP_CMD_EVENT 
IMAGE_CMD_EVENT 
BLOCKS_CMD_EVENT 
BASELINES_CMD_EVENT 
UNIFORM_DISP_CMD_EVENT 
REFRESH_CMD_EVENT 
QUIT_CMD_EVENT 
RECOG_WERDS 
RECOG_PSEUDO 
SHOW_BLOB_FEATURES 
SHOW_SUBSCRIPT_CMD_EVENT 
SHOW_SUPERSCRIPT_CMD_EVENT 
SHOW_ITALIC_CMD_EVENT 
SHOW_BOLD_CMD_EVENT 
SHOW_UNDERLINE_CMD_EVENT 
SHOW_FIXEDPITCH_CMD_EVENT 
SHOW_SERIF_CMD_EVENT 
SHOW_SMALLCAPS_CMD_EVENT 
SHOW_DROPCAPS_CMD_EVENT 

Definition at line 50 of file pgedit.cpp.

51 {
82 };

◆ ColorationMode

Enumerator
CM_RAINBOW 
CM_SUBSCRIPT 
CM_SUPERSCRIPT 
CM_ITALIC 
CM_BOLD 
CM_UNDERLINE 
CM_FIXEDPITCH 
CM_SERIF 
CM_SMALLCAPS 
CM_DROPCAPS 

Definition at line 84 of file pgedit.cpp.

Function Documentation

◆ bln_word_window_handle()

ScrollView* bln_word_window_handle ( )

bln_word_window_handle()

Returns
a WINDOW for the word window, creating it if necessary

Definition at line 165 of file pgedit.cpp.

165  { // return handle
166  // not opened yet
167  if (bln_word_window == nullptr) {
168  pgeditor_msg("Creating BLN word window...");
169  bln_word_window = new ScrollView(editor_word_name.string(),
171  editor_word_height, 4000, 4000, true);
172  BlnEventHandler* a = new BlnEventHandler();
173  bln_word_window->AddEventHandler(a);
174  pgeditor_msg("Creating BLN word window...Done");
175  }
176  return bln_word_window;
177 }
int editor_word_height
Definition: pgedit.cpp:145
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
Definition: scrollview.cpp:416
int editor_word_width
Definition: pgedit.cpp:146
int editor_word_xpos
Definition: pgedit.cpp:143
char * editor_word_name
Definition: pgedit.cpp:142
void pgeditor_msg(const char *msg)
Definition: pgedit.cpp:363
int editor_word_ypos
Definition: pgedit.cpp:144

◆ build_image_window()

void build_image_window ( int  width,
int  height 
)

build_image_window()

Destroy the existing image window if there is one. Work out how big the new window needs to be. Create it and re-display.

Definition at line 186 of file pgedit.cpp.

186  {
187  delete image_win;
188  image_win = new ScrollView(editor_image_win_name.string(),
190  width + 1,
191  height + editor_image_menuheight + 1,
192  width,
193  height,
194  true);
195 }
int editor_image_ypos
Definition: pgedit.cpp:126
int editor_image_menuheight
Definition: pgedit.cpp:127
int editor_image_xpos
Definition: pgedit.cpp:125
char * editor_image_win_name
Definition: pgedit.cpp:124

◆ pgeditor_msg()

void pgeditor_msg ( const char *  msg)

pgeditor_msg()

Display a message - in the command window if there is one, or to stdout

Definition at line 363 of file pgedit.cpp.

364  {
365  image_win->AddMessage(msg);
366 }
void AddMessage(const char *format,...)
Definition: scrollview.cpp:563

◆ pgeditor_show_point()

void pgeditor_show_point ( SVEvent event)

pgeditor_show_point()

Display the coordinates of a point in the command window

Definition at line 374 of file pgedit.cpp.

375  {
376  image_win->AddMessage("Pointing at(%d, %d)", event->x, event->y);
377 }
int x
Definition: scrollview.h:66
int y
Definition: scrollview.h:67
void AddMessage(const char *format,...)
Definition: scrollview.cpp:563

◆ show_point()

void show_point ( PAGE_RES page_res,
float  x,
float  y 
)

show_point()

Show coords of point, blob bounding box, word bounding box and offset from row baseline

Definition at line 653 of file pgedit.cpp.

653  {
654  FCOORD pt(x, y);
655  PAGE_RES_IT pr_it(page_res);
656 
657  const int kBufsize = 512;
658  char msg[kBufsize];
659  char *msg_ptr = msg;
660 
661  msg_ptr += sprintf(msg_ptr, "Pt:(%0.3f, %0.3f) ", x, y);
662 
663  for (WERD_RES* word = pr_it.word(); word != nullptr; word = pr_it.forward()) {
664  if (pr_it.row() != pr_it.prev_row() &&
665  pr_it.row()->row->bounding_box().contains(pt)) {
666  msg_ptr += sprintf(msg_ptr, "BL(x)=%0.3f ",
667  pr_it.row()->row->base_line(x));
668  }
669  if (word->word->bounding_box().contains(pt)) {
670  TBOX box = word->word->bounding_box();
671  msg_ptr += sprintf(msg_ptr, "Wd(%d, %d)/(%d, %d) ",
672  box.left(), box.bottom(),
673  box.right(), box.top());
674  C_BLOB_IT cblob_it(word->word->cblob_list());
675  for (cblob_it.mark_cycle_pt();
676  !cblob_it.cycled_list();
677  cblob_it.forward()) {
678  C_BLOB* cblob = cblob_it.data();
679  box = cblob->bounding_box();
680  if (box.contains(pt)) {
681  msg_ptr += sprintf(msg_ptr,
682  "CBlb(%d, %d)/(%d, %d) ",
683  box.left(), box.bottom(),
684  box.right(), box.top());
685  }
686  }
687  }
688  }
689  image_win->AddMessage(msg);
690 }
Definition: rect.h:34
int16_t left() const
Definition: rect.h:72
int16_t top() const
Definition: rect.h:58
TBOX bounding_box() const
Definition: stepblob.cpp:255
bool contains(const FCOORD pt) const
Definition: rect.h:333
Definition: points.h:189
int16_t right() const
Definition: rect.h:79
int16_t bottom() const
Definition: rect.h:65
void AddMessage(const char *format,...)
Definition: scrollview.cpp:563
WERD * word
Definition: pageres.h:189

Variable Documentation

◆ current_page_res

PAGE_RES* current_page_res = nullptr

Definition at line 121 of file pgedit.cpp.

◆ display_baselines

BOOL8 display_baselines = FALSE

Definition at line 119 of file pgedit.cpp.

◆ display_blocks

BOOL8 display_blocks = FALSE

Definition at line 118 of file pgedit.cpp.

◆ display_image

BOOL8 display_image = FALSE

Definition at line 117 of file pgedit.cpp.

◆ editor_dbwin_height

int editor_dbwin_height = 24

"Editor debug window height"

Definition at line 139 of file pgedit.cpp.

◆ editor_dbwin_name

char* editor_dbwin_name = "EditorDBWin"

"Editor debug window name"

Definition at line 136 of file pgedit.cpp.

◆ editor_dbwin_width

int editor_dbwin_width = 80

"Editor debug window width"

Definition at line 140 of file pgedit.cpp.

◆ editor_dbwin_xpos

int editor_dbwin_xpos = 50

"Editor debug window X Pos"

Definition at line 137 of file pgedit.cpp.

◆ editor_dbwin_ypos

int editor_dbwin_ypos = 500

"Editor debug window Y Pos"

Definition at line 138 of file pgedit.cpp.

◆ editor_debug_config_file

char* editor_debug_config_file = ""

"Config file to apply to single words"

Definition at line 148 of file pgedit.cpp.

◆ editor_image_blob_bb_color

int editor_image_blob_bb_color = ScrollView::YELLOW

"Blob bounding box colour"

Definition at line 131 of file pgedit.cpp.

◆ editor_image_menuheight

int editor_image_menuheight = 50

"Add to image height for menu bar"

Definition at line 127 of file pgedit.cpp.

◆ editor_image_text_color

int editor_image_text_color = ScrollView::WHITE

"Correct text colour"

Definition at line 133 of file pgedit.cpp.

◆ editor_image_win_name

char* editor_image_win_name = "EditorImage"

"Editor image window name"

Definition at line 124 of file pgedit.cpp.

◆ editor_image_word_bb_color

int editor_image_word_bb_color = ScrollView::BLUE

"Word bounding box colour"

Definition at line 129 of file pgedit.cpp.

◆ editor_image_xpos

int editor_image_xpos = 590

"Editor image X Pos"

Definition at line 125 of file pgedit.cpp.

◆ editor_image_ypos

int editor_image_ypos = 10

"Editor image Y Pos"

Definition at line 126 of file pgedit.cpp.

◆ editor_word_height

int editor_word_height = 240

"Word window height"

Definition at line 145 of file pgedit.cpp.

◆ editor_word_name

char* editor_word_name = "BlnWords"

"BL normalized word window"

Definition at line 142 of file pgedit.cpp.

◆ editor_word_width

int editor_word_width = 655

"Word window width"

Definition at line 146 of file pgedit.cpp.

◆ editor_word_xpos

int editor_word_xpos = 60

"Word window X Pos"

Definition at line 143 of file pgedit.cpp.

◆ editor_word_ypos

int editor_word_ypos = 510

"Word window Y Pos"

Definition at line 144 of file pgedit.cpp.

◆ EMPTYBLOCKLIST

const ERRCODE EMPTYBLOCKLIST = "No blocks to edit"

Definition at line 48 of file pgedit.cpp.

◆ word_display_mode

BITS16 word_display_mode

Definition at line 115 of file pgedit.cpp.