LazStats: Inherit form of DistribUnit from TBasicStatsChartForm. Fix TabOrders.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7751 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-06 22:35:16 +00:00
parent 43dca206b2
commit d915a7428e
8 changed files with 183 additions and 263 deletions

View File

@@ -339,9 +339,6 @@ begin
); );
ParamsPanel.Constraints.MinHeight := VarList.Top + VarList.Constraints.MinHeight + ParamsPanel.Constraints.MinHeight := VarList.Top + VarList.Constraints.MinHeight +
ButtonBevel.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top; ButtonBevel.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Around*2;
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 200;
end; end;

View File

@@ -16,22 +16,22 @@ inherited BreakDownFrm: TBreakDownFrm
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 289 Left = 289
Top = 322 Top = 322
TabOrder = 8 TabOrder = 11
end end
inherited ComputeBtn: TButton inherited ComputeBtn: TButton
Left = 206 Left = 206
Top = 322 Top = 322
TabOrder = 9 TabOrder = 10
end end
inherited ResetBtn: TButton inherited ResetBtn: TButton
Left = 144 Left = 144
Top = 322 Top = 322
TabOrder = 10 TabOrder = 9
end end
inherited HelpBtn: TButton inherited HelpBtn: TButton
Left = 85 Left = 85
Top = 322 Top = 322
TabOrder = 11 TabOrder = 8
end end
inherited ButtonBevel: TBevel inherited ButtonBevel: TBevel
Top = 306 Top = 306

View File

@@ -527,13 +527,13 @@ inherited CompareDistFrm: TCompareDistFrm
Height = 519 Height = 519
Top = 8 Top = 8
Width = 599 Width = 599
ActivePage = ReportPage ActivePage = CumFreqChartPage
Align = alClient Align = alClient
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
TabIndex = 0 TabIndex = 1
TabOrder = 1 TabOrder = 1
object ReportPage: TTabSheet object ReportPage: TTabSheet
Caption = 'Report' Caption = 'Report'

View File

@@ -182,7 +182,7 @@ inherited FreqFrm: TFreqFrm
AutoSize = True AutoSize = True
Caption = 'Reset' Caption = 'Reset'
OnClick = ResetBtnClick OnClick = ResetBtnClick
TabOrder = 2 TabOrder = 4
end end
object CloseBtn: TButton object CloseBtn: TButton
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
@@ -202,7 +202,7 @@ inherited FreqFrm: TFreqFrm
Caption = 'Close' Caption = 'Close'
ModalResult = 1 ModalResult = 1
OnClick = CloseBtnClick OnClick = CloseBtnClick
TabOrder = 3 TabOrder = 6
end end
object ComputeBtn: TButton object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn AnchorSideRight.Control = CloseBtn
@@ -219,7 +219,7 @@ inherited FreqFrm: TFreqFrm
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'Compute' Caption = 'Compute'
OnClick = ComputeBtnClick OnClick = ComputeBtnClick
TabOrder = 4 TabOrder = 5
end end
object PlotOptionsGroup: TGroupBox object PlotOptionsGroup: TGroupBox
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@@ -237,7 +237,7 @@ inherited FreqFrm: TFreqFrm
Caption = 'Plot Options' Caption = 'Plot Options'
ClientHeight = 32 ClientHeight = 32
ClientWidth = 251 ClientWidth = 251
TabOrder = 5 TabOrder = 2
object VertBarsBtn: TSpeedButton object VertBarsBtn: TSpeedButton
AnchorSideLeft.Control = PlotOptionsGroup AnchorSideLeft.Control = PlotOptionsGroup
AnchorSideTop.Control = PlotOptionsGroup AnchorSideTop.Control = PlotOptionsGroup
@@ -326,7 +326,7 @@ inherited FreqFrm: TFreqFrm
Caption = 'Bin Selection' Caption = 'Bin Selection'
ClientHeight = 37 ClientHeight = 37
ClientWidth = 251 ClientWidth = 251
TabOrder = 6 TabOrder = 3
object Panel2: TPanel object Panel2: TPanel
AnchorSideLeft.Control = BinSelectionGroup AnchorSideLeft.Control = BinSelectionGroup
AnchorSideTop.Control = BinSelectionGroup AnchorSideTop.Control = BinSelectionGroup

View File

