unit FMXTee.Editor.Series.Surface;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMXTee.Chart.ListBox,
  FMX.TabControl, FMXTee.Series.Surface, FMX.Edit, FMX.ListBox, FMX.Colors,
  FMXTee.Procs, FMX.Layouts, FMX.Grid, FMXTee.Chart.Grid;

type
  TSurfaceSeriesEditor = class(TForm)
    TabControl1: TTabControl;
    TabGlobal: TTabItem;
    CBSmoothPalette: TCheckBox;
    BPen: TButton;
    BBrush: TButton;
    UDSurfaceTransp: TSpinBox;
    Label6: TLabel;
    TabGrid3D: TTabItem;
    GroupBox1: TGroupBox;
    rbWireFrame: TRadioButton;
    rbDotFrame: TRadioButton;
    BSideBrush: TButton;
    BSideLines: TButton;
    CBFastBrush: TCheckBox;
    CBHideCells: TCheckBox;
    rbSolid: TRadioButton;
    procedure FormActivate(Sender: TObject);
    procedure CBSmoothPaletteChange(Sender: TObject);
    procedure BPenClick(Sender: TObject);
    procedure BBrushClick(Sender: TObject);
    procedure UDSurfaceTranspChange(Sender: TObject);
    procedure BSideLinesClick(Sender: TObject);
    procedure rbSolidChange(Sender: TObject);
    procedure rbWireFrameChange(Sender: TObject);
    procedure rbDotFrameChange(Sender: TObject);
    procedure BSideBrushClick(Sender: TObject);
    procedure CBHideCellsChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure CBFastBrushChange(Sender: TObject);
  private
    { Private declarations }
  protected
    Grid3DForm : TCustomForm;
    Surface    : TSurfaceSeries;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Editor.Stroke, FMXTee.Editor.Brush, FMXTee.Editor.Series.Grid;

procedure TSurfaceSeriesEditor.CBFastBrushChange(Sender: TObject);
begin
  if assigned(Surface) then
    Surface.FastBrush:=CBFastBrush.IsChecked;
end;

procedure TSurfaceSeriesEditor.CBHideCellsChange(Sender: TObject);
begin
  if assigned(Surface) then
  begin
    Surface.HideCells:=CBHideCells.IsChecked;
    Surface.Repaint;
  end;
end;

procedure TSurfaceSeriesEditor.CBSmoothPaletteChange(Sender: TObject);
begin
  if assigned(Surface) then
    Surface.SmoothPalette:=CBSmoothPalette.IsChecked;
end;

procedure TSurfaceSeriesEditor.BBrushClick(Sender: TObject);
begin
  if Assigned (Surface) then
    TBrushEditor.Edit(Self, Surface.Brush)
end;

procedure TSurfaceSeriesEditor.BPenClick(Sender: TObject);
begin
  if Assigned(Surface) then
    TStrokeEditor.Edit(Self, Surface.Pen);
end;

procedure TSurfaceSeriesEditor.BSideBrushClick(Sender: TObject);
begin
  if Assigned (Surface) then
    TBrushEditor.Edit(Self, Surface.SideBrush)
end;

procedure TSurfaceSeriesEditor.BSideLinesClick(Sender: TObject);
begin
  if Assigned(Surface) then
    TStrokeEditor.Edit(Self, Surface.SideLines);
end;

procedure TSurfaceSeriesEditor.FormActivate(Sender: TObject);
begin
  if not Assigned(Surface) then
  begin
    Surface:=TSurfaceSeries(TagObject);

    if Assigned(Surface) then
    With Surface do
    begin
      if WireFrame then
         rbWireFrame.IsChecked:=True
      else if DotFrame then
         rbDotFrame.IsChecked:=True
      else
         rbSolid.IsChecked:=True;

      CBSmoothPalette.IsChecked:=SmoothPalette;
      UDSurfaceTransp.Value:=Transparency;
      CBFastBrush.IsChecked:=FastBrush;
      CBHideCells.IsChecked:=HideCells;

      TGrid3DSeriesEditor.CreateEmbedd(Self,Surface,TabGrid3D);
    end;
  end;
end;

procedure TSurfaceSeriesEditor.FormDestroy(Sender: TObject);
begin
  FreeAndNil(Grid3DForm);
end;

procedure TSurfaceSeriesEditor.rbDotFrameChange(Sender: TObject);
begin
  if Assigned(Surface) then
    Surface.DotFrame:=True;
end;

procedure TSurfaceSeriesEditor.rbSolidChange(Sender: TObject);
begin
  if Assigned(Surface) then
  begin
    Surface.DotFrame:=False;
    Surface.WireFrame:=False;
  end;
end;

procedure TSurfaceSeriesEditor.rbWireFrameChange(Sender: TObject);
begin
  if Assigned(Surface) then
    Surface.WireFrame:=True;
end;

procedure TSurfaceSeriesEditor.UDSurfaceTranspChange(Sender: TObject);
begin
  if Assigned(Surface) then
    Surface.Transparency:=Round(UDSurfaceTransp.Value);
end;

initialization
  RegisterSeriesEditor(TSurfaceSeriesEditor);
end.
