Logo Search packages:      
Sourcecode: inkscape version File versions

Inkscape::NodePath::Node* sp_nodepath_get_node_by_index ( int  index  ) 

Return node with the given index

Definition at line 4339 of file nodepath.cpp.

References Inkscape::NodePath::SubPath::closed, Inkscape::NodePath::SubPath::first, Inkscape::NodePath::Node::n, Inkscape::NodePath::SubPath::nodes, sp_nodepath_current(), and Inkscape::NodePath::Path::subpaths.

Referenced by sp_nodepath_add_node_near_point(), and sp_nodepath_select_segment_near_point().

{
    Inkscape::NodePath::Node *e = NULL;

    Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
    if (!nodepath) {
        return e;
    }

    //find segment
    for (GList *l = nodepath->subpaths; l ; l=l->next) {

        Inkscape::NodePath::SubPath *sp = (Inkscape::NodePath::SubPath *)l->data;
        int n = g_list_length(sp->nodes);
        if (sp->closed) {
            n++;
        }

        //if the piece belongs to this subpath grab it
        //otherwise move onto the next subpath
        if (index < n) {
            e = sp->first;
            for (int i = 0; i < index; ++i) {
                e = e->n.other;
            }
            break;
        } else {
            if (sp->closed) {
                index -= (n+1);
            } else {
                index -= n;
            }
        }
    }

    return e;
}


Generated by  Doxygen 1.6.0   Back to index