Logo Search packages:      
Sourcecode: inkscape version File versions

NR::Maybe<NR::Coord> sp_node_selected_common_coord ( Inkscape::NodePath::Path nodepath,
NR::Dim2  axis 

If the coordinates of all selected nodes coincide, return the common coordinate; otherwise return NR::Nothing

Definition at line 1394 of file nodepath.cpp.

References NR::Rect::midpoint(), Inkscape::NodePath::Node::pos, and Inkscape::NodePath::Path::selected.

    NR::Maybe<NR::Coord> no_coord = NR::Nothing();
    g_return_val_if_fail(nodepath->selected, no_coord);

    // determine coordinate of first selected node
    GList *nsel = nodepath->selected;
    Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) nsel->data;
    NR::Coord coord = n->pos[axis];
    bool coincide = true;

    // compare it to the coordinates of all the other selected nodes
    for (GList *l = nsel->next; l != NULL; l = l->next) {
        n = (Inkscape::NodePath::Node *) l->data;
        if (n->pos[axis] != coord) {
            coincide = false;
    if (coincide) {
        return coord;
    } else {
        NR::Rect bbox = sp_node_selected_bbox(nodepath);
        // currently we return the coordinate of the bounding box midpoint because I don't know how
        // to erase the spin button entry field :), but maybe this can be useful behaviour anyway
        return bbox.midpoint()[axis];

Generated by  Doxygen 1.6.0   Back to index