Hi Hendrik,
This should be pretty simple once you’ve got the width, length (height?) and rotation angle. Using the ‘Create Ellipse…’ statement you can set the bounding rectangle for which you want the ellipse to fill. Then it is just a case of rotating that object by the given angle.
In pseudocode (none of this is tested, but should give you an idea I hope):
Include "MapBasic.def"
Include "Icons.def"
Declare Sub Main
Declare Sub toolHandlerProc
Declare Sub ValidateDialog
Sub Main
'// use a custom toolbutton to get the x and y coordinates of the click,
'// specify DM_CUSTOM_POINT as the drawmode if you just want a single click
Create ButtonPad "MakeEllipse" As
ToolButton
HelpMsg "Click a start location"
Calling toolHandlerProc
Icon MI_ICON_CROSSHAIR
DrawMode DM_CUSTOM_POINT
Title "Make Ellipse"
Width 1
Show
End Sub
Sub toolHandlerProc
Dim objEllipse as Object
Dim startX, startY, wid, leng, rotAngleDeg as Float
Set Coordsys Window FrontWindow() '// be sure to set your coordinate system before any spatial commands
'// get the click coordinates
startX = CommandInfo(CMD_INFO_X)
startY = CommandInfo(CMD_INFO_Y)
Dialog
'// get your width, length and rotation values here...
'// probably best to add a handler on the ok button
'// to validate input values before proceeding
Control EDITTEXT
Into wid
Control EDITTEXT
Into leng
Control EDITTEXT
Into rotAngleDeg
Control OKBUTTON
Calling ValidateDialog
If Not CommandInfo(CMD_INFO_DLG_OK) then '// dialog not closed with OK button, get out
Exit Sub
End If
'// create your ellipse and store into a variable
Create Ellipse Into Variable objEllipse (startX, startY) (startX + wid, startY + leng)
'// rotate your newly created object
objEllipse = Rotate(objEllipse, rotAngleDeg)
'// now add your object to a map or table or whatever you like...
End Sub
Sub ValidateDialog
'// do some validation on the EDITTEXT entries
'// if validation fails use Dialog Preserve to
'// stop dialog from closing and prompt user
'// to correct invalid entries
End Sub
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups
"MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX. The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. |
Glad to help. Should have also mentioned there is another function you can use to rotate the object which allows you to specify the rotation anchor point:
RotateAtPoint( object, angle, anchor_point_object )
anchor_point_object is a point object around which you want to rotate your object.
Regards,
|
Error! Filename not specified. |
|
Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX. The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. |
--