MCPcopy Create free account
hub / github.com/dalboris/vpaint / continueTransform

Method continueTransform

src/Gui/VectorAnimationComplex/TransformTool.cpp:942–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940}
941
942void TransformTool::continueTransform(double x, double y)
943{
944 // Cache mouse position
945 x_ = x;
946 y_ = y;
947
948 // Return in trivial cases
949 if (hovered() == None || cells_.isEmpty())
950 return;
951
952 // Move pivot
953 if (hovered() == Pivot)
954 {
955 draggingManualPivot_ = true;
956 manualPivot_ = true;
957 xManualPivot_ = xManualPivot0_ + x - x0_;
958 yManualPivot_ = yManualPivot0_ + y - y0_;
959
960 if (isTransformConstrained_())
961 {
962 double xSnap = 0.1 * obb0_.width();
963 if (std::abs(xManualPivot_-obb0_.xMin()) < xSnap) xManualPivot_ = obb0_.xMin();
964 else if (std::abs(xManualPivot_-obb0_.xMid()) < xSnap) xManualPivot_ = obb0_.xMid();
965 else if (std::abs(xManualPivot_-obb0_.xMax()) < xSnap) xManualPivot_ = obb0_.xMax();
966
967 double ySnap = 0.1 * obb0_.height();
968 if (std::abs(yManualPivot_-obb0_.yMin()) < ySnap) yManualPivot_ = obb0_.yMin();
969 else if (std::abs(yManualPivot_-obb0_.yMid()) < ySnap) yManualPivot_ = obb0_.yMid();
970 else if (std::abs(yManualPivot_-obb0_.yMax()) < ySnap) yManualPivot_ = obb0_.yMax();
971 }
972 }
973
974 // Transform selection
975 else
976 {
977 // Get pivot
978 const Vec2 pivotPos = cachedTransformPivotPosition_();
979 const double xPivot = pivotPos[0];
980 const double yPivot = pivotPos[1];
981
982 // Determine affine transformation
983 Eigen::Affine2d xf;
984 if (hovered() == TopLeftScale ||
985 hovered() == TopRightScale ||
986 hovered() == BottomRightScale ||
987 hovered() == BottomLeftScale)
988 {
989 double sx = scaleFactor_(x, x0_, dx_, xPivot);
990 double sy = scaleFactor_(y, y0_, dy_, yPivot);
991 if (isTransformConstrained_())
992 {
993 sx = 0.5*(sx+sy);
994 sy = sx;
995 }
996 xf = Eigen::Scaling(sx, sy);
997 }
998 else if (hovered() == TopScale ||
999 hovered() == BottomScale)

Callers 1

Calls 10

scaleFactor_Function · 0.85
xMidMethod · 0.80
yMidMethod · 0.80
correctEdgesGeometryMethod · 0.80
ScalingFunction · 0.50
isEmptyMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected