Multiple 3D Series plotted incorrectly

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JonM
Newbie
Newbie
Posts: 23
Joined: Tue Sep 14, 2004 4:00 am
Location: UK

Multiple 3D Series plotted incorrectly

Post by JonM » Wed Aug 15, 2012 1:05 pm

Hello
I am trying to make a 3D plot of several series. I basically have one TTriSurfaceSeries and several TPoint3DSeries (plotted as points). I have made the TTriSurfaceSeries semi transparent and would like to show the TPoint3DSeries above and below the TTriSurfaceSeries surface depending on the data point’s position in 3D space. What I see is that each series work independently to each other and whether they appear above or below the surface depends on the drawing order of the series not the 3D position of the data..

This is not a proper 3D rendition of the data. I am using Delphi 2007 (.Net) with Tchart 7.12.

Does your latest version of Tchart .Net fix this fundamental problem?

Thanks Frank

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Multiple 3D Series plotted incorrectly

Post by Sandra » Thu Aug 16, 2012 11:33 am

Hello Frank,
I am trying to make a 3D plot of several series. I basically have one TTriSurfaceSeries and several TPoint3DSeries (plotted as points). I have made the TTriSurfaceSeries semi transparent and would like to show the TPoint3DSeries above and below the TTriSurfaceSeries surface depending on the data point’s position in 3D space. What I see is that each series work independently to each other and whether they appear above or below the surface depends on the drawing order of the series not the 3D position of the data..

This is not a proper 3D rendition of the data. I am using Delphi 2007 (.Net) with Tchart 7.12.

Does your latest version of Tchart .Net fix this fundamental problem?
We don't consider this problem as a bug. Basically, is a behavior of canvas where we draw TeeChart in VCL and .NET. If you want sereis draw as you want, you need use canvas OpenGL in VCL and in .Net. You can use OpenGL as explain here:

In VCL:
You only need add OpenGL component as do in next project
TriSurfaceTestOpenGL.zip
(4.35 KiB) Downloaded 764 times
In .Net.
You need add the TeeChart.OpenGl.dll assembly and add the component in the chart as do in next code:

Code: Select all

   public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Points3D Series2;
        Steema.TeeChart.Styles.TriSurface Series1;
        private void InitializeChart()
        {
            Series2 = new Steema.TeeChart.Styles.Points3D(tChart1.Chart);
            Series1 = new Steema.TeeChart.Styles.TriSurface(tChart1.Chart);
            Steema.TeeChart.Tools.Rotate rotate = new Steema.TeeChart.Tools.Rotate(tChart1.Chart);
            teeOpenGL1.Chart = tChart1;
            tChart1.Aspect.Chart3DPercent = 100;
            //   teeOpenGL1.Canvas.Brush.Transparency = 50;
            //Add values in Series1:
            Series1.Add(0.872, 2.842, 0.592);
            Series1.Add(0.733, 4.981, 0.929);
            Series1.Add(0.455, 3.445, 0.64);
            Series1.Add(0.88, 1.856, 0.331);
            Series1.Add(0.02, 4.844, 0.789);
            Series1.Add(0.44, 1.724, 0.276);
            Series1.Add(0.736, 5.141, 0.954);
            Series1.Add(0.166, 4.105, 0.71);
            Series1.Add(0.732, 5.121, 0.948);
            //Add valuesi n Series2:
            Series2.Add(0.807, 2.374, 0.469);
            Series2.Add(0.264, 2.173, 0.391);
            Series2.Add(0.856, 3.724, 0.777);
            Series2.Add(0.116, 2.238, 0.403);
            Series2.Add(0.68, 3.676, 0.712);
            Series2.Add(0.112, 6.754, 0.958);
            Series2.Add(0.486, 5.309, 0.882);
            Series2.Add(0.567, 5.171, 0.888);
            Series2.Add(0.193, 1.437, 0.181);
            Series2.Add(0.54, 1.05, 0.024);
            Series1.Brush.Gradient.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.ShowEditor();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            teeOpenGL1.Active = checkBox1.Checked;
        }
Could you please, tell us previous code works as you expect? If you have any problems please let me know.

Thanks,
Best Regards,
Sandra Pazos / 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

JonM
Newbie
Newbie
Posts: 23
Joined: Tue Sep 14, 2004 4:00 am
Location: UK

