Problem while drawing 3D contour and surface

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Sciensoria
Newbie
Newbie
Posts: 20
Joined: Tue Jul 03, 2007 12:00 am
Contact:

Problem while drawing 3D contour and surface

Post by Sciensoria » Sat Nov 14, 2009 11:28 pm

Hello,
I currently have a problem with drawing 3D contour/surface.
I try to read a file which contains 3 colums: x,y and z. While reading (using readln(textfile,x,y,z), I put the data into a Tcontour as follows:

if OpenDialog1.execute then begin
AssignFile(Datafile,OpenDialog1.filename);
Reset(Datafile);
Series1.clear; // Series1 is a TContour
while not(eof(Datafile)) do begin
Readln(Datafile,x,y,z);
Series1.AddXYZ(x,z,z,'',clTeeColor); // add point to the contour
Memo1.Lines.Add(Num2Str(cnt,0,0)+' '+Num2Str(x,2,2) + ' ' + Num2Str(y,2,2) +' ' +Num2Str(z,2,2)); // add values to a TMemo for visualization
end; // end of eof()
CloseFile(Datafile);
end;

The problem is no contour appears on the chart, although the axes correspond to the x and y extents, and the 20 levels legend corresponds to the z values. (please see the attached GIF image).

Just before reading the file, I have tried to populate the chart with for commands, and the following code works:
inherited;
{ First we add XYZ points to the Contour series... }
With Series1 do
begin
Clear;
{ We add values from 0 to 1000. 21x21 cells = 441 }
for x:= -10 to 10 do
for z:= -10 to 10 do
AddXYZ( x, RandomXYZ(x,z) ,z, '', clTeeColor);
end;

I sup

{ Then we specify how many "contour levels" we want }
Series1.NumLevels:=20;
Attachments
Tcontour without contour.GIF
Tcontour without contour.GIF (41.61 KiB) Viewed 9934 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Problem while drawing 3D contour and surface

Post by Narcís » Mon Nov 16, 2009 12:29 pm

Hi Sciensoria,

Have you tried setting contour's IrregularGrid=true? Notice that such series need to be populated as described here. If this doesn't help please attach a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Sciensoria
Newbie
Newbie
Posts: 20
Joined: Tue Jul 03, 2007 12:00 am
Contact:

Re: Problem while drawing 3D contour and surface

Post by Sciensoria » Mon Nov 16, 2009 1:27 pm

Hi Narcis,
Many thanks for your help.
I have just tried to add Series1.IrregularGrid:=true command but nothing changes (Series1 is a TContourSeries).
I attached my project here so that you can have a look in it. When you launch the project, there are some contours due to initialization. Then you click on the Plot data from file button and load the contour1 file. You will get the loaded data on the right of the window, and the Tcontour plot on the left, but there is no contour line for the moment.
The zip file was checked with anti virus software.

One again, thank you for your help.


Sciensoria
http://www.sciensoria.fr
Attachments
TestContour.zip
(52.19 KiB) Downloaded 664 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem while drawing 3D contour and surface

Post by Yeray » Tue Nov 17, 2009 10:19 am

Hi Sciensoria,

According to the explanation that Narcis pointed to you of how the contour series should be populated, I think that adding your values as you do is not correct:

Code: Select all

Series1.AddXYZ(x,z,z,'',clTeeColor); //incorrect input
On the other hand, both the following lines can be applied successfully in your code, giving different results:

Code: Select all

Series1.AddXYZ(x,z,y,'',clTeeColor); //correct input
or...

Code: Select all

Series1.AddXYZ(y,z,x,'',clTeeColor); //correct input
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Sciensoria
Newbie
Newbie
Posts: 20
Joined: Tue Jul 03, 2007 12:00 am
Contact:

Re: Problem while drawing 3D contour and surface

Post by Sciensoria » Sat May 31, 2014 12:03 am

Hello,
I come back to you for another question: how to use mouse to rotate a 3D surface.
I have read the Surface_XYZFloat unit and see that you use TRotate to do it. However, I didn't find the TRotateTool component on the Delphi panels. So how to add the TRotateTool to a form even when the component is not present on the components panel ?
(I have tried to create the component dynamically by TRotateTool.create(self) but this does'n work)

Thank you for your help.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem while drawing 3D contour and surface

Post by Yeray » Mon Jun 02, 2014 8:00 am

Hello,

The fastest way to add a TRotateTool would be:

Code: Select all

uses TeeTools;
//...
  Chart1.Tools.Add(TRotateTool);
However, if you want to change other properties from it, you could save if into a variable:

Code: Select all

uses TeeTools;
//...
var rotateTool1: TRotateTool;
//...
  rotateTool1:=Chart1.Tools.Add(TRotateTool) as TRotateTool;
Alternatively, you should be able to call the Create constructor:

Code: Select all

uses TeeTools;
//...
var rotateTool1: TRotateTool;
//...
  rotate1:=TRotateTool.Create(Self);
  Chart1.Tools.Add(rotate1);
Finally, you can also add it at design time. You can double-click on a TChart to open the editor, then you can navigate to the "Tools" tab.
2014-06-02_1003_001.png
2014-06-02_1003_001.png (6.12 KiB) Viewed 9441 times
You can click on the "Add..." button to open the tools gallery, select the "Rotate" tool in the "Other" tab, and click "Add".
2014-06-02_1003.png
2014-06-02_1003.png (52.36 KiB) Viewed 9436 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply