Jump to content

2D shape handling functions


martin
 Share

Recommended Posts

Some functions for dealing with 2D shapes which are made up of straight lines and arcs.

I have used them in the routing path designer in post 2.

The functions rely on the shape being contained in an array as shown in the include file.

I am indebted to Malkey (whose ideas on points in shapes I have used, copied or robbed)

Some of the functions

_Shape_LoadFromFile

_Shape_SaveToFile

_Shape_CreateRegPoly

_Shape_Draw - draws the shape

_Shape_CreateParallelCopy - makes a parallel smaller or larger copy. Useful for the path of a routing tool.

_Shape_IsPointInside

_Shape_ReverseDirection

_Shape_SetPath - intended for internal use sets all lines so that each continues from the previous so the shape can be draw or cut in one contiuous movement.

_Shape_SortClockWise - sorts direction of lines cw or ccw;

_Shape_GetExtents - gets the minimum bounding rectangle

_Shape_DistToStLine

_Shape_DistToArc

_Shape_GetNearestPt - find nearest point on the shape to a point

_Shape_Rotate

_Shape_Shift

_Shape_MirrorVert

_Shape_MirrorHor

_Shape_MakeCornerSharp - removes a chamfer or radius between two straight lines

_Shape_MakeRadiusCorner - only between 2 straight lines at moment

_Shape_RemoveLine - internal use unless you know what you're doing

_Shape_ChamferCorner - only between 2 straight lines

_Shape_SplitStLine

_Shape_StLineLength

_Shape_InsertStLine

_Shape_MoveStStJuncABs

_Shape_MergeStSt - removes a junction

_Shape_Arc2StLine

_Shape_StLineToArc

_Shape_StLineToVee

_Shape_GetStLineAngle

_Shape_changeStLineAngle

; plus other minor supporting functions

Here is the UDF

LineArcShapes.au3

The example CAD program in post 2 shows how the functions could be used.

UDF and example in post 2 are no longer being updated.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

A screen shot of a simple CAD program using the udf.

The program is here

[link]http://www.mosaiccgl.co.uk/AutoItDownloads/confirm.php?get=LinearC.zip[/link]

The program is designed so that exact dimensions have to be given because the resulting shape is to be used to make something which must be the correct size, so for the moment rubber band type adjustments are not allowed. In any case, the program is just to establish the concept and is not presented as anything like a finished 'product'. Apart from that I know that AutoIt is not the best choice for an application like this.

There are a lot of features to be added but if anyone plays with it then I woul be pleased to know of any problems or suggestions.(But don't suggest rubber banding or the tell me that some menu items don't do anything because I know.)

If you create a shape which the tool can't get round, maybe because of a narrow section it doesn't fit through, then the tool will stop at the point of the problem. If the tool speed is high then it will tend to overshoot so slowing it down as it approaches the problem will allow it to stop more accurately.

Sharp corners won't be sharp if the tool can't touch the corner of course, but this isn't treated as a problem provided the tool is at least able to touch the sides which make the corner.

EDit 22nd May again. versions 1.23 then 1.24 to fix an error in _AngleBetweenStLines.

Edit: 22nd May 2011. version is 1.22

Removed a memory leak which has hopefully cured a tendency to slow everything down.

Fixed missing Undo and Redo icons.

Edit: 21 st May 2011 corrected download so that the icons now show so that the program can actually do something!

post-3602-0-98231700-1304292696_thumb.pn

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

It's pretty nice, like a primitive CAD. This should be improved and can be very useful. :)

Thanks Andreik. I am making the functions for my router (which I haven't designed yet although I've ordered the spindle) but I hope they could be useful for other things. If you want to have hotspot areas in a picture for example then I think these functions can do the job, like the pie chart example or if you want to create a special window shape then they could be used for generating the outiline for a window region.

When I've developed the shape functions a bit more I intend to make a primitive cad - AutoCadIt or something, and that's what the second post is reserved for. The first one is the shape functions and the second post is for a cad system which uses the shape udf but will probably have another udf as well. But I am just groping my way along and I don't know what will happen next.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Nice example. I think it's an interesting project. Just one thing about the example: when I minimize the example window, and then maximize it again, the area under the graphic appears transparent. I can see part of my desktop behind the area near the buttons. I wonder why that is happening.

Edited by czardas
Link to comment
Share on other sites

Nice example. I think it's an interesting project. Just one thing about the example: when I minimize the example window, and then maximize it again, the area under the graphic appears transparent. I can see part of my desktop behind the area near the buttons. I wonder why that is happening.

Yes the technique didn't work so well. If I use a child window for the drawing and just paint that it fixes that problem. But I've used another of Malkeys ideas in the latest example I just posted in the first post because it lets me move a child window over the drawing without lots of flickering.

But I must stop changing the examples because they are realy just me playing and are very badly written. I'll make a decent example and post that, probably next week.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 4 weeks later...

The UDF has been updated with bug fixes and some extra functions.

A sample program is shown in post #2 with a link in case anyone wants to try it.

Edit:8th May 2011, udf in post 1 updated, program linked in post 2 updated.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 3 weeks later...

Corrected CAD example exe linked to in post 2 because I hadn't realized there were no icons shown in the downloaded version and that made it totally useless.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I just tested your LinerC basic CAD program. I like it, it's pretty good but work a little slow on my work computer, I will try it later on my computer. I'm impressed, first time when I saw this UDF there was just few functions but now you proved this can be use for basic CAD programs and still can be improved. Thanks a lot for share and good job martin. :unsure:

When the words fail... music speaks.

Link to comment
Share on other sites

I just tested your LinerC basic CAD program. I like it, it's pretty good but work a little slow on my work computer, I will try it later on my computer. I'm impressed, first time when I saw this UDF there was just few functions but now you proved this can be use for basic CAD programs and still can be improved. Thanks a lot for share and good job martin. :unsure:

Thanks Andreik. It works at a reasonable speed for me, but even so, I am coverting it to a compiled language now that I have convinced myself that the basic idea works.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yea for me too now on this computer but seems I have some troubles on x64. It doesn't appear there left panel with icons and if I try to maximize "Show Extents" checkbox overlaps with the drawing surface. But I didn't encounter this issues on x86, therefore assume that these problems are only on x64. Am I right?

When the words fail... music speaks.

Link to comment
Share on other sites

Yea for me too now on this computer but seems I have some troubles on x64. It doesn't appear there left panel with icons and if I try to maximize "Show Extents" checkbox overlaps with the drawing surface. But I didn't encounter this issues on x86, therefore assume that these problems are only on x64. Am I right?

I'm afraid I have no idea why the gui should not be created correctly on x64. I only have a 32 bit OS.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@Andreik,

you're right it does get slow. I've fixed a memory leak and it's much better now. A new version, V1.22, in the download link in post 2.

I don't think that was anything to do with the x664 problem though.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yea, now it's much better and work on x64 too. I got an error just when path test was running and I pressed fit to window.

Ok, thanks Andreik. I should disable some things when the test path is running. Maybe next weekend.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Will be the source of LinearC released?

Probably not, just the udf. But I'll answer particular questions about the methods used.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yes.

I draw on a bitmap then assign the bitmap to a Pic, so what you are seeing is a pic.There is a child window with scroll bars. In that child window there is another child window which is completely filled with a pic which is the 'drawing surface'. I used a pic because I could not get a bitmap to refresh correctly; If I drag a window across a bitmap then there are nearly always gaps which don't get filled in by an ON_PAINT handler. The tool and the little point icons are actually 2 more child windows, so rather than keep drawing them I just move them around. Without using a pic it was a mess.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...