Re: Multiple 3D Series plotted incorrectly

Post by JonM » Mon Aug 20, 2012 1:58 pm

Hi Sandra

Thanks for this I was not aware Tchart had OpenGL.

I tried adding the OpenGl component to my project, but this on run would crash the program with an Object reference. I then went back and looked at your project you sent me. This looked like a standard VCL project so I created a new .Net VCL project and duplicated your code. When I run the project and click on the OpenGL button the program stops with an ‘Object reference not set to an Instance of an object’ message. Does the OpenGL not work with .Net VCL projects ? I am running Version 8.08 of Tchart.

My code is below, I have changed the points so they are easier to see.

Thanks Frank

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, System.ComponentModel, Borland.Vcl.ExtCtrls, TeeProcs,
  Chart, TeeComma, TeeOpenGL, TeeTriSurface, TeePoin3, Borland.Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    TeeOpenGL1: TTeeOpenGL;
    Panel1: TPanel;
    CheckBox1: TCheckBox;
    TeeCommander1: TTeeCommander;
    procedure FormCreate(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
  private
    { Private declarations }
    Series1:TTriSurfaceSeries;
    Series2:TPoint3DSeries;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.nfm}

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  TeeOpenGL1.Active:= CheckBox1.Checked;
  Series1.Transparency:= 20;
  if TeeOpenGL1.Active then
  begin
    Chart1.Aspect.Rotation := 359;
    Chart1.Aspect.Elevation:= 359;
  end
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
//Add Series:
Series2 := TPoint3DSeries.Create(self);
Series1 := TTriSurfaceSeries.Create(self);

Chart1.AddSeries(Series2);
Chart1.AddSeries(Series1);

//Add values in Series1:
//             Sw, Ht, Phi
Series1.AddXYZ(1.0,0.0,0.1);
Series1.AddXYZ(0.9,2.0,0.1);
Series1.AddXYZ(0.8,6.0,0.1);
Series1.AddXYZ(0.6,12.0,0.1);
Series1.AddXYZ(0.4,25.0,0.1);

Series1.AddXYZ(1.0,0.0,0.15);
Series1.AddXYZ(0.9,3.0,0.15);
Series1.AddXYZ(0.8,8.0,0.15);
Series1.AddXYZ(0.6,18.0,0.15);
Series1.AddXYZ(0.4,35.0,0.15);

Series1.AddXYZ(1.0,0.0,0.2);
Series1.AddXYZ(0.9,10.0,0.2);
Series1.AddXYZ(0.8,25.0,0.2);
Series1.AddXYZ(0.6,50.0,0.2);
Series1.AddXYZ(0.4,100.0,0.2);
//Add values in Series2:
Series2.AddXYZ(0.6,5.0,0.15);
Series2.AddXYZ(0.6,40.0,0.15);
Series1.Transparency := 20;
end;

end.
Last edited by Yeray on Tue Aug 21, 2012 11:39 am, edited 1 time in total.
Reason: code format

JonM
Newbie
Newbie
Posts: 23
Joined: Tue Sep 14, 2004 4:00 am
Location: UK

Re: Multiple 3D Series plotted incorrectly

Post by JonM » Tue Aug 21, 2012 9:50 am

Sandra

We have look into this problem a bit more and find that when the Transparency is set to zero then the OpenGL works.

With the code in the debugger the problem is in the TeeGLCanvas.pas unit function

Code: Select all

Function TGLCanvas.BeginBlending(const R:TRect; Transparency:TTeeTransparency):TTeeBlend;
begin
  if Transparency>0 then
  begin
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  end;

  ITransp:=(100-Transparency)*0.01;
  result:=nil;
end;
This function always returns ‘nil’, which then causes an object reference in the routine calling this ‘TCustomTriSurfaceSeries.DrawAllValues’.

Frank
Last edited by Yeray on Tue Aug 21, 2012 11:39 am, edited 1 time in total.
Reason: code formatting

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

Re: Multiple 3D Series plotted incorrectly

Post by Yeray » Tue Aug 21, 2012 1:35 pm

Hi,

I'm afraid this is a known issue already in the wish list to be revised (TV52015900)
http://www.teechart.net/support/viewtop ... =3&t=12815
I've incremented the item severity.
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