LazStats: Inherit DescriptiveUnit from TBasicStatsReportForm. Fix related issues. Fix compilation with FPC trunk.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7729 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-01 16:03:56 +00:00
parent 219b3d9e97
commit 0175c44fa5
18 changed files with 164 additions and 243 deletions

View File

@ -1519,12 +1519,12 @@
<UnitName Value="GroupFreqUnit"/>
</Unit177>
<Unit178>
<Filename Value="forms\misc\basicstatsreportfromunit.pas"/>
<Filename Value="forms\misc\basicstatsreportformunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="BasicStatsReportForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="BasicStatsReportFromUnit"/>
<UnitName Value="BasicStatsReportFormUnit"/>
</Unit178>
<Unit179>
<Filename Value="forms\misc\basicstatsreportandchartformunit.pas"/>

View File

@ -8,8 +8,7 @@ uses
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, tachartlazaruspkg, tachartprint, lhelpcontrolpkg, Globals, LicenseUnit,
OptionsUnit, MainDM, MainUnit, BasicStatsReportFromUnit,
BasicStatsReportAndChartFormUnit;
OptionsUnit, MainDM, MainUnit;
{$R LazStats.res}
@ -29,8 +28,6 @@ begin
end;
Application.CreateForm(TMainDataModule, MainDataModule);
Application.CreateForm(TOS3MainFrm, OS3MainFrm);
Application.CreateForm(TBasicStatsReportAndChartForm,
BasicStatsReportAndChartForm);
Application.Run;
end.

View File

@ -1,4 +1,4 @@
object DescriptiveFrm: TDescriptiveFrm
inherited DescriptiveFrm: TDescriptiveFrm
Left = 526
Height = 384
Top = 202
@ -8,32 +8,33 @@ object DescriptiveFrm: TDescriptiveFrm
Caption = 'Descriptive Statistics'
ClientHeight = 384
ClientWidth = 900
OnActivate = FormActivate
OnCreate = FormCreate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ReportPanel: TPanel
Left = 343
Height = 384
Top = 0
Width = 557
Align = alClient
Anchors = [akTop, akLeft, akRight]
BevelOuter = bvNone
TabOrder = 0
end
object ParamsPanel: TPanel
Left = 8
Height = 368
Top = 8
inherited ParamsPanel: TPanel
Left = 16
Height = 352
Top = 16
Width = 322
Align = alLeft
BorderSpacing.Around = 8
BevelOuter = bvNone
ClientHeight = 368
ClientHeight = 352
ClientWidth = 322
TabOrder = 1
object Label2: TLabel
inherited CloseBtn: TButton
TabOrder = 9
end
inherited ComputeBtn: TButton
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
TabOrder = 10
end
inherited ResetBtn: TButton
TabOrder = 8
end
inherited HelpBtn: TButton
TabOrder = 7
end
inherited ButtonBevel: TBevel
Top = 311
Width = 322
end
object Label2: TLabel[5]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
Left = 0
@ -43,14 +44,14 @@ object DescriptiveFrm: TDescriptiveFrm
Caption = 'Variables'
ParentColor = False
end
object VarList: TListBox
object VarList: TListBox[6]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AllBtn
AnchorSideBottom.Control = OptionsGroup
Left = 0
Height = 199
Height = 183
Top = 17
Width = 130
Anchors = [akTop, akLeft, akRight, akBottom]
@ -63,7 +64,7 @@ object DescriptiveFrm: TDescriptiveFrm
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object Label3: TLabel
object Label3: TLabel[7]
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = ParamsPanel
Left = 192
@ -73,7 +74,7 @@ object DescriptiveFrm: TDescriptiveFrm
Caption = 'Selected'
ParentColor = False
end
object SelList: TListBox
object SelList: TListBox[8]
AnchorSideLeft.Control = AllBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label3
@ -83,7 +84,7 @@ object DescriptiveFrm: TDescriptiveFrm
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 192
Height = 199
Height = 183
Top = 17
Width = 130
Anchors = [akTop, akLeft, akRight, akBottom]
@ -94,7 +95,7 @@ object DescriptiveFrm: TDescriptiveFrm
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
object InBtn: TBitBtn
object InBtn: TBitBtn[9]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
@ -109,7 +110,7 @@ object DescriptiveFrm: TDescriptiveFrm
Spacing = 0
TabOrder = 1
end
object OutBtn: TBitBtn
object OutBtn: TBitBtn[10]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
@ -126,7 +127,7 @@ object DescriptiveFrm: TDescriptiveFrm
Spacing = 0
TabOrder = 2
end
object AllBtn: TBitBtn
object AllBtn: TBitBtn[11]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = OutBtn
@ -141,60 +142,26 @@ object DescriptiveFrm: TDescriptiveFrm
OnClick = AllBtnClick
TabOrder = 3
end
object CloseBtn: TButton
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 267
Height = 25
Top = 343
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
Caption = 'Close'
ModalResult = 11
OnClick = CloseBtnClick
TabOrder = 9
end
object HelpBtn: TButton
Tag = 119
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 62
Height = 25
Top = 343
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 7
end
object Label1: TLabel
object Label1: TLabel[12]
AnchorSideLeft.Control = OptionsGroup
AnchorSideTop.Control = CIEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CIEdit
Left = 0
Height = 15
Top = 308
Top = 292
Width = 174
BorderSpacing.Right = 8
Caption = 'Confidence Interval for the Mean'
ParentColor = False
end
object OptionsGroup: TGroupBox
object OptionsGroup: TGroupBox[13]
AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CIEdit
Left = 0
Height = 72
Top = 224
Top = 208
Width = 306
Anchors = [akLeft, akBottom]
AutoSize = True
@ -253,42 +220,13 @@ object DescriptiveFrm: TDescriptiveFrm
TabOrder = 3
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 327
Width = 322
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 183
Height = 25
Top = 343
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10
end
object CIEdit: TEdit
object CIEdit: TEdit[14]
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 182
Height = 23
Top = 304
Top = 288
Width = 41
Alignment = taRightJustify
Anchors = [akLeft, akBottom]
@ -296,29 +234,19 @@ object DescriptiveFrm: TDescriptiveFrm
TabOrder = 6
Text = '95.0'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 121
Height = 25
Top = 343
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 8
end
inherited ParamsSplitter: TSplitter
Left = 350
Height = 384
end
object Splitter1: TSplitter
Left = 338
object ReportPanel: TPanel[2]
Left = 355
Height = 384
Top = 0
Width = 5
ResizeStyle = rsPattern
Width = 545
Align = alClient
Anchors = [akTop, akLeft, akRight]
BevelOuter = bvNone
TabOrder = 2
end
end

