From 48e68e866ea465888cdc2c81ab6ef3a320de0b6c Mon Sep 17 00:00:00 2001 From: ask Date: Wed, 2 Mar 2011 14:04:52 +0000 Subject: [PATCH] TAChart: Add OpenGL demo git-svn-id: trunk@29707 - --- .gitattributes | 4 + components/tachart/demo/opengl/Main.lfm | 65 +++++++++++++ components/tachart/demo/opengl/Main.pas | 67 +++++++++++++ components/tachart/demo/opengl/opengldemo.lpi | 97 +++++++++++++++++++ components/tachart/demo/opengl/opengldemo.lpr | 20 ++++ 5 files changed, 253 insertions(+) create mode 100644 components/tachart/demo/opengl/Main.lfm create mode 100644 components/tachart/demo/opengl/Main.pas create mode 100644 components/tachart/demo/opengl/opengldemo.lpi create mode 100644 components/tachart/demo/opengl/opengldemo.lpr diff --git a/.gitattributes b/.gitattributes index abdc69f07c..7ac9b5e5fe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2378,6 +2378,10 @@ components/tachart/demo/multi/Main.lfm svneol=native#text/plain components/tachart/demo/multi/Main.pas svneol=native#text/pascal components/tachart/demo/multi/multidemo.lpi svneol=native#text/plain components/tachart/demo/multi/multidemo.lpr svneol=native#text/pascal +components/tachart/demo/opengl/Main.lfm svneol=native#text/plain +components/tachart/demo/opengl/Main.pas svneol=native#text/pascal +components/tachart/demo/opengl/opengldemo.lpi svneol=native#text/plain +components/tachart/demo/opengl/opengldemo.lpr svneol=native#text/pascal components/tachart/demo/print/Main.lfm svneol=native#text/plain components/tachart/demo/print/Main.pas svneol=native#text/pascal components/tachart/demo/print/printdemo.lpi svneol=native#text/plain diff --git a/components/tachart/demo/opengl/Main.lfm b/components/tachart/demo/opengl/Main.lfm new file mode 100644 index 0000000000..8003a737cc --- /dev/null +++ b/components/tachart/demo/opengl/Main.lfm @@ -0,0 +1,65 @@ +object Form1: TForm1 + Left = 308 + Height = 319 + Top = 132 + Width = 684 + Caption = 'Form1' + ClientHeight = 319 + ClientWidth = 684 + OnCreate = FormCreate + LCLVersion = '0.9.31' + object OpenGLControl1: TOpenGLControl + Left = 344 + Height = 319 + Top = 0 + Width = 340 + Align = alClient + AutoResizeViewport = True + OnPaint = OpenGLControl1Paint + end + object Chart1: TChart + Left = 0 + Height = 319 + Top = 0 + Width = 344 + AxisList = < + item + Marks.Frame.Style = psSolid + Marks.LabelBrush.Color = clYellow + Marks.LabelBrush.Style = bsSolid + Title.LabelFont.Orientation = 900 + end + item + Alignment = calBottom + end> + Foot.Brush.Color = clBtnFace + Foot.Font.Color = clBlue + Title.Brush.Color = clBtnFace + Title.Font.Color = clBlue + Title.Text.Strings = ( + 'Standard' + ) + Title.Visible = True + Align = alLeft + ParentColor = False + object Chart1LineSeries1: TLineSeries + LinePen.Color = clBlue + LinePen.Width = 3 + Source = RandomChartSource1 + end + object Chart1BarSeries1: TBarSeries + BarBrush.Color = clRed + Source = RandomChartSource1 + end + end + object RandomChartSource1: TRandomChartSource + PointsNumber = 10 + RandSeed = 1792875960 + XMax = 10 + XMin = 0 + YMax = 10 + YMin = 0 + left = 210 + top = 161 + end +end diff --git a/components/tachart/demo/opengl/Main.pas b/components/tachart/demo/opengl/Main.pas new file mode 100644 index 0000000000..72efaff0d4 --- /dev/null +++ b/components/tachart/demo/opengl/Main.pas @@ -0,0 +1,67 @@ +unit Main; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, OpenGLContext, SysUtils, FileUtil, Forms, Controls, Graphics, + Dialogs, TAGraph, TASeries, TASources, GL, GLU, TADrawerOpenGL, TADrawUtils; + +type + + { TForm1 } + + TForm1 = class(TForm) + Chart1: TChart; + Chart1BarSeries1: TBarSeries; + Chart1LineSeries1: TLineSeries; + OpenGLControl1: TOpenGLControl; + RandomChartSource1: TRandomChartSource; + procedure FormCreate(Sender: TObject); + procedure OpenGLControl1Paint(Sender: TObject); + private + procedure OnAppIdle(Sender: TObject; var Done: Boolean); + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +procedure TForm1.FormCreate(Sender: TObject); +begin + Application.AddOnIdleHandler(@OnAppIdle); +end; + +procedure TForm1.OnAppIdle(Sender: TObject; var Done: Boolean); +begin + Done:=false; + OpenGLControl1.Invalidate; +end; + +procedure TForm1.OpenGLControl1Paint(Sender: TObject); +var + d: IChartDrawer; +begin + glClearColor(1.0, 1.0, 1.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + with OpenGLControl1 do + gluOrtho2D(0, Width, Height, 0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + d := TOpenGLDrawer.Create(OpenGLControl1); + Chart1.Title.Text.Text := 'OpenGL'; + Chart1.Draw(d, Rect(0, 0, OpenGLControl1.Width, OpenGLControl1.Height)); + Chart1.Title.Text.Text := 'Standard'; + + OpenGLControl1.SwapBuffers; +end; + +end. + diff --git a/components/tachart/demo/opengl/opengldemo.lpi b/components/tachart/demo/opengl/opengldemo.lpi new file mode 100644 index 0000000000..beed2d52c2 --- /dev/null +++ b/components/tachart/demo/opengl/opengldemo.lpi @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/tachart/demo/opengl/opengldemo.lpr b/components/tachart/demo/opengl/opengldemo.lpr new file mode 100644 index 0000000000..3e5961badb --- /dev/null +++ b/components/tachart/demo/opengl/opengldemo.lpr @@ -0,0 +1,20 @@ +program opengldemo; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, lazopenglcontext, Main, tachartlazaruspkg; + +{$R *.res} + +begin + RequireDerivedFormResource := True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. +