Page 1 of 1

How to draw complexer line(Bezier curves, arcs, ...) ?

Posted: Fri Apr 02, 2004 12:59 am
by 9336072
Hi Marjan Slatinek:
I know TDrawLineTool can draw single line, but I don't know how to draw complexer line(Bezier curves, arcs, ...) ,and I wish end-user can select and drag complex curves as if TDrawLineTool control single line.
TDrawLineTool:
0: Lines.Last.Style:=dlLine;
1: Lines.Last.Style:=dlHorizParallel;
2: Lines.Last.Style:=dlVertParallel;
I Wish TDrawLineTool have
3: Lines.Last.Style:=dlBezier;
4: Lines.Last.Style:=dlarcs;
5: Lines.Last.Style:=dlWaves;

....
I have reviewed TDrawLineTool's code in the TeeChart Pro 7, but not found.
I don't know how to do it

jilonger.xusen

Posted: Fri Apr 02, 2004 7:52 am
by Marjan
Hi.

As I said in my post this feature is not supported at TDrawLineTool level. This tool (currently) supports only straight from-to line drawing. We'll add the feature you described to our wish list for next major TeeChart release.
In the meantine if you want to draw non-straight-line curves, you can manually draw them by using one of the TChart.Canvas primitives in one of the TChart events (for example OnAfterDraw event).

Posted: Fri Apr 02, 2004 8:24 am
by 9336072
procedure TDrawLineTool.DrawLine(const StartPos, EndPos: TPoint;
AStyle: TDrawLineStyle);
var
i:integer;
begin
with ParentChart.Canvas do
if ParentChart.View3D then
begin
case AStyle of
dlLine:
begin
MoveTo3D(StartPos.X, StartPos.Y, 0);
LineTo3D(EndPos.X, EndPos.Y, 0);
end;
dlHorizParallel:
begin
HorizLine3D(StartPos.X, EndPos.X, StartPos.Y, 0);
HorizLine3D(StartPos.X, EndPos.X, EndPos.Y, 0);
end;
else
begin
VertLine3D(StartPos.X, StartPos.Y, EndPos.Y, 0);
VertLine3D(EndPos.X, StartPos.Y, EndPos.Y, 0);
end
end;
end
else
{HTS画线开发的扩展线形入口}
case AStyle of
dlLine: Line(StartPos.X, StartPos.Y, EndPos.X, EndPos.Y);
dlHorizParallel:
begin
DoHorizLine(StartPos.X, EndPos.X, StartPos.Y);
DoHorizLine(StartPos.X, EndPos.X, EndPos.Y);
end;
dlVertParallel:
begin
DoVertLine(StartPos.X, StartPos.Y, EndPos.Y);
DoVertLine(EndPos.X, StartPos.Y, EndPos.Y);
end
dl?????:
begin
Line(StartPos.X, StartPos.Y, EndPos.X, EndPos.Y);
for i:=0 to abs((EndPos.X-StartPos.X)) div 10 do
if (EndPos.X-StartPos.X)<0 then
DoVertLine(StartPos.X+i*(-10),ParentChart.ChartRect.Top, ParentChart.ChartRect.Bottom)
else DoVertLine(StartPos.X+i*10,ParentChart.ChartRect.Top, ParentChart.ChartRect.Bottom);
end;
end;
end;


/////////////////////

If I do it so , I can succeed?

Posted: Tue Apr 06, 2004 7:17 am
by Marjan
Hi.

Yes, it might work, but you'll have to replace the straight line drawing with property Bezier and arc drawing code (not by using line segments, but rather by using true arc and bezier methods). But be aware that in addition you'll also have to modify other methods, especially the tool OnChartMove event implementation. This mainly because if you want to draw bezier or arc you need more than two points to define specific curve.

Posted: Tue Apr 06, 2004 9:15 am
by 9336072
thanks.

Yes, It can work.
I try to do it.