@@ -9,16 +9,20 @@ inherited GroupFreqForm: TGroupFreqForm
ClientHeight = 263 ClientHeight = 263
inherited CloseBtn: TButton inherited CloseBtn: TButton
Top = 238 Top = 238
TabOrder = 8
end end
inherited ComputeBtn: TButton inherited ComputeBtn: TButton
Top = 238 Top = 238
TabOrder = 3
end end
inherited ResetBtn: TButton inherited ResetBtn: TButton
Top = 238 Top = 238
TabOrder = 7
end end
inherited HelpBtn: TButton inherited HelpBtn: TButton
Tag = 162 Tag = 162
Top = 238 Top = 238
TabOrder = 6
end end
inherited ButtonBevel: TBevel inherited ButtonBevel: TBevel
Top = 222 Top = 222
@@ -49,7 +53,7 @@ inherited GroupFreqForm: TGroupFreqForm
ItemHeight = 0 ItemHeight = 0
OnDblClick = VarListDblClick OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 4 TabOrder = 0
end end
object GrpInBtn: TBitBtn[7] object GrpInBtn: TBitBtn[7]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@@ -63,7 +67,7 @@ inherited GroupFreqForm: TGroupFreqForm
ImageIndex = 1 ImageIndex = 1
OnClick = GrpInBtnClick OnClick = GrpInBtnClick
Spacing = 0 Spacing = 0
TabOrder = 5 TabOrder = 1
end end
object GrpOutBtn: TBitBtn[8] object GrpOutBtn: TBitBtn[8]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
@@ -79,7 +83,7 @@ inherited GroupFreqForm: TGroupFreqForm
ImageIndex = 0 ImageIndex = 0
OnClick = GrpOutBtnClick OnClick = GrpOutBtnClick
Spacing = 0 Spacing = 0
TabOrder = 6 TabOrder = 2
end end
object Label2: TLabel[9] object Label2: TLabel[9]
AnchorSideLeft.Control = GrpVarEdit AnchorSideLeft.Control = GrpVarEdit
@@ -110,7 +114,7 @@ inherited GroupFreqForm: TGroupFreqForm
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
ReadOnly = True ReadOnly = True
TabOrder = 7 TabOrder = 4
Text = 'GrpVarEdit' Text = 'GrpVarEdit'
end end
object PlotOptionsGroup: TGroupBox[11] object PlotOptionsGroup: TGroupBox[11]
@@ -126,7 +130,7 @@ inherited GroupFreqForm: TGroupFreqForm
Caption = 'Plot Options' Caption = 'Plot Options'
ClientHeight = 59 ClientHeight = 59
ClientWidth = 143 ClientWidth = 143
TabOrder = 8 TabOrder = 5
object VertBarsBtn: TSpeedButton object VertBarsBtn: TSpeedButton
AnchorSideLeft.Control = PlotOptionsGroup AnchorSideLeft.Control = PlotOptionsGroup
AnchorSideTop.Control = PlotOptionsGroup AnchorSideTop.Control = PlotOptionsGroup

View File

@@ -84,6 +84,9 @@ begin
AdjustConstraints; AdjustConstraints;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Around*2;
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300;
if Width < Constraints.MinWidth then Width := 1; // enforce constraints if Width < Constraints.MinWidth then Width := 1; // enforce constraints
if Height < Constraints.MinHeight then Height := 1; if Height < Constraints.MinHeight then Height := 1;

View File

