| 1057 | } |
| 1058 | |
| 1059 | static void |
| 1060 | getTargetRadius(const OfxPointD& scale, |
| 1061 | const OfxPointD& pixelScale, |
| 1062 | OfxPointD* targetRadius) |
| 1063 | { |
| 1064 | targetRadius->x = scale.x * TransformInteract::circleRadiusBase(); |
| 1065 | targetRadius->y = scale.y * TransformInteract::circleRadiusBase(); |
| 1066 | // don't draw too small. 15 pixels is the limit |
| 1067 | if ( ( std::fabs(targetRadius->x) < TransformInteract::circleRadiusMin() ) && ( std::fabs(targetRadius->y) < TransformInteract::circleRadiusMin() ) ) { |
| 1068 | targetRadius->x = targetRadius->x >= 0 ? TransformInteract::circleRadiusMin() : -TransformInteract::circleRadiusMin(); |
| 1069 | targetRadius->y = targetRadius->y >= 0 ? TransformInteract::circleRadiusMin() : -TransformInteract::circleRadiusMin(); |
| 1070 | } else if ( ( std::fabs(targetRadius->x) > TransformInteract::circleRadiusMax() ) && ( std::fabs(targetRadius->y) > TransformInteract::circleRadiusMax() ) ) { |
| 1071 | targetRadius->x = targetRadius->x >= 0 ? TransformInteract::circleRadiusMax() : -TransformInteract::circleRadiusMax(); |
| 1072 | targetRadius->y = targetRadius->y >= 0 ? TransformInteract::circleRadiusMax() : -TransformInteract::circleRadiusMax(); |
| 1073 | } else { |
| 1074 | if ( std::fabs(targetRadius->x) < TransformInteract::circleRadiusMin() ) { |
| 1075 | if ( (targetRadius->x == 0.) && (targetRadius->y != 0.) ) { |
| 1076 | targetRadius->y = targetRadius->y > 0 ? TransformInteract::circleRadiusMax() : -TransformInteract::circleRadiusMax(); |
| 1077 | } else { |
| 1078 | targetRadius->y *= std::fabs(TransformInteract::circleRadiusMin() / targetRadius->x); |
| 1079 | } |
| 1080 | targetRadius->x = targetRadius->x >= 0 ? TransformInteract::circleRadiusMin() : -TransformInteract::circleRadiusMin(); |
| 1081 | } |
| 1082 | if ( std::fabs(targetRadius->x) > TransformInteract::circleRadiusMax() ) { |
| 1083 | targetRadius->y *= std::fabs(TransformInteract::circleRadiusMax() / targetRadius->x); |
| 1084 | targetRadius->x = targetRadius->x > 0 ? TransformInteract::circleRadiusMax() : -TransformInteract::circleRadiusMax(); |
| 1085 | } |
| 1086 | if ( std::fabs(targetRadius->y) < TransformInteract::circleRadiusMin() ) { |
| 1087 | if ( (targetRadius->y == 0.) && (targetRadius->x != 0.) ) { |
| 1088 | targetRadius->x = targetRadius->x > 0 ? TransformInteract::circleRadiusMax() : -TransformInteract::circleRadiusMax(); |
| 1089 | } else { |
| 1090 | targetRadius->x *= std::fabs(TransformInteract::circleRadiusMin() / targetRadius->y); |
| 1091 | } |
| 1092 | targetRadius->y = targetRadius->y >= 0 ? TransformInteract::circleRadiusMin() : -TransformInteract::circleRadiusMin(); |
| 1093 | } |
| 1094 | if ( std::fabs(targetRadius->y) > TransformInteract::circleRadiusMax() ) { |
| 1095 | targetRadius->x *= std::fabs(TransformInteract::circleRadiusMax() / targetRadius->x); |
| 1096 | targetRadius->y = targetRadius->y > 0 ? TransformInteract::circleRadiusMax() : -TransformInteract::circleRadiusMax(); |
| 1097 | } |
| 1098 | } |
| 1099 | // the circle axes are not aligned with the images axes, so we cannot use the x and y scales separately |
| 1100 | double meanPixelScale = (pixelScale.x + pixelScale.y) / 2.; |
| 1101 | targetRadius->x *= meanPixelScale; |
| 1102 | targetRadius->y *= meanPixelScale; |
| 1103 | } |
| 1104 | |
| 1105 | static void |
| 1106 | getTargetPoints(const OfxPointD& targetCenter, |