Page 1 of 1

Drawing speed enhancement

Posted: Wed Jun 24, 2009 6:56 am
by 9335230
Hi!

I would like to know about all options I have to enhance drawing speed. I already use all recommendations in your "Real-time charting in TeeChart VCL" article since several years ago, but yet I'm trying to improve speed with other complementary ways. Besides, some of my charts have to use other kind of TChartSeries (different to TFastLineSeries). A couple ideas came up:

1) Using a very powerful graphic card, but TeeChart should use OpenGL or DirectX. I tried to use the TTeeOpenGL component and associate it to any of my TChart's, activate it but all I got is not to see anything :) How is TTeeOpenGL supposed to work? is a solution to my needs?
2) Improving my graphic classes with much complicated code.

Any tips following the first idea? I don't care If I had to spend a lot of money in a superb graphic card :twisted:

Thanks!!

Re: Drawing speed enhancement

Posted: Wed Jun 24, 2009 7:04 am
by 9335230
I forgot to mention that almost all charts I need to improve are 2D.

Thanks!

Re: Drawing speed enhancement

Posted: Thu Jun 25, 2009 8:48 am
by narcis
Hi beetle,

You just need to add a TTeeOpenGL component to your form, associate it to a chart and activate it, for example:

Code: Select all

uses TeeOpenGL;

procedure TForm4.FormCreate(Sender: TObject);
var TeeOpenGL1: TTeeOpenGL;
begin
  TeeOpenGL1:=TTeeOpenGL.Create(self);
  TeeOpenGL1.TeePanel:=Chart1;
  TeeOpenGL1.Active:=true;

  Chart1.Aspect.Zoom:=50;
end;
Using code above works fine for me here using TeeChart Pro v8.05 VCL. If problem persits please attach a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.

Re: Drawing speed enhancement

Posted: Thu Jun 25, 2009 8:55 am
by yeray
Hi beetle,

To increase drawing speed, have you tried using DownSampling Function?

Re: Drawing speed enhancement

Posted: Thu Jun 25, 2009 6:06 pm
by 9335230
Hi,

The DownSampling is not suitable for my charts because I use several own chart tools to identify and match points between several different charts (altough representing the same data).
The TTeeOpenGL doesn't seem to work in 2D charts, only 3D (and It works really weird).

Thanks.

Re: Drawing speed enhancement

Posted: Fri Jun 26, 2009 7:15 am
by narcis
Hi beetle,

It works fine for me here using TeeChart Pro v8.05 VCL. Can you please confirm the exact TeeChart vresion you are using? Can you also attach a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.

Re: Drawing speed enhancement

Posted: Fri Jun 26, 2009 8:01 am
by 9335230
Hi Narcis,

It's been a while that I'm using TeeChart Pro v7.12 Win32 and CodeGear™ C++Builder® 2007.
You are referring to TeeOpenGL, aren't you? If so, check the attached zip file. It includes the Builder project, the executable file renamed to have .axe extension (TeeOpenGLTest.axe in the Debug folder) and 2 screenshots showing how I see it working, in 2D and 3D. 2D mode doesn't represent the series and 3D mode doesn't show axes and it has a cheesy appearance :lol: , among other things.

Thanks!

Re: Drawing speed enhancement

Posted: Fri Jun 26, 2009 10:48 am
by yeray
Hi beetle,

It's strange, running your exe in two different machines I get always a visible line in 2D and a line that looks a little bit better in 3D.
I've modified you project to add a zoom of 40% to see the axes with opengl. And I've added an about box that would show you if the application is getting TeeChart v7.12 or not.

Re: Drawing speed enhancement

Posted: Fri Jun 26, 2009 11:31 am
by 9335230
Hi Yeray,

I tried your exe file and I compiled your changes myself, and the result is in the screenshots attached. As you may see, 2D series doesn't appear and the looking is really hideous in both views :lol:
I also tried in another computer using the same runtime packages of TeeChart (Tee711.bpl, etc.)
Could you please send me screenshots of the same exe file running in your computer? and the exe file compiled with your latest version of TeeChart?

Thanks!

Re: Drawing speed enhancement

Posted: Fri Jun 26, 2009 1:26 pm
by yeray
Hi beetle,

Here there are the screenshots that the program shows for me here with latest v7 sources. As you are a source code customer, I've sent the url to download the actual v7 sources to your forums registered account. Could you please try if them solve the issue?

Re: Drawing speed enhancement

Posted: Fri Jun 26, 2009 7:07 pm
by 9335230
Hi,

I saw your screenshots and the appearance are similiar to mine (texts are blury, for example), although 2D view does paint the series. So, isn't it possible to get the same looking for charts than without using TeeOpenGL?

Thanks.

Re: Drawing speed enhancement

Posted: Mon Jun 29, 2009 8:29 am
by yeray
Hi beetle,

I'll add those differences to the wish list to be revised for further releases. As you said, texts with small fonts look a little bit blurry (here I can only think in making them bigger for the moment). I also can see that the legend color doesn't respond as expected with OpenGL.

Could you please tell us what other differences are you viewing? Thanks in advance.

Re: Drawing speed enhancement

Posted: Thu Jul 02, 2009 7:48 am
by 9335230
Hi,

I uploaded two images for you to see how I currently see 4 of my graphs and how I see them using TeeOpenGL. As you may see, 2D series are not shown using TeeOpenGL, so I can't tell differences.
Anyways, I'm trying to enhance my source code and I have one question: How could I know the drawn points number of a series when the event OnGetPointerStyle is triggered? I mean, the forthcoming visible points number. Since this event is triggered before OnBeforeDrawAxes (and before OnBeforeChartDraw), if I just zoomed, I can't figure out how to know that.

Thanks!

Re: Drawing speed enhancement

Posted: Thu Jul 02, 2009 8:50 am
by yeray
Hi beetle,

Maybe you should consider using AntiAlias Tool instead of OpenGL since it wasn't thought to be used with 2D.

On the other hand, I still think that the first problem is that activating OpenGL, the chart is moved and zoomed. So, if you still want to use OpenGL, you should try to find the correct zoom, HorizontalOffset, etc... values for your charts like in the following example (I recommend you to use a TeeCommander to find the values easily):

Code: Select all

uses TeeOpenGL;

var Series1: TPointSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1 := TPointSeries.Create(self);
  Series1.ParentChart := Chart1;
  Series1.FillSampleValues(200);
  Chart1.View3D := false;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TTeeOpenGL.Create(self) do
  begin
    TeePanel := Chart1;
    Active := true;
  end;

  Chart1.View3D := true;
  Chart1.Aspect.Zoom := 50;
  Chart1.Aspect.Elevation := 0;
  Chart1.Aspect.Rotation := 0;
  Chart1.Aspect.HorizOffset := -300;
  Chart1.Aspect.VertOffset := -300;
end;
And regarding the "number of shown points" issue, you should calculate it manually doing something like following:

Code: Select all

procedure TForm1.Chart1Zoom(Sender: TObject);
var i, numVisiblePoints: Integer;
begin
  Chart1.Repaint;
  numVisiblePoints := 0;
  for i:=0 to Series1.Count-1 do
  begin
    if PtInRect(Chart1.ChartRect, Point(Series1.CalcXPos(i),Series1.CalcYPos(i))) then
      numVisiblePoints := numVisiblePoints+1;
  end;
  Chart1.Title.Text.Text := inttostr(numVisiblePoints);
end;