ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Draw Line Between Two Points

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
John Posted - Jan 29 2012 : 10:42:25
Hello

Delphi XE, Windows 7 64bit, ImageEn 4.0.2

Utilizing the two procedures, below I can measure the distance between two selected points. Each point represents the center of a bitmap images which is a 6 pixel circle.

The question:
Is there a mechanism to draw via code a line between two selected points similar to how I obtain the distance between two points?

procedure TformXrayMeasure2.MeasureDistanceBetweenTwoPoints;
var
tempCenter_x_Distance_PointA: Integer;
tempCenter_y_Distance_PointA: Integer;

tempCenter_x_Distance_PointB: Integer;
tempCenter_y_Distance_PointB: Integer;

tempCalibratedLength: Extended;
tempLength_x, tempLength_y: double;
tempMeasuredLength: double;
begin
tempCenter_x_Distance_PointA := 0;
tempCenter_y_Distance_PointA := 0;

tempCenter_x_Distance_PointB := 0;
tempCenter_y_Distance_PointB := 0;

if tempCalibrated = True then
begin
if ImageEnVect1.ObjKind[ImageEnVect1.SelObjects[0]] = iekBITMAP then
begin
if tempCenter_x_Distance_PointA = 0 then
begin
GetObjParameters(0);
tempCenter_x_Distance_PointA := tempCenter_X;
tempCenter_y_Distance_PointA := tempCenter_Y;
end;

if ImageEnVect1.ObjKind[ImageEnVect1.SelObjects[1]] = iekBITMAP then
begin
GetObjParameters(1);
tempCenter_x_Distance_PointB := tempCenter_X;
tempCenter_y_Distance_PointB := tempCenter_Y;

{ Because the difference is an absolute measurement, which x and y value is larger than the other
does not have to be determined prior to subtraction.)}
tempLength_x := abs(tempCenter_x_Distance_PointA - tempCenter_x_Distance_PointB);
tempLength_y := abs(tempCenter_y_Distance_PointA - tempCenter_y_Distance_PointB);

tempMeasuredLength := sqrt(tempLength_x * tempLength_x + tempLength_y * tempLength_y);
tempCalibratedLength := RoundDP((tempMeasuredLength/tempPixelsPerMM), 2);
MessageDlg('The total distance between the two selected points = ' + FloatToStr(tempCalibratedLength) + '.',
mtConfirmation, [mbOK], 0 );

with SpeedButtonTwoPoints do
begin
Down := False;
Enabled := False;
end;
end;
end;
end;
end;

procedure TformXrayMeasure2.GetObjParameters(ObjIndex: Integer);
var
tempHeight: Integer;
tempWidth: Integer;
tempLeft_x: Integer;
tempLeft_y: Integer;
begin
with ImageEnVect1 do
begin
tempLeft_x := ObjLeft[ImageEnVect1.SelObjects[ObjIndex]];
tempLeft_y := ObjTop[ImageEnVect1.SelObjects[ObjIndex]];

tempHeight := ObjShapeHeight[ImageEnVect1.SelObjects[ObjIndex]];
tempWidth := ObjShapeWidth[ImageEnVect1.SelObjects[ObjIndex]];
end;

tempCenter_x := tempLeft_x + Round(tempHeight / 2) + Round(tempWidth / 2);
tempCenter_y := tempLeft_y + Round(tempHeight / 2) + Round(tempWidth / 2);
end;

TIA

John
3   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Jan 29 2012 : 13:55:09
quote:
Instead of having the user draw an iekRuler, I need the user to select two existing iekBitmap images and then (utilizing the center coordinates of each of the two selected images) I want to draw VIA CODE an iekRuler between the selected points.


This is the code to draw a ruler from x1,y1 to x2,y2:

ImageEnVect1.AddNewObject(iekRULER, Rect(x1,y1,x2,y2), clBlack);

Of course (x1,y1) and (x2,y2) are the centers of your bitmaps.

Hope this helps.
John Posted - Jan 29 2012 : 13:00:01
Fabrizio

Instead of having the user draw an iekRuler, I need the user to select two existing iekBitmap images and then (utilizing the center coordinates of each of the two selected images) I want to draw VIA CODE an iekRuler between the selected points.

My example was simply to illustrate that I can automatically obtain the coordinates of two selected points and the distance between them. I simply want to go one step further and use the obtained coordinates to draw VIA CODE the iekRULER or iekLine connecting the two points.

TIA

John
fab Posted - Jan 29 2012 : 11:30:30
quote:
Is there a mechanism to draw via code a line between two selected points similar to how I obtain the distance between two points?


Please could you clear the question?
It seems that you need to know the length of a line, but if you already know the starting point and ending point, then you already know its length.
Anyway if you mean to create an object like "miLineLen" the answer is No. The unique placeable object which measures length is the iekRULER.