Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, May 1, 2012 9:54:06 PM(UTC)
Ahmad_Hamdan_iLead

Groups: Registered
Posts: 11


Hello,

I am working on an application were one of the requirements is to show a floating dialog bar above the selected annotation object, i am using The Bounding Rectangle (X & Y) properties to consider them as a starting point but none of them worked correctly as the returned point is far from the top, i used the following code:


Private Sub SetAnnotaionBarStylePosition(ByVal obj As AnnObject)
If obj IsNot Nothing Then
'Dim ScreenAnnPoint As AnnPoint = GetScreenCoordinates(obj)
Dim rec As AnnRectangle = GetObjectRealBoundingRectangle(obj)

Dim ScreenAnnPoint As AnnPoint = GetObjectRealPoints(obj, rec.Location)

Dim boundRectangle As AnnRectangle = obj.BoundingRectangle

barAnnotationStyle.FloatLocation = New Point(boundRectangle.X, boundRectangle.Y)
End If
End Sub


"barAnnotationStyle is a third library control that allows a bar to be floated"

So my question :What is the correct way to get the position of the top left part of an AnnObject?
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, May 2, 2012 5:37:30 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

If you are getting incorrect values when using the obj.BoundingRectangle, you need to use the AnnTransformer class to convert the object's BoundingRectangle to the correct coordinates. Please check the following code:
+-------------------+
Private Function GetObjectRealBoundingRectangle(ByVal obj As AnnObject) As AnnRectangle
' get the un-transformed bounding rectangle
Dim rc As AnnRectangle = obj.BoundingRectangle
'apply the object transformation to this rectangle
Dim t As AnnTransformer = New AnnTransformer(obj.Container.UnitConverter, obj.Transform)
rc = t.RectangleToPhysical(rc)
Return rc
End Function
+-------------------+

If you mean something else, please provide me with more details about the problem.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Wednesday, May 2, 2012 7:51:57 AM(UTC)
Ahmad_Hamdan_iLead

Groups: Registered
Posts: 11


Hi,
Thanks for your reply.

I tried using that code before and still am not getting the result that i want.

I know it by comparing the x and y of the MouseEventArgs with the X and Y of the bounding rectangle

for example when i click on the top left part of the annotation (i.e the gripping part to re size it) i capture both the x and y in MouseClick of RasterImageViewer, let's say in my case it's
X=85, Y=137

when i check the x and y of The AnnRectangle returned by GetObjectRealBoundingRectangle
it will be something like
X=243, Y=391 which is way far than the mouse x and y,

i will rephrase my question to how can i convert the rectangle positions to be in relative to the RasterImageViewer
 
#4 Posted : Wednesday, May 2, 2012 7:57:42 AM(UTC)
Ahmad_Hamdan_iLead

Groups: Registered
Posts: 11


by rectangle positions i meant the top left part of an Annotation Object or it's bounding rectangle.
 
#5 Posted : Wednesday, May 2, 2012 9:26:55 AM(UTC)
Ahmad_Hamdan_iLead

Groups: Registered
Posts: 11


please, ignore my last question.

When i use the GetObjectRealBounds to get a rectangle, The X and Y point of the location property, do they represent the exact X and Y points as screen coordinates regardless of the RasterImageViewer?

if no then how do i get the exact (top, left) coordinates in screen for an annotation object, regardless of the RasterImageViewer?
 
#6 Posted : Wednesday, May 2, 2012 11:04:48 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

The values after the transformation I gave you are for the annotation location in bitmap coordinates.
However, the mouse events give you location values in client coordinates.
If the image is neither scrolled nor zoomed (100% zoom factor), the 2 values should be identical. However, if there's any zooming or scrolling, you can convert between the 2 coordinate systems using Leadtools.Drawing.Transformer class and RasterImageViewer1.Transform as follows:
+--------------------+
' get the un-transformed bounding rectangle
Dim rc As AnnRectangle = automation.CurrentEditObject.BoundingRectangle

'apply the object transformation to this rectangle
Dim t As AnnTransformer = New AnnTransformer(automation.CurrentEditObject.Container.UnitConverter, automation.CurrentEditObject.Transform)

rc = t.RectangleToPhysical(rc)

Dim Trans As Leadtools.Drawing.Transformer = New Leadtools.Drawing.Transformer(RasterImageViewer1.Transform)

'use the following Point
Dim p As PointF = Trans.PointToPhysical(New PointF(rc.X, rc.Y))
+--------------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#7 Posted : Wednesday, May 2, 2012 11:30:54 PM(UTC)
Ahmad_Hamdan_iLead

Groups: Registered
Posts: 11


So if i use this method it will give me the top-left point of the bounding rectangle position relative to The Viewer?
 
#8 Posted : Wednesday, May 2, 2012 11:41:50 PM(UTC)
Ahmad_Hamdan_iLead

Groups: Registered
Posts: 11


thank you very much, after i got the point and used pointToScreen Method on The Viewer i got the right coordinates
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.117 seconds.