{********************************************}
{ TBubbleCloudSeries Editor Dialog           }
{ Copyright (c) 2000-2020 by Steema Software }
{********************************************}
unit TeeBubbleCloudEdit;
{$I TeeDefs.inc}

interface

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

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

     Chart, TeeSurfa, TeCanvas, TeePenDlg, TeeProcs;

type
  TBubbleCloudEditor = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabBorder: TTabSheet;
    TabBrush: TTabSheet;
    Label1: TLabel;
    TBTransp: TTrackBar;
    LTransp: TLabel;
    Label2: TLabel;
    TBRotation: TTrackBar;
    LRotation: TLabel;
    Label3: TLabel;
    TBSeparation: TTrackBar;
    LSeparation: TLabel;
    CBUnits: TComboFlat;
    Label4: TLabel;
    TBRatio: TTrackBar;
    LSizeRatio: TLabel;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
    procedure TBRotationChange(Sender: TObject);
    procedure TBSeparationChange(Sender: TObject);
    procedure CBUnitsChange(Sender: TObject);
    procedure TBRatioChange(Sender: TObject);
  private
    { Private declarations }
  protected
    Grid3DForm : TCustomForm;
    Series     : TBubbleCloudSeries;
  public
    { Public declarations }
  end;

implementation

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

Uses
  TeeBrushDlg, TeeGriEd;

procedure TBubbleCloudEditor.FormShow(Sender: TObject);
begin
  Series:=TBubbleCloudSeries(Tag);

  if Assigned(Series) then
  begin
    With Series do
    begin
      TBRotation.Position:=Rotation;
      LRotation.Caption:=IntToStr(Rotation);

      TBSeparation.Position:=Separation;
      LSeparation.Caption:=IntToStr(Separation);

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

      CBUnits.ItemIndex:=Ord(SeparationUnits);

      TBRatio.Position:=Round(SizeRatio*100);
      LSizeRatio.Caption:=FloatToStr(SizeRatio);
    end;

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

procedure TBubbleCloudEditor.FormCreate(Sender: TObject);
begin
  BorderStyle:=TeeBorderStyle;
  PageControl1.ActivePageIndex:=0;
end;

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

procedure TBubbleCloudEditor.PageControl1Change(Sender: TObject);
begin
  if PageControl1.ActivePage.ControlCount=0 then
     if PageControl1.ActivePage=TabBorder then
        TPenDialog.InsertForm(Series.Pen,TabBorder)
     else
     if PageControl1.ActivePage=TabBrush then
        TBrushDialog.AddDialog(Series.Brush,TabBrush);
end;

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

procedure TBubbleCloudEditor.TBRotationChange(Sender: TObject);
begin
  if Showing then
  begin
    Series.Rotation:=TBRotation.Position;
    LRotation.Caption:=IntToStr(Series.Rotation);
  end;
end;

procedure TBubbleCloudEditor.TBSeparationChange(Sender: TObject);
begin
  if Showing then
  begin
    Series.Separation:=TBSeparation.Position;
    LSeparation.Caption:=IntToStr(Series.Separation);
  end;
end;

procedure TBubbleCloudEditor.CBUnitsChange(Sender: TObject);
begin
  if Showing then
     Series.SeparationUnits:=TTeeUnits(CBUnits.ItemIndex);
end;

procedure TBubbleCloudEditor.TBRatioChange(Sender: TObject);
begin
  if Showing then
  begin
    Series.SizeRatio:=(TBRatio.Position*0.01);
    LSizeRatio.Caption:=FloatToStr(Series.SizeRatio);
  end;
end;

initialization
  RegisterClass(TBubbleCloudEditor);
end.
