Connecting Tech Pros Worldwide Forums | Help | Site Map

How to speed up a program that uses mouse points a lot?

raylopez99
Guest
 
Posts: n/a
#1: Nov 20 '08
I'm wondering, since my program uses a lot of mouse points when the
mouse is moving, but for resolution purposes doesn't really need to
collect so many mouse points, is it conventional to use a timer so
that mouse points are only collected every 100 or 500 ms--i.e. when
the timer fires-- rather than every 10ms (or whatever the default is
when the mouse is moving)?

It seems my program is bogging down with so many mouse points being
collected (though truth is, I have slow hardware).

Any thoughts appreciated.

RL

Family Tree Mike
Guest
 
Posts: n/a
#2: Nov 21 '08

re: How to speed up a program that uses mouse points a lot?


"raylopez99" <raylopez99@yahoo.comwrote in message
news:e86ad532-8d00-4117-919e-57964e57f3e5@v42g2000yqv.googlegroups.com...
Quote:
I'm wondering, since my program uses a lot of mouse points when the
mouse is moving, but for resolution purposes doesn't really need to
collect so many mouse points, is it conventional to use a timer so
that mouse points are only collected every 100 or 500 ms--i.e. when
the timer fires-- rather than every 10ms (or whatever the default is
when the mouse is moving)?
>
It seems my program is bogging down with so many mouse points being
collected (though truth is, I have slow hardware).
>
Any thoughts appreciated.
>
RL

Are you doing somthing allong these lines and finding it slow?

List<PointPoints = new List<Point>();
void Form1_MouseMove(object sender, MouseEventArgs e)
{
Points.Add(e.Location);
}


Family Tree Mike
Guest
 
Posts: n/a
#3: Nov 21 '08

re: How to speed up a program that uses mouse points a lot?


"RayLopez99" <raylopez88@gmail.comwrote in message
news:13a18f9f-d0e7-45b9-bf67-bafa40e72e0c@w22g2000yqd.googlegroups.com...
Quote:
Thanks FTM.
well this confirmed that standard practice for most conventional apps
is not to put a timer to limit the number of points collected by the
mouse. So it must be the extra logic I'm doing (which is
considerable). The lag is not too bad now, but if it gets worse I
might limit the number of points collected with a timer.
>
RL

If the time lag gets too bad, I don't think I would resort to a timer. I
would fall back to the logic used in geographic information systems (GIS)
for thinning complex line segments. One option would be to keep ever N-th
point. Another option is to keep points "significantly different" from the
last point. That would entail looking at the deltas between the last kept
X, Y to the new X, Y. The first option is more likely quicker, while the
second is likely more visually accurate.

Mike

RayLopez99
Guest
 
Posts: n/a
#4: Nov 21 '08

re: How to speed up a program that uses mouse points a lot?


On Nov 21, 1:35*pm, "Family Tree Mike"
<FamilyTreeM...@ThisOldHouse.comwrote:
Quote:
"RayLopez99" <raylope...@gmail.comwrote in message
>
news:13a18f9f-d0e7-45b9-bf67-bafa40e72e0c@w22g2000yqd.googlegroups.com...
>
Quote:
Thanks FTM.
well this confirmed that standard practice for most conventional apps
is not to put a timer to limit the number of points collected by the
mouse. So it must be the extra logic I'm doing (which is
considerable). *The lag is not too bad now, but if it gets worse I
might limit the number of points collected with a timer.
>
Quote:
RL
>
If the time lag gets too bad, I don't think I would resort to a timer. *I
would fall back to the logic used in geographic information systems (GIS)
for thinning complex line segments. *One option would be to keep ever N-th
point. *Another option is to keep points "significantly different" fromthe
last point. *That would entail looking at the deltas between the last kept
X, Y to the new X, Y. *The first option is more likely quicker, while the
second is likely more visually accurate.
>
Mike
Yeah thanks. I like that first option, just do a modulus %N operation
and take every Nth point. I'll keep that in mind. The delta's idea
is good too.

RL
Closed Thread