tesseract v5.3.3.20231005
plotedges.cpp
Go to the documentation of this file.
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
32namespace tesseract {
33
34/*----------------------------------------------------------------------
35 V a r i a b l e s
36----------------------------------------------------------------------*/
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 **********************************************************************/
47void 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 {
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 **********************************************************************/
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 **********************************************************************/
83void 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
#define iterate(l)
Definition: oldlist.h:91
#define NIL_LIST
Definition: oldlist.h:75
const double y
void mark_outline(EDGEPT *edgept)
Definition: plotedges.cpp:83
void render_edgepts(ScrollView *window, EDGEPT *edgept, ScrollView::Color color)
Definition: render.cpp:86
ScrollView * edge_window
Definition: plotedges.cpp:37
LIST destroy(LIST list)
Definition: oldlist.cpp:121
bool wordrec_display_splits
Definition: split.cpp:41
void display_edgepts(LIST outlines)
Definition: plotedges.cpp:47
LIST push(LIST list, void *element)
Definition: oldlist.cpp:178
void draw_blob_edges(TBLOB *blob)
Definition: plotedges.cpp:67
TDimension x
Definition: blobs.h:89
TDimension y
Definition: blobs.h:90
TPOINT pos
Definition: blobs.h:194
TESSLINE * next
Definition: blobs.h:288
TESSLINE * outlines
Definition: blobs.h:404
list_rec * first_node()
Definition: oldlist.h:107