{**********************************************}
{   TPoint3DSeries Component Editor Dialog     }
{   Copyright (c) 1998-2020 by Steema Software }
{**********************************************}
unit TeePo3DEdit;
{$I TeeDefs.inc}

interface

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

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

     Chart, Series, TeePoin3, TeCanvas, TeePenDlg, TeeProcs;

type
  TPoint3DSeriesEditor = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabLine: TTabSheet;
    TabBaseLine: TTabSheet;
    Label4: TLabel;
    LTransp: TLabel;
    GPLine: TGroupBox;
    BColor: TButtonColor;
    CBColorEach: TCheckBox;
    SEPointDepth: TEdit;
    UDPointDepth: TUpDown;
    TBTransp: TTrackBar;
    procedure FormShow(Sender: TObject);
    procedure CBColorEachClick(Sender: TObject);
    procedure SEPointDepthChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
    Grid3DForm : TCustomForm;
    PointerForm : TCustomForm;
    TheSeries   : TPoint3DSeries;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeEngine, TeePoEdi, TeeGriEd, TeeConst;

procedure TPoint3DSeriesEditor.FormShow(Sender: TObject);
begin
  TheSeries:=TPoint3DSeries(Tag);

  if Assigned(TheSeries) then
  begin
    With TheSeries do
    Begin
      UDPointDepth.Position :=Round(DepthSize);
      CBColorEach.Checked:=ColorEachPoint;
      TBTransp.Position:=Transparency;
    end;

    BColor.LinkProperty(TheSeries,'SeriesColor');
    BColor.Enabled:=not TheSeries.ColorEachPoint;

    if not Assigned(PointerForm) then
       PointerForm:=TeeInsertPointerForm(Parent,TheSeries.Pointer,TeeMsg_GalleryPoint);

    if not Assigned(Grid3DForm) then
       Grid3DForm:=TeeInsertGrid3DForm(Parent,TheSeries)
    else
       TGrid3DSeriesEditor(Grid3DForm).RefreshControls(TheSeries);
  end;
end;

procedure TPoint3DSeriesEditor.CBColorEachClick(Sender: TObject);
begin
  TheSeries.ColorEachPoint:=CBColorEach.Checked;
  BColor.Enabled:=not TheSeries.ColorEachPoint;
end;

procedure TPoint3DSeriesEditor.SEPointDepthChange(Sender: TObject);
begin
  if Showing then
     TheSeries.DepthSize:=UDPointDepth.Position;
end;

procedure TPoint3DSeriesEditor.FormCreate(Sender: TObject);
begin
  Align:=alClient;
end;

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

procedure TPoint3DSeriesEditor.TBTranspChange(Sender: TObject);
begin
  TheSeries.Transparency:=TBTransp.Position;
end;

procedure TPoint3DSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabLine) and (TabLine.ControlCount=0) then
     TPenDialog.InsertForm(TheSeries.LinePen,TabLine)
  else
  if (PageControl1.ActivePage=TabBaseLine) and (TabBaseLine.ControlCount=0) then
     TPenDialog.InsertForm(TheSeries.BaseLine,TabBaseLine);
end;

initialization
  RegisterClass(TPoint3DSeriesEditor);
end.
