Logo Search packages:      
Sourcecode: inkscape version File versions

boost::optional< Geom::Point > Inkscape::Selection::center (  )  const

Returns the rotation/skew center of the selection.

Extract the position of the center from the first selected object

Definition at line 424 of file selection.cpp.

References bounds(), Inkscape::Util::first(), SPItem::getCenter(), and SPItem::isCenterSet().

Referenced by Inkscape::ObjectVerb::perform(), and sp_selection_rotate_screen().

                                                 {
    GSList *items = (GSList *) const_cast<Selection *>(this)->itemList();
    Geom::Point center;
    if (items) {
        SPItem *first = reinterpret_cast<SPItem*>(g_slist_last(items)->data); // from the first item in selection
        if (first->isCenterSet()) { // only if set explicitly
            return first->getCenter();
        }
    }
    Geom::OptRect bbox = bounds();
    if (bbox) {
        return bounds()->midpoint();
    } else {
        return boost::optional<Geom::Point>();
    }
}


Generated by  Doxygen 1.6.0   Back to index