comparison mupdf-source/thirdparty/tesseract/src/wordrec/plotedges.cpp @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /******************************************************************************
2 *
3 * File: plotedges.cpp (Formerly plotedges.c)
4 * Description: Graphics routines for "Edges" and "Outlines" windows
5 * Author: Mark Seaman, OCR Technology
6 *
7 * (c) Copyright 1989, Hewlett-Packard Company.
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 // Include automatically generated configuration file if running autoconf.
21 #ifdef HAVE_CONFIG_H
22 # include "config_auto.h"
23 #endif
24
25 #include "plotedges.h"
26
27 #include "render.h"
28 #include "split.h"
29
30 #ifndef GRAPHICS_DISABLED
31
32 namespace tesseract {
33
34 /*----------------------------------------------------------------------
35 V a r i a b l e s
36 ----------------------------------------------------------------------*/
37 ScrollView *edge_window = nullptr;
38
39 /*----------------------------------------------------------------------
40 F u n c t i o n s
41 ----------------------------------------------------------------------*/
42 /**********************************************************************
43 * display_edgepts
44 *
45 * Macro to display edge points in a window.
46 **********************************************************************/
47 void display_edgepts(LIST outlines) {
48 /* Set up window */
49 if (edge_window == nullptr) {
50 edge_window = new ScrollView("Edges", 750, 150, 400, 128, 800, 256, true);
51 } else {
52 edge_window->Clear();
53 }
54 /* Render the outlines */
55 auto window = edge_window;
56 /* Reclaim old memory */
57 iterate(outlines) {
58 render_edgepts(window, reinterpret_cast<EDGEPT *>(outlines->first_node()), ScrollView::WHITE);
59 }
60 }
61
62 /**********************************************************************
63 * draw_blob_edges
64 *
65 * Display the edges of this blob in the edges window.
66 **********************************************************************/
67 void draw_blob_edges(TBLOB *blob) {
68 if (wordrec_display_splits) {
69 LIST edge_list = NIL_LIST;
70 for (TESSLINE *ol = blob->outlines; ol != nullptr; ol = ol->next) {
71 edge_list = push(edge_list, ol->loop);
72 }
73 display_edgepts(edge_list);
74 destroy(edge_list);
75 }
76 }
77
78 /**********************************************************************
79 * mark_outline
80 *
81 * Make a mark on the edges window at a particular location.
82 **********************************************************************/
83 void mark_outline(EDGEPT *edgept) { /* Start of point list */
84 auto window = edge_window;
85 float x = edgept->pos.x;
86 float y = edgept->pos.y;
87
88 window->Pen(ScrollView::RED);
89 window->SetCursor(x, y);
90
91 x -= 4;
92 y -= 12;
93 window->DrawTo(x, y);
94
95 x -= 2;
96 y += 4;
97 window->DrawTo(x, y);
98
99 x -= 4;
100 y += 2;
101 window->DrawTo(x, y);
102
103 x += 10;
104 y += 6;
105 window->DrawTo(x, y);
106
107 window->Update();
108 }
109
110 } // namespace tesseract
111
112 #endif // !GRAPHICS_DISABLED