提交 59d244b0 编写于 作者: T theraysmith@gmail.com

More fixes for GRAPHICS_DISABLED from Zdenko and Ray

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@757 d0cd1f9f-072b-0410-8dd7-cf729c803f20
上级 0ed5c670
......@@ -17,6 +17,11 @@
*
**********************************************************************/
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "mfcpch.h"
#include "blobbox.h"
#include "helpers.h"
......@@ -425,6 +430,13 @@ ScrollView::Color BLOBNBOX::TextlineColor(BlobRegionType region_type,
ScrollView::Color BLOBNBOX::BoxColor() const {
return TextlineColor(region_type_, flow_);
}
void BLOBNBOX::plot(ScrollView* window, // window to draw in
ScrollView::Color blob_colour, // for outer bits
ScrollView::Color child_colour) { // for holes
if (cblob_ptr != NULL)
cblob_ptr->plot(window, blob_colour, child_colour);
}
#endif
/**********************************************************************
* find_cblob_limits
......
......@@ -431,10 +431,7 @@ class BLOBNBOX:public ELIST_LINK
void plot(ScrollView* window, // window to draw in
ScrollView::Color blob_colour, // for outer bits
ScrollView::Color child_colour) { // for holes
if (cblob_ptr != NULL)
cblob_ptr->plot(window, blob_colour, child_colour);
}
ScrollView::Color child_colour); // for holes
#endif
// Initializes the bulk of the members to default values for use at
......
......@@ -26,6 +26,11 @@
/*----------------------------------------------------------------------
I n c l u d e s
----------------------------------------------------------------------*/
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "mfcpch.h"
#include "blobs.h"
#include "ccstruct.h"
......@@ -219,9 +224,9 @@ TBOX TESSLINE::bounding_box() const {
return TBOX(topleft.x, botright.y, botright.x, topleft.y);
}
#ifndef GRAPHICS_DISABLED
void TESSLINE::plot(ScrollView* window, ScrollView::Color color,
ScrollView::Color child_color) {
#ifndef GRAPHICS_DISABLED
if (is_hole)
window->Pen(child_color);
else
......@@ -236,8 +241,8 @@ void TESSLINE::plot(ScrollView* window, ScrollView::Color color,
else
window->DrawTo(pt->pos.x, pt->pos.y);
} while (pt != loop);
#endif // GRAPHICS_DISABLED
}
#endif // GRAPHICS_DISABLED
// Iterate the given list of outlines, converting to TESSLINE by polygonal
// approximation and recursively any children, returning the current tail
......@@ -387,11 +392,13 @@ TBOX TBLOB::bounding_box() const {
return box;
}
#ifndef GRAPHICS_DISABLED
void TBLOB::plot(ScrollView* window, ScrollView::Color color,
ScrollView::Color child_color) {
for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next)
outline->plot(window, color, child_color);
}
#endif // GRAPHICS_DISABLED
// Factory to build a TWERD from a (C_BLOB) WERD, with polygonal
// approximation along the way.
......@@ -511,6 +518,7 @@ void TWERD::MergeBlobs(int start, int end) {
}
}
#ifndef GRAPHICS_DISABLED
void TWERD::plot(ScrollView* window) {
ScrollView::Color color = WERD::NextColor(ScrollView::BLACK);
for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
......@@ -518,6 +526,7 @@ void TWERD::plot(ScrollView* window) {
color = WERD::NextColor(color);
}
}
#endif // GRAPHICS_DISABLED
/**********************************************************************
* blob_origin
......@@ -569,7 +578,7 @@ WIDTH_RECORD *blobs_widths(TBLOB *blobs) { /*blob to compute on */
*
* Return a count of the number of blobs attached to this one.
**********************************************************************/
int count_blobs(TBLOB *blobs) {
int count_blobs(TBLOB *blobs) {
int x = 0;
for (TBLOB* b = blobs; b != NULL; b = b->next)
......
......@@ -154,8 +154,10 @@ struct TESSLINE {
botright.y <= pt.y && pt.y <= topleft.y;
}
#ifndef GRAPHICS_DISABLED
void plot(ScrollView* window, ScrollView::Color color,
ScrollView::Color child_color);
#endif // GRAPHICS_DISABLED
int BBArea() const {
return (botright.x - topleft.x) * (topleft.y - botright.y);
......@@ -210,8 +212,10 @@ struct TBLOB {
TBOX bounding_box() const;
#ifndef GRAPHICS_DISABLED
void plot(ScrollView* window, ScrollView::Color color,
ScrollView::Color child_color);
#endif // GRAPHICS_DISABLED
int BBArea() const {
int total_area = 0;
......
......@@ -158,9 +158,11 @@ class DLLSYM C_OUTLINE:public ELIST_LINK
// being the coords of the upper-left corner of the pix.
void render_outline(int left, int top, Pix* pix) const;
#ifndef GRAPHICS_DISABLED
void plot( //draw one
ScrollView* window, //window to draw in
ScrollView::Color colour) const; //colour to draw it
#endif // GRAPHICS_DISABLED
C_OUTLINE& operator=(const C_OUTLINE& source);
......
......@@ -187,7 +187,6 @@ void ROW::plot( //draw it
word->plot (window, colour); //all in one colour
}
}
#endif
/**********************************************************************
* ROW::plot
......@@ -195,7 +194,6 @@ void ROW::plot( //draw it
* Draw the ROW in rainbow colours.
**********************************************************************/
#ifndef GRAPHICS_DISABLED
void ROW::plot( //draw it
ScrollView* window //window to draw in
) {
......@@ -207,7 +205,7 @@ void ROW::plot( //draw it
word->plot (window); //in rainbow colours
}
}
#endif
#endif // GRAPHICS_DISABLED
/**********************************************************************
* ROW::operator=
......
......@@ -121,20 +121,20 @@ class ROW:public ELIST_LINK
void print( //print
FILE *fp); //file to print on
#ifndef GRAPHICS_DISABLED
void plot( //draw one
ScrollView* window, //window to draw in
ScrollView::Color colour); //uniform colour
void plot( //draw one
ScrollView* window); //in rainbow colours
#ifndef GRAPHICS_DISABLED
void plot_baseline( //draw the baseline
ScrollView* window, //window to draw in
ScrollView::Color colour) { //colour to draw
//draw it
baseline.plot (window, colour);
}
#endif
#endif // GRAPHICS_DISABLED
ROW& operator= (const ROW & source);
private:
......
......@@ -93,6 +93,8 @@ class PDBLK
// Returns a binary Pix mask with a 1 pixel for every pixel within the
// block. Rotates the coordinate system by rerotation prior to rendering.
Pix* render_mask(const FCOORD& rerotation);
#ifndef GRAPHICS_DISABLED
///draw histogram
///@param window window to draw in
///@param serial serial number
......@@ -100,7 +102,7 @@ class PDBLK
void plot(ScrollView* window,
inT32 serial,
ScrollView::Color colour);
#endif // GRAPHICS_DISABLED
///show image
///@param image image to show
///@param window window to show in
......
......@@ -393,7 +393,7 @@ int lessthan(const void *first, const void *second) {
return (0);
}
#ifndef GRAPHICS_DISABLED
/// Returns a color to draw the given type.
ScrollView::Color POLY_BLOCK::ColorForPolyBlockType(PolyBlockType type) {
// Keep kPBColors in sync with PolyBlockType.
......@@ -419,3 +419,4 @@ ScrollView::Color POLY_BLOCK::ColorForPolyBlockType(PolyBlockType type) {
}
return ScrollView::WHITE;
}
#endif // GRAPHICS_DISABLED
......@@ -65,7 +65,9 @@ class DLLSYM POLY_BLOCK {
void plot(ScrollView* window, inT32 num);
#ifndef GRAPHICS_DISABLED
void fill(ScrollView* window, ScrollView::Color colour);
#endif // GRAPHICS_DISABLED
// Returns true if other is inside this.
bool contains(POLY_BLOCK *other);
......@@ -78,10 +80,11 @@ class DLLSYM POLY_BLOCK {
// test_pt outside this.
inT16 winding_number(const ICOORD &test_pt);
#ifndef GRAPHICS_DISABLED
// Static utility functions to handle the PolyBlockType.
// Returns a color to draw the given type.
static ScrollView::Color ColorForPolyBlockType(PolyBlockType type);
#endif // GRAPHICS_DISABLED
private:
ICOORDELT_LIST vertices; // vertices
......
......@@ -17,6 +17,11 @@
*
**********************************************************************/
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "mfcpch.h" //precompiled headers
#include "statistc.h"
#include <string.h>
......@@ -26,11 +31,6 @@
#include "scrollview.h"
#include "tprintf.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
/**********************************************************************
* STATS::STATS
*
......
......@@ -59,10 +59,12 @@ class C_BLOB:public ELIST_LINK
// pixDestroy after use.
Pix* render_outline();
#ifndef GRAPHICS_DISABLED
void plot( //draw one
ScrollView* window, //window to draw in
ScrollView::Color blob_colour, //for outer bits
ScrollView::Color child_colour); //for holes
#endif // GRAPHICS_DISABLED
C_BLOB& operator= (const C_BLOB & source) {
if (!outlines.empty ())
......
......@@ -291,7 +291,6 @@ void WERD::plot(ScrollView *window, ScrollView::Color colour) {
}
plot_rej_blobs(window);
}
#endif // GRAPHICS_DISABLED
// Get the next color in the (looping) rainbow.
ScrollView::Color WERD::NextColor(ScrollView::Color colour) {
......@@ -301,7 +300,6 @@ ScrollView::Color WERD::NextColor(ScrollView::Color colour) {
return next;
}
#ifndef GRAPHICS_DISABLED
/**
* WERD::plot
*
......
......@@ -144,12 +144,10 @@ class WERD : public ELIST2_LINK {
#ifndef GRAPHICS_DISABLED
// plot word on window in a uniform colour
void plot(ScrollView *window, ScrollView::Color colour);
#endif // GRAPHICS_DISABLED
// Get the next color in the (looping) rainbow.
static ScrollView::Color NextColor(ScrollView::Color colour);
#ifndef GRAPHICS_DISABLED
// plot word on window in a rainbow of colours
void plot(ScrollView *window);
......
......@@ -16,6 +16,11 @@
//
///////////////////////////////////////////////////////////////////////
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "classify.h"
#include "fontinfo.h"
#include "intproto.h"
......
......@@ -16,6 +16,12 @@
** See the License for the specific language governing permissions and
** limitations under the License.
******************************************************************************/
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
/*----------------------------------------------------------------------------
Include Files and Type Defines
----------------------------------------------------------------------------*/
......@@ -30,11 +36,6 @@
#include "shapetable.h"
#include <math.h>
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
/*----------------------------------------------------------------------------
Global Data Definitions and Declarations
----------------------------------------------------------------------------*/
......
......@@ -19,6 +19,11 @@
//
///////////////////////////////////////////////////////////////////////
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "mastertrainer.h"
#include <math.h>
#include <time.h>
......
......@@ -13,6 +13,11 @@
//
///////////////////////////////////////////////////////////////////////
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "trainingsample.h"
#include <math.h>
......
......@@ -17,6 +17,11 @@
*
**********************************************************************/
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "mfcpch.h"
#include "errcode.h"
#ifdef __UNIX__
......@@ -32,11 +37,6 @@
#include "host.h"
#include "unichar.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
void
cprintf ( //Trace printf
const char *format, ... //special message
......
......@@ -105,9 +105,11 @@ Pix* CCNonTextDetect::ComputeNonTextMask(bool debug, Pix* photo_map,
pixWrite("junknoisemask.png", pix, IFF_PNG);
}
ScrollView* win = NULL;
#ifndef GRAPHICS_DISABLED
if (debug) {
win = MakeWindow(0, 400, "Photo Mask Blobs");
}
#endif // GRAPHICS_DISABLED
// Large and medium blobs are not text if they overlap with "a lot" of small
// blobs.
MarkAndDeleteNonTextBlobs(&blob_block->large_blobs,
......@@ -136,8 +138,8 @@ Pix* CCNonTextDetect::ComputeNonTextMask(bool debug, Pix* photo_map,
pixWrite("junkccphotomask.png", pix, IFF_PNG);
#ifndef GRAPHICS_DISABLED
delete win->AwaitEvent(SVET_DESTROY);
#endif // GRAPHICS_DISABLED
delete win;
#endif // GRAPHICS_DISABLED
}
return pix;
}
......
......@@ -22,6 +22,11 @@
#pragma warning(disable:4244) // Conversion warnings
#endif
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "colfind.h"
#include "ccnontextdetect.h"
......@@ -37,11 +42,6 @@
#include "params.h"
#include "workingpartset.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
namespace tesseract {
// Minimum width (in pixels) to be considered when making columns.
......
......@@ -660,8 +660,10 @@ class ColPartition : public ELIST2_LINK {
// treated as read-only.
ColPartition* CopyButDontOwnBlobs();
#ifndef GRAPHICS_DISABLED
// Provides a color for BBGrid to draw the rectangle.
ScrollView::Color BoxColor() const;
#endif // GRAPHICS_DISABLED
// Prints debug information on this.
void Print() const;
......
......@@ -17,6 +17,11 @@
//
///////////////////////////////////////////////////////////////////////
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "drawtord.h"
#include "textord.h"
#include "makerow.h"
......
......@@ -36,6 +36,11 @@
#endif
#endif
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#include "classify.h"
#include "cluster.h"
#include "clusttool.h"
......
......@@ -16,6 +16,11 @@
// training data of whole, partial or multiple characters.
// Author: Ray Smith
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#ifndef USE_STD_NAMESPACE
#include "base/commandlineflags.h"
#endif
......
......@@ -34,9 +34,8 @@
#include "config_auto.h"
#endif
#ifndef GRAPHICS_DISABLED
// This class contains the main ScrollView-logic,
// e.g. parsing & sending messages, images etc.
#include "scrollview.h"
#ifdef _MSC_VER
#pragma warning(disable:4786) // Don't give stupid warnings for stl
#pragma warning(disable:4018) // signed/unsigned warnings
......@@ -47,7 +46,6 @@ const int kSvPort = 8461;
const int kMaxMsgSize = 4096;
const int kMaxIntPairSize = 45; // Holds %d,%d, for upto 64 bit.
#include "scrollview.h"
#include "svutil.h"
#include "allheaders.h"
......@@ -82,6 +80,7 @@ SVEvent* SVEvent::copy() {
return any;
}
#ifndef GRAPHICS_DISABLED
/// This is the main loop which handles the ScrollView-logic from the server
/// to the client. It basically loops through messages, parses them to events
/// and distributes it to the waiting handlers.
......@@ -357,8 +356,10 @@ void* ScrollView::StartEventHandler(void* a) {
} while (sv != NULL);
return 0;
}
#endif // GRAPHICS_DISABLED
ScrollView::~ScrollView() {
#ifndef GRAPHICS_DISABLED
svmap_mu->Lock();
if (svmap[window_id_] != NULL) {
svmap_mu->Unlock();
......@@ -381,8 +382,10 @@ ScrollView::~ScrollView() {
delete mutex_;
delete semaphore_;
delete points_;
#endif // GRAPHICS_DISABLED
}
#ifndef GRAPHICS_DISABLED
/// Send a message to the server, attaching the window id.
void ScrollView::SendMsg(const char* format, ...) {
if (!points_->empty)
......
......@@ -154,6 +154,8 @@ class ScrollView {
GREEN_YELLOW // Make sure this one is last.
};
~ScrollView();
#ifndef GRAPHICS_DISABLED
// Create a window. The pixel size of the window may be 0,0, in which case
......@@ -168,8 +170,6 @@ class ScrollView {
ScrollView(const char* name, int x_pos, int y_pos, int x_size, int y_size,
int x_canvas_size, int y_canvas_size, bool y_axis_reversed,
const char* server_name);
~ScrollView();
/*******************************************************************************
* Event handling
* To register as listener, the class has to derive from the SVEventHandler
......
......@@ -11,12 +11,17 @@
// - A LMB click either draws point-to-point, point or text.
// - A LMB dragging either draws a line, a rectangle or ellipse.
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#ifndef GRAPHICS_DISABLED
#include "scrollview.h"
#include "svmnode.h"
#include <stdlib.h>
#include <iostream>
#ifndef GRAPHICS_DISABLED
// The current color values we use, initially white (== ScrollView::WHITE).
int rgb[3] = { 255, 255, 255 };
......
......@@ -22,6 +22,14 @@
** limitations under the License.
*
*********************************************************************************/
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#ifndef GRAPHICS_DISABLED
/*----------------------------------------------------------------------
I n c l u d e s
----------------------------------------------------------------------*/
......@@ -32,13 +40,6 @@
#include "const.h"
#include <math.h>
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#ifndef GRAPHICS_DISABLED
/*----------------------------------------------------------------------
V a r i a b l e s
----------------------------------------------------------------------*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册