BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TChart OpenGL Rendering

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Reporting-Charting
View previous topic :: View next topic  
Author Message
Anderson Carli
Guest





PostPosted: Mon Oct 27, 2003 12:14 am    Post subject: TChart OpenGL Rendering Reply with quote



Hi Teechart People!
We are users of TChart that comes with Delphi and we are considering to buy
Teechart Pro 6
mainly because the OpenGL capabilities
But seems that are some problems on rendering an OpenGL chart.
I make some tests with trial version, and I'm sending a sample of what I
think is a bug.
Look as the "Waterline's" grid and Axis grid dont hide when are behind
series.

You can rotate/elevate the chart with Arrow keys,
Use "A" to show/hide Axis and "W" to show/hide Waterline
Another issue: Zoom proprotions are not the same between OpenGL
and standard 3D canvas. see this turning on/off openGL with "G" Key

To test this app Create a new project, Past Form1 Code, view form as Text an
past form's text.

I tested this with nVidia Gforce and with default Windows XP Open GL without
3d board.

PS: I think this test application could be very nice interactive demo to be
put
inside of main Example App. If it works right ;-)

// Form1 Code //

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, TeeSurfa, StdCtrls, ExtCtrls, TeeProcs, Chart,
TeeOpenGL, F10Debug, TeeEdit;

type
TForm1 = class(TForm)
TeeOpenGL1: TTeeOpenGL;
Chart3D: TChart;
MainSeries: TSurfaceSeries;
HelpLabel: TLabel;
ChartEditor1: TChartEditor;
procedure Chart3DKeyDown(Sender: TObject; var Key: Word; Shift:
TShiftState);
procedure FormCreate(Sender: TObject);
procedure Chart3DDblClick(Sender: TObject);
public
WaterLine: TSurfaceSeries;
end;

var
Form1: TForm1;

const
VK_A = 65; VK_B = 66; VK_C = 67; VK_D = 68; VK_E = 69; VK_F = 70; VK_G =
71;
VK_H = 72; VK_I = 73; VK_J = 74; VK_K = 75; VK_L = 76; VK_M = 77; VK_N =
78;
VK_O = 79; VK_P = 80; VK_Q = 81; VK_R = 82; VK_S = 83; VK_T = 84; VK_U =
85;
VK_V = 86; VK_W = 87; VK_X = 88; VK_Y = 89; VK_Z = 90;

implementation

{$R *.dfm}

function IncAngle(Angle:Integer; Degrees:Integer=1):Integer;
begin
Result := Angle + Degrees;
if Result > 360 then Result := Result-360;
end;

function DecAngle(Angle:Integer; Degrees:Integer=1):Integer;
begin
Result := Angle - Degrees;
if Result < 0 then Result := 360+Result;
end;

function IncLimit(Value:Integer; Limit:Integer=100; Inc:Integer=1):Integer;
begin
Result := Value + Inc;
if Result > Limit then Result := Limit;
end;

function DecLimit(Value:Integer; Limit:Integer=100; Dec:Integer=1):Integer;
begin
Result := Value - Dec;
if Result < Limit then Result := Limit;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
x,z:Integer;
begin
Chart3d.BufferedDisplay := True;
MainSeries.FillSampleValues(30);

WaterLine := TSurfaceSeries(Chart3d.AddSeries(TSurfaceSeries));
WaterLine.BeginUpdate;
try
WaterLine.SeriesColor := clBlue;
WaterLine.UseColorRange := False;
WaterLine.Transparency := 40;
for x := 0 to 31 do
for z := 0 to 31 do
WaterLine.AddXYZ(x,0,z);
// for x := 0 to 32 do
// WaterLine.AddXYZ(x,-0.8,0);
// for z := 0 to 32 do
// WaterLine.AddXYZ(32,-0.8,z);
finally
WaterLine.EndUpdate;
end;
end;

procedure TForm1.Chart3DDblClick(Sender: TObject);
begin
ChartEditor1.Execute;
end;

