📄 ocrblock.cpp
字号:
row->bounding_box ().topleft ()); box += row->bounding_box (); } leftside.clear (); icoordelt_it.set_to_list (&leftside); icoordelt_it.add_to_end (new ICOORDELT (box.left (), box.bottom ())); icoordelt_it.add_to_end (new ICOORDELT (box.left (), box.top ())); rightside.clear (); icoordelt_it.set_to_list (&rightside); icoordelt_it.add_to_end (new ICOORDELT (box.right (), box.bottom ())); icoordelt_it.add_to_end (new ICOORDELT (box.right (), box.top ()));}/********************************************************************** * BLOCK::check_pitch * * Check whether the block is fixed or prop, set the flag, and set * the pitch if it is fixed. **********************************************************************/void BLOCK::check_pitch() { // check prop // tprintf("Missing FFT fixed pitch stuff!\n"); pitch = -1;}/********************************************************************** * BLOCK::compress * * Compress and move in a single operation. **********************************************************************/void BLOCK::compress( // squash it up const ICOORD vec // and move ) { box.move (vec); compress();}/********************************************************************** * BLOCK::print * * Print the info on a block **********************************************************************/void BLOCK::print( //print list of sides FILE *, //file to print on BOOL8 dump //print full detail ) { ICOORDELT_IT it = &leftside; //iterator box.print (); tprintf ("Proportional= %s\n", proportional ? "TRUE" : "FALSE"); tprintf ("Kerning= %d\n", kerning); tprintf ("Spacing= %d\n", spacing); tprintf ("Fixed_pitch=%d\n", pitch); tprintf ("Filename= %s\n", filename.string ()); if (dump) { tprintf ("Left side coords are:\n"); for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) tprintf ("(%d,%d) ", it.data ()->x (), it.data ()->y ()); tprintf ("\n"); tprintf ("Right side coords are:\n"); it.set_to_list (&rightside); for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) tprintf ("(%d,%d) ", it.data ()->x (), it.data ()->y ()); tprintf ("\n"); }}/********************************************************************** * BLOCK::plot * * Plot the outline of a block in the given colour. **********************************************************************///void BLOCK::plot( //draw outline//WINDOW window, //window to draw in//inT32 serial, //serial number//COLOUR colour //colour to draw in//)//{// ICOORD startpt; //start of outline// ICOORD endpt; //end of outline// ICOORD prevpt; //previous point// ICOORDELT_IT it= &leftside; //iterator// char number[32]; //block id// line_color_index(window,colour); //set the colour// text_color_index(window,colour);// character_height(window,(float)BLOCK_LABEL_HEIGHT);// text_font_index(window,6);// if (!leftside.empty())// {// startpt= *(it.data()); //bottom left corner//// fprintf(stderr,"Block %d bottom left is (%d,%d)\n",//// serial,startpt.x(),startpt.y());// sprintf(number,"%d",serial);// text2d(window,startpt.x(),startpt.y(),number,0,FALSE);// move2d(window,startpt.x(),startpt.y());// do// {// prevpt= *(it.data()); //previous point// it.forward(); //move to next point// draw2d(window,prevpt.x(),it.data()->y()); //draw round corner// draw2d(window,it.data()->x(),it.data()->y());// }// while (!it.at_last()); //until end of list// endpt= *(it.data()); //end point// move2d(window,startpt.x(),startpt.y()); //other side of boundary// it.set_to_list(&rightside);// prevpt=startpt;// for (it.mark_cycle_pt();!it.cycled_list();it.forward())// {// draw2d(window,prevpt.x(),it.data()->y()); //draw round corner// draw2d(window,it.data()->x(),it.data()->y());// prevpt= *(it.data()); //previous point// }// draw2d(window,endpt.x(),endpt.y()); //close boundary// if (hand_block!=NULL)// hand_block->plot(window,colour,serial);// }//}/********************************************************************** * BLOCK::show * * Show the image corresponding to a block as its set of rectangles. **********************************************************************///void BLOCK::show( //show image block//IMAGE *image, //image to show//WINDOW window //window to show in//)//{// BLOCK_RECT_IT it=this; //rectangle iterator// ICOORD bleft,tright; //corners of rectangle// for (it.start_block();!it.cycled_rects();it.forward())// {// it.bounding_box(bleft,tright); //get rectangle//// fprintf(stderr,"Drawing a block with a bottom left of (%d,%d)\n",//// bleft.x(),bleft.y());// show_sub_image(image,bleft.x(),bleft.y(),// tright.x()-bleft.x(),tright.y()-bleft.y(),// window,bleft.x(),bleft.y()); //show it// }//}/********************************************************************** * BLOCK::operator= * * Assignment - duplicate the block structure, but with an EMPTY row list. **********************************************************************/BLOCK & BLOCK::operator= ( //assignmentconst BLOCK & source //from this) { this->ELIST_LINK::operator= (source); this->PDBLK::operator= (source); proportional = source.proportional; kerning = source.kerning; spacing = source.spacing; filename = source.filename; //STRINGs assign ok if (!rows.empty ()) rows.clear (); // if ( !leftside.empty() ) // leftside.clear(); // if ( !rightside.empty() ) // rightside.clear(); // leftside.deep_copy( &source.leftside ); // rightside.deep_copy( &source.rightside ); // box=source.box; return *this;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -