Logo Search packages:      
Sourcecode: inkscape version File versions

int sp_object_compare_position ( SPObject const *  first,
SPObject const *  second 

Compares height of objects in tree.

Works for different-parent objects, so long as they have a common ancestor.

 *    0    positions are equivalent
 *    1    first object's position is greater than the second
 *   -1    first object's position is less than the second   

Definition at line 410 of file sp-object.cpp.

References SPObject::nearestCommonAncestor(), and sp_repr_compare_position().

    if (first == second) return 0;

    SPObject const *ancestor = first->nearestCommonAncestor(second);
    if (ancestor == NULL) return 0; // cannot compare, no common ancestor!

    // we have an object and its ancestor (should not happen when sorting selection)
    if (ancestor == first)
        return 1;
    if (ancestor == second)
        return -1;

    SPObject const *to_first = AncestorSon(first, ancestor);
    SPObject const *to_second = AncestorSon(second, ancestor);

    g_assert(SP_OBJECT_PARENT(to_second) == SP_OBJECT_PARENT(to_first));

    return sp_repr_compare_position(SP_OBJECT_REPR(to_first), SP_OBJECT_REPR(to_second));

Generated by  Doxygen 1.6.0   Back to index