LazStats: LazStats: Inherit form of BreakdownUnit from TBasicStatsReportForm.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7750 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-06 21:29:34 +00:00
parent 2d3368e257
commit 43dca206b2
2 changed files with 99 additions and 212 deletions

View File

@ -8,109 +8,40 @@ inherited BreakDownFrm: TBreakDownFrm
Caption = 'Breakdown' Caption = 'Breakdown'
ClientHeight = 363 ClientHeight = 363
ClientWidth = 873 ClientWidth = 873
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate
Position = poMainFormCenter
object ParamsPanel: TPanel[0]
Left = 8
Height = 347 Height = 347
Top = 8
Width = 344 Width = 344
Align = alLeft
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 4
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 347 ClientHeight = 347
ClientWidth = 344 ClientWidth = 344
TabOrder = 0 inherited CloseBtn: TButton
object CloseBtn: TButton
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 289 Left = 289
Height = 25
Top = 322 Top = 322
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Close'
ModalResult = 11
OnClick = CloseBtnClick
TabOrder = 11
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 143
Height = 25
Top = 322
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 9
end
object HelpBtn: TButton
Tag = 109
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 84
Height = 25
Top = 322
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 8 TabOrder = 8
end end
object Bevel1: TBevel inherited ComputeBtn: TButton
AnchorSideLeft.Control = ParamsPanel Left = 206
AnchorSideRight.Control = ParamsPanel Top = 322
AnchorSideRight.Side = asrBottom TabOrder = 9
AnchorSideBottom.Control = CloseBtn end
Left = 0 inherited ResetBtn: TButton
Height = 8 Left = 144
Top = 306
Width = 344
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 205
Height = 25
Top = 322 Top = 322
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10 TabOrder = 10
end end
object CheckGroup1: TCheckGroup inherited HelpBtn: TButton
Left = 85
Top = 322
TabOrder = 11
end
inherited ButtonBevel: TBevel
Top = 306
Width = 344
end
object CheckGroup1: TCheckGroup[5]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1 AnchorSideBottom.Control = ButtonBevel
Left = 0 Left = 0
Height = 51 Height = 51
Top = 255 Top = 255
@ -139,7 +70,7 @@ inherited BreakDownFrm: TBreakDownFrm
0100000002 0100000002
} }
end end
object AvailLabel: TLabel object AvailLabel: TLabel[6]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel AnchorSideTop.Control = ParamsPanel
Left = 0 Left = 0
@ -149,7 +80,7 @@ inherited BreakDownFrm: TBreakDownFrm
Caption = 'Available Variables' Caption = 'Available Variables'
ParentColor = False ParentColor = False
end end
object AnalLabel: TLabel object AnalLabel: TLabel[7]
AnchorSideLeft.Control = SelList AnchorSideLeft.Control = SelList
AnchorSideTop.Control = ParamsPanel AnchorSideTop.Control = ParamsPanel
Left = 194 Left = 194
@ -159,7 +90,7 @@ inherited BreakDownFrm: TBreakDownFrm
Caption = 'Variables to Analyze' Caption = 'Variables to Analyze'
ParentColor = False ParentColor = False
end end
object SelLabel: TLabel object SelLabel: TLabel[8]
AnchorSideLeft.Control = SelList AnchorSideLeft.Control = SelList
AnchorSideBottom.Control = DepVar AnchorSideBottom.Control = DepVar
Left = 194 Left = 194
@ -171,7 +102,7 @@ inherited BreakDownFrm: TBreakDownFrm
Caption = 'Selected Continuous Variable' Caption = 'Selected Continuous Variable'
ParentColor = False ParentColor = False
end end
object VarList: TListBox object VarList: TListBox[9]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = AvailLabel AnchorSideTop.Control = AvailLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
@ -190,7 +121,7 @@ inherited BreakDownFrm: TBreakDownFrm
OnSelectionChange = VarListSelectionChange OnSelectionChange = VarListSelectionChange
TabOrder = 0 TabOrder = 0
end end
object SelList: TListBox object SelList: TListBox[10]
AnchorSideLeft.Control = InBtn AnchorSideLeft.Control = InBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = AnalLabel AnchorSideTop.Control = AnalLabel
@ -211,7 +142,7 @@ inherited BreakDownFrm: TBreakDownFrm
OnSelectionChange = SelListSelectionChange OnSelectionChange = SelListSelectionChange
TabOrder = 3 TabOrder = 3
end end
object DepVar: TEdit object DepVar: TEdit[11]
AnchorSideLeft.Control = SelList AnchorSideLeft.Control = SelList
AnchorSideTop.Control = SelLabel AnchorSideTop.Control = SelLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
@ -230,7 +161,7 @@ inherited BreakDownFrm: TBreakDownFrm
TabOrder = 6 TabOrder = 6
Text = 'DepVar' Text = 'DepVar'
end end
object InBtn: TBitBtn object InBtn: TBitBtn[12]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList AnchorSideTop.Control = VarList
@ -244,7 +175,7 @@ inherited BreakDownFrm: TBreakDownFrm
Spacing = 0 Spacing = 0
TabOrder = 1 TabOrder = 1
end end
object OutBtn: TBitBtn object OutBtn: TBitBtn[13]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn AnchorSideTop.Control = InBtn
@ -260,7 +191,7 @@ inherited BreakDownFrm: TBreakDownFrm
Spacing = 0 Spacing = 0
TabOrder = 2 TabOrder = 2
end end
object SelVarInBtn: TBitBtn object SelVarInBtn: TBitBtn[14]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = SelVarOutBtn AnchorSideBottom.Control = SelVarOutBtn
@ -276,7 +207,7 @@ inherited BreakDownFrm: TBreakDownFrm
Spacing = 0 Spacing = 0
TabOrder = 4 TabOrder = 4
end end
object SelVarOutBtn: TBitBtn object SelVarOutBtn: TBitBtn[15]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList AnchorSideBottom.Control = VarList
@ -293,25 +224,22 @@ inherited BreakDownFrm: TBreakDownFrm
TabOrder = 5 TabOrder = 5
end end
end end
object ParamsSplitter: TSplitter[1] inherited ParamsSplitter: TSplitter
Left = 356 Left = 356
Height = 363 Height = 363
Top = 0
Width = 5
ResizeStyle = rsPattern
end end
object PageControl1: TPageControl[2] object PageControl: TPageControl[2]
Left = 365 Left = 365
Height = 347 Height = 347
Top = 8 Top = 8
Width = 500 Width = 500
ActivePage = AnovaPage ActivePage = BreakDownPage
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 = 1 TabIndex = 0
TabOrder = 2 TabOrder = 2
object BreakDownPage: TTabSheet object BreakDownPage: TTabSheet
Caption = 'Report' Caption = 'Report'

