AXTutorial16

From Steema Software Reference Wiki
Jump to: navigation, search

Ax.png

Contents page
Previous | Next

Tutorial 16 - Chart 3D and OpenGL

Chart display modes

(3D) Chart Editor page

You may define the major 2D/3D display options with the Chart Editor at design time.

EDIT3D.png

2D Chart

The 2D Chart may be selected at design time using the Chart Editor. Deselecting the 3D checkbox on the Editor page puts the Chart in 2D mode. At runtime you can change the Chart to 2D at any time with:


TChart1.Aspect.View3D = False

Working with the 2D Chart presents no special issues. All object co-ordinates are positions relative to the Chart panel or Chart rectangle, there is no need to make any allowance for 3D offset (see following sections).

3D Orthogonal Chart

3D Orthogonal mode is the default way to obtain 3D 'effect'. TeeChart draws depth effect at an orthogonal angle according to the Chart1.Aspect.Chart3DPercent property setting (also available at design time on the Chart Editor page). You cannot rotate a 3D Orthogonal Chart, the Bottom Axis is always horizontal.

When working with 3D orthogonal Charts you will need to take into account the Width3D and Height3D 3D offset when custom drawing to the Canvas. If you wish an item to be drawn to be flush with the Chart Backwall you should add the offset. See the following examples:

Example


Private Sub TChart1_OnAfterDraw()
'This example draws a diagonal line across the Chart
'flush to the Front of the Chart
With TChart1
  'Move the pointer to the top left Chart point
  .Canvas.MoveTo .Axis.Left.Position, .Axis.Top.Position
  'Draw the Line
  .Canvas.LineTo .Axis.Right.Position, .Axis.Bottom.Position
End With

'This example draws a diagonal line across the Chart
'flush to the Back of the Chart
With TChart1
  'Move the pointer to the top left Chart point
  .Canvas.MoveTo .Axis.Left.Position   .Aspect.Width3D, .Axis.Top.Position - .Aspect.Height3D
  'Draw the Line
  .Canvas.LineTo .Axis.Right.Position   .Aspect.Width3D, .Axis.Bottom.Position - .Aspect.Height3D
End With
End Sub


Use the Aspect interface when working with display properties for 3D Charts at runtime (*Note. Not all options are available for Orthogonal Charts).

3D "Native" Windows Chart

This 3D mode offers many of the display advantages obtainable with OpenGL but is faster. Native Windows mode 3D offers Chart rotation and elevation through 90�. You may Zoom in and out on the overall Chart (Zoom within the Chart is available too, see the [tutorial11.htm Zoom/Scroll] tutorial).

Select Native Windows mode 3D for TeeChart at design time by deselecting the Orthogonal checkbox on the 3D Editor page.


//Runtime
TChart1.Aspect.Orthogonal = False

In the Chart Editor, disactivating Orthogonal will simultaneously activate the slide bars for Elevation and Rotation allowing design time changes for these display properties.

For a closer look at the definition of the TeeChart Canvases look at the [tutorial13.htm#Advanced Custom drawing tutorial].


3D OpenGL Chart

You can convert the 3D Chart to an OpenGL Chart by using the OpenGL Boolean property found below the Aspect interface.


TChart1.Aspect.OpenGL.Active = True

You will see the Chart immediately convert to OpenGL at runtime.


Chart Editor and OpenGL

The Chart Editor will show the OpenGL Editor page when OpenGL is Active. If you require the OpenGL page to be permanently visible and for the application user to be able to activate/disactivate the Chart's OpenGL view mode, you should use the TeeEditor component which includes the page as default. If you are using the TeeEditor and require the OpenGL page to be hidden, you should set the TeeEditor.ShowPages.OpenGL property to false.

Example


' This example associates the TeeCommander Editor with
' a TeeEditor component to edit TChart1.
' The OpenGL page is hidden
TeeCommander1.Chart = TChart1
TeeCommander1.Editor = TeeEditor1
TeeEditor1.Chart = TChart1
TeeEditor1.ShowPages.OpenGL = False


OpenGL driver support

To use OpenGL support at designtime or runtime, be sure to have OpenGL enabled in the Windows machine. The standard Microsoft dll, OpenGL32.dll, is normally located in the Windows\System folder in the case of Windows95 and Windows98 and in the Winnt\System32 folder in the case of Windows NT.

Alternative OpenGL drivers are available form Silicon Graphics, www.sgi.com, both for NT and Windows 95/98.
Depending on your CPU and video hardware, it may be that the OpenGL dll's from Silicon Graphics are faster than the ones from Microsoft.


For a closer look at the definition of the TeeChart Canvases look at the [tutorial13.htm#Advanced Custom drawing tutorial].



PREVIOUS

NEXT


© 1998-2019 Steema Software SL. All rights reserved.