Page 1 of 1

### How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Mon Feb 11, 2019 8:05 pm
Hello,

How can I draw nice 3D arrows like in the attached picture?
By using the code below I only get "flat" arrows
and can't draw an arrow in Z direction:

Code: Select all

``````var
tmpX,tmpY,tmpZ: Integer;
FromPoint,ToPoint: TPoint;
begin
tmpY := Chart.ChartYCenter + Round(Chart.Canvas.RotationCenter.Y);
tmpX := Chart.ChartXCenter + Round(Chart.Canvas.RotationCenter.X);
tmpZ := (Chart.Width3D div 2) + Round(Chart.Canvas.RotationCenter.Z);
StrainChart.Canvas.Pen.Color := clRed;
StrainChart.Canvas.Pen.Width := 4;
StrainChart.Canvas.Pen.Style := psSolid;

FromPoint.X := Chart.ChartRect.Left;
FromPoint.Y := tmpY;
ToPoint.X := Chart.ChartRect.Right;
ToPoint.Y := tmpY;
Chart.Canvas.Arrow(True, FromPoint, ToPoint, 50, 50, tmpZ);

FromPoint.X := tmpX;
FromPoint.Y := Chart.ChartRect.Bottom;
ToPoint.X := tmpX;
ToPoint.Y := StrainChart.ChartRect.Top;
Chart.Canvas.Arrow(True, FromPoint, ToPoint, 50, 50, tmpZ);`````` Nice3DArrowsCapture.PNG (62.85 KiB) Viewed 4884 times Flat2DArrowsCapture.PNG (108.13 KiB) Viewed 4884 times

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Mon Feb 18, 2019 9:11 am
Hello,

You can give it a try at the Vector series. Ie:

Code: Select all

``````uses TeeSurfa;

procedure TForm1.FormCreate(Sender: TObject);
begin
with Chart1 do
begin
Chart3DPercent:=100;
Aspect.Orthogonal:=False;
Aspect.Zoom:=70;
Legend.Hide;

Axes.Left.SetMinMax(0,10);
Axes.Bottom.SetMinMax(0,10);
Axes.Depth.SetMinMax(0,10);
Axes.Depth.Visible:=True;

Axes.Left.Increment:=1;
Axes.Bottom.Increment:=1;
Axes.Depth.Increment:=1;
end;

begin
Color:=clRed;
Pen.Width:=2;
ArrowHeight:=10;
ArrowWidth:=10;
end;
end;`````` Project1_2019-02-18_10-09-28.png (51.61 KiB) Viewed 4851 times

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Mon Feb 18, 2019 11:36 am
Hello Yeray,

that's a nice solution, interesting is that I can't get the Labels to work in call "AddVector", like:

Do you have a solution for that?
Also it would be nice to have real 3D Arrows on top of the Vector lines.

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Tue Feb 19, 2019 11:17 am
Hello,
axrDegen wrote:
Mon Feb 18, 2019 11:36 am
interesting is that I can't get the Labels to work in call "AddVector", like:

Do you have a solution for that?
Try turning the Marks visible:

Code: Select all

``````    Marks.Visible:=True;
Marks.Style:=smsLabel;``````
axrDegen wrote:
Mon Feb 18, 2019 11:36 am
Also it would be nice to have real 3D Arrows on top of the Vector lines.
How would you like them to look exactly?

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Tue Feb 19, 2019 12:39 pm
Ok, that makes them appear, but all the Labels are displayed together at the center point, please see the screenshot: LabelsCapture.PNG (74.15 KiB) Viewed 4827 times
How Can I display the labels at the end of the Arrows?
The Arrowheads I would expect to be shown as a (3D) Cone, see below: ### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Wed Feb 20, 2019 11:18 am
Hello,

I'm afraid this is not possible right now.
I've created a new ticket in the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=2161

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Wed Feb 20, 2019 12:42 pm
Ok, that is about making it nice, but what about the markers/labels, how can I get these displayed correctly?

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Thu Feb 21, 2019 3:55 pm
Hello,
axrDegen wrote:
Wed Feb 20, 2019 12:42 pm
but what about the markers/labels, how can I get these displayed correctly?
Sorry, I missed that point.
You could use marks custom positioning at OnGetMarkText event. Ie:

