Exemplo n.º 1
0
TO_ROW::TO_ROW (                 //constructor
BLOBNBOX * blob,                 //first blob
float top,                       //corrected top
float bottom,                    //of row
float row_size                   //ideal
) {
  clear();
  y_min = bottom;
  y_max = top;
  initial_y_min = bottom;

  float diff;                    //in size
  BLOBNBOX_IT it = &blobs;       //list of blobs

  it.add_to_end (blob);
  diff = top - bottom - row_size;
  if (diff > 0) {
    y_max -= diff / 2;
    y_min += diff / 2;
  }
                                 //very small object
  else if ((top - bottom) * 3 < row_size) {
    diff = row_size / 3 + bottom - top;
    y_max += diff / 2;
    y_min -= diff / 2;
  }
}
Exemplo n.º 2
0
void TO_ROW::add_blob(                 //constructor
                      BLOBNBOX *blob,  //first blob
                      float top,       //corrected top
                      float bottom,    //of row
                      float row_size   //ideal
                     ) {
  float allowed;                 //allowed expansion
  float available;               //expansion
  BLOBNBOX_IT it = &blobs;       //list of blobs

  it.add_to_end (blob);
  allowed = row_size + y_min - y_max;
  if (allowed > 0) {
    available = top > y_max ? top - y_max : 0;
    if (bottom < y_min)
                                 //total available
        available += y_min - bottom;
    if (available > 0) {
      available += available;    //do it gradually
      if (available < allowed)
        available = allowed;
      if (bottom < y_min)
        y_min -= (y_min - bottom) * allowed / available;
      if (top > y_max)
        y_max += (top - y_max) * allowed / available;
    }
  }
}
Exemplo n.º 3
0
void plot_to_row(                 //draw a row
        TO_ROW *row,     //row to draw
        ScrollView::Color colour,   //colour to draw in
        FCOORD rotation  //rotation for line
) {
    FCOORD plot_pt;                //point to plot
    //blobs
    BLOBNBOX_IT it = row->blob_list();
    float left, right;             //end of row

    if (it.empty()) {
        tprintf("No blobs in row at %g\n", row->parallel_c());
        return;
    }
    left = it.data()->bounding_box().left();
    it.move_to_last();
    right = it.data()->bounding_box().right();
    plot_blob_list(to_win, row->blob_list(), colour, ScrollView::BROWN);
    to_win->Pen(colour);
    plot_pt = FCOORD(left, row->line_m() * left + row->line_c());
    plot_pt.rotate(rotation);
    to_win->SetCursor(plot_pt.x(), plot_pt.y());
    plot_pt = FCOORD(right, row->line_m() * right + row->line_c());
    plot_pt.rotate(rotation);
    to_win->DrawTo(plot_pt.x(), plot_pt.y());
}
Exemplo n.º 4
0
void plot_parallel_row(                 //draw a row
        TO_ROW *row,     //row to draw
        float gradient,  //gradients of lines
        inT32 left,      //edge of block
        ScrollView::Color colour,   //colour to draw in
        FCOORD rotation  //rotation for line
) {
    FCOORD plot_pt;                //point to plot
    //blobs
    BLOBNBOX_IT it = row->blob_list();
    float fleft = (float) left;    //floating version
    float right;                   //end of row

    //      left=it.data()->bounding_box().left();
    it.move_to_last();
    right = it.data()->bounding_box().right();
    plot_blob_list(to_win, row->blob_list(), colour, ScrollView::BROWN);
    to_win->Pen(colour);
    plot_pt = FCOORD(fleft, gradient * left + row->max_y());
    plot_pt.rotate(rotation);
    to_win->SetCursor(plot_pt.x(), plot_pt.y());
    plot_pt = FCOORD(fleft, gradient * left + row->min_y());
    plot_pt.rotate(rotation);
    to_win->DrawTo(plot_pt.x(), plot_pt.y());
    plot_pt = FCOORD(fleft, gradient * left + row->parallel_c());
    plot_pt.rotate(rotation);
    to_win->SetCursor(plot_pt.x(), plot_pt.y());
    plot_pt = FCOORD(right, gradient * right + row->parallel_c());
    plot_pt.rotate(rotation);
    to_win->DrawTo(plot_pt.x(), plot_pt.y());
}
Exemplo n.º 5
0
void plot_blob_list(ScrollView* win,                   // window to draw in
                    BLOBNBOX_LIST *list,               // blob list
                    ScrollView::Color body_colour,     // colour to draw
                    ScrollView::Color child_colour) {  // colour of child
  BLOBNBOX_IT it = list;
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    it.data()->plot(win, body_colour, child_colour);
  }
}
Exemplo n.º 6
0
static void clear_blobnboxes(BLOBNBOX_LIST* boxes) {
  BLOBNBOX_IT it = boxes;
  // A BLOBNBOX generally doesn't own its blobs, so if they do, you
  // have to delete them explicitly.
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    BLOBNBOX* box = it.data();
    delete box->cblob();
  }
}
Exemplo n.º 7
0
void plot_box_list(                      //make gradients win
        ScrollView *win,           //window to draw in
        BLOBNBOX_LIST *list,  //blob list
        ScrollView::Color body_colour    //colour to draw
) {
    BLOBNBOX_IT it = list;         //iterator

    win->Pen(body_colour);
    win->Brush(ScrollView::NONE);
    for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
        it.data()->bounding_box().plot(win);
    }
}
Exemplo n.º 8
0
void TO_ROW::insert_blob(                //constructor
                         BLOBNBOX *blob  //first blob
                        ) {
  BLOBNBOX_IT it = &blobs;       //list of blobs

  if (it.empty ())
    it.add_before_then_move (blob);
  else {
    it.mark_cycle_pt ();
    while (!it.cycled_list ()
      && it.data ()->bounding_box ().left () <=
      blob->bounding_box ().left ())
      it.forward ();
    if (it.cycled_list ())
      it.add_to_end (blob);
    else
      it.add_before_stay_put (blob);
  }
}