procedure TForm1.Chart3DKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
with Chart3d, View3DOptions do begin
if ssShift in Shift then
case key of
VK_LEFT: HorizOffset := DecLimit(HorizOffset, -1000, 10);
VK_RIGHT: HorizOffset := IncLimit(HorizOffset, 1000, 10);
VK_UP: VertOffset := DecLimit(VertOffset, -1000, 10);
VK_DOWN: VertOffset := IncLimit(VertOffset, 1000, 10);
end
else
case key of
VK_RIGHT: Rotation := IncAngle(Rotation, 2);
VK_LEFT: Rotation := DecAngle(Rotation, 2);
VK_UP: Elevation := IncAngle(Elevation,2);
VK_DOWN: Elevation := DecAngle(Elevation,2);
VK_A: Chart3d.AxisVisible := not Chart3d.AxisVisible;
VK_Z: Zoom := IncLimit(Zoom, 500, 2);
VK_X: Zoom := DecLimit(Zoom, 1, 2);
VK_P: Perspective := IncLimit(Perspective, 100, 2);
VK_O: Perspective := DecLimit(Perspective, 0, 2);
VK_G: TeeOpenGL1.Active := not TeeOpenGL1.Active;
VK_W: WaterLine.Visible := not WaterLine.Visible;
VK_F1: HelpLabel.Visible := not HelpLabel.Visible;
end;
end;
end;

end.

// Form's Text //

object Form1: TForm1
Left = 348
Top = 79
Width = 800
Height = 600
Caption = 'Form1'
Color = clBtnFace
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Courier New'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnKeyDown = Chart3DKeyDown
PixelsPerInch = 96
TextHeight = 16
object HelpLabel: TLabel
Left = 0
Top = 0
Width = 792
Height = 64
Align = alTop
Caption =
'Left/Right Arrows: Rotate Chart Shift Arrows.....: Hor' +
'iz/Vert Offset Move'#13#10'G................: Turn OpenGLOn/Off
Z' +
'/X..............: Zoom in/out'#13#10'P/O..............: Inc/Dec
Perspe' +
'ctive F1...............: Show/Hide This
Help'#13#10'A..............' +
'..: Show/Hide Axis W................: Show/Hide "Waterli' +
'ne"'
end
object Chart3D: TChart
Left = 0
Top = 64
Width = 792
Height = 509
BackWall.Color = 8454143
BackWall.Pen.Color = 4210752
BottomWall.Color = 8454143
BottomWall.Pen.Color = 4210752
LeftWall.Pen.Color = 4210752
LeftWall.Transparent = True
Legend.Visible = False
MarginBottom = 1
MarginLeft = 1
MarginRight = 2
MarginTop = 2
RightWall.Color = clBlack
RightWall.Pen.Color = 4210752
Title.Text.Strings = (
'TChart')
Title.Visible = False
BottomAxis.Axis.Color = 2105376
BottomAxis.ExactDateTime = False
BottomAxis.Grid.Color = 2105376
BottomAxis.Grid.Style = psSolid
BottomAxis.LabelsFont.Color = clGray
BottomAxis.LabelsOnAxis = False
BottomAxis.LabelsSeparation = 100
Chart3DPercent = 100
ClipPoints = False
DepthAxis.Axis.Color = 2105376
DepthAxis.ExactDateTime = False
DepthAxis.Grid.Color = 2105376
DepthAxis.Grid.Style = psSolid
DepthAxis.LabelsFont.Color = clGray
DepthAxis.LabelsOnAxis = False
DepthAxis.LabelsSeparation = 100
DepthAxis.RoundFirstLabel = False
DepthAxis.Visible = True
Frame.Color = 4210752
LeftAxis.Axis.Color = 2105376
LeftAxis.Axis.Width = 3
LeftAxis.ExactDateTime = False
LeftAxis.Grid.Color = 2105376
LeftAxis.Grid.Style = psSolid
LeftAxis.LabelsFont.Color = clGray
LeftAxis.LabelsOnAxis = False
LeftAxis.LabelsSeparation = 100
View3DOptions.Elevation = 334
View3DOptions.Orthogonal = False
View3DOptions.Perspective = 50
View3DOptions.Rotation = 301
View3DOptions.VertOffset = -166
View3DOptions.Zoom = 31
View3DOptions.ZoomText = False
View3DWalls = False
Zoom.Allow = False
Align = alClient
BevelOuter = bvNone
Color = clBlack
TabOrder = 0
OnDblClick = Chart3DDblClick
OnKeyDown = Chart3DKeyDown
object MainSeries: TSurfaceSeries
Marks.ArrowLength = 8
Marks.Callout.Brush.Color = clBlack
Marks.Callout.Length = 8
Marks.Visible = False
SeriesColor = clRed
EndColor = clBlack
MidColor = 8454143
NumXValues = 20
NumZValues = 20
Pen.Color = 2105376
SideBrush.Color = clWhite
SideBrush.Style = bsClear
StartColor = clRed
XValues.Name = 'X'
YValues.Name = 'Y'
ZValues.Name = 'Z'
end
end
object TeeOpenGL1: TTeeOpenGL
Active = True
AmbientLight = 63
Light.Color = 10526880
Light.Visible = True
Light.Position.X = -100
Light.Position.Y = -100
Light.Position.Z = -100
Light1.Color = clGray
Light1.Visible = False
Light1.Position.X = -100
Light1.Position.Y = -100
Light1.Position.Z = -100
Light2.Color = clGray
Light2.Visible = False
Light2.Position.X = -100
Light2.Position.Y = -100
Light2.Position.Z = -100
Shininess = 1
TeePanel = Chart3D
Left = 40
Top = 39
end
object ChartEditor1: TChartEditor
Chart = Chart3D
Series = MainSeries
Left = 144
Top = 132
end
end


