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

void SPDesktop::zoom_quick ( bool  enable = true )

Performs a quick zoom into what the user is working on.

Parameters:
enableWhether we're going in or out of quick zoom

Definition at line 883 of file desktop.cpp.

References _quick_zoom_enabled, _quick_zoom_stored_area, Geom::D2< Interval >::area(), Inkscape::Selection::bounds(), get_display_area(), Inkscape::NodePath::Node::n, Inkscape::NodePath::SubPath::nodes, Inkscape::NodePath::Node::p, Inkscape::NodePath::Node::pos, Inkscape::NodePath::Node::selected, Inkscape::NodePath::Path::selected, selection, set_display_area(), Inkscape::Selection::singleItem(), Inkscape::NodePath::Path::subpaths, and zoom_relative().

Referenced by sp_event_context_private_root_handler().

{
    if (enable == _quick_zoom_enabled) {
        return;
    }

    if (enable == true) {
        _quick_zoom_stored_area = get_display_area();
        bool zoomed = false;

        if (!zoomed) {
            SPItem * singleItem = selection->singleItem();
            if (singleItem != NULL && tools_isactive(this, TOOLS_NODES)) {

                Inkscape::NodePath::Path * nodepath = event_context->shape_editor->get_nodepath();
                // printf("I've got a nodepath, crazy\n");

                        if (nodepath) {
                              Geom::Rect nodes;
                              bool firstnode = true;

                              if (nodepath->selected) {
                                    for (GList *spl = nodepath->subpaths; spl != NULL; spl = spl->next) {
                                       Inkscape::NodePath::SubPath *subpath = (Inkscape::NodePath::SubPath *) spl->data;
                                          for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) {
                                             Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data;
                                                if (node->selected) {
                                                      // printf("\tSelected node\n");
                                                      if (firstnode) {
                                                            nodes = Geom::Rect(node->pos, node->pos);
                                                            firstnode = false;
                                                      } else {
                                                            nodes.expandTo(node->pos);
                                                      }

                                                      if (node->p.other != NULL) {
                                                            /* Include previous node pos */
                                                            nodes.expandTo(node->p.other->pos);

                                                            /* Include previous handle */
                                                            if (!sp_node_side_is_line(node, &node->p)) {
                                                                  nodes.expandTo(node->p.pos);
                                                            }
                                                      }

                                                      if (node->n.other != NULL) {
                                                            /* Include previous node pos */
                                                            nodes.expandTo(node->n.other->pos);

                                                            /* Include previous handle */
                                                            if (!sp_node_side_is_line(node, &node->n)) {
                                                                  nodes.expandTo(node->n.pos);
                                                            }
                                                      }
                                                }
                                          }
                                    }

                                    if (!firstnode && nodes.area() * 2.0 < _quick_zoom_stored_area.area()) {
                                          set_display_area(nodes, 10);
                                          zoomed = true;
                                    }
                              }
                        }
            }
        }

        if (!zoomed) {
            Geom::OptRect const d = selection->bounds();
            if (d && d->area() * 2.0 < _quick_zoom_stored_area.area()) {
                set_display_area(*d, 10);
                zoomed = true;
            }
        }

        if (!zoomed) {
            zoom_relative(_quick_zoom_stored_area.midpoint()[Geom::X], _quick_zoom_stored_area.midpoint()[Geom::Y], 2.0);
            zoomed = true;
        }
    } else {
        set_display_area(_quick_zoom_stored_area, 0);
    }

    _quick_zoom_enabled = enable;
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index