Code: Select all

``````procedure TForm1.VectorGetMarkText(Sender:TChartSeries; ValueIndex:Integer; var MarkText:String);
begin
if Assigned(Sender) and (ValueIndex>-1) and (ValueIndex<Sender.count) and
Assigned(Sender.Marks.Positions) and Assigned(Sender.Marks.Positions[ValueIndex]) then
begin
with TVector3DSeries(Sender), Marks.Positions[ValueIndex] do
begin
Custom:=True;
LeftTop:=ParentChart.Canvas.Calculate3DPosition(CalcXPosValue(EndXValues[ValueIndex]),
CalcYPosValue(EndYValues[ValueIndex]),
ParentChart.Axes.Depth.CalcPosValue(EndZValues[ValueIndex]));
end;
end;
end;``````

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Fri Feb 22, 2019 7:50 am
Thank you Yeray, that works for X and Y but not for Z, please see screenshot: ZLabelProblemCapture.PNG (204.48 KiB) Viewed 4792 times
Note that I use the Min/Max of another series to calculate the Max values for the Vectors, like that:

Code: Select all

``````    MaxX := Max(FPoint3DSeries.MaxXValue, Abs(FPoint3DSeries.MinXValue));
MaxY := Max(FPoint3DSeries.MaxYValue, Abs(FPoint3DSeries.MinYValue));
MaxZ := Max(FPoint3DSeries.MaxZValue, Abs(FPoint3DSeries.MinZValue));
How to solve that ?

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Fri Feb 22, 2019 10:29 am
I don't really understand that source code anyway, LeftTop (a TPoint value) is set per series Mark via call "Chart.Canvas.Calculate3DPosition"
How is the 3D position (X, Y, Z) coded into a TPoint, which only has X and Y ?
So where do you finally set the Z position of each Mark?

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Mon Feb 25, 2019 10:44 am
Hello,

It seems to work fine for me here: Project1_2019-02-25_11-38-47.png (87.19 KiB) Viewed 4732 times
testVectorArrow2.zip
axrDegen wrote:
Fri Feb 22, 2019 10:29 am
I don't really understand that source code anyway, LeftTop (a TPoint value) is set per series Mark via call "Chart.Canvas.Calculate3DPosition"
How is the 3D position (X, Y, Z) coded into a TPoint, which only has X and Y ?
So where do you finally set the Z position of each Mark?
The Calculate3DPosition function converts 3D coordinates to 2D coordinates to be used when custom drawing (ref here)
Calculates and returns the XY position in pixels of the XYZ 3D coordinate.

Can be used when custom drawing using 3D XYZ coordinates, either returned from the axes or not.

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Mon Feb 25, 2019 11:17 am
Thank you, but this doesn't work. I am finally painting the axes labels in the OnAfterDraw event like that:

Code: Select all

``````    XCent := FAxesSeries.CalcXPosValue(0);
YCent := FAxesSeries.CalcYPosValue(0);
ZCent := aChart.Axes.Depth.CalcPosValue(0);
XPosi := FAxesSeries.CalcXPosValue(FXAxisMax);
YPosi := FAxesSeries.CalcYPosValue(FYAxisMax) - aChart.Canvas.TextHeight('b');
ZPosi := aChart.Axes.Depth.CalcPosValue(FZAxisMax);
aChart.Canvas.TextOut3D(XPosi, YCent, ZCent, 'a');
aChart.Canvas.TextOut3D(XCent, YPosi, ZCent, 'b');
aChart.Canvas.TextOut3D(XCent, YCent, ZPosi, 'c');``````

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Mon Feb 25, 2019 11:39 am
Hello,
axrDegen wrote:
Mon Feb 25, 2019 11:17 am
I am finally painting the axes labels in the OnAfterDraw event
That's another possibility. Does it work as you want?

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Mon Feb 25, 2019 12:34 pm
Yes, that works very well

### Re: How can I draw nice 3D Arrows to depict axes (a,b,c)

Posted: Tue Feb 26, 2019 7:22 am
axrDegen wrote:
Mon Feb 25, 2019 12:34 pm
Yes, that works very well
Great!