// RotateBy void ChannelTransform::RotateBy(double degrees) { if (degrees == 0.0) return; fRotation += degrees; _UpdateMatrix(); }
// SetPivot void ChannelTransform::SetPivot(BPoint pivot) { if (pivot == fPivot) return; fPivot = pivot; _UpdateMatrix(); }
// TranslateBy void ChannelTransform::TranslateBy(BPoint offset) { if (offset.x == 0.0 && offset.y == 0.0) return; fTranslation += offset; _UpdateMatrix(); }
// SetPivot void AdvancedTransform::SetPivot(BPoint pivot) { if (pivot == fPivot) return; fPivot = pivot; _UpdateMatrix(); }
// ScaleBy void ChannelTransform::ScaleBy(double xScale, double yScale) { if (xScale == 1.0 && yScale == 1.0) return; fXScale *= xScale; fYScale *= yScale; _UpdateMatrix(); }
// TranslateBy void AdvancedTransform::TranslateBy(double x, double y) { if (x == 0.0 && y == 0.0) return; fTranslation.x += x; fTranslation.y += y; _UpdateMatrix(); }
// SetTranslationAndScale void ChannelTransform::SetTranslationAndScale(BPoint offset, double xScale, double yScale) { if (fTranslation == offset && fXScale == xScale && fYScale == yScale) return; fTranslation = offset; fXScale = xScale; fYScale = yScale; _UpdateMatrix(); }
// ScaleBy // // converts a scalation in world coordinates into // a combined local scalation and a translation void ChannelTransform::ScaleBy(BPoint origin, double xScale, double yScale) { // TODO: Untested? if (xScale == 1.0 && yScale == 1.0) return; fXScale *= xScale; fYScale *= yScale; // scale fTranslation double xOffset = fTranslation.x - origin.x; double yOffset = fTranslation.y - origin.y; fTranslation.x = origin.x + (xOffset * xScale); fTranslation.y = origin.y + (yOffset * yScale); _UpdateMatrix(); }
/*! Converts a rotation in world coordinates into a combined local rotation and a translation. */ void ChannelTransform::RotateBy(BPoint origin, double degrees) { if (degrees == 0.0) return; origin -= fPivot; fRotation += degrees; // rotate fTranslation double xOffset = fTranslation.x - origin.x; double yOffset = fTranslation.y - origin.y; agg::trans_affine_rotation m(degrees * M_PI / 180.0); m.transform(&xOffset, &yOffset); fTranslation.x = origin.x + xOffset; fTranslation.y = origin.y + yOffset; _UpdateMatrix(); }
// SetTransformation void AdvancedTransform::SetTransformation(BPoint pivot, BPoint translation, double rotation, double xScale, double yScale) { if (fTranslation != translation || fPivot != pivot || fRotation != rotation || fXScale != xScale || fYScale != yScale) { fPivot = pivot; fTranslation = translation; fRotation = rotation; fXScale = xScale; fYScale = yScale; _UpdateMatrix(); } }
// SetTransformation void ChannelTransform::SetTransformation(BPoint pivot, BPoint translation, double rotation, double xScale, double yScale) { //printf("SetTransformation(BPoint(%.1f, %.1f), BPoint(%.1f, %.1f), " //"%.2f, %.2f, %.2f)\n", pivot.x, pivot.y, translation.x, translation.y, //rotation, xScale, yScale); if (fTranslation != translation || fPivot != pivot || fRotation != rotation || fXScale != xScale || fYScale != yScale) { fPivot = pivot; fTranslation = translation; fRotation = rotation; fXScale = xScale; fYScale = yScale; _UpdateMatrix(); } }