Logo Search packages:      
Sourcecode: inkscape version File versions

static double sp_canvas_group_point ( SPCanvasItem item,
Geom::Point  p,
SPCanvasItem **  actual_item 
) [static]

Point handler for canvas groups.

Definition at line 813 of file sp-canvas.cpp.

References SPCanvasItem::canvas, SPCanvas::close_enough, SPCanvasGroup::items, sp_canvas_item_invoke_point(), SPCanvasItem::x1, SPCanvasItem::x2, SPCanvasItem::y1, and SPCanvasItem::y2.

Referenced by sp_canvas_group_class_init().

{
    SPCanvasGroup const *group = SP_CANVAS_GROUP (item);
    double const x = p[Geom::X];
    double const y = p[Geom::Y];
    int x1 = (int)(x - item->canvas->close_enough);
    int y1 = (int)(y - item->canvas->close_enough);
    int x2 = (int)(x + item->canvas->close_enough);
    int y2 = (int)(y + item->canvas->close_enough);

    double best = 0.0;
    *actual_item = NULL;

    double dist = 0.0;

    for (GList *list = group->items; list; list = list->next) {
        SPCanvasItem *child = (SPCanvasItem *)list->data;

        if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) {
            SPCanvasItem *point_item = NULL; /* cater for incomplete item implementations */

            int has_point;
            if ((child->flags & SP_CANVAS_ITEM_VISIBLE) && SP_CANVAS_ITEM_GET_CLASS (child)->point) {
                dist = sp_canvas_item_invoke_point (child, p, &point_item);
                has_point = TRUE;
            } else
                has_point = FALSE;

            if (has_point && point_item && ((int) (dist + 0.5) <= item->canvas->close_enough)) {
                best = dist;
                *actual_item = point_item;
            }
        }
    }

    return best;
}


Generated by  Doxygen 1.6.0   Back to index