View File

@ -7,60 +7,48 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons,
MainUnit, Globals, FunctionsLib, BasicStatsFormUnit,
ReportFrameUnit, DataProcs, DictionaryUnit, ContextHelpUnit;
MainUnit, Globals, FunctionsLib, BasicStatsReportFormUnit,
DataProcs, DictionaryUnit;
type
{ TDescriptiveFrm }
TDescriptiveFrm = class(TBasicStatsForm)
Bevel1: TBevel;
ComputeBtn: TButton;
TDescriptiveFrm = class(TBasicStatsReportForm)
CaseChk: TCheckBox;
ZScoresToGridChk: TCheckBox;
AllQrtilesChk: TCheckBox;
HelpBtn: TButton;
Label2: TLabel;
Label3: TLabel;
ReportPanel: TPanel;
ParamsPanel: TPanel;
PcntileChk: TCheckBox;
OptionsGroup: TGroupBox;
InBtn: TBitBtn;
OutBtn: TBitBtn;
AllBtn: TBitBtn;
ResetBtn: TButton;
CloseBtn: TButton;
CIEdit: TEdit;
Label1: TLabel;
Splitter1: TSplitter;
VarList: TListBox;
SelList: TListBox;
procedure AllBtnClick(Sender: TObject);
procedure CloseBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure SelListDblClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean);
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
private
{ private declarations }
FReportFrame: TReportFrame;
FAutoSized: Boolean;
sum, variance, stddev, value, mean, min, max, range, skew, prob, df, CI : double;
kurtosis, z, semean, seskew, sekurtosis, deviation, devsqr, M2, M3, M4 : double;
procedure UpdateBtnStates;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
public
{ public declarations }
procedure Reset; override;
end;
@ -77,6 +65,18 @@ uses
{ TDescriptiveFrm }
procedure TDescriptiveFrm.AdjustConstraints;
begin
ParamsPanel.Constraints.MinHeight := AllBtn.Top + AllBtn.Height + OptionsGroup.Height +
CIEdit.Height + ButtonBevel.Height + CloseBtn.Height + VarList.BorderSpacing.Bottom +
OptionsGroup.BorderSpacing.Bottom + CloseBtn.BorderSpacing.Top;
ParamsPanel.Constraints.MinWidth := Math.Max(
4*CloseBtn.Width + 3*HelpBtn.BorderSpacing.Right,
OptionsGroup.Width
);
end;
procedure TDescriptiveFrm.AllBtnClick(Sender: TObject);
var
i : integer;
@ -88,61 +88,7 @@ begin
end;
procedure TDescriptiveFrm.CloseBtnClick(Sender: TObject);
begin
Close;
end;
procedure TDescriptiveFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
ParamsPanel.AutoSize := true;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
ParamsPanel.Constraints.MinHeight := AllBtn.Top + AllBtn.Height + OptionsGroup.Height +
CIEdit.Height + Bevel1.Height + CloseBtn.Height + VarList.BorderSpacing.Bottom +
OptionsGroup.BorderSpacing.Bottom + CloseBtn.BorderSpacing.Top;
ParamsPanel.Constraints.MinWidth := Math.Max(
4*w + 3*HelpBtn.BorderSpacing.Right,
OptionsGroup.Width
);
ParamsPanel.AutoSize := false;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Around*2;
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + ParamsPanel.BorderSpacing.Around*2;
Position := poDesigned;
FAutoSized := true;
end;
procedure TDescriptiveFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
Width := Scale96ToFont(DEFAULT_WIDTH);
Height := Scale96ToFont(DEFAULT_HEIGHT);
FReportFrame := TReportFrame.Create(self);
FReportFrame.Parent := ReportPanel;
FReportFrame.Align := alClient;
FReportFrame.ReportToolBar.Align := alRight;
FReportFrame.ReportToolbar.EdgeBorders := [];
Reset;
end;
procedure TDescriptiveFrm.ComputeBtnClick(Sender: TObject);
procedure TDescriptiveFrm.Compute;
var
i, j, k, m: integer;
nCases, noSelected: integer;
@ -417,14 +363,6 @@ begin
end;
procedure TDescriptiveFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
end;
procedure TDescriptiveFrm.InBtnClick(Sender: TObject);
var
i: integer;
@ -462,23 +400,18 @@ begin
UpdateBtnStates;
end;
procedure TDescriptiveFrm.Reset;
var
i: integer;
begin
inherited;
CIEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT);
VarList.Clear;
SelList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
FReportFrame.Clear;
end;
procedure TDescriptiveFrm.ResetBtnClick(Sender: TObject);
begin
Reset;
end;
@ -515,6 +448,8 @@ var
lSelected: Boolean;
i: Integer;
begin
inherited;
lSelected := false;
for i := 0 to VarList.Items.Count-1 do
if VarList.Selected[i] then

