Logo Search packages:      
Sourcecode: inkscape version File versions

void sp_nodepath_selected_nodes_rotate ( Inkscape::NodePath::Path nodepath,
gdouble  angle,
int  which,
bool  screen 
)

Rotate selected nodes.

Definition at line 3779 of file nodepath.cpp.

References SPDesktop::current_zoom(), Inkscape::NodePath::Path::desktop, NR::L2(), Inkscape::NodePath::Node::n, node_rotate_one(), Inkscape::NodePath::Node::p, Inkscape::NodePath::Node::pos, Inkscape::NodePath::Path::selected, sp_node_update_handles(), and sp_nodepath_update_repr_keyed().

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

    if (g_list_length(nodepath->selected) == 1) {
       Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) nodepath->selected->data;
        node_rotate_one (n, angle, which, screen);
    } else {
       // rotate as an object:

        Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data;
        NR::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
        }

        gdouble rot;
        if (screen) {
            gdouble const zoom = nodepath->desktop->current_zoom();
            gdouble const zmove = angle / zoom;
            gdouble const r = NR::L2(box.max() - box.midpoint());
            rot = atan2(zmove, r);
        } else {
            rot = angle;
        }

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

        NR::Matrix t =
            NR::Matrix (NR::translate(-rot_center)) *
            NR::Matrix (NR::rotate(rot)) *
            NR::Matrix (NR::translate(rot_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, angle > 0 ? "nodes:rot:p" : "nodes:rot:n", _("Rotate nodes"));
}


Generated by  Doxygen 1.6.0   Back to index