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 #ifndef GRAPHICS_DISABLED
34
35 /*----------------------------------------------------------------------
36 V a r i a b l e s
37 ----------------------------------------------------------------------*/
38 ScrollView *edge_window = NULL;
39
40 /*----------------------------------------------------------------------
41 F u n c t i o n s
42 ----------------------------------------------------------------------*/
43 /**********************************************************************
44 * display_edgepts
45 *
46 * Macro to display edge points in a window.
47 **********************************************************************/
display_edgepts(LIST outlines)48 void display_edgepts(LIST outlines) {
49 void *window;
50 /* Set up window */
51 if (edge_window == NULL) {
52 edge_window = c_create_window ("Edges", 750, 150,
53 400, 128, -400.0, 400.0, 0.0, 256.0);
54 }
55 else {
56 c_clear_window(edge_window);
57 }
58 /* Render the outlines */
59 window = edge_window;
60 /* Reclaim old memory */
61 iterate(outlines) {
62 render_edgepts (window, (EDGEPT *) first_node (outlines), White);
63 }
64 }
65
66
67 /**********************************************************************
68 * draw_blob_edges
69 *
70 * Display the edges of this blob in the edges window.
71 **********************************************************************/
draw_blob_edges(TBLOB * blob)72 void draw_blob_edges(TBLOB *blob) {
73 TESSLINE *ol;
74 LIST edge_list = NIL;
75
76 if (wordrec_display_splits) {
77 for (ol = blob->outlines; ol != NULL; ol = ol->next)
78 push_on (edge_list, ol->loop);
79 display_edgepts(edge_list);
80 destroy(edge_list);
81 }
82 }
83
84
85 /**********************************************************************
86 * mark_outline
87 *
88 * Make a mark on the edges window at a particular location.
89 **********************************************************************/
mark_outline(EDGEPT * edgept)90 void mark_outline(EDGEPT *edgept) { /* Start of point list */
91 void *window = edge_window;
92 float x = edgept->pos.x;
93 float y = edgept->pos.y;
94
95 c_line_color_index(window, Red);
96 c_move(window, x, y);
97
98 x -= 4;
99 y -= 12;
100 c_draw(window, x, y);
101
102 x -= 2;
103 y += 4;
104 c_draw(window, x, y);
105
106 x -= 4;
107 y += 2;
108 c_draw(window, x, y);
109
110 x += 10;
111 y += 6;
112 c_draw(window, x, y);
113
114 c_make_current(window);
115 }
116
117
118 /**********************************************************************
119 * mark_split
120 *
121 * Set up the marks list to be displayed in subsequent updates and draw
122 * the marks in the current window. The marks are stored in the second
123 * sublist. The first sublist is left unmodified.
124 **********************************************************************/
mark_split(SPLIT * split)125 void mark_split(SPLIT *split) {
126 void *window = edge_window;
127
128 c_line_color_index(window, Green);
129 c_move (window, (float) split->point1->pos.x, (float) split->point1->pos.y);
130 c_draw (window, (float) split->point2->pos.x, (float) split->point2->pos.y);
131 c_make_current(window);
132 }
133
134 #endif // GRAPHICS_DISABLED
135