View File

@ -101,7 +101,7 @@ var
grps: StrDyneVec = nil;
means: array[0..1] of Double = (0.0, 0.0);
stdDevs: array[0..1] of Double = (0.0, 0.0);
selected: array[0..2] of Integer = (0, 0, 0);
selected: array of Integer = nil;
begin
// Get selected variables
xCol := 0;
@ -120,6 +120,7 @@ begin
exit;
end;
SetLength(selected, 3);
selected[0] := xCol;
selected[1] := yCol;
selected[2] := grpCol;

View File

@ -11,8 +11,7 @@ inherited NormalityFrm: TNormalityFrm
OnActivate = FormActivate
OnCreate = FormCreate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ParamsPanel: TPanel
object ParamsPanel: TPanel[0]
Left = 8
Height = 500
Top = 8
@ -192,14 +191,14 @@ inherited NormalityFrm: TNormalityFrm
ParentColor = False
end
end
object ParamsSplitter: TSplitter
object ParamsSplitter: TSplitter[1]
Left = 332
Height = 516
Top = 0
Width = 5
ResizeStyle = rsPattern
end
object PageControl: TPageControl
object PageControl: TPageControl[2]
Left = 341
Height = 500
Top = 8

View File

@ -125,7 +125,7 @@ var
DP: DblDyneVec = nil;
mean, variance, stddev: Double;
deviation, devSqr: Double;
M2, M3, M4, F1, DPP, t2: Double;
M2, M3, M4, DPP, t2: Double;
A0, C1, D025, D05, D10, D15: Double;
begin
// Count of data values

View File

@ -1,4 +1,4 @@
object PlotXYFrm: TPlotXYFrm
inherited PlotXYFrm: TPlotXYFrm
Left = 427
Height = 500
Top = 175
@ -11,8 +11,7 @@ object PlotXYFrm: TPlotXYFrm
OnActivate = FormActivate
OnCreate = FormCreate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ParamsPanel: TPanel
object ParamsPanel: TPanel[0]
Left = 8
Height = 484
Top = 8
@ -324,14 +323,14 @@ object PlotXYFrm: TPlotXYFrm
end
end
end
object ParamsSplitter: TSplitter
object ParamsSplitter: TSplitter[1]
Left = 392
Height = 500
Top = 0
Width = 5
ResizeStyle = rsPattern
end
object PageControl1: TPageControl
object PageControl1: TPageControl[2]
Left = 405
Height = 484
Top = 8

