unit Vis3D_GridSettings;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, TextEditor, Vcl.StdCtrls, rgl,
  UxPanel, Vcl.ExtCtrls, ColorContainer, ScrollBoxEx, Vis3D_GeoObjSettings;

type
  TVis3D_GridSettingsFrm = class(TDrawableOptionsFrm3D)
    btnApply: TUxButton;
    ScrollBox1: TScrollBoxEx;
    pnTransforms: TPanel;
    lblGridSettings: TLabel;
    eumin: TTextEditor;
    eumax: TTextEditor;
    lblFirst: TLabel;
    eustep: TTextEditor;
    evstep: TTextEditor;
    evmax: TTextEditor;
    evmin: TTextEditor;
    lblSecond: TLabel;
    lblMin: TLabel;
    lblMax: TLabel;
    lblStep: TLabel;
    cbVisible: TCheckBox;
    procedure btnApplyClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure cbVisibleClick(Sender: TObject);
  strict private
    FTransforms: TVis3D_GeoObjSettingsFrm;
  public
    procedure Initialize; override;
    procedure UpdateDrawable; override;
  end;

implementation

{$R *.dfm}

procedure TVis3D_GridSettingsFrm.btnApplyClick(Sender: TObject);
begin
  UpdateDrawable;
end;

procedure TVis3D_GridSettingsFrm.cbVisibleClick(Sender: TObject);
begin
  UpdateDrawable;
end;

procedure TVis3D_GridSettingsFrm.FormCreate(Sender: TObject);
begin

  FTransforms := TVis3D_GeoObjSettingsFrm.Create(Self, FDrawable);
  FTransforms.Parent := pnTransforms;
  FTransforms.BorderStyle := bsNone;
  FTransforms.Customize(True, True, False);
  FTransforms.Show;
  pnTransforms.Width := FTransforms.Width;
  pnTransforms.Height := FTransforms.Height;
  FTransforms.Align := alClient;

end;

procedure TVis3D_GridSettingsFrm.Initialize;
begin
  inherited;
  var Obj := FDrawable as TGrid;
  cbVisible.Checked := Obj.Visible;
  eumin.PlainText := FormatFloat('0.####', Obj.XMin);
  eumax.PlainText := FormatFloat('0.####', Obj.XMax);
  eustep.PlainText := FormatFloat('0.####', Obj.XDelta);
  evmin.PlainText := FormatFloat('0.####', Obj.YMin);
  evmax.PlainText := FormatFloat('0.####', Obj.YMax);
  evstep.PlainText := FormatFloat('0.####', Obj.YDelta);
end;

procedure TVis3D_GridSettingsFrm.UpdateDrawable;
begin
  if not FInitialized then
    Exit;
  var Obj := FDrawable as TGrid;
  Obj.Visible := cbVisible.Checked;
  Obj.XMin := StrToFloat(eumin.PlainText);
  Obj.XMax := StrToFloat(eumax.PlainText);
  Obj.XDelta := StrToFloat(eustep.PlainText);
  Obj.YMin := StrToFloat(evmin.PlainText);
  Obj.YMax := StrToFloat(evmax.PlainText);
  Obj.YDelta := StrToFloat(evstep.PlainText);
  if Assigned(FTransforms) then
    FTransforms.UpdateDrawable;
  inherited;
end;

end.
