AnnGetPoint... example for Delphi
Note: |
This topic is for Document/Medical only. |
//In the AnnDrawn event, this example checks to see if the annotation object is a polygon.
//If it is a polygon, the example gets the number of points that define the object;
//then it gets the arrays of X and Y coordinates and displays the points in a message box.
var
//Global declarations
RasterAnn: LEADRasterAnnotation;
RasterAnnToolbar: LEADRasterAnnToolBar;
procedure TForm1.Button1Click(Sender: TObject);
begin
RasterAnn:= CoLEADRasterAnnotation.Create ();
RasterAnnToolbar:= CoLEADRasterAnnToolBar.Create ();
RasterAnn.AnnParentRasterView := LEADRasterView1.Raster;
LEADEventSink1.Connect (RasterAnn, _LEADRasterAnnotationEvents);
LEADEventSink1
RasterAnn.AnnUserMode:= ANN_USERMODE_DESIGN;
end;
/*In the AnnDrawn event, this example checks to see if the annotation object is a polygon.
If it is a polygon, the example gets the number of points that define the object;
then it gets the arrays of X and Y coordinates and displays the points in a message box.*/
procedure TForm1.LEADEventSink1Invoke(Sender: TObject; DispID: Integer;
const IID: TGUID; LocaleID: Integer; Flags: Word; Params: tagDISPPARAMS;
varResult, ExcepInfo, ArgErr: Pointer);
var
nType: TOleEnum;
a: Integer;
hAnnObject: OleVariant;
RasterVarX: LEADRasterVariant; //array for the X coordinates
RasterVarY: LEADRasterVariant; //array for the Y coordinates
nPoints: Longint; //number of points in the object
msgStr: String;
begin
RasterVarX:= CoLEADRasterVariant.Create ( );
RasterVarY:= CoLEADRasterVariant.Create ( );
case (DispID) of
LEADRASTERANNOTATIONEVENTS_ANNDRAWN:
begin
hAnnObject:= OleVariant(Params.rgvarg^[0]);
RasterAnn.AnnGetType(hAnnObject);
nType:= RasterAnn.AnnType;
if (nType = ANN_OBJECT_POLYGON) then //Is the object a polygon?
begin
RasterVarX:= CoLEADRasterVariant.Create ( );
RasterVarY:= CoLEADRasterVariant.Create ( );
ShowMessage ('Object is a Polygon');
RasterAnn.AnnGetPointCount (hAnnObject); //get the number of points
nPoints:= RasterAnn.AnnPointCount;
RasterAnn.AnnGetPointX(hAnnObject, RasterVarX); //get the X coordinates
RasterAnn. AnnGetPointY (hAnnObject, RasterVarY); //get the Y coordinates
msgStr:= '(';
for a:= 1 to nPoints do
msgStr:= msgStr + '{' + IntToStr(RasterVarX.LongItemValue[a - 1]) + ',' + IntToStr(RasterVarY.LongItemValue[a - 1]) + '}';
msgStr:= msgStr + ')';
ShowMessage ( 'The Polygon`s ' + IntToStr(nPoints) + ' points are:' + Chr(13) + msgStr ) ;
end;
end;
end;
end;