View File

@ -9,65 +9,52 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, ComCtrls, StdCtrls, ExtCtrls, Buttons, ComCtrls,
MainUnit, Globals, FunctionsLib, DataProcs, ContextHelpUnit, MainUnit, Globals, DataProcs, BasicStatsReportFormUnit, ReportFrameUnit;
BasicStatsFormUnit, ReportFrameUnit;
type type
{ TBreakDownFrm } { TBreakDownFrm }
TBreakDownFrm = class(TBasicStatsForm) TBreakDownFrm = class(TBasicStatsReportForm)
Bevel1: TBevel;
ComputeBtn: TButton;
HelpBtn: TButton;
InBtn: TBitBtn; InBtn: TBitBtn;
OutBtn: TBitBtn; OutBtn: TBitBtn;
PageControl1: TPageControl; PageControl: TPageControl;
ParamsPanel: TPanel;
SelVarInBtn: TBitBtn; SelVarInBtn: TBitBtn;
SelVarOutBtn: TBitBtn; SelVarOutBtn: TBitBtn;
ResetBtn: TButton;
CloseBtn: TButton;
CheckGroup1: TCheckGroup; CheckGroup1: TCheckGroup;
DepVar: TEdit; DepVar: TEdit;
AvailLabel: TLabel; AvailLabel: TLabel;
AnalLabel: TLabel; AnalLabel: TLabel;
SelLabel: TLabel; SelLabel: TLabel;
SelList: TListBox; SelList: TListBox;
ParamsSplitter: TSplitter;
BreakDownPage: TTabSheet; BreakDownPage: TTabSheet;
AnovaPage: TTabSheet; AnovaPage: TTabSheet;
VarList: TListBox; VarList: TListBox;
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 InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject); procedure OutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure SelListDblClick(Sender: TObject); procedure SelListDblClick(Sender: TObject);
procedure SelListSelectionChange(Sender: TObject; User: boolean); procedure SelListSelectionChange(Sender: TObject; {%H-}User: boolean);
procedure SelVarInBtnClick(Sender: TObject); procedure SelVarInBtnClick(Sender: TObject);
procedure SelVarOutBtnClick(Sender: TObject); procedure SelVarOutBtnClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject); procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
private private
{ private declarations }
FBreakdownReportFrame: TReportFrame;
FANOVAReportFrame: TReportFrame; FANOVAReportFrame: TReportFrame;
FAutoSized: Boolean;
procedure ANOVA(ListSize: Integer; Freq, Selected, Minimum, Subscript, procedure ANOVA(ListSize: Integer; Freq, Selected, Minimum, Subscript,
Levels, Displace: IntDyneVec; Mean, SS: DblDyneVec; AReport: TStrings); Levels, Displace: IntDyneVec; Mean, SS: DblDyneVec; AReport: TStrings);
procedure GetLevels(const AMinimum, AMaximum, ALevels, ADisplace: IntDyneVec); procedure GetLevels(const AMinimum, AMaximum, ALevels, ADisplace: IntDyneVec);
procedure GetMinMax(const AMinimum, AMaximum, ASelected: IntDyneVec); procedure GetMinMax(const AMinimum, AMaximum, ASelected: IntDyneVec);
function Index_Pos(const X, ADisplace: IntDyneVec; AListSize: integer): Integer; function Index_Pos(const X, ADisplace: IntDyneVec; AListSize: integer): Integer;
procedure UpdateBtnStates;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override; procedure Reset; override;
end; end;
@ -87,6 +74,44 @@ uses
{ TBreakDownFrm } { TBreakDownFrm }
constructor TBreakDownFrm.Create(AOwner: TComponent);
begin
inherited;
FReportFrame.Parent := BreakDownPage;
FANOVAReportFrame := TReportFrame.Create(ANOVAPage);
with FANOVAReportFrame do
begin
Parent := ANOVAPage;
Align := alClient;
end;
PageControl.ActivePage := BreakdownPage;
Reset;
end;
procedure TBreakDownFrm.AdjustConstraints;
begin
inherited;
ParamsPanel.Constraints.MinWidth := Max(
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left,
SelLabel.Width * 2 + InBtn.Width + VarList.BorderSpacing.Right * 2);
ParamsPanel.Constraints.MinHeight := InBtn.Top +
4*InBtn.Height + 3*OutBtn.BorderSpacing.Bottom +
CheckGroup1.BorderSpacing.Top + CheckGroup1.Height + ButtonBevel.Height +
CloseBtn.BorderSpacing.Top + CloseBtn.Height;
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Left*2;
if Width < Constraints.MinWidth then Width := 1; // enforce constraints
if Height < Constraints.MinHeight then Height := 1;
end;
procedure TBreakDownFrm.ANOVA(ListSize: Integer; Freq, Selected, Minimum, procedure TBreakDownFrm.ANOVA(ListSize: Integer; Freq, Selected, Minimum,
Subscript, Levels, Displace: IntDyneVec; Mean, SS: DblDyneVec; AReport: TStrings); Subscript, Levels, Displace: IntDyneVec; Mean, SS: DblDyneVec; AReport: TStrings);
var var
@ -167,7 +192,7 @@ begin
AReport.Add('Insufficient data for ANOVA'); AReport.Add('Insufficient data for ANOVA');
AReport.Add(''); AReport.Add('');
AReport.Add(DIVIDER_SMALL_AUTO); AReport.Add(DIVIDER_AUTO);
AReport.Add(''); AReport.Add('');
SSB := 0.0; SSB := 0.0;
@ -252,13 +277,7 @@ begin
end; end;
procedure TBreakDownFrm.CloseBtnClick(Sender: TObject); procedure TBreakDownFrm.Compute;
begin
Close;
end;
procedure TBreakDownFrm.ComputeBtnClick(Sender: TObject);
label label
Label1, Label3, Label4, NextStep; Label1, Label3, Label4, NextStep;
var var
@ -288,6 +307,8 @@ var
tempval: string; tempval: string;
lReport: TStrings; lReport: TStrings;
begin begin
inherited;
// Identify columns of variables to analyze and the dependent var. // Identify columns of variables to analyze and the dependent var.
NoSelected := SelList.Items.Count; NoSelected := SelList.Items.Count;
@ -470,7 +491,8 @@ begin
lReport.Add('Std. Dev. across levels: ********'); lReport.Add('Std. Dev. across levels: ********');
lReport.Add(''); lReport.Add('');
lReport.Add('==============================================================='); lReport.Add(DIVIDER_AUTO);
// lReport.Add('===============================================================');
lReport.Add(''); lReport.Add('');
//OutputFrm.ShowModal; //OutputFrm.ShowModal;
//OutputFrm.Clear; //OutputFrm.Clear;
@ -516,7 +538,7 @@ begin
lReport.Add('Overall Standard Deviation: %8.3f', [SD]); lReport.Add('Overall Standard Deviation: %8.3f', [SD]);
end; end;
FBreakdownReportFrame.DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
lReport.Clear; lReport.Clear;
// Do ANOVA's if requested // Do ANOVA's if requested
@ -526,6 +548,7 @@ begin
// Show ANOVA in pagecontrol // Show ANOVA in pagecontrol
FANovaReportFrame.DisplayReport(lReport); FANovaReportFrame.DisplayReport(lReport);
end; end;
AnovaPage.TabVisible := CheckGroup1.Checked[0];
finally finally
lReport.Free; lReport.Free;
@ -533,61 +556,6 @@ begin
end; end;
procedure TBreakDownFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
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.MinWidth := Max(
4*w + 3*CloseBtn.BorderSpacing.Left,
SelLabel.Width * 2 + InBtn.Width + VarList.BorderSpacing.Right * 2);
ParamsPanel.Constraints.MinHeight := InBtn.Top +
4*InBtn.Height + 3*OutBtn.BorderSpacing.Bottom +
CheckGroup1.BorderSpacing.Top + CheckGroup1.Height + Bevel1.Height +
CloseBtn.BorderSpacing.Top + CloseBtn.Height;
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 300;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Left*2;
if Width < Constraints.MinWidth then Width := 1; // enforce constraints
if Height < Constraints.MinHeight then Height := 1;
Position := poDesigned;
FAutoSized := true;
end;
procedure TBreakDownFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
InitForm(self);
FBreakDownReportFrame := TReportFrame.Create(self);
with FBreakdownReportFrame do
begin
Parent := BreakDownPage;
Align := alClient;
end;
FANOVAReportFrame := TReportFrame.Create(ANOVAPage);
with FANOVAReportFrame do
begin
Parent := ANOVAPage;
Align := alClient;
end;
Reset;
end;
procedure TBreakDownFrm.GetLevels(const AMinimum, AMaximum, ALevels, ADisplace: IntDyneVec); procedure TBreakDownFrm.GetLevels(const AMinimum, AMaximum, ALevels, ADisplace: IntDyneVec);
var var
i: Integer; i: Integer;
@ -633,13 +601,6 @@ begin
end; end;
end; end;
procedure TBreakDownFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TBreakDownFrm.InBtnClick(Sender: TObject); procedure TBreakDownFrm.InBtnClick(Sender: TObject);
var var
@ -704,7 +665,9 @@ begin
for i := 1 to NoVariables do for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
FBreakdownReportFrame.Clear; if FReportFrame <> nil then
FReportFrame.Clear;
if FAnovaReportFrame <> nil then
FAnovaReportFrame.Clear; FAnovaReportFrame.Clear;
BreakdownPage.Caption := 'Report'; BreakdownPage.Caption := 'Report';
@ -714,12 +677,6 @@ begin
end; end;
procedure TBreakDownFrm.ResetBtnClick(Sender: TObject);
begin
Reset;
end;
procedure TBreakDownFrm.SelListDblClick(Sender: TObject); procedure TBreakDownFrm.SelListDblClick(Sender: TObject);
var var
index: Integer; index: Integer;
@ -788,7 +745,9 @@ begin
SelVarInBtn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = ''); SelVarInBtn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = '');
SelVarOutBtn.Enabled := (DepVar.Text <> ''); SelVarOutBtn.Enabled := (DepVar.Text <> '');
FBreakdownReportFrame.UpdateBtnStates; if FReportFrame <> nil then
FReportFrame.UpdateBtnStates;
if FAnovaReportFrame <> nil then
FAnovaReportFrame.UpdateBtnStates; FAnovaReportFrame.UpdateBtnStates;
end; end;