tesseract  5.0.0-alpha-619-ge9db
plotedges.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * File: plotedges.cpp (Formerly plotedges.c)
4  * Description: Graphics routines for "Edges" and "Outlines" windows
5  * Author: Mark Seaman, OCR Technology
6  *
7  * (c) Copyright 1989, Hewlett-Packard Company.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  *****************************************************************************/
19 
20 #include "plotedges.h"
21 #include "render.h"
22 #include "split.h"
23 
24 // Include automatically generated configuration file if running autoconf.
25 #ifdef HAVE_CONFIG_H
26 #include "config_auto.h"
27 #endif
28 
29 #ifndef GRAPHICS_DISABLED
30 
31 /*----------------------------------------------------------------------
32  V a r i a b l e s
33 ----------------------------------------------------------------------*/
34 ScrollView *edge_window = nullptr;
35 
36 /*----------------------------------------------------------------------
37  F u n c t i o n s
38 ----------------------------------------------------------------------*/
39 /**********************************************************************
40  * display_edgepts
41  *
42  * Macro to display edge points in a window.
43  **********************************************************************/
44 void display_edgepts(LIST outlines) {
45  void *window;
46  /* Set up window */
47  if (edge_window == nullptr) {
48  edge_window = c_create_window ("Edges", 750, 150,
49  400, 128, -400.0, 400.0, 0.0, 256.0);
50  }
51  else {
53  }
54  /* Render the outlines */
55  window = edge_window;
56  /* Reclaim old memory */
57  iterate(outlines) {
58  render_edgepts (window, reinterpret_cast<EDGEPT *>first_node (outlines), White);
59  }
60 }
61 
62 
63 /**********************************************************************
64  * draw_blob_edges
65  *
66  * Display the edges of this blob in the edges window.
67  **********************************************************************/
68 void draw_blob_edges(TBLOB *blob) {
70  LIST edge_list = NIL_LIST;
71  for (TESSLINE* ol = blob->outlines; ol != nullptr; ol = ol->next) {
72  edge_list = push(edge_list, ol->loop);
73  }
74  display_edgepts(edge_list);
75  destroy(edge_list);
76  }
77 }
78 
79 
80 /**********************************************************************
81  * mark_outline
82  *
83  * Make a mark on the edges window at a particular location.
84  **********************************************************************/
85 void mark_outline(EDGEPT *edgept) { /* Start of point list */
86  void *window = edge_window;
87  float x = edgept->pos.x;
88  float y = edgept->pos.y;
89 
90  c_line_color_index(window, Red);
91  c_move(window, x, y);
92 
93  x -= 4;
94  y -= 12;
95  c_draw(window, x, y);
96 
97  x -= 2;
98  y += 4;
99  c_draw(window, x, y);
100 
101  x -= 4;
102  y += 2;
103  c_draw(window, x, y);
104 
105  x += 10;
106  y += 6;
107  c_draw(window, x, y);
108 
109  c_make_current(window);
110 }
111 
112 #endif // GRAPHICS_DISABLED
render.h
ScrollView
Definition: scrollview.h:97
plotedges.h
first_node
#define first_node(l)
Definition: oldlist.h:84
split.h
draw_blob_edges
void draw_blob_edges(TBLOB *blob)
Definition: plotedges.cpp:65
list_rec
Definition: oldlist.h:73
TBLOB::outlines
TESSLINE * outlines
Definition: blobs.h:398
TESSLINE
Definition: blobs.h:201
TESSLINE::next
TESSLINE * next
Definition: blobs.h:279
NIL_LIST
#define NIL_LIST
Definition: oldlist.h:68
c_move
void c_move(void *win, double x, double y)
Definition: callcpp.cpp:71
render_edgepts
void render_edgepts(void *window, EDGEPT *edgept, C_COL color)
Definition: render.cpp:81
TPOINT::x
int16_t x
Definition: blobs.h:91
Red
Definition: callcpp.h:29
TPOINT::y
int16_t y
Definition: blobs.h:92
c_clear_window
void c_clear_window(void *win)
Definition: callcpp.cpp:96
push
LIST push(LIST list, void *element)
Definition: oldlist.cpp:172
wordrec_display_splits
bool wordrec_display_splits
Definition: split.cpp:39
TBLOB
Definition: blobs.h:282
iterate
#define iterate(l)
Definition: oldlist.h:92
White
Definition: callcpp.h:28
destroy
LIST destroy(LIST list)
Definition: oldlist.cpp:123
c_create_window
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
EDGEPT
Definition: blobs.h:97
c_line_color_index
void c_line_color_index(void *win, C_COL index)
Definition: callcpp.cpp:62
c_draw
void c_draw(void *win, double x, double y)
Definition: callcpp.cpp:80
mark_outline
void mark_outline(EDGEPT *edgept)
Definition: plotedges.cpp:81
display_edgepts
void display_edgepts(LIST outlines)
Definition: plotedges.cpp:42
edge_window
ScrollView * edge_window
Definition: plotedges.cpp:33
EDGEPT::pos
TPOINT pos
Definition: blobs.h:184
c_make_current
void c_make_current(void *win)
Definition: callcpp.cpp:89