Tesseract  3.02
tesseract-ocr/ccmain/pgedit.cpp File Reference
#include "pgedit.h"
#include <ctype.h>
#include <math.h>
#include "blread.h"
#include "control.h"
#include "svshowim.h"
#include "paramsd.h"
#include "pageres.h"
#include "tordmain.h"
#include "scrollview.h"
#include "svmnode.h"
#include "statistc.h"
#include "tesseractclass.h"

Go to the source code of this file.

Classes

class  BlnEventHandler

Namespaces

namespace  tesseract

Defines

#define ASC_HEIGHT   (2 * kBlnBaselineOffset + kBlnXHeight)
#define X_HEIGHT   (kBlnBaselineOffset + kBlnXHeight)
#define BL_HEIGHT   kBlnBaselineOffset
#define DESC_HEIGHT   0
#define MAXSPACING   128

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_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 display_bln_lines (ScrollView *window, ScrollView::Color colour, float scale_factor, float y_offset, float minx, float maxx)
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"
ScrollViewimage_win
ParamsEditorpe
bool stillRunning = false
ScrollViewbln_word_window = NULL
CMD_EVENTS mode = CHANGE_DISP_CMD_EVENT
bool recog_done = false
BITS16 word_display_mode
BOOL8 display_image = FALSE
BOOL8 display_blocks = FALSE
BOOL8 display_baselines = FALSE
PAGE_REScurrent_page_res = NULL
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 = ""

Define Documentation

#define ASC_HEIGHT   (2 * kBlnBaselineOffset + kBlnXHeight)

Definition at line 46 of file pgedit.cpp.

#define BL_HEIGHT   kBlnBaselineOffset

Definition at line 48 of file pgedit.cpp.

#define DESC_HEIGHT   0

Definition at line 49 of file pgedit.cpp.

#define MAXSPACING   128

Definition at line 50 of file pgedit.cpp.

#define X_HEIGHT   (kBlnBaselineOffset + kBlnXHeight)

Definition at line 47 of file pgedit.cpp.


Enumeration Type Documentation

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_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 54 of file pgedit.cpp.

Enumerator:
CM_RAINBOW 
CM_SUBSCRIPT 
CM_SUPERSCRIPT 
CM_ITALIC 
CM_BOLD 
CM_UNDERLINE 
CM_FIXEDPITCH 
CM_SERIF 
CM_SMALLCAPS 
CM_DROPCAPS 

Definition at line 87 of file pgedit.cpp.


Function Documentation

ScrollView* bln_word_window_handle ( )

bln_word_window_handle()

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

