LazStats: Integrate report output into the form of BreakDownUnit. Begin refactoring of Compute routine. Fix TabOrder of MultXvsYUnit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7704 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-09-27 22:43:10 +00:00
parent bd95521f4b
commit 697e7ba4f8
4 changed files with 410 additions and 328 deletions

View File

@ -1,74 +1,147 @@
object BreakDownFrm: TBreakDownFrm
inherited BreakDownFrm: TBreakDownFrm
Left = 400
Height = 367
Height = 363
Top = 248
Width = 428
Width = 873
HelpType = htKeyword
HelpKeyword = 'html/Breakdown.htm'
AutoSize = True
Caption = 'Breakdown'
ClientHeight = 367
ClientWidth = 428
ClientHeight = 363
ClientWidth = 873
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object CheckGroup1: TCheckGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Panel2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
object ParamsPanel: TPanel[0]
Left = 8
Height = 51
Top = 267
Width = 140
Anchors = [akLeft, akBottom]
AutoFill = True
AutoSize = True
Height = 347
Top = 8
Width = 344
Align = alLeft
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Option'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 31
ClientWidth = 136
Items.Strings = (
'One Way ANOVA'
)
TabOrder = 1
Data = {
0100000002
}
end
object Panel2: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CheckGroup1
Left = 8
Height = 251
Top = 8
Width = 412
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 8
BorderSpacing.Right = 4
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 251
ClientWidth = 412
Constraints.MinHeight = 200
ClientHeight = 347
ClientWidth = 344
TabOrder = 0
object CloseBtn: TButton
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 289
Height = 25
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
end
object Bevel1: TBevel
AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
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
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 10
end
object CheckGroup1: TCheckGroup
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 0
Height = 51
Top = 255
Width = 140
Anchors = [akLeft, akBottom]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Option'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 31
ClientWidth = 136
Items.Strings = (
'One Way ANOVA'
)
TabOrder = 7
Data = {
0100000002
}
end
object AvailLabel: TLabel
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = Panel2
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
Left = 0
Height = 15
Top = 0
@ -78,8 +151,8 @@ object BreakDownFrm: TBreakDownFrm
end
object AnalLabel: TLabel
AnchorSideLeft.Control = SelList
AnchorSideTop.Control = Panel2
Left = 228
AnchorSideTop.Control = ParamsPanel
Left = 194
Height = 15
Top = 0
Width = 104
@ -89,9 +162,9 @@ object BreakDownFrm: TBreakDownFrm
object SelLabel: TLabel
AnchorSideLeft.Control = SelList
AnchorSideBottom.Control = DepVar
Left = 228
Left = 194
Height = 15
Top = 199
Top = 195
Width = 153
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
@ -99,16 +172,15 @@ object BreakDownFrm: TBreakDownFrm
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = AvailLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = InBtn
AnchorSideBottom.Control = Panel2
AnchorSideBottom.Side = asrBottom
AnchorSideBottom.Control = CheckGroup1
Left = 0
Height = 234
Height = 230
Top = 17
Width = 184
Width = 150
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 8
@ -122,13 +194,13 @@ object BreakDownFrm: TBreakDownFrm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = AnalLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel2
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SelVarInBtn
Left = 228
Height = 166
Left = 194
Height = 162
Top = 17
Width = 184
Width = 150
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
@ -145,10 +217,10 @@ object BreakDownFrm: TBreakDownFrm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SelVarOutBtn
AnchorSideBottom.Side = asrBottom
Left = 228
Left = 194
Height = 23
Top = 216
Width = 184
Top = 212
Width = 150
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Bottom = 12
@ -157,10 +229,10 @@ object BreakDownFrm: TBreakDownFrm
Text = 'DepVar'
end
object InBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 192
Left = 158
Height = 28
Top = 17
Width = 28
@ -171,11 +243,11 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 1
end
object OutBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = InBtn
AnchorSideTop.Side = asrBottom
Left = 192
Left = 158
Height = 28
Top = 49
Width = 28
@ -187,12 +259,12 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 2
end
object SelVarInBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = SelVarOutBtn
Left = 192
Left = 158
Height = 28
Top = 191
Top = 187
Width = 28
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 4
@ -203,13 +275,13 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 4
end
object SelVarOutBtn: TBitBtn
AnchorSideLeft.Control = Panel2
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = VarList
AnchorSideBottom.Side = asrBottom
Left = 192
Left = 158
Height = 28
Top = 223
Top = 219
Width = 28
Anchors = [akLeft, akBottom]
Images = MainDataModule.ImageList
@ -219,89 +291,32 @@ object BreakDownFrm: TBreakDownFrm
TabOrder = 5
end
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 361
Height = 25
Top = 334
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 12
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 4
object ParamsSplitter: TSplitter[1]
Left = 356
Height = 363
Top = 0
Width = 5
ResizeStyle = rsPattern
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 215
Height = 25
Top = 334
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
object PageControl1: TPageControl[2]
Left = 365
Height = 347
Top = 8
Width = 500
ActivePage = BreakDownPage
Align = alClient
BorderSpacing.Left = 4
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object HelpBtn: TButton
Tag = 109
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 156
Height = 25
Top = 334
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabIndex = 0
TabOrder = 2
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 318
Width = 428
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 277
Height = 25
Top = 334
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 5
object BreakDownPage: TTabSheet
Caption = 'Report'
end
object AnovaPage: TTabSheet
Caption = 'Analaxis of Variance'
TabVisible = False
end
end
end

