BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Polyline Question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Erik Turner
Guest





PostPosted: Fri Jun 25, 2004 2:44 am    Post subject: Polyline Question Reply with quote



I wrote an application to display logic analyzer trace files on the PC a
couple of months ago. At the time, we were all running WinNT4 SP6 and
this application was used extensively by several people with no problems.

Recently, my employer "upgraded" to XP Pro and now the application crashes
during a Polyline call. This is not a normal crash, it is catastrophic. The video
output completely stops (the monitor reports loss of signal). The machine is
unresponsively to anything but holding down the power button for 5+ seconds.

The problem seems to be triggered by the sequence of polyline calls which
can have up to 65300 points (TPoint). This works fine under Windows 2000
and Windows NT4. However, under XP, bad things happen.

There doesn't seem to be a stated limit for Polyline under WinNT,2K,XP but
I'm thinking that maybe there is one. Does anyone have any experience with
this problem? I can make the max size smaller and do more of them but what
is the real limit?

I'm using Delphi 5 SP1, my dataset consists of about 2000000 points drawn
12 times (the number of transitions is less). I'm using a TPaintBox to draw
the logic trace.

Thanks in advance,
Erik Turner


Back to top
William
Guest





PostPosted: Fri Jun 25, 2004 2:53 am    Post subject: Re: Polyline Question Reply with quote



Erik Turner wrote:

Quote:
I'm using Delphi 5 SP1, my dataset consists of about 2000000 points
drawn 12 times (the number of transitions is less). I'm using a
TPaintBox to draw the logic trace.

Are you not making any effort to *not* draw redundant lines? If you
have so many data points, then there must certainly be lines drawn over
top of one another. Besides wasting time, these also consume storage
for points that deliver no value on screen, as you are unable to
differentiate lines when they share the same pixel addresses.

It seems unlikely that you would be consuming excessive memory, but how
are you accessing the collection of points? Surely they are contained
in something?

Just some thoughts, as I try to imagine what must be happening in the
app...

Bill

Back to top
Erik Turner
Guest





PostPosted: Fri Jun 25, 2004 10:39 am    Post subject: Re: Polyline Question Reply with quote



Good question.

I originally thought that it would be faster to collapse the zero-length
line segments so I spent some time optimizing this. However, when I
measured the elapsed time of the "optimized" method, it took longer.
So I went back to the simpler "unoptimized" method.

I've included the core drawing routine at the end of this email.
Basically, I add two new points every time the sample changes from
high to low or low to high. When I get to 65300 points (determined
empirically under Windows 2000/NT), I issue a PolyLine call and
reset the point vector. After the loop is finished, I issue a PolyLine
call to draw the remaining points.

When I was testing this under Windows 2000/NT, even failures didn't
crash the machine; they just failed to draw the requested PolyLine.

Erik Turner

************* DRAWING CODE ***********************

PointIdx := 0;
PointVec[PointIdx].X := StartSamplePixel + SamplePixel;
if SampleValue = 0
then PointVec[PointIdx].Y := SignalLowY
else PointVec[PointIdx].Y := SignalHighY;
Inc(PointIdx);
for SampleIdx := StartSampleIdx+1 to FDispRightSampleIdx do
begin
PrevSampleValue := SampleValue;
PrevSampleTime := SampleTime;
SampleValue := FLogicData.SampleSignal[SampleIdx,SignalIdx];
SampleTime := PrevSampleTime + FLogicData.SampleDeltaPsec;
SamplePixel := Round((SampleTime - StartSampleTime) / FDispPsecPerPixel);
PointVec[PointIdx].X := StartSamplePixel + SamplePixel;
if PrevSampleValue <> SampleValue then
begin
if PointIdx > 65300 then
begin
Windows.PolyLine(Canvas.Handle,PointVec,PointIdx-1);
PointVec[0] := PointVec[PointIdx-1];
PointVec[1] := PointVec[PointIdx];
PointIdx := 1;
end;
Inc(PointIdx);
PointVec[PointIdx].X := StartSamplePixel + SamplePixel;
if SampleValue = 0
then PointVec[PointIdx].Y := SignalLowY
else PointVec[PointIdx].Y := SignalHighY;
Inc(PointIdx);
PointVec[PointIdx] := PointVec[PointIdx-1];
end;
end;
Windows.PolyLine(Canvas.Handle,PointVec,PointIdx+1);


"William" <bill_meyer (AT) earthlink (DOT) net> wrote

Quote:
Erik Turner wrote:

I'm using Delphi 5 SP1, my dataset consists of about 2000000 points
drawn 12 times (the number of transitions is less). I'm using a
TPaintBox to draw the logic trace.

Are you not making any effort to *not* draw redundant lines? If you
have so many data points, then there must certainly be lines drawn over
top of one another. Besides wasting time, these also consume storage
for points that deliver no value on screen, as you are unable to
differentiate lines when they share the same pixel addresses.

It seems unlikely that you would be consuming excessive memory, but how
are you accessing the collection of points? Surely they are contained
in something?

Just some thoughts, as I try to imagine what must be happening in the
app...

Bill



Back to top
David J Taylor
Guest





PostPosted: Fri Jun 25, 2004 2:53 pm    Post subject: Re: Polyline Question Reply with quote

"Erik Turner" <erik (AT) spamless (DOT) turner.org> wrote

[]
Quote:
I've included the core drawing routine at the end of this email.
Basically, I add two new points every time the sample changes from
high to low or low to high. When I get to 65300 points (determined
empirically under Windows 2000/NT), I issue a PolyLine call and
reset the point vector. After the loop is finished, I issue a PolyLine
call to draw the remaining points.

Erik,

Under Windows 98, the maximum number of points in a single polyline call
is 16K. Yes, I know you are using NT/2000/XP, but perhaps trying the
smaller number of points may help?

Cheers,
David



Back to top
quick
Guest





PostPosted: Fri Jun 25, 2004 3:13 pm    Post subject: Re: Polyline Question Reply with quote

Erik Turner wrote:

Quote:
Recently, my employer "upgraded" to XP Pro and now the application crashes


Try updating the video drivers. I've had problems with bad video drivers

causing problems that
cound olny be reproduced on computers with the same drivers.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.