DrawAllPoints
Posted: Thu Sep 28, 2006 8:37 am
Hi,
the DrawAllPoints property leads to a slow reaction if true and a high number of points. But if DrawAllPoints is switched off the resulting curve quite often looks weird.
So I propose to modify the DrawValues procedure in Series.pas:
1) add 4 new variables in the TFastLineSeries class definition in section {internal}:
minpoint : Integer; // new variable
maxpoint : Integer; // new variable
minpointdefined : Boolean; // new variable
maxpointdefined : Boolean; // new variable
2) modify the DrawValues procedure:
procedure TFastLineSeries.DrawValue(ValueIndex:Integer);
var X : Integer;
Y : Integer;
begin
CalcPosition(ValueIndex,X,Y);
if X=OldX then
begin
if (Y=OldY) then exit;
if (not DrawAllPoints) then
begin
if minpointdefined and maxpointdefined then
begin
if (Y > minpoint) and (Y < maxpoint) then exit
else
if Y > maxpoint then maxpoint := Y;
if Y < minpoint then minpoint := Y;
end
else
if minpointdefined and not maxpointdefined then
begin
if Y > minpoint then maxpoint := Y; maxpointdefined := true;
if Y < minpoint then
begin
maxpoint := minpoint; minpoint := Y; maxpointdefined := true;
end;
end
else
begin
minpoint := Y;
minpointdefined := true;
end;
end;
end
else
begin
minpointdefined := false;
maxpointdefined := false;
end;
if IgnoreNulls or (ValueColor[ValueIndex]<>clNone) then
begin
With ParentChart.Canvas do
if ParentChart.View3D then
begin
if Stairs then
if InvertedStairs then LineTo3D(OldX,Y,MiddleZ)
else LineTo3D(X,OldY,MiddleZ);
LineTo3D(X,Y,MiddleZ);
end
else
begin
if Stairs then
if InvertedStairs then LineTo(OldX,Y)
else LineTo(X,OldY);
LineTo(X,Y);
end;
end
else DoMove(X,Y);
OldX:=X;
OldY:=Y;
end;
With this modification it is checked if a new point to be drawn is at an existing x position. If yes then it is checked if it is between minpoint and maxpoint or outside. If it is inside then the new point is not drawn. If it is outside then it is drawn and minpoint/maxpoint are adjusted accordingly.
By this modification the drawed curve is always looking perfect like with all points drawn. The disadvantage is that e.g. a curve with a continous rising/falling slope is is not drawn quicker. But more random curves are drawn very quick under statistical aspects.
Now the reason for my post:
I would like to have this code in V7.08 which is binary only. In V7.07 source code it is possible but V7.07 is different to V7.08, so I get error messages about different compilations together with other used software libraries.
Uli
the DrawAllPoints property leads to a slow reaction if true and a high number of points. But if DrawAllPoints is switched off the resulting curve quite often looks weird.
So I propose to modify the DrawValues procedure in Series.pas:
1) add 4 new variables in the TFastLineSeries class definition in section {internal}:
minpoint : Integer; // new variable
maxpoint : Integer; // new variable
minpointdefined : Boolean; // new variable
maxpointdefined : Boolean; // new variable
2) modify the DrawValues procedure:
procedure TFastLineSeries.DrawValue(ValueIndex:Integer);
var X : Integer;
Y : Integer;
begin
CalcPosition(ValueIndex,X,Y);
if X=OldX then
begin
if (Y=OldY) then exit;
if (not DrawAllPoints) then
begin
if minpointdefined and maxpointdefined then
begin
if (Y > minpoint) and (Y < maxpoint) then exit
else
if Y > maxpoint then maxpoint := Y;
if Y < minpoint then minpoint := Y;
end
else
if minpointdefined and not maxpointdefined then
begin
if Y > minpoint then maxpoint := Y; maxpointdefined := true;
if Y < minpoint then
begin
maxpoint := minpoint; minpoint := Y; maxpointdefined := true;
end;
end
else
begin
minpoint := Y;
minpointdefined := true;
end;
end;
end
else
begin
minpointdefined := false;
maxpointdefined := false;
end;
if IgnoreNulls or (ValueColor[ValueIndex]<>clNone) then
begin
With ParentChart.Canvas do
if ParentChart.View3D then
begin
if Stairs then
if InvertedStairs then LineTo3D(OldX,Y,MiddleZ)
else LineTo3D(X,OldY,MiddleZ);
LineTo3D(X,Y,MiddleZ);
end
else
begin
if Stairs then
if InvertedStairs then LineTo(OldX,Y)
else LineTo(X,OldY);
LineTo(X,Y);
end;
end
else DoMove(X,Y);
OldX:=X;
OldY:=Y;
end;
With this modification it is checked if a new point to be drawn is at an existing x position. If yes then it is checked if it is between minpoint and maxpoint or outside. If it is inside then the new point is not drawn. If it is outside then it is drawn and minpoint/maxpoint are adjusted accordingly.
By this modification the drawed curve is always looking perfect like with all points drawn. The disadvantage is that e.g. a curve with a continous rising/falling slope is is not drawn quicker. But more random curves are drawn very quick under statistical aspects.
Now the reason for my post:
I would like to have this code in V7.08 which is binary only. In V7.07 source code it is possible but V7.07 is different to V7.08, so I get error messages about different compilations together with other used software libraries.
Uli