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;
Problem while drawing 3D contour and surface
-
- Newbie
- Posts: 20
- Joined: Tue Jul 03, 2007 12:00 am
- Contact:
Problem while drawing 3D contour and surface
- Attachments
-
- Tcontour without contour.GIF (41.61 KiB) Viewed 9923 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Problem while drawing 3D contour and surface
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.
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 |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 20
- Joined: Tue Jul 03, 2007 12:00 am
- Contact:
Re: Problem while drawing 3D contour and surface
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.
LÊ
Sciensoria
http://www.sciensoria.fr
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.
LÊ
Sciensoria
http://www.sciensoria.fr
- Attachments
-
- TestContour.zip
- (52.19 KiB) Downloaded 662 times
Re: Problem while drawing 3D contour and surface
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:
On the other hand, both the following lines can be applied successfully in your code, giving different results:
or...
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
Code: Select all
Series1.AddXYZ(x,z,y,'',clTeeColor); //correct input
Code: Select all
Series1.AddXYZ(y,z,x,'',clTeeColor); //correct input
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 20
- Joined: Tue Jul 03, 2007 12:00 am
- Contact:
Re: Problem while drawing 3D contour and surface
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.
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.
Re: Problem while drawing 3D contour and surface
Hello,
The fastest way to add a TRotateTool would be:
However, if you want to change other properties from it, you could save if into a variable:
Alternatively, you should be able to call the Create constructor:
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.
You can click on the "Add..." button to open the tools gallery, select the "Rotate" tool in the "Other" tab, and click "Add".
The fastest way to add a TRotateTool would be:
Code: Select all
uses TeeTools;
//...
Chart1.Tools.Add(TRotateTool);
Code: Select all
uses TeeTools;
//...
var rotateTool1: TRotateTool;
//...
rotateTool1:=Chart1.Tools.Add(TRotateTool) as TRotateTool;
Code: Select all
uses TeeTools;
//...
var rotateTool1: TRotateTool;
//...
rotate1:=TRotateTool.Create(Self);
Chart1.Tools.Add(rotate1);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |