Results 1 to 7 of 7

Thread: vector drawing

  1. #1
    Guest

    Question

    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.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I think you could make those handles yourself, make an array of UDT's:
    Code:
    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:
    Code:
    if sqr((y-handle.y)/(x-handle-x))<10 then...
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest

    good for handles, but how do I modify the objects?

    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...

  4. #4
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    More info

    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

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Guest

    here is the info

    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....) [email protected]


    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!


  7. #7
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    PolyBounds project

    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
    Paul Lewis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width