tree edit_graphics_rep::graphical_select (double x, double y) { frame f= find_frame (); if (is_nil (f)) return tuple (); gr_selections sels; point p0 = point (x, y); point p = f (p0); sels= eb->graphical_select ((SI)p[0], (SI)p[1], 10*get_pixel_size ()); gs= sels; pts= array<point> (0); ci= array<point> (0); cgi= array<point> (0); gr0= empty_grid (); grid g= find_grid (); frame f2= find_frame (true); if (!is_nil (g) && !is_nil (f2)) { gr0= g; p = f2 (point (x, y)); int i, j, n= N(sels); for (i=0; i<n; i++) { array<point> pts2= sels[i]->pts; if (N(pts2)>0 && norm (pts2[0] - p) <= 10*get_pixel_size ()) pts= pts << pts2[0]; if (N(pts2)>1 && norm (pts2[1] - p) <= 10*get_pixel_size ()) pts= pts << pts2[1]; } double eps= get_pixel_size () / 10.0; for (i=0; i<n; i++) { for (j=0; j<n; j++) if (i<j) { curve c1= sels[i]->c; curve c2= sels[j]->c; if (!is_nil (c1) && !is_nil (c2)) ci= ci << intersection (c1, c2, p, eps); } } array<grid_curve> gc= g->get_curves_around (p0, 10*get_pixel_size (), f); //FIXME: Too slow for (i=0; i<N(gc); i++) { curve c= f2 (gc[i]->c); for (j=0; j<n; j++) if (!is_nil (sels[j]->c)) cgi= cgi << intersection (c, sels[j]->c, p, eps); } } return as_tree (sels); }
int main (int argc, char *argv[]) { gtk_init (NULL, NULL); if (g_getenv ("RTL")) gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); simple_grid (); text_grid (); box_comparison (); empty_line (); scrolling (); insert (); empty_grid (); gtk_main (); return 0; }
tree edit_graphics_rep::graphical_select (double x, double y) { frame f= find_frame (); if (is_nil (f)) return tuple (); gr_selections pre_sels, sels; point p0 = point (x, y); point p = f (p0); pre_sels= eb->graphical_select ((SI)p[0], (SI)p[1], snap_distance); for (int i=0; i<N(pre_sels); i++) if (admissible_selection (pre_sels[i])) sels << pre_sels[i]; //for (int i=0; i<N(sels); i++) // cout << i << ":\t" << sels[i] << "\n"; gs= sels; gr0= empty_grid (); grid g= find_grid (); frame f2= find_frame (true); if (!is_nil (g) && !is_nil (f2)) { gr0= g; p_x= x; p_y= y; } return as_tree (sels); }