Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!cica!iuvax!maytag!aries5!jb From: jb@aries5.uucp (James Bruyn) Newsgroups: comp.sys.mac.programmer Subject: Re: Line selection algorithims.. Message-ID: <1043@maytag.waterloo.edu> Date: 18 Dec 89 01:50:00 GMT References: <8912160053.AA00720@cadman.nyu.edu> <981@biar.UUCP> Sender: daemon@maytag.waterloo.edu Reply-To: jb@aries5.UUCP (James Bruyn) Organization: Computer Systems Group, University of Waterloo Lines: 30 In article <981@biar.UUCP> trebor@biar.UUCP (Robert J Woodhead) writes: >deragon@CADMAN.NYU.EDU (John Deragon) writes: > >> I was wondering how the current applications like >>MacDraw, MacDraft...etc etc do the line selection. For example in >>MacDraw you click on the line and it becomes selected? How does it >>do this? What is it testing on mouseDown? > >I don't know how THEY do it, but at first thought, the way I would do >it is as follows: > >1) Note that every object has an associated rectangle that contains >it. > That was my immediate thought to - gee how simple. But then I realized that a line could be on a diagonal, and the enclosing rectangle would then be quite large. So I think a more reasonable way would be to define a region around the line with some room for slop. i.e. assuming the line goes from lower left to upper right. (left.h-3,left.v-3;, right.h+3, right.h-3; right.h+3, right.v+3; left.h+3, left.v+3; left.h+3, left.v-3) and then checking whether the mouse in local coordinates is within the region. Jim Bruyn Computer Systems Group University of Waterloo.