Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

void sp_nodepath_selected_nodes_scale ( Inkscape::NodePath::Path nodepath,
gdouble const   grow,
int const   which 
)

Scale selected nodes.

Definition at line 4396 of file nodepath.cpp.

References Inkscape::NodePath::Path::desktop, SPDesktop::event_context, Inkscape::NodePath::Node::n, node_scale_one(), Inkscape::NodePath::Node::p, Inkscape::NodePath::Node::pos, Inkscape::NodePath::Path::selected, Inkscape::MessageContext::setF(), sp_node_update_handles(), and sp_nodepath_update_repr_keyed().

{
    if (!nodepath || !nodepath->selected) return;

    if (g_list_length(nodepath->selected) == 1) {
        // scale handles of the single selected node
        Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) nodepath->selected->data;
        node_scale_one (n, grow, which);
    } else {
        // scale nodes as an "object":

        Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data;
        Geom::Rect box (n0->pos, n0->pos); // originally includes the first selected node
        for (GList *l = nodepath->selected; l != NULL; l = l->next) {
            Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
            box.expandTo (n->pos); // contain all selected nodes
        }

        if ( Geom::are_near(box.maxExtent(), 0) ) {
            SPEventContext *ec = nodepath->desktop->event_context;
            if (!ec) return;
            Inkscape::MessageContext *mc = get_message_context(ec);
            if (!mc) return;
            mc->setF(Inkscape::WARNING_MESSAGE,
                             _("Cannot scale nodes when all are at the same location."));
            return;
        }
        double scale = (box.maxExtent() + grow)/box.maxExtent();


        Geom::Point scale_center;
        if (Inkscape::NodePath::Path::active_node == NULL)
            scale_center = box.midpoint();
        else
            scale_center = Inkscape::NodePath::Path::active_node->pos;

        Geom::Matrix t =
            Geom::Translate(-scale_center) *
            Geom::Scale(scale, scale) *
            Geom::Translate(scale_center);

        for (GList *l = nodepath->selected; l != NULL; l = l->next) {
            Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
            n->pos *= t;
            n->n.pos *= t;
            n->p.pos *= t;
            sp_node_update_handles(n, false);
        }
    }

    sp_nodepath_update_repr_keyed(nodepath, grow > 0 ? "nodes:scale:p" : "nodes:scale:n", _("Scale nodes"));
}


Generated by  Doxygen 1.6.0   Back to index