Are you saying that you do not want the rotation handle to indicate the current angle of the object that was rotated? So that after every rotation operation by RotatingTool the Resizing Adornment is reset to be above the node?
And you also do not want the Selection Adornment to follow along with the rotated object?
Have you set either Part.selectionObjectName or Part.rotateObjectName?
Could you please share with us a screenshot of the current behavior and a sketch of what you want instead? It would be good if you considered a case where the rotation was of some non-multiple of 90 degrees, unless your app will only do rotations that are a multiple of 90 degrees.
right when drawn a shape it appears like this, this has rotation adornment, resize adornment and selection adornment.
I’ve set { rotateObjectName = “SHAPE” }
If you use this class, replacing the standard ToolManager.rotatingTool, you won’t need to override “rotatingTool.doActivate” or “rotatingTool.doDeactivate” any more.
class ResettingRotatingTool extends go.RotatingTool {
constructor() {
super();
this.relativeAngle = 0;
this.initialAngle = 0;
}
// The rotation handle always starts at zero, where zero is above the rotationPoint.
// Its position is always at relativeAngle, relative to the rotationPoint.
updateAdornments(part) {
super.updateAdornments(part);
let adornment = part.findAdornment(this.name);
if (adornment) adornment.angle = this.relativeAngle;
}
computeAdornmentLocation(obj) { // don't call super method, which depends on adornedObject.angle
let p = this.rotationPoint;
if (!p.isReal()) p = this.computeRotationPoint(obj);
// don't use handleAngle but assume it's -90
const q = new go.Point(0, - (obj.naturalBounds.width + obj.naturalBounds.height)/2 - this.handleDistance);
return q.rotate(this.relativeAngle).offset(p.x, p.y);
}
// The angle of the adornedObject shouldn't be set to the relativeAngle,
// but to the initialAngle plus the relativeAngle.
doActivate() {
this.handleAngle = 0; // don't depend on this property
super.doActivate();
this.initialAngle = this.adornedObject.angle;
// hide any selection Adornment
this._savedSelAd = this.adornedObject.part.selectionAdorned;
this.adornedObject.part.selectionAdorned = false;
}
doDeactivate() {
const part = this.adornedObject.part;
// maybe re-show any selection Adornment
part.selectionAdorned = this._savedSelAd;
super.doDeactivate();
this.relativeAngle = 0;
this.updateAdornments(part);
}
computeRotate(newPoint) {
// this doesn't use handleAngle, but assumes it's -90 both here and in computeAdornmentLocation
let a = super.computeRotate(newPoint) + 90;
if (a >= 360) a -= 360; else if (a < 0) a += 360;
this.relativeAngle = a;
a += this.initialAngle; // real angle will be initialAngle + relativeAngle
if (a >= 360) a -= 360; else if (a < 0) a += 360;
return a;
}
} // end of ResettingRotatingTool