{**********************************************}
{   TTriSurfaceSeries Editor Dialog            }
{   Copyright (c) 1996-2020 by Steema Software }
{**********************************************}
unit TeeTriSurfEdit;
{$I TeeDefs.inc}

interface

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

     Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,

     Chart, TeeSurfa, TeeTriSurface, TeCanvas, TeePenDlg, TeeProcs;

type
  TTriSurfaceSeriesEditor = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabBorder: TTabSheet;
    TabPattern: TTabSheet;
    TabOutline: TTabSheet;
    LHeight: TLabel;
    CBFastBrush: TCheckBox;
    CBHide: TCheckBox;
    TBTransp: TTrackBar;
    LTransp: TLabel;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CBFastBrushClick(Sender: TObject);
    procedure CBHideClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
    Surface : TTriSurfaceSeries;
    Grid3DForm : TCustomForm;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeBrushDlg, TeeGriEd;

procedure TTriSurfaceSeriesEditor.FormShow(Sender: TObject);
begin
  Surface:=TTriSurfaceSeries(Tag);

  if Assigned(Surface) then
  begin
    CBFastBrush.Checked:=Surface.FastBrush;
    CBHide.Checked:=Surface.HideTriangles;

    TBTransp.Position:=Surface.Transparency;
    LTransp.Caption:=IntToStr(Surface.Transparency);

    if not Assigned(Grid3DForm) then
       Grid3DForm:=TeeInsertGrid3DForm(Parent,Surface);
  end;
end;

procedure TTriSurfaceSeriesEditor.FormCreate(Sender: TObject);
begin
  BorderStyle:=TeeBorderStyle;
end;

procedure TTriSurfaceSeriesEditor.CBFastBrushClick(Sender: TObject);
begin
  Surface.FastBrush:=CBFastBrush.Checked;
end;

procedure TTriSurfaceSeriesEditor.CBHideClick(Sender: TObject);
begin
  Surface.HideTriangles:=CBHide.Checked;
end;

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

procedure TTriSurfaceSeriesEditor.TBTranspChange(Sender: TObject);
begin
  if Showing then
  begin
    Surface.Transparency:=TBTransp.Position;
    LTransp.Caption:=IntToStr(Surface.Transparency);
  end;
end;

procedure TTriSurfaceSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabBorder) and (TabBorder.ControlCount=0) then
     TPenDialog.InsertForm(Surface.Pen,TabBorder)
  else
  if (PageControl1.ActivePage=TabPattern) and (TabPattern.ControlCount=0) then
     TBrushDialog.AddDialog(Surface.Brush,TabPattern)
  else
  if (PageControl1.ActivePage=TabOutline) and (TabOutline.ControlCount=0) then
     TPenDialog.InsertForm(Surface.Border,TabOutline);
end;

initialization
  RegisterClass(TTriSurfaceSeriesEditor);
end.
