{********************************************}
{ TeeChart Pro Charting Library              }
{ IsoSurface (Surface+Color Banding) Series  }
{ Copyright (c) 2006-2020 by Steema Software }
{ All Rights Reserved                        }
{********************************************}
unit TeeIsoSurface;
{$I TeeDefs.inc}

interface

uses
  {$IFNDEF LINUX}
  Windows,
  {$ENDIF}
  Classes,

  ComCtrls, StdCtrls, Controls, ExtCtrls, Forms,

  TeeSurfa, TeeSurfEdit, TeePenDlg, TeCanvas;

type
  TIsoSurfaceEditor = class(TSurfaceSeriesEditor)
    GroupBox1: TGroupBox;
    CBUseY: TCheckBox;
    EYPosition: TEdit;
    TabBands: TTabSheet;
    procedure FormShow(Sender: TObject);
    procedure CBUseYClick(Sender: TObject);
    procedure EYPositionChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
    IModifying : Boolean;
  public
    { Public declarations }
  end;

implementation

{$IFNDEF LCL}
{$R *.DFM}
{$ELSE}
{$R *.lfm}
{$ENDIF}

uses
  Chart, TeeProCo, SysUtils;

procedure TIsoSurfaceEditor.FormShow(Sender: TObject);
begin
  inherited;

  if Assigned(Surface) then
  begin
    IModifying:=True;

    CBUseY.Checked:=TIsoSurfaceSeries(Surface).UseYPosition;
    EYPosition.Text:=FormatFloat(Surface.ValueFormat, TIsoSurfaceSeries(Surface).YPosition);
    EYPosition.Enabled:=CBUseY.Checked;

    IModifying:=False;
  end;
end;

procedure TIsoSurfaceEditor.CBUseYClick(Sender: TObject);
begin
  if not IModifying then
  begin
    TIsoSurfaceSeries(Surface).UseYPosition:=CBUseY.Checked;
    EYPosition.Enabled:=CBUseY.Checked;
  end;
end;

procedure TIsoSurfaceEditor.EYPositionChange(Sender: TObject);
begin
  if not IModifying then
     TIsoSurfaceSeries(Surface).YPosition:=StrToFloat(EYPosition.Text);
end;

procedure TIsoSurfaceEditor.PageControl1Change(Sender: TObject);
begin
  inherited;

  if (PageControl1.ActivePage=TabBands) and (TabBands.ControlCount=0) then
     TPenDialog.InsertForm(TIsoSurfaceSeries(Surface).BandPen,TabBands);
end;

initialization
  RegisterClass(TIsoSurfaceEditor);
end.