Back to top
David Berneda
Guest





PostPosted: Fri Oct 31, 2003 6:47 pm    Post subject: Re: TChart OpenGL Rendering Reply with quote



Hi Anderson
While developing TeeChart v7 (now in beta),
I fixed a bug that I think is the same you describe.
The problem is when the lines are dotted, and only when using 32 bit per pixel
video mode.

The fix is to change the last parameter at TeeGLCanvas.pas unit, from "0" to "1"

HRC:=CreateRenderingContext(GetDCHandle,[opDoubleBuffered],24,1); // 7.0

If you wish the updated code, apply for v7 beta:

http://www.steema.com/support/teechart/7/beta_testing.html

regards
david berneda
www.teechart.com



"Anderson Carli" <acarli at bol com br> wrote

Quote:
Hi Teechart People!
We are users of TChart that comes with Delphi and we are considering to buy
Teechart Pro 6
mainly because the OpenGL capabilities
But seems that are some problems on rendering an OpenGL chart.
I make some tests with trial version, and I'm sending a sample of what I
think is a bug.
Look as the "Waterline's" grid and Axis grid dont hide when are behind
series.

You can rotate/elevate the chart with Arrow keys,
Use "A" to show/hide Axis and "W" to show/hide Waterline
Another issue: Zoom proprotions are not the same between OpenGL
and standard 3D canvas. see this turning on/off openGL with "G" Key

To test this app Create a new project, Past Form1 Code, view form as Text an
past form's text.

I tested this with nVidia Gforce and with default Windows XP Open GL without
3d board.

PS: I think this test application could be very nice interactive demo to be
put
inside of main Example App. If it works right ;-)

// Form1 Code //

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, TeeSurfa, StdCtrls, ExtCtrls, TeeProcs, Chart,
TeeOpenGL, F10Debug, TeeEdit;

type
TForm1 = class(TForm)
TeeOpenGL1: TTeeOpenGL;
Chart3D: TChart;
MainSeries: TSurfaceSeries;
HelpLabel: TLabel;
ChartEditor1: TChartEditor;
procedure Chart3DKeyDown(Sender: TObject; var Key: Word; Shift:
TShiftState);
procedure FormCreate(Sender: TObject);
procedure Chart3DDblClick(Sender: TObject);
public
WaterLine: TSurfaceSeries;
end;

