selection text_box_rep::find_selection (path lbp, path rbp) { SI x1, y1, x2, y2; metric ex; fn->get_extents (str (0, lbp->item), ex); x1= ex->x2; fn->get_extents (str (0, rbp->item), ex); x2= ex->x2; if (!is_nil (xk) && N(str) != 0) { STACK_NEW_ARRAY (xpos, SI, N(str)+1); fn->get_xpositions (str, xpos, xk->padding); SI d= xk->padding - xk->left; x1= xpos[lbp->item] - d; x2= xpos[rbp->item] - d; if (lbp->item == 0) x1 += d; if (rbp->item == 0) x2 += d; if (lbp->item == N(str)) x1 += xk->right; if (rbp->item == N(str)) x2 += xk->right; STACK_DELETE_ARRAY (xpos); } fn->get_extents (str (lbp->item, rbp->item), ex); y1= ex->y1; y2= ex->y2; return selection (rectangle (x1, y1, x2, y2), find_tree_path (lbp), find_tree_path (rbp)); }
selection box_rep::find_selection (path lbp, path rbp) { if (lbp == rbp) return selection (rectangles (), find_tree_path (lbp), find_tree_path (rbp)); else return selection (rectangle (x1, y1, x2, y2), find_tree_path (path (0)), find_tree_path (path (1))); }
path box_rep::find_tree_path (SI x, SI y, SI delta) { path bp= find_box_path (x, y, delta, false); //cout << "Find " << x << ", " << y << "; " << delta; //cout << " -> " << bp << "\n"; return find_tree_path (bp); }
gr_selections box_rep::graphical_select (SI x, SI y, SI dist) { gr_selections res; if (graphical_distance (x, y) <= dist) { gr_selection gs; gs->type= "box"; gs->dist= graphical_distance (x, y); gs->cp << find_tree_path (x, y, dist); // FIXME: check whether this is correct: I do not remember whether // find_tree_path returns an absolute or a relative path gs->c= curve (); res << gs; } return res; }
gr_selections box_rep::graphical_select (SI x1, SI y1, SI x2, SI y2) { gr_selections res; if (in_rectangle (x1, y1, x2, y2)) { gr_selection gs; gs->type= "box"; gs->dist= graphical_distance (x1, y1); SI dist= (SI)norm (point (x2-x1, y2-y1)); gs->cp << find_tree_path (x1, y1, dist); // FIXME: as above, check whether this is correct or not gs->pts= array<point> (0); gs->c= curve (); res << gs; } return res; }