tesseract  4.1.0
render.cpp
Go to the documentation of this file.
1 /* -*-C-*-
2  ********************************************************************************
3  *
4  * File: render.cpp (Formerly render.c)
5  * Description: Convert the various data type into line lists
6  * Author: Mark Seaman, OCR Technology
7  *
8  * (c) Copyright 1989, Hewlett-Packard Company.
9  ** Licensed under the Apache License, Version 2.0 (the "License");
10  ** you may not use this file except in compliance with the License.
11  ** You may obtain a copy of the License at
12  ** http://www.apache.org/licenses/LICENSE-2.0
13  ** Unless required by applicable law or agreed to in writing, software
14  ** distributed under the License is distributed on an "AS IS" BASIS,
15  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  ** See the License for the specific language governing permissions and
17  ** limitations under the License.
18  *
19  *********************************************************************************/
20 #include "render.h"
21 #include "blobs.h"
22 
23 #include <cmath>
24 
25 #include "vecfuncs.h"
26 
27 // Include automatically generated configuration file if running autoconf.
28 #ifdef HAVE_CONFIG_H
29 #include "config_auto.h"
30 #endif
31 
32 /*----------------------------------------------------------------------
33  V a r i a b l e s
34 ----------------------------------------------------------------------*/
36 
39 };
40 
41 BOOL_VAR(wordrec_display_all_blobs, 0, "Display Blobs");
42 
43 BOOL_VAR(wordrec_display_all_words, 0, "Display Words");
44 
45 BOOL_VAR(wordrec_blob_pause, 0, "Blob pause");
46 
47 /*----------------------------------------------------------------------
48  F u n c t i o n s
49 ----------------------------------------------------------------------*/
50 #ifndef GRAPHICS_DISABLED
51 /**********************************************************************
52  * display_blob
53  *
54  * Macro to display blob in a window.
55  **********************************************************************/
56 void display_blob(TBLOB *blob, C_COL color) {
57  /* Size of drawable */
58  if (blob_window == nullptr) {
59  blob_window = c_create_window ("Blobs", 520, 10,
60  500, 256, -1000.0, 1000.0, 0.0, 256.0);
61  }
62  else {
63  c_clear_window(blob_window);
64  }
65 
66  render_blob(blob_window, blob, color);
67 }
68 
69 /**********************************************************************
70  * render_blob
71  *
72  * Create a list of line segments that represent the expanded outline
73  * that was supplied as input.
74  **********************************************************************/
75 void render_blob(void *window, TBLOB *blob, C_COL color) {
76  /* No outline */
77  if (!blob)
78  return;
79 
80  render_outline (window, blob->outlines, color);
81 }
82 
83 
84 /**********************************************************************
85  * render_edgepts
86  *
87  * Create a list of line segments that represent the expanded outline
88  * that was supplied as input.
89  **********************************************************************/
90 void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
91  if (!edgept)
92  return;
93 
94  float x = edgept->pos.x;
95  float y = edgept->pos.y;
96  EDGEPT *this_edge = edgept;
97 
98  c_line_color_index(window, color);
99  c_move(window, x, y);
100  do {
101  this_edge = this_edge->next;
102  x = this_edge->pos.x;
103  y = this_edge->pos.y;
104  c_draw(window, x, y);
105  }
106  while (edgept != this_edge);
107 }
108 
109 
110 /**********************************************************************
111  * render_outline
112  *
113  * Create a list of line segments that represent the expanded outline
114  * that was supplied as input.
115  **********************************************************************/
116 void render_outline(void *window,
117  TESSLINE *outline,
118  C_COL color) {
119  /* No outline */
120  if (!outline)
121  return;
122  /* Draw Compact outline */
123  if (outline->loop)
124  render_edgepts (window, outline->loop, color);
125  /* Add on next outlines */
126  render_outline (window, outline->next, color);
127 }
128 
129 #endif // GRAPHICS_DISABLED
C_COL color_list[]
Definition: render.cpp:37
TESSLINE * next
Definition: blobs.h:260
void c_clear_window(void *win)
Definition: callcpp.cpp:96
int16_t x
Definition: blobs.h:73
EDGEPT * next
Definition: blobs.h:171
TESSLINE * outlines
Definition: blobs.h:379
EDGEPT * loop
Definition: blobs.h:259
TPOINT pos
Definition: blobs.h:165
Definition: blobs.h:263
bool wordrec_display_all_words
Definition: render.cpp:43
void render_edgepts(void *window, EDGEPT *edgept, C_COL color)
Definition: render.cpp:90
void c_move(void *win, double x, double y)
Definition: callcpp.cpp:71
void display_blob(TBLOB *blob, C_COL color)
Definition: render.cpp:56
Definition: callcpp.h:30
int16_t y
Definition: blobs.h:74
Definition: callcpp.h:34
void c_draw(void *win, double x, double y)
Definition: callcpp.cpp:80
Definition: blobs.h:78
ScrollView * blob_window
Definition: render.cpp:35
void render_blob(void *window, TBLOB *blob, C_COL color)
Definition: render.cpp:75
Definition: callcpp.h:35
void render_outline(void *window, TESSLINE *outline, C_COL color)
Definition: render.cpp:116
bool wordrec_display_all_blobs
Definition: render.cpp:41
bool wordrec_blob_pause
Definition: render.cpp:45
#define BOOL_VAR(name, val, comment)
Definition: params.h:306
C_COL
Definition: callcpp.h:28
Definition: callcpp.h:33
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:47
Definition: callcpp.h:31
void c_line_color_index(void *win, C_COL index)
Definition: callcpp.cpp:62
Definition: callcpp.h:32