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