From: Jeff Godfrey on
I'm using a canvas as the core display widget for a geometry viewer.
The app supports panning and zooming of the canvas contents. One
supported zoom method allows the User to drag out a rectangle over the
area to be zoomed, which is then scaled to fit within the canvas view.

With large data sets (say, upwards of 25,000 canvas entities), I notice
a delay when dragging the zoom rectangle out over the canvas contents.
The delay makes the whole operation seem "sluggish", as if running
through waist-deep water. The magnitude of the effect is directly
related to the density of canvas items at the current mouse location
(more items = deeper water).

I assume this is related to the scanning that must be going on under to
covers in order to keep the item tagged as "current" up-to-date.

So, my questions:

1. Am I correct regarding the reason for the delay?
2. Do other factors play a large role? If so, what are those factors?

Assuming my guess is correct, it'd be nice to control when the canvas
does the automatic scanning. For instance, during a zoom drag
operation, I don't care about the current item, and I can't really
afford the CPU cycles needed to find it. If I could, I'd turn the
scanning off at the beginning of the zoom operation and turn it back on
at the end.

AFAIK, that's not currently possible, but I wonder if it might be a
worthy feature suggestion? Thoughts?

Any other suggestions to improve the situation with existing
capabilities are appreciated. Heck, if it were possible, I'd think
overlaying a temporary, transparent rectangle on top of the data might
work nicely too (as it'd always be "current"), but again, AFAIK, I can't
do that today.

Thanks,

Jeff
From: Jeff Godfrey on
On 4/30/2010 10:26 AM, Jeff Godfrey wrote:
> The magnitude of the effect is directly
> related to the density of canvas items at the current mouse location
> (more items = deeper water).

Hmmm... After a bit more testing, the above isn't quite accurate. It
seems the effect is more related to amount of canvas geometry found
"within" the rectangle I'm dragging out. As the rectangle surrounds
more geometry, the effect gets worse.

So, now I'm wondering whether the update of the "current" item is even
related, since I can make the effect much worse without ever having any
geometry at the mouse position.

My code is doing nothing but manipulating the coords of the single
rectangle during the drag, so I don't think the problem is at the script
level.

Jeff
From: Alexandre Ferrieux on
On Apr 30, 5:53 pm, Jeff Godfrey <jeff_godf...(a)pobox.com> wrote:
> On 4/30/2010 10:26 AM, Jeff Godfrey wrote:
>
> > The magnitude of the effect is directly
> > related to the density of canvas items at the current mouse location
> > (more items = deeper water).
>
> Hmmm... After a bit more testing, the above isn't quite accurate.  It
> seems the effect is more related to amount of canvas geometry found
> "within" the rectangle I'm dragging out.  As the rectangle surrounds
> more geometry, the effect gets worse.
>
> So, now I'm wondering whether the update of the "current" item is even
> related, since I can make the effect much worse without ever having any
> geometry at the mouse position.
>

Indeed, this most likely is not the 'current' detection that's hitting
you most, but rather the redisplay of the tiny part of the canvas that
is marked dirty after you move the rectangle a bit. This operation
involves detecting all items intersecting the dirty area, which means
a big scan...

As a side note, the BLT graph (regardless of the state of the project)
is admittedly one of the rare things that can display tens of
thousands of dots/lines on a canvas quickly. Individual canvas items
don't scale up.

If BLT is not an option and you can restrict yourself to single pixels
or rectangular dots, then a bitmap/photo image may be the way to go.
You can overlay it with your selection rectangle and it will refresh
in no time.

-Alex
From: Jeff Godfrey on
On 4/30/2010 11:21 AM, Alexandre Ferrieux wrote:
> On Apr 30, 5:53 pm, Jeff Godfrey<jeff_godf...(a)pobox.com> wrote:
>> On 4/30/2010 10:26 AM, Jeff Godfrey wrote:
>>
>>> The magnitude of the effect is directly
>>> related to the density of canvas items at the current mouse location
>>> (more items = deeper water).
>>
>> Hmmm... After a bit more testing, the above isn't quite accurate. It
>> seems the effect is more related to amount of canvas geometry found
>> "within" the rectangle I'm dragging out. As the rectangle surrounds
>> more geometry, the effect gets worse.
>>
>> So, now I'm wondering whether the update of the "current" item is even
>> related, since I can make the effect much worse without ever having any
>> geometry at the mouse position.
>>
>
> If BLT is not an option and you can restrict yourself to single pixels
> or rectangular dots, then a bitmap/photo image may be the way to go.
> You can overlay it with your selection rectangle and it will refresh
> in no time.

Alex,

Thanks for the input (as usual)... ;^)

Currently, I'd have to say that BLT is not an option, but I'm not
following your above suggestion. Do you mind trying again?

Thanks,

Jeff

From: Will Duquette on
On Apr 30, 9:43 am, Jeff Godfrey <jeff_godf...(a)pobox.com> wrote:
> On 4/30/2010 11:21 AM, Alexandre Ferrieux wrote:
>
>
>
>
>
> > On Apr 30, 5:53 pm, Jeff Godfrey<jeff_godf...(a)pobox.com>  wrote:
> >> On 4/30/2010 10:26 AM, Jeff Godfrey wrote:
>
> >>> The magnitude of the effect is directly
> >>> related to the density of canvas items at the current mouse location
> >>> (more items = deeper water).
>
> >> Hmmm... After a bit more testing, the above isn't quite accurate.  It
> >> seems the effect is more related to amount of canvas geometry found
> >> "within" the rectangle I'm dragging out.  As the rectangle surrounds
> >> more geometry, the effect gets worse.
>
> >> So, now I'm wondering whether the update of the "current" item is even
> >> related, since I can make the effect much worse without ever having any
> >> geometry at the mouse position.
>
> > If BLT is not an option and you can restrict yourself to single pixels
> > or rectangular dots, then a bitmap/photo image may be the way to go.
> > You can overlay it with your selection rectangle and it will refresh
> > in no time.
>
> Alex,
>
> Thanks for the input (as usual)...  ;^)
>
> Currently, I'd have to say that BLT is not an option, but I'm not
> following your above suggestion.  Do you mind trying again?
>
> Thanks,
>
> Jeff

Well, you could try this:

1. Using Img, you can capture the visible area of the canvas as a
Tk image.
2. Delete the contents of the canvas. (You're going to redraw it
anyway, once you get the rectangle, right?)
3. Position the Tk image on the visible area of the canvas. Now
there's no geometry to slow things down.
4. When they've selected the rectangle, delete the image, and redraw.

 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9
Prev: Problem Setting Color in ttk combobox
Next: wm geometry