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

Geom::Point SnapManager::_transformPoint ( Inkscape::SnapCandidatePoint const &  p,
Transformation const   transformation_type,
Geom::Point const &  transformation,
Geom::Point const &  origin,
Geom::Dim2 const   dim,
bool const   uniform 
) const [private]

Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code.

pThe untransformed position of the point, paired with an identifier of the type of the snap source.
transformation_typeType of transformation to apply.
transformationMathematical description of the transformation; details depend on the type.
originOrigin of the transformation, if applicable.
dimDimension to which the transformation applies, if applicable.
uniformtrue if the transformation should be uniform; only applicable for stretching and scaling.
The position of the point after transformation

Definition at line 1108 of file snap.cpp.

Referenced by _snapTransformed(), constrainedSnapScale(), constrainedSnapSkew(), constrainedSnapStretch(), constrainedSnapTranslation(), freeSnapScale(), and freeSnapTranslation().

    /* Work out the transformed version of this point */
    Geom::Point transformed;
    switch (transformation_type) {
        case TRANSLATION:
            transformed = p.getPoint() + transformation;
        case SCALE:
            transformed = (p.getPoint() - origin) * Geom::Scale(transformation[Geom::X], transformation[Geom::Y]) + origin;
        case STRETCH:
            Geom::Scale s(1, 1);
            if (uniform)
                s[Geom::X] = s[Geom::Y] = transformation[dim];
            else {
                s[dim] = transformation[dim];
                s[1 - dim] = 1;
            transformed = ((p.getPoint() - origin) * s) + origin;
        case SKEW:
            // Apply the skew factor
            transformed[dim] = (p.getPoint())[dim] + transformation[0] * ((p.getPoint())[1 - dim] - origin[1 - dim]);
            // While skewing, mirroring and scaling (by integer multiples) in the opposite direction is also allowed.
            // Apply that scale factor here
            transformed[1-dim] = (p.getPoint() - origin)[1 - dim] * transformation[1] + origin[1 - dim];

    return transformed;

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index