2007-03-08 04:03:40 +08:00
|
|
|
/* -*-C-*-
|
|
|
|
********************************************************************************
|
|
|
|
*
|
2017-07-03 05:35:47 +08:00
|
|
|
* File: plotedges.cpp (Formerly plotedges.c)
|
2007-03-08 04:03:40 +08:00
|
|
|
* Description: Graphics routines for "Edges" and "Outlines" windows
|
|
|
|
* Author: Mark Seaman, OCR Technology
|
|
|
|
* Created: Fri Jul 28 13:14:48 1989
|
|
|
|
* Modified: Tue Jul 9 17:22:22 1991 (Mark Seaman) marks@hpgrlt
|
|
|
|
* Language: C
|
|
|
|
* Package: N/A
|
|
|
|
* Status: Experimental (Do Not Distribute)
|
|
|
|
*
|
|
|
|
* (c) Copyright 1989, Hewlett-Packard Company.
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*
|
|
|
|
*********************************************************************************/
|
|
|
|
#ifdef __UNIX__
|
|
|
|
#include <assert.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "plotedges.h"
|
|
|
|
#include "render.h"
|
|
|
|
#include "split.h"
|
|
|
|
|
2010-09-30 23:53:40 +08:00
|
|
|
// Include automatically generated configuration file if running autoconf.
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config_auto.h"
|
|
|
|
#endif
|
|
|
|
|
2009-06-04 01:24:08 +08:00
|
|
|
#ifndef GRAPHICS_DISABLED
|
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
V a r i a b l e s
|
|
|
|
----------------------------------------------------------------------*/
|
2016-12-13 00:23:59 +08:00
|
|
|
ScrollView *edge_window = nullptr;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
F u n c t i o n s
|
|
|
|
----------------------------------------------------------------------*/
|
|
|
|
/**********************************************************************
|
|
|
|
* display_edgepts
|
|
|
|
*
|
|
|
|
* Macro to display edge points in a window.
|
|
|
|
**********************************************************************/
|
|
|
|
void display_edgepts(LIST outlines) {
|
|
|
|
void *window;
|
|
|
|
/* Set up window */
|
2016-12-13 00:23:59 +08:00
|
|
|
if (edge_window == nullptr) {
|
2007-03-08 04:03:40 +08:00
|
|
|
edge_window = c_create_window ("Edges", 750, 150,
|
|
|
|
400, 128, -400.0, 400.0, 0.0, 256.0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_clear_window(edge_window);
|
|
|
|
}
|
|
|
|
/* Render the outlines */
|
|
|
|
window = edge_window;
|
|
|
|
/* Reclaim old memory */
|
|
|
|
iterate(outlines) {
|
2007-05-16 09:23:42 +08:00
|
|
|
render_edgepts (window, (EDGEPT *) first_node (outlines), White);
|
2007-03-08 04:03:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* draw_blob_edges
|
|
|
|
*
|
|
|
|
* Display the edges of this blob in the edges window.
|
|
|
|
**********************************************************************/
|
|
|
|
void draw_blob_edges(TBLOB *blob) {
|
|
|
|
TESSLINE *ol;
|
2010-11-24 02:34:14 +08:00
|
|
|
LIST edge_list = NIL_LIST;
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2009-07-11 10:46:01 +08:00
|
|
|
if (wordrec_display_splits) {
|
2016-12-13 00:23:59 +08:00
|
|
|
for (ol = blob->outlines; ol != nullptr; ol = ol->next)
|
2007-03-08 04:03:40 +08:00
|
|
|
push_on (edge_list, ol->loop);
|
|
|
|
display_edgepts(edge_list);
|
|
|
|
destroy(edge_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* mark_outline
|
|
|
|
*
|
|
|
|
* Make a mark on the edges window at a particular location.
|
|
|
|
**********************************************************************/
|
|
|
|
void mark_outline(EDGEPT *edgept) { /* Start of point list */
|
|
|
|
void *window = edge_window;
|
|
|
|
float x = edgept->pos.x;
|
|
|
|
float y = edgept->pos.y;
|
|
|
|
|
|
|
|
c_line_color_index(window, Red);
|
|
|
|
c_move(window, x, y);
|
|
|
|
|
|
|
|
x -= 4;
|
|
|
|
y -= 12;
|
|
|
|
c_draw(window, x, y);
|
|
|
|
|
|
|
|
x -= 2;
|
|
|
|
y += 4;
|
|
|
|
c_draw(window, x, y);
|
|
|
|
|
|
|
|
x -= 4;
|
|
|
|
y += 2;
|
|
|
|
c_draw(window, x, y);
|
|
|
|
|
|
|
|
x += 10;
|
|
|
|
y += 6;
|
|
|
|
c_draw(window, x, y);
|
|
|
|
|
|
|
|
c_make_current(window);
|
|
|
|
}
|
|
|
|
|
2009-06-04 01:24:08 +08:00
|
|
|
#endif // GRAPHICS_DISABLED
|