tesseract  4.0.0-1-g2a2b
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  * Created: Fri Jul 28 13:14:48 1989
8  * Modified: Mon Jul 15 10:23:37 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 #include "render.h"
26 #include "blobs.h"
27 
28 #include <cmath>
29 
30 #include "vecfuncs.h"
31 
32 // Include automatically generated configuration file if running autoconf.
33 #ifdef HAVE_CONFIG_H
34 #include "config_auto.h"
35 #endif
36 
37 /*----------------------------------------------------------------------
38  V a r i a b l e s
39 ----------------------------------------------------------------------*/
41 
44 };
45 
46 BOOL_VAR(wordrec_display_all_blobs, 0, "Display Blobs");
47 
48 BOOL_VAR(wordrec_display_all_words, 0, "Display Words");
49 
50 BOOL_VAR(wordrec_blob_pause, 0, "Blob pause");
51 
52 /*----------------------------------------------------------------------
53  F u n c t i o n s
54 ----------------------------------------------------------------------*/
55 #ifndef GRAPHICS_DISABLED
56 /**********************************************************************
57  * display_blob
58  *
59  * Macro to display blob in a window.
60  **********************************************************************/
61 void display_blob(TBLOB *blob, C_COL color) {
62  /* Size of drawable */
63  if (blob_window == nullptr) {
64  blob_window = c_create_window ("Blobs", 520, 10,
65  500, 256, -1000.0, 1000.0, 0.0, 256.0);
66  }
67  else {
69  }
70 
71  render_blob(blob_window, blob, color);
72 }
73 
74 /**********************************************************************
75  * render_blob
76  *
77  * Create a list of line segments that represent the expanded outline
78  * that was supplied as input.
79  **********************************************************************/
80 void render_blob(void *window, TBLOB *blob, C_COL color) {
81  /* No outline */
82  if (!blob)
83  return;
84 
85  render_outline (window, blob->outlines, color);
86 }
87 
88 
89 /**********************************************************************
90  * render_edgepts
91  *
92  * Create a list of line segments that represent the expanded outline
93  * that was supplied as input.
94  **********************************************************************/
95 void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
96  if (!edgept)
97  return;
98 
99  float x = edgept->pos.x;
100  float y = edgept->pos.y;
101  EDGEPT *this_edge = edgept;
102 
103  c_line_color_index(window, color);
104  c_move(window, x, y);
105  do {
106  this_edge = this_edge->next;
107  x = this_edge->pos.x;
108  y = this_edge->pos.y;
109  c_draw(window, x, y);
110  }
111  while (edgept != this_edge);
112 }
113 
114 
115 /**********************************************************************
116  * render_outline
117  *
118  * Create a list of line segments that represent the expanded outline
119  * that was supplied as input.
120  **********************************************************************/
121 void render_outline(void *window,
122  TESSLINE *outline,
123  C_COL color) {
124  /* No outline */
125  if (!outline)
126  return;
127  /* Draw Compact outline */
128  if (outline->loop)
129  render_edgepts (window, outline->loop, color);
130  /* Add on next outlines */
131  render_outline (window, outline->next, color);
132 }
133 
134 #endif // GRAPHICS_DISABLED
Definition: callcpp.h:35
ScrollView * blob_window
Definition: render.cpp:40
TESSLINE * next
Definition: blobs.h:265
#define BOOL_VAR(name, val, comment)
Definition: params.h:279
TPOINT pos
Definition: blobs.h:170
Definition: callcpp.h:31
void c_draw(void *win, double x, double y)
Definition: callcpp.cpp:81
C_COL color_list[]
Definition: render.cpp:42
Definition: callcpp.h:36
C_COL
Definition: callcpp.h:29
bool wordrec_display_all_blobs
Definition: render.cpp:46
void render_blob(void *window, TBLOB *blob, C_COL color)
Definition: render.cpp:80
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
Definition: callcpp.h:34
Definition: callcpp.h:33
void render_outline(void *window, TESSLINE *outline, C_COL color)
Definition: render.cpp:121
EDGEPT * loop
Definition: blobs.h:264
void c_move(void *win, double x, double y)
Definition: callcpp.cpp:72
Definition: blobs.h:83
void display_blob(TBLOB *blob, C_COL color)
Definition: render.cpp:61
int16_t x
Definition: blobs.h:78
bool wordrec_display_all_words
Definition: render.cpp:48
bool wordrec_blob_pause
Definition: render.cpp:50
Definition: blobs.h:268
int16_t y
Definition: blobs.h:79
TESSLINE * outlines
Definition: blobs.h:384
EDGEPT * next
Definition: blobs.h:176
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