Skip to content

Commit 26dd0b8

Browse files
committed
pgedit: Remove unused global functions
pgeditor_show_point is unused, so remove it completely. Some more functions are only used locally, so make them static functions. Signed-off-by: Stefan Weil <[email protected]>
1 parent 47598fa commit 26dd0b8

File tree

2 files changed

+59
-82
lines changed

2 files changed

+59
-82
lines changed

src/ccmain/pgedit.cpp

+59-72
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,63 @@ INT_VAR(editor_word_width, 655, "Word window width");
146146

147147
STRING_VAR(editor_debug_config_file, "", "Config file to apply to single words");
148148

149+
/**
150+
* show_point()
151+
*
152+
* Show coords of point, blob bounding box, word bounding box and offset from
153+
* row baseline
154+
*/
155+
156+
static void show_point(PAGE_RES* page_res, float x, float y) {
157+
FCOORD pt(x, y);
158+
PAGE_RES_IT pr_it(page_res);
159+
160+
const int kBufsize = 512;
161+
char msg[kBufsize];
162+
char *msg_ptr = msg;
163+
164+
msg_ptr += sprintf(msg_ptr, "Pt:(%0.3f, %0.3f) ", x, y);
165+
166+
for (WERD_RES* word = pr_it.word(); word != nullptr; word = pr_it.forward()) {
167+
if (pr_it.row() != pr_it.prev_row() &&
168+
pr_it.row()->row->bounding_box().contains(pt)) {
169+
msg_ptr += sprintf(msg_ptr, "BL(x)=%0.3f ",
170+
pr_it.row()->row->base_line(x));
171+
}
172+
if (word->word->bounding_box().contains(pt)) {
173+
TBOX box = word->word->bounding_box();
174+
msg_ptr += sprintf(msg_ptr, "Wd(%d, %d)/(%d, %d) ",
175+
box.left(), box.bottom(),
176+
box.right(), box.top());
177+
C_BLOB_IT cblob_it(word->word->cblob_list());
178+
for (cblob_it.mark_cycle_pt();
179+
!cblob_it.cycled_list();
180+
cblob_it.forward()) {
181+
C_BLOB* cblob = cblob_it.data();
182+
box = cblob->bounding_box();
183+
if (box.contains(pt)) {
184+
msg_ptr += sprintf(msg_ptr,
185+
"CBlb(%d, %d)/(%d, %d) ",
186+
box.left(), box.bottom(),
187+
box.right(), box.top());
188+
}
189+
}
190+
}
191+
}
192+
image_win->AddMessage(msg);
193+
}
194+
195+
/**
196+
* pgeditor_msg()
197+
*
198+
* Display a message - in the command window if there is one, or to stdout
199+
*/
200+
201+
static void pgeditor_msg( // message display
202+
const char *msg) {
203+
image_win->AddMessage(msg);
204+
}
205+
149206
class BlnEventHandler : public SVEventHandler {
150207
public:
151208
void Notify(const SVEvent* sv_event) override {
@@ -161,7 +218,7 @@ class BlnEventHandler : public SVEventHandler {
161218
*
162219
* @return a WINDOW for the word window, creating it if necessary
163220
*/
164-
ScrollView* bln_word_window_handle() { // return handle
221+
static ScrollView* bln_word_window_handle() { // return handle
165222
// not opened yet
166223
if (bln_word_window == nullptr) {
167224
pgeditor_msg("Creating BLN word window...");
@@ -182,7 +239,7 @@ ScrollView* bln_word_window_handle() { // return handle
182239
* new window needs to be. Create it and re-display.
183240
*/
184241

185-
void build_image_window(int width, int height) {
242+
static void build_image_window(int width, int height) {
186243
delete image_win;
187244
image_win = new ScrollView(editor_image_win_name.string(),
188245
editor_image_xpos, editor_image_ypos,
@@ -352,29 +409,6 @@ void Tesseract::pgeditor_main(int width, int height, PAGE_RES *page_res) {
352409
}
353410
} // namespace tesseract
354411

355-
356-
/**
357-
* pgeditor_msg()
358-
*
359-
* Display a message - in the command window if there is one, or to stdout
360-
*/
361-
362-
void pgeditor_msg( // message display
363-
const char *msg) {
364-
image_win->AddMessage(msg);
365-
}
366-
367-
/**
368-
* pgeditor_show_point()
369-
*
370-
* Display the coordinates of a point in the command window
371-
*/
372-
373-
void pgeditor_show_point( // display coords
374-
SVEvent *event) {
375-
image_win->AddMessage("Pointing at(%d, %d)", event->x, event->y);
376-
}
377-
378412
/**
379413
* process_cmd_win_event()
380414
*
@@ -642,53 +676,6 @@ void Tesseract::debug_word(PAGE_RES* page_res, const TBOX &selection_box) {
642676
} // namespace tesseract
643677

644678

645-
/**
646-
* show_point()
647-
*
648-
* Show coords of point, blob bounding box, word bounding box and offset from
649-
* row baseline
650-
*/
651-
652-
void show_point(PAGE_RES* page_res, float x, float y) {
653-
FCOORD pt(x, y);
654-
PAGE_RES_IT pr_it(page_res);
655-
656-
const int kBufsize = 512;
657-
char msg[kBufsize];
658-
char *msg_ptr = msg;
659-
660-
msg_ptr += sprintf(msg_ptr, "Pt:(%0.3f, %0.3f) ", x, y);
661-
662-
for (WERD_RES* word = pr_it.word(); word != nullptr; word = pr_it.forward()) {
663-
if (pr_it.row() != pr_it.prev_row() &&
664-
pr_it.row()->row->bounding_box().contains(pt)) {
665-
msg_ptr += sprintf(msg_ptr, "BL(x)=%0.3f ",
666-
pr_it.row()->row->base_line(x));
667-
}
668-
if (word->word->bounding_box().contains(pt)) {
669-
TBOX box = word->word->bounding_box();
670-
msg_ptr += sprintf(msg_ptr, "Wd(%d, %d)/(%d, %d) ",
671-
box.left(), box.bottom(),
672-
box.right(), box.top());
673-
C_BLOB_IT cblob_it(word->word->cblob_list());
674-
for (cblob_it.mark_cycle_pt();
675-
!cblob_it.cycled_list();
676-
cblob_it.forward()) {
677-
C_BLOB* cblob = cblob_it.data();
678-
box = cblob->bounding_box();
679-
if (box.contains(pt)) {
680-
msg_ptr += sprintf(msg_ptr,
681-
"CBlb(%d, %d)/(%d, %d) ",
682-
box.left(), box.bottom(),
683-
box.right(), box.top());
684-
}
685-
}
686-
}
687-
}
688-
image_win->AddMessage(msg);
689-
}
690-
691-
692679
/**********************************************************************
693680
* WERD PROCESSOR FUNCTIONS
694681
* ========================

src/ccmain/pgedit.h

-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// File: pgedit.h
33
// Description: Page structure file editor
44
// Author: Joern Wanke
5-
// Created: Wed Jul 18 10:05:01 PDT 2007
65
//
76
// (C) Copyright 2007, Google Inc.
87
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -67,13 +66,4 @@ extern INT_VAR_H (editor_word_height, 240, "Word window height");
6766
extern INT_VAR_H (editor_word_width, 655, "Word window width");
6867
extern double_VAR_H (editor_smd_scale_factor, 1.0, "Scaling for smd image");
6968

70-
ScrollView* bln_word_window_handle(); //return handle
71-
void build_image_window(int width, int height);
72-
void pgeditor_msg( //message display
73-
const char *msg);
74-
void pgeditor_show_point( //display coords
75-
SVEvent *event);
76-
//put bln word in box
77-
void show_point(PAGE_RES* page_res, float x, float y);
78-
7969
#endif

0 commit comments

Comments
 (0)