Inherit ABCLogLinUnit from BasicStatsReportFormUnit

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7916 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-12-02 23:35:42 +00:00
parent 0e430a07bc
commit 013f93a05f
6 changed files with 737 additions and 809 deletions

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
@ -97,7 +99,6 @@
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="7">
<Item1>
@ -597,7 +598,7 @@
<Unit61>
<Filename Value="forms\analysis\cross-classification\loglinscreenunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="LogLinScreenFrm"/>
<ComponentName Value="LogLinScreenForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="LogLinScreenUnit"/>
@ -613,7 +614,7 @@
<Unit63>
<Filename Value="forms\analysis\cross-classification\abcloglinunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="ABCLogLinearFrm"/>
<ComponentName Value="ABCLogLinearForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="ABCLogLinUnit"/>

View File

@ -1,115 +1,94 @@
object ABCLogLinearFrm: TABCLogLinearFrm
inherited ABCLogLinearForm: TABCLogLinearForm
Left = 596
Height = 432
Height = 408
Top = 216
Width = 395
Width = 854
HelpType = htKeyword
HelpKeyword = 'html/html/AxBxCLogLinear.htm'
AutoSize = True
Caption = 'Log Linear Analysis for AxBxC Classification Table'
ClientHeight = 432
ClientWidth = 395
OnActivate = FormActivate
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 186
Height = 25
Top = 399
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 248
Height = 25
Top = 399
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 4
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 332
Height = 25
Top = 399
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
ClientHeight = 408
ClientWidth = 854
inherited ParamsPanel: TPanel
Height = 392
Width = 376
ClientHeight = 392
ClientWidth = 376
inherited CloseBtn: TButton
Left = 321
Top = 367
TabOrder = 5
end
object HelpBtn: TButton
inherited ComputeBtn: TButton
Left = 237
Top = 367
TabOrder = 4
end
inherited ResetBtn: TButton
Left = 175
Top = 367
TabOrder = 3
end
inherited HelpBtn: TButton
Tag = 101
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 127
Height = 25
Top = 399
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Help'
OnClick = HelpBtnClick
Left = 116
Top = 367
TabOrder = 2
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
inherited ButtonBevel: TBevel
Top = 351
Width = 376
end
object FileFromGrp: TRadioGroup[5]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ParamsPanel
Left = 7
Height = 51
Top = 0
Width = 362
AutoFill = True
AutoSize = True
Caption = 'Enter Data From:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 358
Columns = 2
Items.Strings = (
'File Data in the Main Grid'
'Data Entered on this Form'
)
OnClick = FileFromGrpClick
TabOrder = 0
end
object Notebook: TNotebook[6]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = FileFromGrp
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 316
AnchorSideBottom.Control = ButtonBevel
Left = 0
Height = 284
Top = 67
Width = 379
PageIndex = 0
Width = 376
PageIndex = 1
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Top = 16
TabOrder = 1
object Page1: TPage
object Label3: TLabel
AnchorSideLeft.Control = RowVarEdit
AnchorSideBottom.Control = RowVarEdit
Left = 211
Left = 210
Height = 15
Top = 8
Width = 67
@ -121,7 +100,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
object Label4: TLabel
AnchorSideLeft.Control = ColVarEdit
AnchorSideBottom.Control = ColVarEdit
Left = 211
Left = 210
Height = 15
Top = 84
Width = 87
@ -133,7 +112,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
object Label5: TLabel
AnchorSideLeft.Control = SliceVarEdit
AnchorSideBottom.Control = SliceVarEdit
Left = 211
Left = 210
Height = 15
Top = 160
Width = 68
@ -145,7 +124,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
object Label6: TLabel
AnchorSideLeft.Control = FreqVarEdit
AnchorSideBottom.Control = FreqVarEdit
Left = 211
Left = 210
Height = 15
Top = 236
Width = 99
@ -161,12 +140,13 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideBottom.Control = Page1
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 316
Height = 292
Top = 0
Width = 167
Width = 166
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 8
ItemHeight = 0
OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
@ -174,7 +154,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideLeft.Control = Page1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 175
Left = 174
Height = 28
Top = 0
Width = 28
@ -189,7 +169,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RowInBtn
AnchorSideTop.Side = asrBottom
Left = 175
Left = 174
Height = 28
Top = 32
Width = 28
@ -206,7 +186,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = RowOutBtn
AnchorSideTop.Side = asrBottom
Left = 175
Left = 174
Height = 28
Top = 76
Width = 28
@ -222,7 +202,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ColInBtn
AnchorSideTop.Side = asrBottom
Left = 175
Left = 174
Height = 28
Top = 108
Width = 28
@ -239,7 +219,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ColOutBtn
AnchorSideTop.Side = asrBottom
Left = 175
Left = 174
Height = 28
Top = 152
Width = 28
@ -255,7 +235,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = SliceBtnIn
AnchorSideTop.Side = asrBottom
Left = 175
Left = 174
Height = 28
Top = 184
Width = 28
@ -272,7 +252,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = SliceBtnOut
AnchorSideTop.Side = asrBottom
Left = 175
Left = 174
Height = 28
Top = 228
Width = 28
@ -289,7 +269,7 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideTop.Control = FreqInBtn
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 175
Left = 174
Height = 28
Top = 260
Width = 28
@ -308,10 +288,10 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = RowOutBtn
AnchorSideBottom.Side = asrBottom
Left = 211
Left = 210
Height = 23
Top = 25
Width = 168
Width = 166
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
@ -326,10 +306,10 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ColOutBtn
AnchorSideBottom.Side = asrBottom
Left = 211
Left = 210
Height = 23
Top = 101
Width = 168
Width = 166
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
@ -344,10 +324,10 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SliceBtnOut
AnchorSideBottom.Side = asrBottom
Left = 211
Left = 210
Height = 23
Top = 177
Width = 168
Width = 166
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
@ -362,10 +342,10 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = FreqOutBtn
AnchorSideBottom.Side = asrBottom
Left = 211
Left = 210
Height = 23
Top = 253
Width = 168
Width = 166
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
@ -449,15 +429,17 @@ object ABCLogLinearFrm: TABCLogLinearFrm
AnchorSideBottom.Control = Page2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 339
Height = 253
Top = 31
Width = 444
Width = 376
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 8
ColCount = 2
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goTabs, goSmoothScroll]
ColCount = 4
FixedCols = 3
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goTabs, goThumbTracking, goSmoothScroll]
RowCount = 2
TabOrder = 2
TabOrder = 3
end
object NslicesEdit: TEdit
AnchorSideLeft.Control = Label7
@ -470,61 +452,14 @@ object ABCLogLinearFrm: TABCLogLinearFrm
Alignment = taRightJustify
BorderSpacing.Left = 8
OnKeyPress = NslicesEditKeyPress
TabOrder = 3
TabOrder = 2
Text = 'NslicesEdit'
end
end
end
object FileFromGrp: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 51
Top = 8
Width = 362
AutoFill = True
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Enter Data From:'
ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 24
ChildSizing.VerticalSpacing = 2
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 31
ClientWidth = 358
Columns = 2
Items.Strings = (
'File Data in the Main Grid'
'Data Entered on this Form'
)
OnClick = FileFromGrpClick
TabOrder = 0
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 383
Width = 395
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Bevel2: TBevel
Left = 1
Height = 12
Top = 434
Width = 10
Shape = bsSpacer
inherited ParamsSplitter: TSplitter
Left = 388
Height = 408
end
end