var
Form1: TForm1;

const
VK_A = 65; VK_B = 66; VK_C = 67; VK_D = 68; VK_E = 69; VK_F = 70; VK_G =
71;
VK_H = 72; VK_I = 73; VK_J = 74; VK_K = 75; VK_L = 76; VK_M = 77; VK_N =
78;
VK_O = 79; VK_P = 80; VK_Q = 81; VK_R = 82; VK_S = 83; VK_T = 84; VK_U =
85;
VK_V = 86; VK_W = 87; VK_X = 88; VK_Y = 89; VK_Z = 90;

implementation

{$R *.dfm}

function IncAngle(Angle:Integer; Degrees:Integer=1):Integer;
begin
Result := Angle + Degrees;
if Result > 360 then Result := Result-360;
end;

function DecAngle(Angle:Integer; Degrees:Integer=1):Integer;
begin
Result := Angle - Degrees;
if Result < 0 then Result := 360+Result;
end;

function IncLimit(Value:Integer; Limit:Integer=100; Inc:Integer=1):Integer;
begin
Result := Value + Inc;
if Result > Limit then Result := Limit;
end;

function DecLimit(Value:Integer; Limit:Integer=100; Dec:Integer=1):Integer;
begin
Result := Value - Dec;
if Result < Limit then Result := Limit;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
x,z:Integer;
begin
Chart3d.BufferedDisplay := True;
MainSeries.FillSampleValues(30);

WaterLine := TSurfaceSeries(Chart3d.AddSeries(TSurfaceSeries));
WaterLine.BeginUpdate;
try
WaterLine.SeriesColor := clBlue;
WaterLine.UseColorRange := False;
WaterLine.Transparency := 40;
for x := 0 to 31 do
for z := 0 to 31 do
WaterLine.AddXYZ(x,0,z);
// for x := 0 to 32 do
// WaterLine.AddXYZ(x,-0.8,0);
// for z := 0 to 32 do
// WaterLine.AddXYZ(32,-0.8,z);
finally
WaterLine.EndUpdate;
end;
end;

procedure TForm1.Chart3DDblClick(Sender: TObject);
begin
ChartEditor1.Execute;
end;

procedure TForm1.Chart3DKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
with Chart3d, View3DOptions do begin
if ssShift in Shift then
case key of
VK_LEFT: HorizOffset := DecLimit(HorizOffset, -1000, 10);
VK_RIGHT: HorizOffset := IncLimit(HorizOffset, 1000, 10);
VK_UP: VertOffset := DecLimit(VertOffset, -1000, 10);
VK_DOWN: VertOffset := IncLimit(VertOffset, 1000, 10);
end
else
case key of
VK_RIGHT: Rotation := IncAngle(Rotation, 2);
VK_LEFT: Rotation := DecAngle(Rotation, 2);
VK_UP: Elevation := IncAngle(Elevation,2);
VK_DOWN: Elevation := DecAngle(Elevation,2);
VK_A: Chart3d.AxisVisible := not Chart3d.AxisVisible;
VK_Z: Zoom := IncLimit(Zoom, 500, 2);
VK_X: Zoom := DecLimit(Zoom, 1, 2);
VK_P: Perspective := IncLimit(Perspective, 100, 2);
VK_O: Perspective := DecLimit(Perspective, 0, 2);
VK_G: TeeOpenGL1.Active := not TeeOpenGL1.Active;
VK_W: WaterLine.Visible := not WaterLine.Visible;
VK_F1: HelpLabel.Visible := not HelpLabel.Visible;
end;
end;
end;

end.

// Form's Text //