View File

@ -414,7 +414,7 @@ end;
procedure TPlotXYFrm.PlotXY(XPoints, YPoints, UpConf, LowConf: DblDyneVec;
XMean, YMean, R, Slope, Intercept: Double);
var
tmpX, tmpY: array[0..1] of Double;
tmpX, tmpY: array of Double;
xmin, xmax, ymin, ymax: Double;
rightLabels: TListChartSource;
topLabels: TListChartSource;
@ -467,6 +467,7 @@ begin
// Draw regression line
if LineChk.Checked then
begin
SetLength(tmpX, 2); SetLength(tmpY, 2);
tmpX[0] := xmin; tmpY[0] := tmpX[0] * slope + intercept;
tmpX[1] := xmax; tmpY[1] := tmpX[1] * slope + intercept;
ser := FChartFrame.PlotXY(ptLines, tmpX, tmpY, nil, nil, 'Predicted', clBlack);

View File

@ -204,6 +204,8 @@ var
grp: String;
i: Integer;
begin
Result := nil;
SetLength(ColNoSelected, 2);
ColNoSelected[0] := GrpVar;
ColNoSelected[1] := MeasVar;
@ -401,8 +403,6 @@ end;
function TBasicSPCForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
x: Double;
begin
Result := false;
if GroupEdit.Visible and (GroupEdit.Text = '') then begin

View File

@ -105,7 +105,7 @@ end;
procedure TXBarChartForm.Compute;
var
i, j: Integer;
i: Integer;
upperSpec: Double = NaN;
lowerSpec: Double = NaN;
targetSpec: Double = NaN;

View File

@ -1,8 +1,8 @@
object BasicStatsForm: TBasicStatsForm
Left = 519
Height = 459
Height = 452
Top = 260
Width = 717
Width = 715
Caption = 'BasicStatsForm'
LCLVersion = '2.1.0.0'
end

View File

@ -1,5 +1,7 @@
inherited BasicStatsParamsForm: TBasicStatsParamsForm
Width = 709
Caption = 'BasicStatsParamsForm'
ClientWidth = 709
Position = poMainFormCenter
object ParamsPanel: TPanel[0]
Left = 8

View File

@ -31,7 +31,7 @@ type
procedure Activate; override;
procedure AdjustConstraints; virtual;
procedure Compute; virtual;
procedure InitForm;
procedure InitForm; virtual;
procedure UpdateBtnStates; virtual;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; virtual;

View File

@ -1,9 +1,36 @@
inherited BasicStatsReportAndChartForm: TBasicStatsReportAndChartForm
Height = 450
Width = 716
Caption = 'BasicStatsReportAndChartForm'
ClientHeight = 450
ClientWidth = 716
inherited ParamsPanel: TPanel
Height = 434
ClientHeight = 434
inherited CloseBtn: TButton
Top = 409
end
inherited ComputeBtn: TButton
Top = 409
end
inherited ResetBtn: TButton
Top = 409
end
inherited HelpBtn: TButton
Top = 409
end
inherited ButtonBevel: TBevel
Top = 393
end
end
inherited ParamsSplitter: TSplitter
Height = 450
end
object PageControl: TPageControl[2]
Left = 312
Height = 443
Height = 434
Top = 8
Width = 397
Width = 396
ActivePage = ReportPage
Align = alClient
BorderSpacing.Left = 4

View File

@ -54,6 +54,13 @@ begin
end;
procedure TBasicStatsReportAndChartForm.InitForm;
begin
inherited;
PageControl.ActivePageIndex := 0;
end;
procedure TBasicStatsReportAndChartForm.Reset;
begin
inherited;

View File

@ -1,4 +1,29 @@
inherited BasicStatsReportForm: TBasicStatsReportForm
Height = 449
Width = 711
Caption = 'BasicStatsReportForm'
OnCreate = FormCreate
ClientHeight = 449
ClientWidth = 711
inherited ParamsPanel: TPanel
Height = 433
ClientHeight = 433
inherited CloseBtn: TButton
Top = 408
end
inherited ComputeBtn: TButton
Top = 408
end
inherited ResetBtn: TButton
Top = 408
end
inherited HelpBtn: TButton
Top = 408
end
inherited ButtonBevel: TBevel
Top = 392
end
end
inherited ParamsSplitter: TSplitter
Height = 449
end
end

View File

@ -275,7 +275,7 @@ end;
DF degrees of freedom. }
function ProbT(t, DF1: double): double;
var
F, prob: double;
F: double;
begin
F := t * t;
Result := ProbF(F, 1.0, DF1);