tesseract  4.0.0-1-g2a2b
plotedges.cpp
Go to the documentation of this file.
1 /* -*-C-*-
2  ********************************************************************************
3  *
4  * File: plotedges.cpp (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 
26 #include "plotedges.h"
27 #include "render.h"
28 #include "split.h"
29 
30 // Include automatically generated configuration file if running autoconf.
31 #ifdef HAVE_CONFIG_H
32 #include "config_auto.h"
33 #endif
34 
35 #ifndef GRAPHICS_DISABLED
36 
37 /*----------------------------------------------------------------------
38  V a r i a b l e s
39 ----------------------------------------------------------------------*/
41 
42 /*----------------------------------------------------------------------
43  F u n c t i o n s
44 ----------------------------------------------------------------------*/
45 /**********************************************************************
46  * display_edgepts
47  *
48  * Macro to display edge points in a window.
49  **********************************************************************/
50 void display_edgepts(LIST outlines) {
51  void *window;
52  /* Set up window */
53  if (edge_window == nullptr) {
54  edge_window = c_create_window ("Edges", 750, 150,
55  400, 128, -400.0, 400.0, 0.0, 256.0);
56  }
57  else {
59  }
60  /* Render the outlines */
61  window = edge_window;
62  /* Reclaim old memory */
63  iterate(outlines) {
64  render_edgepts (window, (EDGEPT *) first_node (outlines), White);
65  }
66 }
67 
68 
69 /**********************************************************************
70  * draw_blob_edges
71  *
72  * Display the edges of this blob in the edges window.
73  **********************************************************************/
74 void draw_blob_edges(TBLOB *blob) {
75  TESSLINE *ol;
76  LIST edge_list = NIL_LIST;
77 
79  for (ol = blob->outlines; ol != nullptr; ol = ol->next)
80  push_on (edge_list, ol->loop);
81  display_edgepts(edge_list);
82  destroy(edge_list);
83  }
84 }
85 
86 
87 /**********************************************************************
88  * mark_outline
89  *
90  * Make a mark on the edges window at a particular location.
91  **********************************************************************/
92 void mark_outline(EDGEPT *edgept) { /* Start of point list */
93  void *window = edge_window;
94  float x = edgept->pos.x;
95  float y = edgept->pos.y;
96 
97  c_line_color_index(window, Red);
98  c_move(window, x, y);
99 
100  x -= 4;
101  y -= 12;
102  c_draw(window, x, y);
103 
104  x -= 2;
105  y += 4;
106  c_draw(window, x, y);
107 
108  x -= 4;
109  y += 2;
110  c_draw(window, x, y);
111 
112  x += 10;
113  y += 6;
114  c_draw(window, x, y);
115 
116  c_make_current(window);
117 }
118 
119 #endif // GRAPHICS_DISABLED
TESSLINE * next
Definition: blobs.h:265
TPOINT pos
Definition: blobs.h:170
Definition: callcpp.h:31
bool wordrec_display_splits
Definition: split.cpp:47
void c_draw(void *win, double x, double y)
Definition: callcpp.cpp:81
LIST destroy(LIST list)
Definition: oldlist.cpp:170
void render_edgepts(void *window, EDGEPT *edgept, C_COL color)
Definition: render.cpp:95
void c_clear_window(void *win)
Definition: callcpp.cpp:97
Definition: callcpp.h:32
EDGEPT * loop
Definition: blobs.h:264
void c_move(void *win, double x, double y)
Definition: callcpp.cpp:72
Definition: blobs.h:83
void mark_outline(EDGEPT *edgept)
Definition: plotedges.cpp:92
#define first_node(l)
Definition: oldlist.h:141
int16_t x
Definition: blobs.h:78
#define NIL_LIST
Definition: oldlist.h:127
ScrollView * edge_window
Definition: plotedges.cpp:40
#define iterate(l)
Definition: oldlist.h:161
#define push_on(list, thing)
Definition: oldlist.h:202
Definition: blobs.h:268
void c_make_current(void *win)
Definition: callcpp.cpp:90
int16_t y
Definition: blobs.h:79
TESSLINE * outlines
Definition: blobs.h:384
ScrollView * c_create_window(const char *name, int16_t xpos, int16_t ypos, int16_t xsize, int16_t ysize, double xmin, double xmax, double ymin, double ymax)
Definition: callcpp.cpp:48
void c_line_color_index(void *win, C_COL index)
Definition: callcpp.cpp:63
void display_edgepts(LIST outlines)
Definition: plotedges.cpp:50
void draw_blob_edges(TBLOB *blob)
Definition: plotedges.cpp:74