object Form1: TForm1
Left = 348
Top = 79
Width = 800
Height = 600
Caption = 'Form1'
Color = clBtnFace
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Courier New'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnKeyDown = Chart3DKeyDown
PixelsPerInch = 96
TextHeight = 16
object HelpLabel: TLabel
Left = 0
Top = 0
Width = 792
Height = 64
Align = alTop
Caption =
'Left/Right Arrows: Rotate Chart Shift Arrows.....: Hor' +
'iz/Vert Offset Move'#13#10'G................: Turn OpenGLOn/Off
Z' +
'/X..............: Zoom in/out'#13#10'P/O..............: Inc/Dec
Perspe' +
'ctive F1...............: Show/Hide This
Help'#13#10'A..............' +
'..: Show/Hide Axis W................: Show/Hide "Waterli' +
'ne"'
end
object Chart3D: TChart
Left = 0
Top = 64
Width = 792
Height = 509
BackWall.Color = 8454143
BackWall.Pen.Color = 4210752
BottomWall.Color = 8454143
BottomWall.Pen.Color = 4210752
LeftWall.Pen.Color = 4210752
LeftWall.Transparent = True
Legend.Visible = False
MarginBottom = 1
MarginLeft = 1
MarginRight = 2
MarginTop = 2
RightWall.Color = clBlack
RightWall.Pen.Color = 4210752
Title.Text.Strings = (
'TChart')
Title.Visible = False
BottomAxis.Axis.Color = 2105376
BottomAxis.ExactDateTime = False
BottomAxis.Grid.Color = 2105376
BottomAxis.Grid.Style = psSolid
BottomAxis.LabelsFont.Color = clGray
BottomAxis.LabelsOnAxis = False
BottomAxis.LabelsSeparation = 100
Chart3DPercent = 100
ClipPoints = False
DepthAxis.Axis.Color = 2105376
DepthAxis.ExactDateTime = False
DepthAxis.Grid.Color = 2105376
DepthAxis.Grid.Style = psSolid
DepthAxis.LabelsFont.Color = clGray
DepthAxis.LabelsOnAxis = False
DepthAxis.LabelsSeparation = 100
DepthAxis.RoundFirstLabel = False
DepthAxis.Visible = True
Frame.Color = 4210752
LeftAxis.Axis.Color = 2105376
LeftAxis.Axis.Width = 3
LeftAxis.ExactDateTime = False
LeftAxis.Grid.Color = 2105376
LeftAxis.Grid.Style = psSolid
LeftAxis.LabelsFont.Color = clGray
LeftAxis.LabelsOnAxis = False
LeftAxis.LabelsSeparation = 100
View3DOptions.Elevation = 334
View3DOptions.Orthogonal = False
View3DOptions.Perspective = 50
View3DOptions.Rotation = 301
View3DOptions.VertOffset = -166
View3DOptions.Zoom = 31
View3DOptions.ZoomText = False
View3DWalls = False
Zoom.Allow = False
Align = alClient
BevelOuter = bvNone
Color = clBlack
TabOrder = 0
OnDblClick = Chart3DDblClick
OnKeyDown = Chart3DKeyDown
object MainSeries: TSurfaceSeries
Marks.ArrowLength = 8
Marks.Callout.Brush.Color = clBlack
Marks.Callout.Length = 8
Marks.Visible = False
SeriesColor = clRed
EndColor = clBlack
MidColor = 8454143
NumXValues = 20
NumZValues = 20
Pen.Color = 2105376
SideBrush.Color = clWhite
SideBrush.Style = bsClear
StartColor = clRed
XValues.Name = 'X'
YValues.Name = 'Y'
ZValues.Name = 'Z'
end
end
object TeeOpenGL1: TTeeOpenGL
Active = True
AmbientLight = 63
Light.Color = 10526880
Light.Visible = True
Light.Position.X = -100
Light.Position.Y = -100
Light.Position.Z = -100
Light1.Color = clGray
Light1.Visible = False
Light1.Position.X = -100
Light1.Position.Y = -100
Light1.Position.Z = -100
Light2.Color = clGray
Light2.Visible = False
Light2.Position.X = -100
Light2.Position.Y = -100
Light2.Position.Z = -100
Shininess = 1
TeePanel = Chart3D
Left = 40
Top = 39
end
object ChartEditor1: TChartEditor
Chart = Chart3D
Series = MainSeries
Left = 144
Top = 132
end
end





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Reporting-Charting All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.