gnome-canvas search item set with bounding box
- From: TANGE Toshio <t-tange ats nis nec co jp>
- To: "gnome-devel-list gnome org" <gnome-devel-list gnome org>
- Subject: gnome-canvas search item set with bounding box
- Date: Wed, 24 Nov 1999 11:43:18 +0900
I need function that select items in canvas widget with bounding box.
like follow this.
/**
* gnome_canvas_get_items_at:
* @canvas: A canvas.
* @x1: X1 position in world coordinates.
* @y1: Y1 position in world coordinates.
* @x2: X2 position in world coordinates.
* @y2: Y2 position in world coordinates.
* @set: found canvas items vector
* @max: size of vector(get maximum items)
*
* Looks for the item sets that is in bounding box, which must be
* specified in world coordinates.
*
* Return value: number of find items ;
**/
gint gnome_canvas_get_items_at(GnomeCanvas *canvas, double x1, double
y1, double x2, double y2,GnomeCanvasItem** set,gint max)
{
int ret;
GnomeCanvasGroup * group;
GList *node;
GnomeCanvasItem* item;
double ix1,ix2,iy1,iy2;
g_return_val_if_fail (canvas != NULL, -1);
g_return_val_if_fail (GNOME_IS_CANVAS (canvas),-1);
group = gnome_canvas_root (canvas);
ret = -1;
--max;
for (node = group->item_list; node; node = node->next){
item = (GnomeCanvasItem*)node->data;
gnome_canvas_item_get_bounds(item,&ix1,&iy1,&ix2,&iy2);
if ((x1 <= ix1)&&(ix1 <= x2)&&(x1 <= ix2)&&(ix2 <= x2)&&
(y1 <= iy1)&&(iy1 <= y2)&&(y1 <= iy2)&&(iy2 <= y2)){
++ret;
set[ret] = item;
if (ret == max) {
break;
}
}
}
++ret;
return ret;
}
--
##########################################
#NEC Informatech Systems
#Advanced Technical Systems 1st
#TANGE Toshio
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]