PDA

Click to See Complete Forum and Search --> : vector drawing


Sep 12th, 2000, 10:46 PM
I'm looking for a way (some OCX or API function I guess...) to be able to use vector drawings where I could "call back" objects created, i.e.: once the application draws a circle (for example), I would have some sort of "handle" on it and I could move it, rsize it, delete it, etc... In other words, I'm looking for some sort of a CAD tool.

kedaman
Sep 13th, 2000, 07:02 AM
I think you could make those handles yourself, make an array of UDT's:

TYpe cadhandle
x as single
y as single
obj as object
End type

make a sub to draw these handles, and one that you call from the mousedown/mousemove events on the form/picturebox you draw the objects on. To detect a click on the handle, check if the distance to the handles is short enough:

if sqr((y-handle.y)/(x-handle-x))<10 then...

Sep 13th, 2000, 08:40 AM
Thanks. That works allright for handles. But as far as I know, once I draw a circle or a line in a form/picturebox, there are no functions in VB to modify its shape, other that to redraw the exact same object using the background color. That solution is not an option since it erases whatever is drawn behind it. I know about Shape objects in VB, which would work fine, but they are to limited (only circles, ellipse, rectangles and rounded rectangles). I need polyline, arc of circle, etc... I tought about writing a EMF file and refreshing a Picturebox everytime there is a click on that picture box, but since I don't know much about EMF files...

PaulLewis
Sep 13th, 2000, 09:01 PM
Are all of the objects you plan to draw allowed to be moved/resized etc?

How many such shapes per picturebox are you anticipating. Also, are the shapes going to be transparent or will they be solid (or either)

These answers will help to devise a method that might work for you. I have made a related program that simply draws random polygons but allows the user to store the shape for re-use later.

This could easily be converted into the sort of thing you are talking about EXCEPT my guess is that too many of these shapes on a picturebox would end up being way too slow for you to use.

Regards
Paul Lewis

kedaman
Sep 14th, 2000, 03:12 AM
You have two options, either you go on with the objects or (the one i recommend) you draw these lines and circles directly on the form/picturebox.

Check out line and circle functions, you can draw polygons, with many lines, boxes and filled boxes with line with B and F flag. Arcs with Circle (you specify the angle in radians for start and end, look it up in vb-help).

Now if you modify something you have to clear the whole image, use CLS. To avoid flickering set autoredraw to true, and redraw all lines (arcs) circles (polygons) and then you have it. With A fast computer, it shouldn't be a problem with the performance, i've done something similar myself.

Sep 14th, 2000, 09:00 AM
For Paul:

Yes, "all" of the objects would need to be "selectable", therefore moved, resized, deleted, etc... Although there wouldn't be that many objects on a form (rarely more than 200). I'm greatly interested in your application. If you could send it to me, I would appriciate it (that is if you wish to share it, of course....) amoisan@ige-xao.com


For Kedaman:

Your solution is worth the try. Although I beleive it would be a bit slow since I will have from 100 to 200 objects to redraw. I will use API functions, wich are faster than Line, Circle and Pset functions.

Thank you very much guys!

PaulLewis
Sep 14th, 2000, 05:14 PM
Alain,

The project I will email you was designed to do the job of working out if a point is inside or outside a given closed polygon. The polygon could be pseudo-randomly generated or hand drawn (sorry project has no help file). If hand drawn, you can make interesting shapes like square spirals and so on which are usually quite hard for even a human to tell if a point is inside or outside.

However the polygon is generated, I allow the user to save it to file and reload it later. Nothing fancy here - just simple file formats.

It may contain something useful to you or may not. I am interested in the topic you have raised and will do some investigation. Keep us informed.

Cheers
Paul Lewis