View File

@ -7,19 +7,17 @@ unit ABCLogLinUnit;
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, Buttons, Grids,
OutputUnit, MainUnit, Globals, DataProcs, ContextHelpUnit;
MainUnit, Globals, DataProcs, BasicStatsReportFormUnit;
type
{ TABCLogLinearFrm }
{ TABCLogLinearForm }
TABCLogLinearFrm = class(TForm)
Bevel1: TBevel;
TABCLogLinearForm = class(TBasicStatsReportForm)
Bevel2: TBevel;
HelpBtn: TButton;
Notebook1: TNotebook;
Notebook: TNotebook;
Page1: TPage;
Page2: TPage;
RowInBtn: TBitBtn;
@ -32,9 +30,6 @@ type
FreqOutBtn: TBitBtn;
NslicesEdit: TEdit;
Label7: TLabel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
NRowsEdit: TEdit;
NColsEdit: TEdit;
RowVarEdit: TEdit;
@ -52,26 +47,20 @@ type
FileFromGrp: TRadioGroup;
procedure ColInBtnClick(Sender: TObject);
procedure ColOutBtnClick(Sender: TObject);
procedure ComputeBtnClick(Sender: TObject);
procedure FileFromGrpClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FreqInBtnClick(Sender: TObject);
procedure FreqOutBtnClick(Sender: TObject);
procedure NColsEditKeyPress(Sender: TObject; var Key: char);
procedure NRowsEditKeyPress(Sender: TObject; var Key: char);
procedure NslicesEditKeyPress(Sender: TObject; var Key: char);
procedure ResetBtnClick(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure RowInBtnClick(Sender: TObject);
procedure RowOutBtnClick(Sender: TObject);
procedure SliceBtnInClick(Sender: TObject);
procedure SliceBtnOutClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
private
{ private declarations }
FAutoSized: Boolean;
procedure ModelEffect(
Nrows, Ncols, Nslices: integer;
const Data: DblDyneCube;
@ -95,200 +84,56 @@ type
procedure PrintMatrix(const X: DblDyneMat;
Nrows, Ncols: integer; Title: string; AReport: TStrings);
procedure UpdateBtnStates;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override;
public
{ public declarations }
procedure Reset; override;
end;
var
ABCLogLinearFrm: TABCLogLinearFrm;
ABCLogLinearForm: TABCLogLinearForm;
implementation
{$R *.lfm}
uses
Math;
Math,
GridProcs;
{ TABCLogLinearFrm }
procedure TABCLogLinearFrm.ResetBtnClick(Sender: TObject);
var
i: integer;
{ TABCLogLinearForm }
procedure TABCLogLinearForm.AdjustConstraints;
begin
Grid.ColCount := 4;
Grid.RowCount := 2;
Grid.Cells[0,0] := 'ROW';
Grid.Cells[1,0] := 'COL';
Grid.Cells[2,0] := 'SLICE';
Grid.Cells[3,0] := 'FREQ.';
VarList.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
RowVarEdit.Text := '';
ColVarEdit.Text := '';
SliceVarEdit.Text := '';
FreqVarEdit.Text := '';
NRowsEdit.Text := '';
NColsEdit.Text := '';
NSlicesEdit.Text := '';
FileFromGrp.ItemIndex := -1;
Notebook1.Hide;
UpdateBtnStates;
inherited;
ParamsPanel.Constraints.MinWidth := MaxValue([
FileFromGrp.Width,
NSlicesEdit.Left + NSlicesEdit.Width,
4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left
]);
ParamsPanel.Constraints.MinHeight :=
FileFromGrp.Height + NoteBook.BorderSpacing.Top +
FreqOutBtn.Top + FreqOutBtn.Height + ButtonBevel.Height +
Closebtn.BorderSpacing.Top + CloseBtn.Height;
end;
procedure TABCLogLinearFrm.HelpBtnClick(Sender: TObject);
procedure TABCLogLinearForm.FileFromGrpClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).tag);
Notebook.Show;
Notebook.PageIndex := fileFromGrp.ItemIndex;
end;
procedure TABCLogLinearFrm.RowInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (RowVarEdit.Text = '') then
begin
RowVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TABCLogLinearFrm.RowOutBtnClick(Sender: TObject);
begin
if RowVarEdit.Text <> '' then
begin
VarList.Items.Add(RowVarEdit.Text);
RowVarEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TABCLogLinearFrm.SliceBtnInClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (SliceVarEdit.Text = '') then
begin
SliceVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TABCLogLinearFrm.SliceBtnOutClick(Sender: TObject);
begin
if SliceVarEdit.Text <> '' then
begin
VarList.Items.Add(SliceVarEdit.Text);
SliceVarEdit.Text := '';
end;
end;
procedure TABCLogLinearFrm.VarListSelectionChange(Sender: TObject;
User: boolean);
begin
UpdateBtnStates;
end;
procedure TABCLogLinearFrm.FileFromGrpClick(Sender: TObject);
begin
NoteBook1.Show;
NoteBook1.PageIndex := fileFromGrp.ItemIndex;
{
if FileFromGrp.ItemIndex = 0 then // file from main form
begin
VarList.Visible := true;
RowInBtn.Visible := true;
RowOutBtn.Visible := false;
ColInBtn.Visible := true;
ColOutBtn.Visible := false;
SliceBtnIn.Visible := true;
SliceBtnOut.Visible := false;
FreqInBtn.Visible := true;
FreqOutBtn.Visible := false;
Label4.Visible := true;
Label5.Visible := true;
Label6.Visible := true;
Label3.Visible := true;
RowVarEdit.Visible := true;
ColVarEdit.Visible := true;
SliceVarEdit.Visible := true;
FreqVarEdit.Visible := true;
Label1.Visible := false;
Label2.Visible := false;
Label7.Visible := false;
NRowsEdit.Visible := false;
NColsEdit.Visible := false;
NSlicesEdit.Visible := false;
Grid.Visible := false;
end;
if FileFromGrp.ItemIndex = 1 then // data from this form
begin
VarList.Visible := false;
RowInBtn.Visible := false;
RowOutBtn.Visible := false;
ColInBtn.Visible := false;
ColOutBtn.Visible := false;
SliceBtnIn.Visible := false;
SliceBtnOut.Visible := false;
FreqInBtn.Visible := false;
FreqOutBtn.Visible := false;
Label4.Visible := false;
Label5.Visible := false;
Label6.Visible := false;
Label3.Visible := false;
RowVarEdit.Visible := false;
ColVarEdit.Visible := false;
SliceVarEdit.Visible := false;
FreqVarEdit.Visible := false;
Label1.Visible := true;
Label2.Visible := true;
Label7.Visible := true;
NRowsEdit.Visible := true;
NColsEdit.Visible := true;
NSlicesEdit.Visible := true;
Grid.Visible := true;
end;
}
end;
procedure TABCLogLinearFrm.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;
VarList.Constraints.MinHeight := FreqOutBtn.Top + FreqOutBtn.Height - VarList.Top;
Grid.Constraints.MinHeight := FreqOutBtn.Top + FreqOutBtn.Height - Grid.Top;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TABCLogLinearFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TABCLogLinearFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(Self);
end;
procedure TABCLogLinearFrm.FreqInBtnClick(Sender: TObject);
procedure TABCLogLinearForm.FreqInBtnClick(Sender: TObject);
var
index: integer;
begin
@ -301,7 +146,7 @@ begin
UpdateBtnStates;
end;
procedure TABCLogLinearFrm.FreqOutBtnClick(Sender: TObject);
procedure TABCLogLinearForm.FreqOutBtnClick(Sender: TObject);
begin
if FreqVarEdit.Text <> '' then
begin
@ -310,17 +155,17 @@ begin
end;
end;
procedure TABCLogLinearFrm.NColsEditKeyPress(Sender: TObject; var Key: char);
procedure TABCLogLinearForm.NColsEditKeyPress(Sender: TObject; var Key: char);
begin
if ord(Key) = 13 then NslicesEdit.SetFocus;
end;
procedure TABCLogLinearFrm.NRowsEditKeyPress(Sender: TObject; var Key: char);
procedure TABCLogLinearForm.NRowsEditKeyPress(Sender: TObject; var Key: char);
begin
if ord(Key) = 13 then NcolsEdit.SetFocus;
end;
procedure TABCLogLinearFrm.NslicesEditKeyPress(Sender: TObject; var Key: char);
procedure TABCLogLinearForm.NslicesEditKeyPress(Sender: TObject; var Key: char);
var
i, j, k, row : integer;
Nslices, Ncols, Nrows : integer;
@ -349,7 +194,7 @@ begin
end;
end;
procedure TABCLogLinearFrm.ColInBtnClick(Sender: TObject);
procedure TABCLogLinearForm.ColInBtnClick(Sender: TObject);
var
index: integer;
begin
@ -362,7 +207,7 @@ begin
UpdateBtnStates;
end;
procedure TABCLogLinearFrm.ColOutBtnClick(Sender: TObject);
procedure TABCLogLinearForm.ColOutBtnClick(Sender: TObject);
begin
if ColVarEdit.Text <> '' then
begin
@ -372,43 +217,26 @@ begin
UpdateBtnStates;
end;
procedure TABCLogLinearFrm.ComputeBtnClick(Sender: TObject);
procedure TABCLogLinearForm.Compute;
var
i, j, k, row, col, slice, Nrows, Ncols, Nslices : integer;
Data : DblDyneCube;
AB, AC, BC : DblDyneMat;
RowMarg, ColMarg, SliceMarg : DblDyneVec;
Data: DblDyneCube = nil;
AB: DblDyneMat = nil;
AC: DblDyneMat = nil;
BC: DblDyneMat = nil;
RowMarg: DblDyneVec = nil;
ColMarg: DblDyneVec = nil;
SliceMarg: DblDyneVec = nil;
Total: double;
arraysize: integer;
Model: integer;
astr, Title: string;
RowCol, ColCol, SliceCol, Fcol: integer;
GridPos : IntDyneVec;
GridPos: IntDyneVec = nil;
value: integer;
Fx: double;
lReport: TStrings;
begin
if RowVarEdit.Text = '' then
begin
MessageDlg('Row variable is not selected.', mtError, [mbOK], 0);
exit;
end;
if ColVarEdit.Text = '' then
begin
MessageDlg('Column variable is not selected.', mtError, [mbOK], 0);
exit;
end;
if SliceVarEdit.Text = '' then
begin
MessageDlg('Slice variable is not selected.', mtError, [mbOK], 0);
exit;
end;
if FreqVarEdit.Text = '' then
begin
MessageDlg('Frequency variable is not selected.', mtError, [mbOK], 0);
exit;
end;
Nrows := 0;
Ncols := 0;
Nslices := 0;
@ -417,13 +245,10 @@ begin
if FileFromGrp.ItemIndex = 0 then // mainfrm input
begin
SetLength(GridPos, 4);
for i := 1 to NoVariables do
begin
if RowVarEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then GridPos[0] := i;
if ColVarEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then GridPos[1] := i;
if SliceVarEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then GridPos[2] := i;
if FreqVarEdit.Text = OS3MainFrm.DataGrid.Cells[i,0] then GridPos[3] := i;
end;
GridPos[0] := GetVariableIndex(OS3MainFrm.DataGrid, RowVarEdit.Text);
GridPos[1] := GetVariableIndex(OS3MainFrm.DataGrid, ColVarEdit.Text);
GridPos[2] := GetVariableIndex(OS3MainFrm.DataGrid, SliceVarEdit.Text);
GridPos[3] := GetVariableIndex(OS3MainFrm.DataGrid, FreqVarEdit.Text);
// get no. of rows, columns and slices
for i := 1 to OS3MainFrm.DataGrid.RowCount - 1 do
@ -466,7 +291,7 @@ begin
Fcol := GridPos[3];
for i := 1 to OS3MainFrm.DataGrid.RowCount - 1 do
begin
if not GoodRecord(i, 4, GridPos) then continue;
if not GoodRecord(OS3MainFrm.DataGrid, i, GridPos) then continue;
row := StrToInt(OS3MainFrm.DataGrid.Cells[rowcol,i]);
col := StrToInt(OS3MainFrm.DataGrid.Cells[colcol,i]);
slice := StrToInt(OS3MainFrm.DataGrid.Cells[slicecol,i]);
@ -547,21 +372,14 @@ begin
for Model := 1 to 9 do
ModelEffect(Nrows, Ncols, Nslices, Data, RowMarg, ColMarg, SliceMarg, AB, AC, BC, Total, Model, lReport);
DisplayReport(lReport);
FReportFrame.DisplayReport(lReport);
finally
lReport.Free;
SliceMarg := nil;
ColMarg := nil;
RowMarg := nil;
Data := nil;
BC := nil;
AC := nil;
AB := nil;
end;
end;
procedure TABCLogLinearFrm.ModelEffect(
procedure TABCLogLinearForm.ModelEffect(
Nrows, Ncols, Nslices: integer;
const Data: DblDyneCube;
const RowMarg, ColMarg, SliceMarg: DblDyneVec;
@ -840,7 +658,7 @@ begin
end;
//-------------------------------------------------------------------
procedure TABCLogLinearFrm.Iterate(
procedure TABCLogLinearForm.Iterate(
Nrows, Ncols, Nslices: integer;
const Data: DblDyneCube; const RowMarg, ColMarg, SliceMarg: DblDyneVec;
var Total: double;
@ -937,7 +755,7 @@ Step:
end;
//-------------------------------------------------------------------
procedure TABCLogLinearFrm.PrintTable(
procedure TABCLogLinearForm.PrintTable(
Nrows, Ncols, Nslices: integer;
const Data: DblDyneCube; const RowMarg, ColMarg, SliceMarg: DblDyneVec;
Total: double;
@ -963,9 +781,9 @@ begin
for k := 1 to Nslices do
AReport.Add('Slice %d %8.3f', [k, SliceMarg[k]]);
end;
//-------------------------------------------------------------------
procedure TABCLogLinearFrm.PrintLamdas(Nrows, Ncols, Nslices: integer;
procedure TABCLogLinearForm.PrintLamdas(Nrows, Ncols, Nslices: integer;
const CellLambdas: DblDyneQuad; mu: Double; AReport: TStrings);
var
i, j, k, l: integer;
@ -989,9 +807,9 @@ begin
AReport.Add('');
end;
end;
//-------------------------------------------------------------------
procedure TABCLogLinearFrm.PrintMatrix(const X: DblDyneMat;
procedure TABCLogLinearForm.PrintMatrix(const X: DblDyneMat;
Nrows, Ncols: integer; Title: string; AReport: TStrings);
Label loop;
var
@ -1031,8 +849,89 @@ loop:
AReport.Add('');
end;
procedure TABCLogLinearFrm.UpdateBtnStates;
procedure TABCLogLinearForm.Reset;
var
i: integer;
begin
inherited;
Grid.ColCount := 4;
Grid.RowCount := 2;
Grid.Cells[0,0] := 'ROW';
Grid.Cells[1,0] := 'COL';
Grid.Cells[2,0] := 'SLICE';
Grid.Cells[3,0] := 'FREQ.';
CollectVariableNames(OS3MainFrm.DataGrid, VarList.Items);
RowVarEdit.Text := '';
ColVarEdit.Text := '';
SliceVarEdit.Text := '';
FreqVarEdit.Text := '';
NRowsEdit.Text := '';
NColsEdit.Text := '';
NSlicesEdit.Text := '';
FileFromGrp.ItemIndex := -1;
Notebook.Hide;
UpdateBtnStates;
end;
procedure TABCLogLinearForm.RowInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (RowVarEdit.Text = '') then
begin
RowVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TABCLogLinearForm.RowOutBtnClick(Sender: TObject);
begin
if RowVarEdit.Text <> '' then
begin
VarList.Items.Add(RowVarEdit.Text);
RowVarEdit.Text := '';
end;
UpdateBtnStates;
end;
procedure TABCLogLinearForm.SliceBtnInClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (SliceVarEdit.Text = '') then
begin
SliceVarEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TABCLogLinearForm.SliceBtnOutClick(Sender: TObject);
begin
if SliceVarEdit.Text <> '' then
begin
VarList.Items.Add(SliceVarEdit.Text);
SliceVarEdit.Text := '';
end;
end;
procedure TABCLogLinearForm.UpdateBtnStates;
begin
inherited;
RowInBtn.Enabled := (VarList.ItemIndex > -1) and (RowVarEdit.Text = '');
RowOutBtn.Enabled := (RowVarEdit.Text <> '');
ColInBtn.Enabled := (VarList.ItemIndex > -1) and (ColVarEdit.Text = '');
@ -1043,8 +942,98 @@ begin
FreqOutBtn.Enabled := (FreqVarEdit.Text <> '');
end;
initialization
{$I abcloglinunit.lrs}
function TABCLogLinearForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var
i, n: Integer;
begin
Result := false;
if FileFromGrp.ItemIndex = 0 then // mainfrm input
begin
if RowVarEdit.Text = '' then
begin
AMsg := 'Row variable is not selected.';
AControl := VarList;
exit;
end;
if ColVarEdit.Text = '' then
begin
AMsg := 'Column variable is not selected.';
AControl := VarList;
exit;
end;
if SliceVarEdit.Text = '' then
begin
AMsg := 'Slice variable is not selected.';
AControl := VarList;
exit;
end;
if FreqVarEdit.Text = '' then
begin
AMsg := 'Frequency variable is not selected.';
AControl := VarList;
exit;
end;
end
else
for i := 1 to Grid.RowCount-1 do
begin
if Grid.Cells[3, i] = '' then
begin
AMsg := 'Data missing in row ' + IntToStr(i);
AControl := Grid;
Grid.Row := i;
Grid.Col := 3;
exit;
end;
if not TryStrToInt(Grid.Cells[3, i], n) then
begin
AMsg := 'No valid integer in row ' + IntToStr(i);
AControl := Grid;
Grid.Row := i;
Grid.Col := 3;
exit;
end;
end;
Result := true;
end;
procedure TABCLogLinearForm.VarListDblClick(Sender: TObject);
var
index: Integer;
s: String;
begin
index := VarList.ItemIndex;
if index > -1 then begin
s := VarList.Items[index];
if RowVarEdit.Text = '' then
RowVarEdit.Text := s
else
if ColVarEdit.Text = '' then
ColVarEdit.text := s
else
if SliceVarEdit.Text = '' then
SliceVarEdit.Text := s
else
if FreqVaredit.Text = '' then
FreqVarEdit.Text := s
else
exit;
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TABCLogLinearForm.VarListSelectionChange(Sender: TObject;
User: boolean);
begin
UpdateBtnStates;
end;
end.

View File

@ -19,7 +19,7 @@ object OS3MainFrm: TOS3MainFrm
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
LCLVersion = '2.0.10.0'
LCLVersion = '2.1.0.0'
object PanelTop: TPanel
Left = 0
Height = 35

View File

@ -734,30 +734,6 @@ begin
DblDeclineFrm.ShowModal;
end;
// Menu "Analysis" > "Cross-classification" > "AxB Log Linear"
procedure TOS3MainFrm.mnuAnalysisCC_ABLogLinClick(Sender: TObject);
begin
if TwoWayLogLinFrm = nil then
Application.CreateForm(TTwoWayLogLinFrm, TwoWayLogLinFrm);
TwoWayLogLinFrm.ShowModal;
end;
// Menu "Analysis" > "Cross-Classification" > "AxBxC Log Linear"
procedure TOS3MainFrm.mnuAnalysisCC_ABCLogLinClick(Sender: TObject);
begin
if ABCLogLinearFrm = nil then
Application.CreateForm(TABCLogLinearFrm, ABCLogLinearFrm);
ABCLogLinearFrm.ShowModal;
end;
// Menu "Analysis" > "Cross-classification" > "Log Linear Screen"
procedure TOS3MainFrm.mnuAnalysisCC_LogLinScreenClick(Sender: TObject);
begin
if LogLinScreenFrm = nil then
Application.CreateForm(TLogLinScreenFrm, LogLinScreenFrm);
LogLinScreenFrm.ShowModal;
end;
// Menu "Analysis" > "One sample tests"
procedure TOS3MainFrm.mnuAnalysisOneSampleTestsClick(Sender: TObject);
begin
@ -1509,6 +1485,33 @@ begin
end;
{ "Cross-classification" commands }
// Menu "Analysis" > "Cross-classification" > "AxB Log Linear"
procedure TOS3MainFrm.mnuAnalysisCC_ABLogLinClick(Sender: TObject);
begin
if TwoWayLogLinFrm = nil then
Application.CreateForm(TTwoWayLogLinFrm, TwoWayLogLinFrm);
TwoWayLogLinFrm.Show;
end;
// Menu "Analysis" > "Cross-Classification" > "AxBxC Log Linear"
procedure TOS3MainFrm.mnuAnalysisCC_ABCLogLinClick(Sender: TObject);
begin
if ABCLogLinearForm = nil then
Application.CreateForm(TABCLogLinearForm, ABCLogLinearForm);
ABCLogLinearForm.Show;
end;
// Menu "Analysis" > "Cross-classification" > "Log Linear Screen"
procedure TOS3MainFrm.mnuAnalysisCC_LogLinScreenClick(Sender: TObject);
begin
if LogLinScreenForm = nil then
Application.CreateForm(TLogLinScreenForm, LogLinScreenForm);
LogLinScreenForm.Show;
end;
{ "Measurement Programs" commands }
// Menu "Analysis" > "Measurement Programs" > "Generate Sample Test Data"