@@ -1,4 +1,4 @@
object DistribFrm: TDistribFrm inherited DistribFrm: TDistribFrm
Left = 398 Left = 398
Height = 428 Height = 428
Top = 241 Top = 241
@@ -8,63 +8,48 @@ object DistribFrm: TDistribFrm
Caption = 'Distributions' Caption = 'Distributions'
ClientHeight = 428 ClientHeight = 428
ClientWidth = 948 ClientWidth = 948
OnActivate = FormActivate
OnCreate = FormCreate
Position = poMainFormCenter
ShowHint = True ShowHint = True
LCLVersion = '2.1.0.0' inherited ParamsPanel: TPanel
object ChartPanel: TPanel Height = 412
AnchorSideLeft.Control = ParameterPanel Width = 208
AnchorSideLeft.Side = asrBottom ClientHeight = 412
AnchorSideTop.Control = Owner ClientWidth = 208
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 235
Height = 411
Top = 8
Width = 705
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 9
BevelOuter = bvNone
BorderStyle = bsSingle
Color = clWhite
ParentColor = False
TabOrder = 0
end
object ParameterPanel: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 420
Top = 8
Width = 227
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BevelOuter = bvNone
ClientHeight = 420
ClientWidth = 227
TabOrder = 1 TabOrder = 1
object GroupBox1: TGroupBox inherited CloseBtn: TButton
AnchorSideLeft.Control = ParameterPanel Left = 153
AnchorSideTop.Control = ParameterPanel Top = 387
AnchorSideRight.Control = ParameterPanel TabOrder = 6
AnchorSideRight.Side = asrBottom end
inherited ComputeBtn: TButton
Left = 70
Top = 387
TabOrder = 5
end
inherited ResetBtn: TButton
Left = 8 Left = 8
Top = 387
TabOrder = 4
end
inherited HelpBtn: TButton
Left = -51
Top = 387
Visible = False
end
inherited ButtonBevel: TBevel
Top = 371
Width = 208
end
object GroupBox1: TGroupBox[5]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
Left = 0
Height = 175 Height = 175
Top = 0 Top = 0
Width = 219 Width = 208
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Left = 8
Caption = 'Plot Distribution' Caption = 'Plot Distribution'
ChildSizing.LeftRightSpacing = 16 ChildSizing.LeftRightSpacing = 16
ChildSizing.TopBottomSpacing = 8 ChildSizing.TopBottomSpacing = 8
@@ -74,7 +59,7 @@ object DistribFrm: TDistribFrm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 155 ClientHeight = 155
ClientWidth = 215 ClientWidth = 204
TabOrder = 0 TabOrder = 0
object NDChk: TRadioButton object NDChk: TRadioButton
Left = 16 Left = 16
@@ -92,7 +77,7 @@ object DistribFrm: TDistribFrm
Width = 183 Width = 183
Caption = 'Student t Distribution (1-sided)' Caption = 'Student t Distribution (1-sided)'
OnClick = DistributionClick OnClick = DistributionClick
TabOrder = 3 TabOrder = 1
end end
object FChk: TRadioButton object FChk: TRadioButton
Left = 16 Left = 16
@@ -110,7 +95,7 @@ object DistribFrm: TDistribFrm
Width = 183 Width = 183
Caption = 'Chi-Square Distribution' Caption = 'Chi-Square Distribution'
OnClick = DistributionClick OnClick = DistributionClick
TabOrder = 1 TabOrder = 3
end end
object Bevel2: TBevel object Bevel2: TBevel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@@ -131,29 +116,29 @@ object DistribFrm: TDistribFrm
TabOrder = 4 TabOrder = 4
end end
end end
object GroupBox2: TGroupBox object GroupBox2: TGroupBox[6]
AnchorSideLeft.Control = GroupBox1 AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = GroupBox1 AnchorSideTop.Control = GroupBox1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = GroupBox1 AnchorSideRight.Control = GroupBox1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 0
Height = 107 Height = 107
Top = 191 Top = 191
Width = 219 Width = 208
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 16 BorderSpacing.Top = 16
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
Caption = 'Parameters' Caption = 'Parameters'
ClientHeight = 87 ClientHeight = 87
ClientWidth = 215 ClientWidth = 204
TabOrder = 1 TabOrder = 1
object AlphaLabel: TLabel object AlphaLabel: TLabel
AnchorSideTop.Control = AlphaEdit AnchorSideTop.Control = AlphaEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = AlphaEdit AnchorSideRight.Control = AlphaEdit
Left = 68 Left = 57
Height = 15 Height = 15
Top = 6 Top = 6
Width = 84 Width = 84
@@ -166,7 +151,7 @@ object DistribFrm: TDistribFrm
AnchorSideTop.Control = DF1Edit AnchorSideTop.Control = DF1Edit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = DF1Edit AnchorSideRight.Control = DF1Edit
Left = 61 Left = 50
Height = 15 Height = 15
Top = 33 Top = 33
Width = 91 Width = 91
@@ -180,7 +165,7 @@ object DistribFrm: TDistribFrm
AnchorSideTop.Control = DF2Edit AnchorSideTop.Control = DF2Edit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = DF2Edit AnchorSideRight.Control = DF2Edit
Left = 61 Left = 50
Height = 15 Height = 15
Top = 60 Top = 60
Width = 91 Width = 91
@@ -194,7 +179,7 @@ object DistribFrm: TDistribFrm
AnchorSideTop.Control = GroupBox2 AnchorSideTop.Control = GroupBox2
AnchorSideRight.Control = GroupBox2 AnchorSideRight.Control = GroupBox2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 160 Left = 149
Height = 23 Height = 23
Top = 2 Top = 2
Width = 43 Width = 43
@@ -210,7 +195,7 @@ object DistribFrm: TDistribFrm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AlphaEdit AnchorSideRight.Control = AlphaEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 160 Left = 149
Height = 23 Height = 23
Top = 29 Top = 29
Width = 43 Width = 43
@@ -225,7 +210,7 @@ object DistribFrm: TDistribFrm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AlphaEdit AnchorSideRight.Control = AlphaEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 160 Left = 149
Height = 23 Height = 23
Top = 56 Top = 56
Width = 43 Width = 43
@@ -237,8 +222,7 @@ object DistribFrm: TDistribFrm
Text = 'DF2Edit' Text = 'DF2Edit'
end end
end end
object ShowCriticalValuesChk: TCheckBox object ShowCriticalValuesChk: TCheckBox[7]
AnchorSideLeft.Control = ParameterPanel
AnchorSideTop.Control = GroupBox2 AnchorSideTop.Control = GroupBox2
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 16
@@ -246,63 +230,32 @@ object DistribFrm: TDistribFrm
Top = 310 Top = 310
Width = 123 Width = 123
BorderSpacing.Left = 16 BorderSpacing.Left = 16
BorderSpacing.Bottom = 16
Caption = 'Show critical values' Caption = 'Show critical values'
Checked = True Checked = True
OnChange = ShowCriticalValuesChkChange OnChange = ShowCriticalValuesChkChange
State = cbChecked State = cbChecked
TabOrder = 2 TabOrder = 2
end end
object CloseBtn: TButton end
AnchorSideRight.Control = ParameterPanel inherited ParamsSplitter: TSplitter
AnchorSideRight.Side = asrBottom Left = 220
AnchorSideBottom.Control = ParameterPanel Height = 428
AnchorSideBottom.Side = asrBottom end
Left = 172 object ChartPanel: TPanel[2]
Height = 25 Left = 229
Hint = 'Close the form' Height = 412
Top = 387 Top = 8
Width = 55 Width = 711
Anchors = [akRight, akBottom] Align = alClient
AutoSize = True BorderSpacing.Left = 4
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
OnClick = CloseBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideTop.Control = CloseBtn
AnchorSideRight.Control = CloseBtn
Left = 88
Height = 25
Hint = 'Perform the calculation'
Top = 387
Width = 76
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object ResetBtn: TButton
AnchorSideTop.Control = CloseBtn
AnchorSideRight.Control = ComputeBtn
Left = 26
Height = 25
Hint = 'Reset all parameters to default'
Top = 387
Width = 54
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Right = 8 BorderSpacing.Right = 8
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Reset' BevelOuter = bvNone
OnClick = ResetBtnClick BorderStyle = bsSingle
TabOrder = 5 Color = clWhite
end ParentColor = False
TabOrder = 0
end end
end end