View File

@ -7,21 +7,23 @@ unit BreakDownUnit;
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons,
MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, ContextHelpUnit;
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons, ComCtrls,
MainUnit, Globals, FunctionsLib, DataProcs, ContextHelpUnit,
BasicStatsFormUnit, ReportFrameUnit;
type
{ TBreakDownFrm }
TBreakDownFrm = class(TForm)
TBreakDownFrm = class(TBasicStatsForm)
Bevel1: TBevel;
ComputeBtn: TButton;
HelpBtn: TButton;
InBtn: TBitBtn;
OutBtn: TBitBtn;
Panel2: TPanel;
PageControl1: TPageControl;
ParamsPanel: TPanel;
SelVarInBtn: TBitBtn;
SelVarOutBtn: TBitBtn;
ResetBtn: TButton;
@ -32,11 +34,14 @@ type
AnalLabel: TLabel;
SelLabel: TLabel;
SelList: TListBox;
ParamsSplitter: TSplitter;
BreakDownPage: TTabSheet;
AnovaPage: TTabSheet;
VarList: TListBox;
procedure CloseBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure InBtnClick(Sender: TObject);
procedure OutBtnClick(Sender: TObject);
@ -48,12 +53,13 @@ type
private
{ private declarations }
FBreakdownReportFrame: TReportFrame;
FANOVAReportFrame: TReportFrame;
FAutoSized: Boolean;
Minimum, Maximum, levels, displace, subscript : IntDyneVec;
Freq : IntDyneVec;
Selected : IntDyneVec;
mean, variance, Stddev, SS : DblDyneVec;
index, NoSelected, ListSize, Dependentvar, X, length_array : integer;
index, ListSize, length_array : integer;
ptr1, ptr2, sum, grandsum : integer;
xsumtotal, xsqrtotal, grandsumx, grandsumx2, value, SD : double;
SST, SSW, SSB, MSW, MSB, F, FProb, DF1, DF2 : double;
@ -61,130 +67,46 @@ type
outline : string;
valstr : string;
dataread : boolean;
function Index_Pos(var X1: IntDyneVec; var displace1: IntDyneVec; ListSize1: integer): Integer;
function Index_Pos(const X, ADisplace: IntDyneVec; AListSize: integer): Integer;
procedure UpdateBtnStates;
public
{ public declarations }
procedure Reset; override;
end;
var
BreakDownFrm: TBreakDownFrm;
implementation
{$R *.lfm}
uses
Math;
Math, Utils;
{ TBreakDownFrm }
procedure TBreakDownFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
procedure TBreakDownFrm.CloseBtnClick(Sender: TObject);
begin
VarList.Clear;
SelList.Clear;
DepVar.Text := '';
InBtn.Enabled := true;
OutBtn.Enabled := false;
SelVarInBtn.Enabled := true;
SelVarOutBtn.Enabled := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
Close;
end;
procedure TBreakDownFrm.SelListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarInBtnClick(Sender: TObject);
var
index1 : integer;
begin
index1 := VarList.ItemIndex;
if (index1 > -1) and (DepVar.Text = '') then
begin
DepVar.Text := VarList.Items[index1];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarOutBtnClick(Sender: TObject);
begin
if DepVar.Text <> '' then
VarList.Items.Add(DepVar.Text);
UpdateBtnStates;
end;
procedure TBreakDownFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
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;
//Panel2.Constraints.MinWidth := SelLabel.Width * 2 + InBtn.Width + 2 * VarList.BorderSpacing.Right;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TBreakDownFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TBreakDownFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TBreakDownFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if (VarList.Selected[i]) then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.ComputeBtnClick(Sender: TObject);
label
Label1, Label3, Label4, NextStep, FirstOne, SecondOne, ThirdOne, LastStep;
var
mean: DblDyneVec = nil;
variance: DblDyneVec = nil;
stddev: DblDyneVec = nil;
SS: DblDyneVec = nil;
X: Integer;
i, j: integer;
Dependentvar, NoSelected: Integer;
tempval: string;
lReport: TStrings;
begin
@ -306,16 +228,19 @@ begin
// setup the output
lReport := TStringList.Create;
try
BreakdownPage.Caption := 'Breakdown Analysis';
lReport.Add('BREAKDOWN ANALYSIS PROGRAM');
lReport.Add('');
lReport.Add('VARIABLE SEQUENCE FOR THE BREAKDOWN:');
for i := 1 to ListSize do
begin
index := Selected[i-1];
lReport.Add('%-10s (Variable %3d) Lowest level = %2d Highest level = %2d', [
lReport.Add('%-10s (Variable %3d) Lowest level: %2d Highest level: %2d', [
OS3MainFrm.DataGrid.Cells[index,0],i, Minimum[i-1], Maximum[i-1]
]);
end;
lReport.Add('');
// Breakdown the data
ptr1 := ListSize - 1;
@ -335,7 +260,7 @@ begin
for i := 1 to ListSize do
begin
j := Selected[i-1];
lReport.Add('%-10s level = %3d', [
lReport.Add('%-10s level %3d', [
OS3MainFrm.DataGrid.Cells[j,0], Minimum[i-1] + subscript[i-1] - 1
]);
end;
@ -345,15 +270,17 @@ begin
xsumtotal := xsumtotal + mean[index];
xsqrtotal := xsqrtotal + variance[index];
lReport.Add('Freq. Mean Std. Dev.');
outline := Format('%3d', [Freq[index]]);
lReport.Add(' Freq. Mean Std. Dev.');
lReport.Add('-------- -------- ---------');
// xxxxxxx xxxxxxxx xxxxxxxx
outline := Format('%7d', [Freq[index]]);
if Freq[index] > 0 then
begin
valstr := Format(' %8.3f ',[mean[index] / Freq[index]]);
valstr := Format(' %8.3f ',[mean[index] / Freq[index]]);
outline := outline + valstr;
end
else
outline := outline +' ******** ';
outline := outline +' ******** ';
if Freq[index] > 1 then
begin
@ -371,18 +298,19 @@ begin
subscript[ptr2-1] := subscript[ptr2-1] + 1;
if subscript[ptr2-1] <= levels[ptr2-1] then goto Label1;
lReport.Add('Number of observations across levels = %d',[sum]);
lReport.Add ('Number of observations across levels: %8d',[sum]);
if sum > 0 then
lReport.Add('Mean across levels = %8.3f',[ xsumtotal / sum])
lReport.Add('Mean across levels: %8.3f',[ xsumtotal / sum])
else
lReport.Add('Mean across levels = ********');
lReport.Add('Mean across levels: ********');
if sum > 1 then
begin
SD := sqrt( (xsqrtotal - (xsumtotal * xsumtotal) / sum) / (sum - 1));
lReport.Add('Std. Dev. across levels = %8.3f', [SD]);
lReport.Add('Std. Dev. across levels: %8.3f', [SD]);
end else
lReport.Add('Std. Dev. across levels = *******');
lReport.Add('Std. Dev. across levels: ********');
lReport.Add('');
lReport.Add('===============================================================');
@ -422,24 +350,23 @@ begin
goto Label1;
NextStep:
lReport.Add('Grand number of observations across all categories = %3d', [grandsum]);
lReport.Add ('Grand number of observations across all categories: %8d', [grandsum]);
if grandsum > 0 then
lReport.Add('Overall Mean = %8.3f', [grandsumx / grandsum]);
lReport.Add('Overall Mean: %8.3f', [grandsumx / grandsum]);
if grandsum > 1 then
begin
SD := sqrt((grandsumx2 - (grandsumx * grandsumx) / grandsum) / (grandsum - 1));
lReport.Add('Overall standard deviation = %8.3f', [SD]);
SD := sqrt((grandsumx2 - sqr(grandsumx) / grandsum) / (grandsum - 1));
lReport.Add('Overall Standard Deviation: %8.3f', [SD]);
end;
lReport.Add('');
lReport.Add('===============================================================');
lReport.Add('');
//OutputFrm.ShowModal;
//OutputFrm.Clear;
FBreakdownReportFrame.DisplayReport(lReport);
lReport.Clear;
// Do ANOVA's if requested
if CheckGroup1.CheckEnabled[0] then
if CheckGroup1.Checked[0] then
begin
AnovaPage.Caption := 'Analysis of Variance';
AnovaPage.TabVisible := true;
lReport.Add('ANALYSES OF VARIANCE SUMMARY TABLES');
lReport.Add('');
ptr1 := ListSize - 1;
@ -582,28 +509,111 @@ begin
begin
lReport.Add('Only 1 group. No ANOVA possible.');
end;
// Show ANOVA in pagecontrol
FANovaReportFrame.DisplayReport(lReport);
end;
// Show report in output form
DisplayReport(lReport);
finally
lReport.Free;
SS := nil;
Stddev := nil;
variance := nil;
mean := nil;
Freq := nil;
selected := nil;
subscript := nil;
displace := nil;
levels := nil;
Maximum := nil;
Minimum := nil;
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.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TBreakDownFrm.InBtnClick(Sender: TObject);
var
i: integer;
begin
i := 0;
while i < VarList.Items.Count do
begin
if (VarList.Selected[i]) then
begin
SelList.Items.Add(VarList.Items[i]);
VarList.Items.Delete(i);
i := 0;
end else
inc(i);
end;
UpdateBtnStates;
end;
function TBreakDownFrm.Index_Pos(const X, ADisplace: IntDyneVec;
AListSize: integer): integer;
var
i: integer;
begin
Result := X[AListSize-1];
for i := 1 to AListSize - 1 do
Result := Result + (X[i-1] - 1) * ADisplace[i-1];
end;
procedure TBreakDownFrm.OutBtnClick(Sender: TObject);
var
i: integer;
@ -622,16 +632,65 @@ begin
UpdateBtnStates;
end;
function TBreakDownFrm.Index_Pos(var X1: IntDyneVec; var displace1: IntDyneVec;
ListSize1: integer): integer;
procedure TBreakDownFrm.Reset;
var
i: integer;
begin
Result := X1[ListSize-1];
for i := 1 to ListSize - 1 do
Result := Result + ((X1[i-1] - 1) * displace[i-1]);
VarList.Clear;
SelList.Clear;
DepVar.Text := '';
InBtn.Enabled := true;
OutBtn.Enabled := false;
SelVarInBtn.Enabled := true;
SelVarOutBtn.Enabled := false;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
FBreakdownReportFrame.Clear;
FAnovaReportFrame.Clear;
BreakdownPage.Caption := 'Report';
AnovaPage.TabVisible := false;
UpdateBtnStates;
end;
procedure TBreakDownFrm.ResetBtnClick(Sender: TObject);
begin
Reset;
end;
procedure TBreakDownFrm.SelListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarInBtnClick(Sender: TObject);
var
index1 : integer;
begin
index1 := VarList.ItemIndex;
if (index1 > -1) and (DepVar.Text = '') then
begin
DepVar.Text := VarList.Items[index1];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TBreakDownFrm.SelVarOutBtnClick(Sender: TObject);
begin
if DepVar.Text <> '' then
VarList.Items.Add(DepVar.Text);
UpdateBtnStates;
end;
procedure TBreakDownFrm.UpdateBtnStates;
var
lSelected: Boolean;
@ -657,10 +716,17 @@ begin
SelVarInBtn.Enabled := (VarList.ItemIndex > -1) and (DepVar.Text = '');
SelVarOutBtn.Enabled := (DepVar.Text <> '');
FBreakdownReportFrame.UpdateBtnStates;
FAnovaReportFrame.UpdateBtnStates;
end;
procedure TBreakDownFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
initialization
{$I breakdownunit.lrs}
end.

View File

@ -41,7 +41,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 0
TabOrder = 13
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
@ -58,7 +58,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 1
TabOrder = 14
end
object CloseBtn: TButton
AnchorSideRight.Control = ParamsPanel
@ -76,7 +76,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
Caption = 'Close'
ModalResult = 11
OnClick = CloseBtnClick
TabOrder = 2
TabOrder = 15
end
object HelpBtn: TButton
Tag = 134
@ -93,7 +93,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Right = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 3
TabOrder = 12
end
object ButtonBevel: TBevel
AnchorSideLeft.Control = ParamsPanel
@ -129,7 +129,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
Width = 290
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
TabOrder = 4
TabOrder = 11
TextHint = 'Text above the plot'
end
object Label1: TLabel
@ -157,7 +157,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ItemHeight = 0
OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange
TabOrder = 5
TabOrder = 0
end
object XInBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
@ -171,7 +171,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 1
OnClick = XInBtnClick
Spacing = 0
TabOrder = 6
TabOrder = 1
end
object XOutBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
@ -187,7 +187,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 0
OnClick = XOutBtnClick
Spacing = 0
TabOrder = 7
TabOrder = 2
end
object YInBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
@ -203,7 +203,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 1
OnClick = YInBtnClick
Spacing = 0
TabOrder = 8
TabOrder = 4
end
object YOutBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
@ -219,7 +219,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 0
OnClick = YOutBtnClick
Spacing = 0
TabOrder = 9
TabOrder = 5
end
object GroupInBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
@ -235,7 +235,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 1
OnClick = GroupInBtnClick
Spacing = 0
TabOrder = 10
TabOrder = 7
end
object GroupOutBtn: TBitBtn
AnchorSideLeft.Control = ParamsPanel
@ -252,7 +252,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ImageIndex = 0
OnClick = GroupOutBtnClick
Spacing = 0
TabOrder = 11
TabOrder = 8
end
object OptionsGroup: TGroupBox
AnchorSideLeft.Control = GroupOutBtn
@ -272,7 +272,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
ChildSizing.TopBottomSpacing = 2
ClientHeight = 29
ClientWidth = 178
TabOrder = 12
TabOrder = 10
object LinesChk: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 12
@ -312,7 +312,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 13
TabOrder = 3
Text = 'XEdit'
end
object Label3: TLabel
@ -342,7 +342,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 14
TabOrder = 6
Text = 'YEdit'
end
object Label4: TLabel
@ -372,7 +372,7 @@ inherited MultXvsYFrm: TMultXvsYFrm
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 15
TabOrder = 9
Text = 'GroupEdit'
end
end

View File

@ -57,6 +57,7 @@ const
constructor TReportFrame.Create(AOwner: TComponent);
begin
Name := '';
inherited;
ReportPanel.Color := ReportMemo.Color;
UpdateBtnStates;