Tesseract  3.02
tesseract-ocr/wordrec/plotedges.cpp
Go to the documentation of this file.
00001 /* -*-C-*-
00002  ********************************************************************************
00003  *
00004  * File:        plotedges.c  (Formerly plotedges.c)
00005  * Description:  Graphics routines for "Edges" and "Outlines" windows
00006  * Author:       Mark Seaman, OCR Technology
00007  * Created:      Fri Jul 28 13:14:48 1989
00008  * Modified:     Tue Jul  9 17:22:22 1991 (Mark Seaman) marks@hpgrlt
00009  * Language:     C
00010  * Package:      N/A
00011  * Status:       Experimental (Do Not Distribute)
00012  *
00013  * (c) Copyright 1989, Hewlett-Packard Company.
00014  ** Licensed under the Apache License, Version 2.0 (the "License");
00015  ** you may not use this file except in compliance with the License.
00016  ** You may obtain a copy of the License at
00017  ** http://www.apache.org/licenses/LICENSE-2.0
00018  ** Unless required by applicable law or agreed to in writing, software
00019  ** distributed under the License is distributed on an "AS IS" BASIS,
00020  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00021  ** See the License for the specific language governing permissions and
00022  ** limitations under the License.
00023  *
00024  *********************************************************************************/
00025 #ifdef __UNIX__
00026 #include <assert.h>
00027 #endif
00028 
00029 #include "plotedges.h"
00030 #include "render.h"
00031 #include "split.h"
00032 
00033 // Include automatically generated configuration file if running autoconf.
00034 #ifdef HAVE_CONFIG_H
00035 #include "config_auto.h"
00036 #endif
00037 
00038 #ifndef GRAPHICS_DISABLED
00039 
00040 /*----------------------------------------------------------------------
00041               V a r i a b l e s
00042 ----------------------------------------------------------------------*/
00043 ScrollView *edge_window = NULL;
00044 
00045 /*----------------------------------------------------------------------
00046               F u n c t i o n s
00047 ----------------------------------------------------------------------*/
00048 /**********************************************************************
00049  * display_edgepts
00050  *
00051  * Macro to display edge points in a window.
00052  **********************************************************************/
00053 void display_edgepts(LIST outlines) {
00054   void *window;
00055   /* Set up window */
00056   if (edge_window == NULL) {
00057     edge_window = c_create_window ("Edges", 750, 150,
00058       400, 128, -400.0, 400.0, 0.0, 256.0);
00059   }
00060   else {
00061     c_clear_window(edge_window);
00062   }
00063   /* Render the outlines */
00064   window = edge_window;
00065   /* Reclaim old memory */
00066   iterate(outlines) {
00067     render_edgepts (window, (EDGEPT *) first_node (outlines), White);
00068   }
00069 }
00070 
00071 
00072 /**********************************************************************
00073  * draw_blob_edges
00074  *
00075  * Display the edges of this blob in the edges window.
00076  **********************************************************************/
00077 void draw_blob_edges(TBLOB *blob) {
00078   TESSLINE *ol;
00079   LIST edge_list = NIL_LIST;
00080 
00081   if (wordrec_display_splits) {
00082     for (ol = blob->outlines; ol != NULL; ol = ol->next)
00083       push_on (edge_list, ol->loop);
00084     display_edgepts(edge_list);
00085     destroy(edge_list);
00086   }
00087 }
00088 
00089 
00090 /**********************************************************************
00091  * mark_outline
00092  *
00093  * Make a mark on the edges window at a particular location.
00094  **********************************************************************/
00095 void mark_outline(EDGEPT *edgept) {  /* Start of point list */
00096   void *window = edge_window;
00097   float x = edgept->pos.x;
00098   float y = edgept->pos.y;
00099 
00100   c_line_color_index(window, Red);
00101   c_move(window, x, y);
00102 
00103   x -= 4;
00104   y -= 12;
00105   c_draw(window, x, y);
00106 
00107   x -= 2;
00108   y += 4;
00109   c_draw(window, x, y);
00110 
00111   x -= 4;
00112   y += 2;
00113   c_draw(window, x, y);
00114 
00115   x += 10;
00116   y += 6;
00117   c_draw(window, x, y);
00118 
00119   c_make_current(window);
00120 }
00121 
00122 
00123 /**********************************************************************
00124  * mark_split
00125  *
00126  * Set up the marks list to be displayed in subsequent updates and draw
00127  * the marks in the current window.  The marks are stored in the second
00128  * sublist. The first sublist is left unmodified.
00129  **********************************************************************/
00130 void mark_split(SPLIT *split) {
00131   void *window = edge_window;
00132 
00133   c_line_color_index(window, Green);
00134   c_move (window, (float) split->point1->pos.x, (float) split->point1->pos.y);
00135   c_draw (window, (float) split->point2->pos.x, (float) split->point2->pos.y);
00136   c_make_current(window);
00137 }
00138 
00139 #endif  // GRAPHICS_DISABLED