Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plotedges.cpp
Go to the documentation of this file.
1 /* -*-C-*-
2 ********************************************************************************
3 *
4 * File: plotedges.c (Formerly plotedges.c)
5 * Description: Graphics routines for "Edges" and "Outlines" windows
6 * Author: Mark Seaman, OCR Technology
7 * Created: Fri Jul 28 13:14:48 1989
8 * Modified: Tue Jul 9 17:22:22 1991 (Mark Seaman) marks@hpgrlt
9 * Language: C
10 * Package: N/A
11 * Status: Experimental (Do Not Distribute)
12 *
13 * (c) Copyright 1989, Hewlett-Packard Company.
14 ** Licensed under the Apache License, Version 2.0 (the "License");
15 ** you may not use this file except in compliance with the License.
16 ** You may obtain a copy of the License at
17 ** http://www.apache.org/licenses/LICENSE-2.0
18 ** Unless required by applicable law or agreed to in writing, software
19 ** distributed under the License is distributed on an "AS IS" BASIS,
20 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 ** See the License for the specific language governing permissions and
22 ** limitations under the License.
23 *
24 *********************************************************************************/
25 #ifdef __UNIX__
26 #include <assert.h>
27 #endif
28
29 #include "plotedges.h"
30 #include "render.h"
31 #include "split.h"
32
33 // Include automatically generated configuration file if running autoconf.
34 #ifdef HAVE_CONFIG_H
35 #include "config_auto.h"
36 #endif
37
38 #ifndef GRAPHICS_DISABLED
39
40 /*----------------------------------------------------------------------
41 V a r i a b l e s
42 ----------------------------------------------------------------------*/
43 ScrollView *edge_window = NULL;
44
45 /*----------------------------------------------------------------------
46 F u n c t i o n s
47 ----------------------------------------------------------------------*/
48 /**********************************************************************
49 * display_edgepts
50 *
51 * Macro to display edge points in a window.
52 **********************************************************************/
53 void display_edgepts(LIST outlines) {
54 void *window;
55 /* Set up window */
56 if (edge_window == NULL) {
57 edge_window = c_create_window ("Edges", 750, 150,
58 400, 128, -400.0, 400.0, 0.0, 256.0);
59 }
60 else {
61 c_clear_window(edge_window);
62 }
63 /* Render the outlines */
64 window = edge_window;
65 /* Reclaim old memory */
66 iterate(outlines) {
67 render_edgepts (window, (EDGEPT *) first_node (outlines), White);
68 }
69 }
70
71
72 /**********************************************************************
73 * draw_blob_edges
74 *
75 * Display the edges of this blob in the edges window.
76 **********************************************************************/
77 void draw_blob_edges(TBLOB *blob) {
78 TESSLINE *ol;
79 LIST edge_list = NIL_LIST;
80
81 if (wordrec_display_splits) {
82 for (ol = blob->outlines; ol != NULL; ol = ol->next)
83 push_on (edge_list, ol->loop);
84 display_edgepts(edge_list);
85 destroy(edge_list);
86 }
87 }
88
89
90 /**********************************************************************
91 * mark_outline
92 *
93 * Make a mark on the edges window at a particular location.
94 **********************************************************************/
95 void mark_outline(EDGEPT *edgept) { /* Start of point list */
96 void *window = edge_window;
97 float x = edgept->pos.x;
98 float y = edgept->pos.y;
99
100 c_line_color_index(window, Red);
101 c_move(window, x, y);
102
103 x -= 4;
104 y -= 12;
105 c_draw(window, x, y);
106
107 x -= 2;
108 y += 4;
109 c_draw(window, x, y);
110
111 x -= 4;
112 y += 2;
113 c_draw(window, x, y);
114
115 x += 10;
116 y += 6;
117 c_draw(window, x, y);
118
119 c_make_current(window);
120 }
121
122
123 /**********************************************************************
124 * mark_split
125 *
126 * Set up the marks list to be displayed in subsequent updates and draw
127 * the marks in the current window. The marks are stored in the second
128 * sublist. The first sublist is left unmodified.
129 **********************************************************************/
130 void mark_split(SPLIT *split) {
131 void *window = edge_window;
132
133 c_line_color_index(window, Green);
134 c_move (window, (float) split->point1->pos.x, (float) split->point1->pos.y);
135 c_draw (window, (float) split->point2->pos.x, (float) split->point2->pos.y);
136 c_make_current(window);
137 }
138
139 #endif // GRAPHICS_DISABLED