Re: 'notify' signal handler



On Sun, Nov 21, 2010 at 06:33, Robert Park <rbpark exolucere ca> wrote:
> Hi guys,
>
> I have a question that should hopefully be unrelated to the pygobject
> introspection problem that is still ongoing ;-)
>
> My application provides a crosshair that displays directly at map
> center, and a text label that displays the map center coordinates.
> Obviously, these two items need to be updated frequently to stay
> accurate (if the stage changes it's size due to a user resize event, I
> need to reposition the crosshair, and if the user moves the map view,
> I need to update the coordinates).
>
> Up until now, I have naively been connecting to the 'paint' signal to
> do both of these things, since that seemed like the only way to update
> as frequently as possible, and there were never any problems. However,
> today I learned about the 'notify' signal (which was quite well hidden
> in the documentation), and I thought it would be a good way to reduce
> the number of calls to my signal handlers without letting the display
> go stale.
>
> So, for starters, this worked like a charm:
>
>        self.stage.connect('notify::height', self.position_crosshair)
>        self.stage.connect('notify::width',  self.position_crosshair)
>
> It had exactly the intended result. The crosshair only updates it's
> position when it needs to, and not "constantly all the time always."
>
> The problem I'm having is with my latitude/longitude label. This
> mostly works as expected:
>
>        self.map_view.connect('notify::latitude',  self.display_coords)
>        self.map_view.connect('notify::longitude', self.display_coords)
>
> But the precision is terrible! If I do one long click+drag on the map,
> the signal fires every 100m or so, but it's actually possible to make
> a series of short drags to move a great distance before the signal
> fires. I was able to move almost an entire kilometer before it fired,
> just by moving in very small increments.
>
> Playing with this a bit, I realize that the same problem existed
> before when I was connected to the 'paint' signal handler, I just
> didn't notice it then. The label was updating with a furious
> frequency, but it was just setting the same imprecise value over and
> over until a minimum threshhold of movement was achieved.
>
> What gives? Ideally I'd like my label to be very precise and update
> with precise coordinates after every mouse movement, no matter how
> subtle.
>
> Thanks guys.

Would you mind creating a bug report for this issue (basically copying
this email)? From what I remember, in the ChamplainView code there is
some limitation how often the signal is emitted in respect to the
distance you drag (I guess it was done due to some performance
issues). I also remember that when I was looking at the code it
appeared to me that the signal might not get emitted if you drag the
view too slowly. I need to have a look at that again.

Cheers,

Jiri


>
> --
> http://exolucere.ca
> _______________________________________________
> libchamplain-list mailing list
> libchamplain-list gnome org
> http://mail.gnome.org/mailman/listinfo/libchamplain-list
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]