{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Series.IsoSurface;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMXTee.Editor.Series.Surface,
  FMX.Edit, FMX.TabControl, FMXTee.Series.Surface, FMXTee.Editor.Stroke, FMXTee.Canvas,
  FMX.StdCtrls;

type
  TIsoSurfaceSeriesEditor = class(TSurfaceSeriesEditor)
    TabBands: TTabItem;
    GroupBox2: TGroupBox;
    EYPosition: TEdit;
    CBUseY: TCheckBox;
    procedure FormActivate(Sender: TObject);
    procedure CBUseYChange(Sender: TObject);
    procedure EYPositionChange(Sender: TObject);
    procedure TabControl1Change(Sender: TObject);
  private
    { Private declarations }
    IModifying : Boolean;
    FBandPen : TStrokeEditor;
  public
    { Public declarations }
  end;

var
  IsoSurfaceSeriesEditor: TIsoSurfaceSeriesEditor;

implementation

{$R *.fmx}

uses
  FMXTee.Chart, FMXTee.ProConstants;

procedure TIsoSurfaceSeriesEditor.CBUseYChange(Sender: TObject);
begin
  inherited;
  if not IModifying then
  begin
    TIsoSurfaceSeries(Surface).UseYPosition:=CBUseY.IsChecked;
    EYPosition.Enabled:=CBUseY.IsChecked;
  end;
end;

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

procedure TIsoSurfaceSeriesEditor.FormActivate(Sender: TObject);
begin
  inherited;

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

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

    IModifying:=False;
  end;
end;

procedure TIsoSurfaceSeriesEditor.TabControl1Change(Sender: TObject);
begin
  inherited;
  if (TabControl1.ActiveTab=TabBands) and (not Assigned(FBandPen)) then
     FBandPen:=TStrokeEditor.InsertForm(TIsoSurfaceSeries(Surface).BandPen,TabBands);
end;

initialization
  RegisterClass(TIsoSurfaceSeriesEditor);
end.