Definition at line 171 of file pgedit.cpp.

                                     {  // return handle
                                 // not opened yet
  if (bln_word_window == NULL) {
    pgeditor_msg("Creating BLN word window...");
    bln_word_window = new ScrollView(editor_word_name.string(),
      editor_word_xpos, editor_word_ypos, editor_word_width,
      editor_word_height, 4000, 4000, true);
    BlnEventHandler* a = new BlnEventHandler();
    bln_word_window->AddEventHandler(a);
    pgeditor_msg("Creating BLN word window...Done");
  }
  return bln_word_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 192 of file pgedit.cpp.

                                               {
  if (image_win != NULL) { delete image_win; }
  image_win = new ScrollView(editor_image_win_name.string(),
                             editor_image_xpos, editor_image_ypos,
                             width + 1,
                             height + editor_image_menuheight + 1,
                             width,
                             height,
                             true);
}
void display_bln_lines ( ScrollView window,
ScrollView::Color  colour,
float  scale_factor,
float  y_offset,
float  minx,
float  maxx 
)

display_bln_lines()

Display normalized baseline, x-height, ascender limit and descender limit

Definition at line 209 of file pgedit.cpp.

                                   {
  window->Pen(colour);
  window->Line(minx, y_offset + scale_factor * DESC_HEIGHT,
               maxx, y_offset + scale_factor * DESC_HEIGHT);
  window->Line(minx, y_offset + scale_factor * BL_HEIGHT,
               maxx, y_offset + scale_factor * BL_HEIGHT);
  window->Line(minx, y_offset + scale_factor * X_HEIGHT,
               maxx, y_offset + scale_factor * X_HEIGHT);
  window->Line(minx, y_offset + scale_factor * ASC_HEIGHT,
               maxx, y_offset + scale_factor * ASC_HEIGHT);
}
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 372 of file pgedit.cpp.

                                   {
    image_win->AddMessage(msg);
}
void pgeditor_show_point ( SVEvent event)

pgeditor_show_point()

Display the coordinates of a point in the command window

Definition at line 383 of file pgedit.cpp.

                                         {
  image_win->AddMessage("Pointing at(%d, %d)", event->x, event->y);
}
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 650 of file pgedit.cpp.

                                                      {
  FCOORD pt(x, y);
  PAGE_RES_IT pr_it(page_res);

  char msg[160];
  char *msg_ptr = msg;

  msg_ptr += sprintf(msg_ptr, "Pt:(%0.3f, %0.3f) ", x, y);

  for (WERD_RES* word = pr_it.word(); word != NULL; word = pr_it.forward()) {
    if (pr_it.row() != pr_it.prev_row() &&
        pr_it.row()->row->bounding_box().contains(pt)) {
      msg_ptr += sprintf(msg_ptr, "BL(x)=%0.3f ",
                         pr_it.row()->row->base_line(x));
    }
    if (word->word->bounding_box().contains(pt)) {
      TBOX box = word->word->bounding_box();
      msg_ptr += sprintf(msg_ptr, "Wd(%d, %d)/(%d, %d) ",
                         box.left(), box.bottom(),
                         box.right(), box.top());
      C_BLOB_IT cblob_it(word->word->cblob_list());
      for (cblob_it.mark_cycle_pt();
           !cblob_it.cycled_list();
           cblob_it.forward()) {
        C_BLOB* cblob = cblob_it.data();
        box = cblob->bounding_box();
        if (box.contains(pt)) {
          msg_ptr += sprintf(msg_ptr,
                             "CBlb(%d, %d)/(%d, %d) ",
                             box.left(), box.bottom(),
                             box.right(), box.top());
        }
      }
    }
  }
  image_win->AddMessage(msg);
}

Variable Documentation

Definition at line 113 of file pgedit.cpp.

Definition at line 127 of file pgedit.cpp.

Definition at line 125 of file pgedit.cpp.

Definition at line 124 of file pgedit.cpp.

Definition at line 123 of file pgedit.cpp.

"Editor debug window height"

Definition at line 145 of file pgedit.cpp.

char* editor_dbwin_name = "EditorDBWin"

"Editor debug window name"

Definition at line 142 of file pgedit.cpp.

"Editor debug window width"

Definition at line 146 of file pgedit.cpp.

"Editor debug window X Pos"

Definition at line 143 of file pgedit.cpp.

int editor_dbwin_ypos = 500

"Editor debug window Y Pos"

Definition at line 144 of file pgedit.cpp.

"Config file to apply to single words"

Definition at line 154 of file pgedit.cpp.

int editor_image_blob_bb_color = ScrollView::YELLOW

"Blob bounding box colour"

Definition at line 137 of file pgedit.cpp.

"Add to image height for menu bar"

Definition at line 133 of file pgedit.cpp.

int editor_image_text_color = ScrollView::WHITE

"Correct text colour"

Definition at line 139 of file pgedit.cpp.

char* editor_image_win_name = "EditorImage"

"Editor image window name"

Definition at line 130 of file pgedit.cpp.

int editor_image_word_bb_color = ScrollView::BLUE

"Word bounding box colour"

Definition at line 135 of file pgedit.cpp.

int editor_image_xpos = 590

"Editor image X Pos"

Definition at line 131 of file pgedit.cpp.

"Editor image Y Pos"

Definition at line 132 of file pgedit.cpp.

int editor_word_height = 240

"Word window height"

Definition at line 151 of file pgedit.cpp.

char* editor_word_name = "BlnWords"

"BL normalized word window"

Definition at line 148 of file pgedit.cpp.

int editor_word_width = 655

"Word window width"

Definition at line 152 of file pgedit.cpp.

int editor_word_xpos = 60

"Word window X Pos"

Definition at line 149 of file pgedit.cpp.

int editor_word_ypos = 510

"Word window Y Pos"

Definition at line 150 of file pgedit.cpp.

const ERRCODE EMPTYBLOCKLIST = "No blocks to edit"

Definition at line 52 of file pgedit.cpp.

Definition at line 106 of file pgedit.cpp.

CMD_EVENTS mode = CHANGE_DISP_CMD_EVENT

Definition at line 115 of file pgedit.cpp.

Definition at line 107 of file pgedit.cpp.

bool recog_done = false

Definition at line 117 of file pgedit.cpp.

bool stillRunning = false

Definition at line 108 of file pgedit.cpp.

Definition at line 121 of file pgedit.cpp.