Tk Source Code

View Ticket
Login
Ticket UUID: 226357
Title: Overlapping with Polygon objects wrong
Type: Bug Version: obsolete: 8.4a3
Submitter: hinteger Created on: 2000-12-19 17:14:12
Subsystem: 05. Canvas Items Assigned To: hobbs
Priority: 7 High Severity:
Status: Closed Last Modified: 2001-07-04 07:39:08
Resolution: Fixed Closed By: hobbs
    Closed on: 2001-07-04 00:39:08
Description:
According to the man page a point inside the polygon should return the polygon id when calling [canvas find overlapping]. Don“t know when this changed, it worked well under 8.0.5, and does not work with 8.4a1 and 8.4a2.
User Comments: hobbs added on 2001-07-04 07:39:08:
Logged In: YES 
user_id=72656

Added to 8.4a3cvs.

dkf added on 2001-06-18 15:48:59:
Logged In: YES 
user_id=79902

(Patch not applied yet, so this bug is *not* fixed.)

(Jeff, this bug probably ought to be assigned to Jan
Nijtmans, but he's not got the right SF role on this project
and I've not the permission to fix this.  Could you...?)

hinteger added on 2001-05-31 13:38:17:
Logged In: YES 
user_id=124720

I can not reproduce the problem with the <Enter>/<Leave>
events. I really can't remember how i did that. So
everything looks fine now exept the "wrong" behavior of
arc/oval. I've posted a question about that on c.l.t. See
http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=bc218777f11f9f2a,1

hinteger added on 2001-05-31 04:24:01:
Logged In: YES 
user_id=124720

Not the case- the manpage says:
Polygon items are different from other items such as
rectangles, ovals and arcs in that interior points are
considered to be ``inside'' a polygon
(e.g. for purposes of the find closest and find overlapping
widget commands) even if it is not filled. For most other
item types, an interior
point is considered to be inside the item only if the item
is filled or if it has neither a fill nor an outline. If you
would like an unfilled polygon
whose interior points are not considered to be inside the
polygon, use a line item instead.

So oval is at least conforming with the manpage. But the
sense of that behavior should really be discussed. It is not
possible to determine if a point is inside of a not filled
oval. I'm gone post a link on c.l.t.

ellson added on 2001-05-31 03:03:23:
Logged In: YES 
user_id=3788

Hang on a minute...

Oval has the same problem, but in that code there is this
comment:
 "If itemPtr is filled, then anywhere in the interior is
considered "inside"; if itemPtr isn't filled, then "inside"
means only the area occupied by the outline."

Basically I don't see this as useful behavior, and it
doesn't agree with the canvas man page, but I'm
now wondering if we can just apply this fix without wider
discussion?

ellson added on 2001-05-31 03:02:47:
Logged In: YES 
user_id=3788

Hang on a minute...

Oval has the same problem, but in that code there is this
comment:
 "If itemPtr is filled, then anywhere in the interior is
considered "inside"; if itemPtr isn't filled, then "inside"
means only the area occupied by the outline."

Basically I don't see this as useful behavior, and it
doesn't agree with the canvas man page, but I'm
now wondering if we can just apply this fix without wider
discussion?

hinteger added on 2001-05-31 02:29:17:
Logged In: YES 
user_id=124720

Confirmed.
The thing with the <Enter>/<Leave> events I cannot reproduce
right now. Maybe my machine is to fast ;-) or I remembered
that one false, that was more than 4 month ago, I'll try
that tommorrow at the customer with the real application (a
canvas with >2000 elements)

ellson added on 2001-05-31 01:39:46:

File Added - 6820: tkCanvPoly.c.patch

Logged In: YES 
user_id=3788

Here's a fix, I think.

I can think of no reason why a test for fill is needed at
line 1488 in tkCanvPoly.c.
.
Anyway, removing the test works for me (see patch)

(How does this fix get into CVS now?)

hinteger added on 2001-05-31 00:38:56:
Logged In: YES 
user_id=124720

Yes, that's true. The error must have been introduced
somewhere after 8.0.5 and before 8.3.2 (I migrated my script
from 8.0.5 to 8.3.2 and discovered the bug)
In addition <Enter> and <Leave> events are _not_ generated,
if you move the mouse over the polygon so fast, so that you
don't hit a vertice.

ellson added on 2001-05-31 00:11:55:
Logged In: YES 
user_id=3788

The problem seems to be specific to -fill ""

e.g. this fails in 8.4a3 from CVS 5/30/01

pack [canvas .c]
.c create poly 30 30 30 90 90 90 90 30 -fill "" -outline black
puts [.c find over 45 45 45 45]
puts [.c find over 0 0 0 0]

hinteger added on 2000-12-21 23:08:25:
I use -fill "" and -outline black for the polygon, i forgot to write that.
When the overlapping rectangle is over a vertice, it works, inside the polygon it does't

in your example .c find over 60 40 60 40 should return 1
I get an empty string

dkf added on 2000-12-20 17:03:00:
It seems to work for me under Solaris:
  $ /tmp/bin/wish8.4 
  % pack [canvas .c];.c create poly 30 30 90 90 30 90 90 30
  1
  % .c find over 40 40 45 45
  1
  % .c find over 40 40 40 40
  1
  % .c find over 0 0 0 0
  % .c find over 30 40 30 40
  % .c find over 40 30 40 30
  1
  % info patch
  8.4a2
Could you supply some more details?

Attachments: