1 /////////////////////////////////////////////////////////////////////// 2 // File: pgedit.h 3 // Description: Page structure file editor 4 // Author: Joern Wanke 5 // Created: Wed Jul 18 10:05:01 PDT 2007 6 // 7 // (C) Copyright 2007, Google Inc. 8 // Licensed under the Apache License, Version 2.0 (the "License"); 9 // you may not use this file except in compliance with the License. 10 // You may obtain a copy of the License at 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // Unless required by applicable law or agreed to in writing, software 13 // distributed under the License is distributed on an "AS IS" BASIS, 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 // See the License for the specific language governing permissions and 16 // limitations under the License. 17 // 18 /////////////////////////////////////////////////////////////////////// 19 20 #ifndef PGEDIT_H 21 #define PGEDIT_H 22 23 #include "ocrblock.h" 24 #include "ocrrow.h" 25 #include "werd.h" 26 #include "rect.h" 27 #include "pagewalk.h" 28 #include "varable.h" 29 #include "notdll.h" 30 #include "tesseractclass.h" 31 32 class ScrollView; 33 class SVMenuNode; 34 struct SVEvent; 35 36 // A small event handler class to process incoming events to 37 // this window. 38 class PGEventHandler : public SVEventHandler { 39 public: PGEventHandler(tesseract::Tesseract * tess)40 PGEventHandler(tesseract::Tesseract* tess) : tess_(tess) { 41 } 42 void Notify(const SVEvent* sve); 43 private: 44 tesseract::Tesseract* tess_; 45 }; 46 47 extern BLOCK_LIST *current_block_list; 48 extern BOOL8 *current_image_changed; 49 extern STRING_VAR_H (editor_image_win_name, "EditorImage", 50 "Editor image window name"); 51 extern INT_VAR_H (editor_image_xpos, 590, "Editor image X Pos"); 52 extern INT_VAR_H (editor_image_ypos, 10, "Editor image Y Pos"); 53 extern INT_VAR_H (editor_image_height, 680, "Editor image height"); 54 extern INT_VAR_H (editor_image_width, 655, "Editor image width"); 55 extern INT_VAR_H (editor_image_word_bb_color, BLUE, 56 "Word bounding box colour"); 57 extern INT_VAR_H (editor_image_blob_bb_color, YELLOW, 58 "Blob bounding box colour"); 59 extern INT_VAR_H (editor_image_text_color, WHITE, "Correct text colour"); 60 extern STRING_VAR_H (editor_dbwin_name, "EditorDBWin", 61 "Editor debug window name"); 62 extern INT_VAR_H (editor_dbwin_xpos, 50, "Editor debug window X Pos"); 63 extern INT_VAR_H (editor_dbwin_ypos, 500, "Editor debug window Y Pos"); 64 extern INT_VAR_H (editor_dbwin_height, 24, "Editor debug window height"); 65 extern INT_VAR_H (editor_dbwin_width, 80, "Editor debug window width"); 66 extern STRING_VAR_H (editor_word_name, "BlnWords", 67 "BL normalised word window"); 68 extern INT_VAR_H (editor_word_xpos, 60, "Word window X Pos"); 69 extern INT_VAR_H (editor_word_ypos, 510, "Word window Y Pos"); 70 extern INT_VAR_H (editor_word_height, 240, "Word window height"); 71 extern INT_VAR_H (editor_word_width, 655, "Word window width"); 72 extern double_VAR_H (editor_smd_scale_factor, 1.0, "Scaling for smd image"); 73 74 void add_word( //to block list 75 WERD *word, //word to be added 76 ROW *src_row, //source row 77 BLOCK *src_block, //source block 78 BLOCK_LIST *dest_block_list //add to this 79 ); 80 ScrollView* bln_word_window_handle(); //return handle 81 void build_image_window(TBOX page_bounding_box); 82 void display_bln_lines(ScrollView window, 83 ScrollView::Color colour, 84 float scale_factor, 85 float y_offset, 86 float minx, 87 float maxx); 88 //function to call 89 void do_re_display (BOOL8 word_painter ( 90 BLOCK *, ROW *, WERD *)); 91 const TBOX do_tidy_cmd(); //tidy 92 void do_view_cmd(); 93 void do_write_file( //serialise 94 char *name //file name 95 ); 96 void pgeditor_msg( //message display 97 const char *msg); 98 void pgeditor_show_point( //display coords 99 SVEvent *event); 100 void pgeditor_write_file( //serialise 101 char *name, //file name 102 BLOCK_LIST *blocks //block list to write 103 ); 104 //put bln word in box 105 float re_scale_and_move_bln_word(WERD *norm_word, //BL normalised word 106 const TBOX &box //destination box 107 ); 108 void re_segment_word( //break/join words 109 BLOCK_LIST *block_list, //blocks to check 110 TBOX &selection_box); 111 void block_space_stat( //show space stats 112 BLOCK_LIST *block_list, //blocks to check 113 TBOX &selection_box); 114 void row_space_stat( //show space stats 115 BLOCK_LIST *block_list, //blocks to check 116 TBOX &selection_box); 117 void show_point( //display posn of bloba word 118 BLOCK_LIST *block_list, //blocks to check 119 float x, 120 float y); 121 //display a word 122 BOOL8 word_blank_and_set_display(BLOCK *block, //block holding word 123 ROW *row, //row holding word 124 WERD *word //word to be processed 125 ); 126 BOOL8 word_bln_display( //bln & display 127 BLOCK *, //block holding word 128 ROW *row, //row holding word 129 WERD *word //word to be processed 130 ); 131 BOOL8 word_change_text( //change correct text 132 BLOCK *block, //block holding word 133 ROW *row, //row holding word 134 WERD *word //word to be processed 135 ); 136 BOOL8 word_copy( //copy a word 137 BLOCK *block, //block holding word 138 ROW *row, //row holding word 139 WERD *word //word to be processed 140 ); 141 BOOL8 word_delete( //delete a word 142 BLOCK *block, //block holding word 143 ROW *row, //row holding word 144 WERD *word, //word to be processed 145 BLOCK_IT &block_it, //block list iterator 146 ROW_IT &row_it, //row list iterator 147 WERD_IT &word_it //word list iterator 148 ); 149 BOOL8 word_display( // display a word 150 BLOCK *, //block holding word 151 ROW *row, //row holding word 152 WERD *word //word to be processed 153 ); 154 BOOL8 word_dumper( //dump word 155 BLOCK *block, //block holding word 156 ROW *row, //row holding word 157 WERD *word //word to be processed 158 ); 159 BOOL8 word_set_display( //display a word 160 BLOCK *block, //block holding word 161 ROW *row, //row holding word 162 WERD *word //word to be processed 163 ); 164 BOOL8 word_toggle_seg( //toggle seg flag 165 BLOCK *, //block holding word 166 ROW *, //row holding word 167 WERD *word //word to be processed 168 ); 169 void do_check_mem( //do it 170 inT32 level); 171 #endif 172