Logo Search packages:      
Sourcecode: inkscape version File versions

NR::Maybe< NR::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 364 of file selection.cpp.

References bounds(), SPItem::getCenter(), and SPItem::isCenterSet().

Referenced by Inkscape::ObjectVerb::perform().

                                         {
    GSList *items = (GSList *) const_cast<Selection *>(this)->itemList();
    NR::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();
        }
    }
    NR::Maybe<NR::Rect> bbox = bounds();
    if (bbox) {
        return bounds()->midpoint();
    } else {
        return NR::Nothing();
    }
}


Generated by  Doxygen 1.6.0   Back to index