View File

@@ -3,8 +3,6 @@
// Test input parameters: // Test input parameters:
// - F distribution: DF1 = 3, DF2 = 20 // - F distribution: DF1 = 3, DF2 = 20
// ToDo: Fix calculation of t distribution
unit DistribUnit; unit DistribUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
@@ -15,37 +13,29 @@ uses
Classes, SysUtils, FileUtil, LCLVersion, Classes, SysUtils, FileUtil, LCLVersion,
Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Math, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Math,
TAFuncSeries, TAFuncSeries,
Globals, FunctionsLib, ChartFrameUnit; Globals, FunctionsLib, ChartFrameUnit, BasicStatsChartFormUnit;
type type
{ TDistribFrm } { TDistribFrm }
TDistribFrm = class(TForm) TDistribFrm = class(TBasicStatsChartForm)
AlphaEdit: TEdit; AlphaEdit: TEdit;
Bevel2: TBevel; Bevel2: TBevel;
ShowCriticalValuesChk: TCheckBox; ShowCriticalValuesChk: TCheckBox;
CumulativeChk: TCheckBox; CumulativeChk: TCheckBox;
tChk: TRadioButton; tChk: TRadioButton;
ParameterPanel: TPanel;
ChiChk: TRadioButton; ChiChk: TRadioButton;
DF1Edit: TEdit; DF1Edit: TEdit;
DF2Edit: TEdit; DF2Edit: TEdit;
FChk: TRadioButton; FChk: TRadioButton;
NDChk: TRadioButton; NDChk: TRadioButton;
ChartPanel: TPanel; ChartPanel: TPanel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
GroupBox2: TGroupBox; GroupBox2: TGroupBox;
AlphaLabel: TLabel; AlphaLabel: TLabel;
DF1Label: TLabel; DF1Label: TLabel;
DF2Label: TLabel; DF2Label: TLabel;
GroupBox1: TGroupBox; GroupBox1: TGroupBox;
procedure CloseBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CalcChi2(const AX: Double; out AY: Double); procedure CalcChi2(const AX: Double; out AY: Double);
procedure CalcChi2_Cumulative(const AX: Double; out AY: Double); procedure CalcChi2_Cumulative(const AX: Double; out AY: Double);
procedure CalcF(const AX: Double; out AY: Double); procedure CalcF(const AX: Double; out AY: Double);
@@ -55,14 +45,10 @@ type
procedure CalcT(const AX: Double; out AY: Double); procedure CalcT(const AX: Double; out AY: Double);
procedure CalcT_Cumulative(const AX: Double; out AY: Double); procedure CalcT_Cumulative(const AX: Double; out AY: Double);
procedure DistributionClick(Sender: TObject); procedure DistributionClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure ShowCriticalValuesChkChange(Sender: TObject); procedure ShowCriticalValuesChkChange(Sender: TObject);
procedure tbEraseClick(Sender: TObject); procedure tbEraseClick(Sender: TObject);
private private
{ private declarations }
FAutoSized: Boolean;
FChartFrame: TChartFrame;
Alpha: Double; Alpha: Double;
DF1: Integer; DF1: Integer;
DF2: Integer; DF2: Integer;
@@ -73,11 +59,15 @@ type
procedure Chi2Plot; procedure Chi2Plot;
procedure FPlot; procedure FPlot;
procedure tPlot; procedure tPlot;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; procedure Reset; override;
end; end;
var var
@@ -97,6 +87,26 @@ const
{ TDistribFrm } { TDistribFrm }
constructor TDistribFrm.Create(AOwner: TComponent);
begin
inherited;
FChartFrame.Chart.Legend.Alignment := laBottomCenter;
FChartFrame.Chart.Legend.ColumnCount := 3;
FChartFrame.Chart.Legend.TextFormat := tfHTML;
// InitToolbar(FChartFrame.ChartToolbar, tpTop);
tbErase := TToolButton.Create(self);
tbErase.ImageIndex := 6;
tbErase.Caption := 'Erase';
tbErase.Hint := 'Clear chart';
tbErase.OnClick := @tbEraseClick;
AddButtonToToolbar(tbErase, FChartFrame.ChartToolBar);
Reset;
end;
procedure TDistribFrm.AddSeries(ATitle: string; XMin, XMax: Double; procedure TDistribFrm.AddSeries(ATitle: string; XMin, XMax: Double;
xCrit, yCrit: Double; Cumulative: Boolean; ACalcFunc: TFuncCalculateEvent); xCrit, yCrit: Double; Cumulative: Boolean; ACalcFunc: TFuncCalculateEvent);
var var
@@ -183,8 +193,60 @@ begin
end; end;
procedure TDistribFrm.AdjustConstraints;
begin
inherited;
paramsPanel.Constraints.MinWidth := 3*CloseBtn.Width + 2*CloseBtn.BorderSpacing.Left;
ParamsPanel.Constraints.MinHeight :=
ShowCriticalValuesChk.Top + ShowCriticalValuesChk.Height + ShowCriticalValuesChk.BorderSpacing.Bottom +
ButtonBevel.Height + CloseBtn.Height;
end;
procedure TDistribFrm.Compute;
var
msg: String;
C: TWinControl;
ok: Boolean;
begin
inherited;
ok := false;
if NDChk.Checked then
begin
NormalDistPlot();
ok := true;
end;
if tChk.Checked then
begin
tPlot();
ok := true;
end;
if ChiChk.Checked then
begin
Chi2Plot();
ok := true;
end;
if FChk.Checked then
begin
FPlot();
ok := true;
end;
if not ok then
MessageDlg('Please select a distribution.', mtError, [mbOK], 0);
end;
procedure TDistribFrm.Reset; procedure TDistribFrm.Reset;
begin begin
inherited;
NDChk.Checked := false; NDChk.Checked := false;
tChk.Checked := false; tChk.Checked := false;
FChk.Checked := false; FChk.Checked := false;
@@ -193,16 +255,14 @@ begin
DF1Edit.Text := ''; DF1Edit.Text := '';
DF2Edit.Text := ''; DF2Edit.Text := '';
GroupBox2.Enabled := false; GroupBox2.Enabled := false;
if FChartFrame <> nil then
FChartFrame.Clear; FChartFrame.Clear;
if tbErase <> nil then
tbErase.Enabled := false; tbErase.Enabled := false;
end; end;
procedure TDistribFrm.ResetBtnClick(Sender: TObject);
begin
Reset;
end;
procedure TDistribFrm.ShowCriticalValuesChkChange(Sender: TObject); procedure TDistribFrm.ShowCriticalValuesChkChange(Sender: TObject);
var var
i: Integer; i: Integer;
@@ -298,55 +358,6 @@ begin
end; end;
procedure TDistribFrm.ComputeBtnClick(Sender: TObject);
var
msg: String;
C: TWinControl;
ok: Boolean;
begin
if not Validate(msg, C) then
begin
C.SetFocus;
MessageDlg(msg, mtError, [mbOK], 0);
exit;
end;
ok := false;
if NDChk.Checked then
begin
NormalDistPlot();
ok := true;
end;
if tChk.Checked then
begin
tPlot();
ok := true;
end;
if ChiChk.Checked then
begin
Chi2Plot();
ok := true;
end;
if FChk.Checked then
begin
FPlot();
ok := true;
end;
if not ok then
MessageDlg('Please select a distribution.', mtError, [mbOK], 0);
end;
procedure TDistribFrm.CloseBtnClick(Sender: TObject);
begin
Close;
end;
// Plots the normal distribution // Plots the normal distribution
procedure TDistribFrm.NormalDistPlot; procedure TDistribFrm.NormalDistPlot;
var var
@@ -429,54 +440,9 @@ begin
end; end;
procedure TDistribFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinHeight :=
ShowCriticalValuesChk.Top + ShowCriticalValuesChk.Height + 16 +
CloseBtn.Height + CloseBtn.BorderSpacing.Bottom;
Constraints.MinWidth := ParameterPanel.Width * 2;
Position := poDefault;
FAutoSized := true;
end;
procedure TDistribFrm.FormCreate(Sender: TObject);
begin
InitForm(self);
FChartFrame := TChartFrame.Create(self);
FChartFrame.Parent := ChartPanel;
FChartFrame.Align := alClient;
FChartFrame.Chart.Legend.Alignment := laBottomCenter;
FChartFrame.Chart.Legend.ColumnCount := 3;
FChartFrame.Chart.Legend.TextFormat := tfHTML;
FChartFrame.Chart.BottomAxis.Intervals.MaxLength := 80;
FChartFrame.Chart.BottomAxis.Intervals.MinLength := 30;
InitToolbar(FChartFrame.ChartToolbar, tpTop);
tbErase := TToolButton.Create(self);
tbErase.ImageIndex := 6;
tbErase.Caption := 'Erase';
tbErase.Hint := 'Clear chart';
tbErase.OnClick := @tbEraseClick;
AddButtonToToolbar(tbErase, FChartFrame.ChartToolBar);
Reset;
end;
procedure TDistribFrm.tbEraseClick(Sender: TObject); procedure TDistribFrm.tbEraseClick(Sender: TObject);
begin begin
if FChartFrame <> nil then
FChartFrame.Clear; FChartFrame.Clear;
tbErase.Enabled := false; tbErase.Enabled := false;
end; end;
@@ -539,8 +505,5 @@ begin
Result := true; Result := true;
end; end;
//initialization
// {$I distribunit.lrs}
end. end.