AnnDefine2 example for Delphi
//This example uses static variables to simulate user input to
//'rotate/resize a rectangle around a point on the bottom center line of the rectangle.
//'Intially the rectangle must not be rotated.
Procedure TForm1.ExampleAnnDefine2 ( hObject: HANNOBJECT );
var
hContainer: L_INT32;
nObjectType: L_INT;
dAngle: L_DOUBLE;
lCallCount: L_INT32;
dRectTop: L_DOUBLE;
dRectLeft: L_DOUBLE;
dRectWidth: L_DOUBLE;
dRectHeight: L_DOUBLE;
dRectRight: L_DOUBLE;
dRectBottom: L_DOUBLE;
dAnchorX: L_DOUBLE;
dAnchorY:L_DOUBLE;
dMoveX: L_DOUBLE;
dMoveY: L_DOUBLE;
dAnnPointX: L_DOUBLE;
dAnnPointY: L_DOUBLE;
begin
nObjectType:= LEADAnn1.AnnGetType(hObject);
lCallCount:=0;
if (nObjectType = ANNOBJECT_RECT ) then
begin
ShowMessage ('This object is not Rect Object');
end;
dAngle:= LEADAnn1.AnnRotateAngle[hObject];
if (dAngle = 0 ) then
begin
ShowMessage ('Object must not be rotated');
end;
lCallCount:= lCallCount + 1;
Case lCallCount of
1:
begin
dRectTop:= LEADAnn1.AnnRectTop[hObject];
dRectLeft:= LEADAnn1.AnnRectLeft[hObject];
dRectWidth:= LEADAnn1.AnnRectWidth[hObject];
dRectHeight:= LEADAnn1.AnnRectHeight[hObject];
dRectRight:= dRectWidth + dRectLeft;
dRectBottom:= dRectHeight + dRectTop;
dAnchorX:= (dRectLeft + dRectRight) / 2;
dAnchorY:= dRectBottom;
dAnnPointX:= (dRectLeft + dRectRight) / 2;
dAnnPointY:= dRectTop;
LEADAnn1.AnnDefine2(hObject, dAnchorX, dAnchorY, ANNDEFINE_SETANCHORPOINT);
LEADAnn1.AnnDefine2(hObject, dAnnPointX, dAnnPointY, ANNDEFINE_BEGINMOVEPOINT);
end;
2:
begin
dRectTop:= LEADAnn1.AnnRectTop[hObject];
dRectLeft:= LEADAnn1.AnnRectLeft[hObject];
dRectWidth:= LEADAnn1.AnnRectWidth[hObject];
dRectHeight:= LEADAnn1.AnnRectHeight[hObject];
dRectRight:= dRectWidth + dRectLeft;
dRectBottom:= dRectHeight + dRectTop;
LEADAnn1.PointsCount:= 1;
LEADAnn1.AnnContainerPointX[1]:= dRectRight;
LEADAnn1.AnnContainerPointY[1]:= dRectTop;
hContainer:= LEADAnn1.AnnContainer;
LEADAnn1.AnnConvert(hContainer, ANNCONVERT_TO_CLIENT);
dMoveX:= LEADAnn1.ClientPointX[0];
dMoveY:= LEADAnn1.ClientPointY[0];
LEADAnn1.AnnDefine2(hObject, dMoveX, dMoveY, ANNDEFINE_END);
lCallCount:= 0;
end;
end;
end;