From a67c29af626cc333a45a80187dbf72cb2d0e0b6f Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 19 Sep 2020 16:36:44 +0000 Subject: [PATCH] LazStats: Use ReportFrame in DescriptiveUnit. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7671 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../analysis/descriptive/descriptiveunit.lfm | 578 +++++++++--------- .../analysis/descriptive/descriptiveunit.pas | 168 ++--- .../lazstats/source/forms/mainunit.pas | 4 +- .../source/frames/reportframeunit.pas | 38 +- .../lazstats/source/units/globals.pas | 1 + 5 files changed, 430 insertions(+), 359 deletions(-) diff --git a/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.lfm b/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.lfm index e0bdd2245..cb5c9b094 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.lfm +++ b/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.lfm @@ -1,307 +1,323 @@ object DescriptiveFrm: TDescriptiveFrm - Left = 626 - Height = 393 - Top = 226 - Width = 453 + Left = 526 + Height = 384 + Top = 202 + Width = 900 HelpType = htKeyword HelpKeyword = 'html/DistributionStatistics.htm' - AutoSize = True Caption = 'Descriptive Statistics' - ClientHeight = 393 - ClientWidth = 453 + ClientHeight = 384 + ClientWidth = 900 OnActivate = FormActivate OnCreate = FormCreate OnShow = FormShow Position = poMainFormCenter LCLVersion = '2.1.0.0' - object CloseBtn: TButton - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 390 - Height = 25 - Top = 360 - Width = 55 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Close' - ModalResult = 11 - TabOrder = 9 - end - object ResetBtn: TButton - AnchorSideRight.Control = ComputeBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 244 - Height = 25 - Top = 360 - Width = 54 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 8 - end - object HelpBtn: TButton - Tag = 119 - AnchorSideRight.Control = ResetBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 185 - Height = 25 - Top = 360 - Width = 51 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Help' - OnClick = HelpBtnClick - TabOrder = 7 - end - object Label1: TLabel - AnchorSideLeft.Control = GroupBox1 - AnchorSideTop.Control = CIEdit - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = CIEdit - Left = 8 - Height = 15 - Top = 325 - Width = 174 - BorderSpacing.Right = 8 - Caption = 'Confidence Interval for the Mean' - ParentColor = False - end - object Label2: TLabel - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Owner - Left = 8 - Height = 15 - Top = 8 - Width = 46 - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - Caption = 'Variables' - ParentColor = False - end - object Label3: TLabel - AnchorSideLeft.Control = SelList - AnchorSideTop.Control = Owner - Left = 257 - Height = 15 - Top = 8 - Width = 44 - BorderSpacing.Top = 8 - Caption = 'Selected' - ParentColor = False - end - object VarList: TListBox - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Label2 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = AllBtn - AnchorSideBottom.Control = GroupBox1 - Left = 8 - Height = 208 - Top = 25 - Width = 187 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 2 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Constraints.MinHeight = 200 - ItemHeight = 0 - MultiSelect = True - OnSelectionChange = VarListSelectionChange + object ReportPanel: TPanel + Left = 343 + Height = 384 + Top = 0 + Width = 557 + Align = alClient + Anchors = [akTop, akLeft, akRight] + BevelOuter = bvNone TabOrder = 0 end - object SelList: TListBox - AnchorSideLeft.Control = AllBtn - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = Label3 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = VarList - AnchorSideBottom.Side = asrBottom - Left = 257 - Height = 208 - Top = 25 - Width = 188 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 2 - BorderSpacing.Right = 8 - ItemHeight = 0 - OnSelectionChange = VarListSelectionChange - TabOrder = 4 - end - object CIEdit: TEdit - AnchorSideLeft.Control = Label1 - AnchorSideLeft.Side = asrBottom - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Bevel1 - Left = 190 - Height = 23 - Top = 321 - Width = 41 - Alignment = taRightJustify - Anchors = [akLeft, akBottom] - BorderSpacing.Left = 8 - TabOrder = 6 - Text = '95.0' - end - object GroupBox1: TGroupBox - AnchorSideLeft.Control = Owner - AnchorSideBottom.Control = CIEdit + object ParamsPanel: TPanel Left = 8 - Height = 72 - Top = 241 - Width = 306 - Anchors = [akLeft, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Options' - ChildSizing.LeftRightSpacing = 12 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.HorizontalSpacing = 24 - ChildSizing.VerticalSpacing = 2 - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 2 - ClientHeight = 52 - ClientWidth = 302 - TabOrder = 5 - object CaseChk: TCheckBox - Left = 12 - Height = 19 - Top = 6 - Width = 138 - BorderSpacing.Left = 12 - BorderSpacing.Right = 12 - Caption = 'Casewise Deletion' + Height = 368 + Top = 8 + Width = 322 + Align = alLeft + BorderSpacing.Around = 8 + BevelOuter = bvNone + ClientHeight = 368 + ClientWidth = 322 + TabOrder = 1 + object Label2: TLabel + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = ParamsPanel + Left = 0 + Height = 15 + Top = 0 + Width = 46 + Caption = 'Variables' + ParentColor = False + end + object VarList: TListBox + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = Label2 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = AllBtn + AnchorSideBottom.Control = OptionsGroup + Left = 0 + Height = 199 + Top = 17 + Width = 130 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 2 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 + ItemHeight = 0 + MultiSelect = True + OnSelectionChange = VarListSelectionChange TabOrder = 0 end - object CheckBox1: TCheckBox + object Label3: TLabel + AnchorSideLeft.Control = SelList + AnchorSideTop.Control = ParamsPanel + Left = 192 + Height = 15 + Top = 0 + Width = 44 + Caption = 'Selected' + ParentColor = False + end + object SelList: TListBox + AnchorSideLeft.Control = AllBtn + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label3 AnchorSideTop.Side = asrBottom - Left = 174 - Height = 19 - Top = 6 - Width = 116 - BorderSpacing.Left = 12 - BorderSpacing.Right = 12 - Caption = 'z Scores to Grid' + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = VarList + AnchorSideBottom.Side = asrBottom + Left = 192 + Height = 199 + Top = 17 + Width = 130 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + ItemHeight = 0 + OnSelectionChange = VarListSelectionChange + TabOrder = 4 + end + object InBtn: TBitBtn + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = VarList + AnchorSideRight.Side = asrBottom + Left = 147 + Height = 28 + Top = 17 + Width = 28 + Images = MainDataModule.ImageList + ImageIndex = 1 + OnClick = InBtnClick + Spacing = 0 TabOrder = 1 end - object PcntileChk: TCheckBox + object OutBtn: TBitBtn + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = InBtn AnchorSideTop.Side = asrBottom - Left = 12 - Height = 19 - Top = 27 - Width = 138 - BorderSpacing.Left = 12 - BorderSpacing.Right = 12 - Caption = 'Show Percentile Ranks' + AnchorSideRight.Side = asrBottom + Left = 147 + Height = 28 + Top = 49 + Width = 28 + BorderSpacing.Top = 4 + Images = MainDataModule.ImageList + ImageIndex = 0 + OnClick = OutBtnClick + Spacing = 0 TabOrder = 2 end - object AltQrtilesChk: TCheckBox + object AllBtn: TBitBtn + AnchorSideLeft.Control = ParamsPanel + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = OutBtn AnchorSideTop.Side = asrBottom - Left = 174 - Height = 19 - Top = 27 - Width = 116 - BorderSpacing.Left = 12 - BorderSpacing.Right = 12 - Caption = 'Show All Quartiles' + Left = 138 + Height = 25 + Top = 109 + Width = 46 + AutoSize = True + BorderSpacing.Top = 32 + Caption = 'ALL' + 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 + 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.Left = 8 + BorderSpacing.Top = 8 + BorderSpacing.Right = 8 + Caption = 'Help' + OnClick = HelpBtnClick + TabOrder = 7 + end + object Label1: TLabel + AnchorSideLeft.Control = OptionsGroup + AnchorSideTop.Control = CIEdit + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = CIEdit + Left = 0 + Height = 15 + Top = 308 + Width = 174 + BorderSpacing.Right = 8 + Caption = 'Confidence Interval for the Mean' + ParentColor = False + end + object OptionsGroup: TGroupBox + AnchorSideLeft.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = CIEdit + Left = 0 + Height = 72 + Top = 224 + Width = 306 + Anchors = [akLeft, akBottom] + AutoSize = True + BorderSpacing.Bottom = 8 + Caption = 'Options' + ChildSizing.LeftRightSpacing = 12 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.HorizontalSpacing = 24 + ChildSizing.VerticalSpacing = 2 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 2 + ClientHeight = 52 + ClientWidth = 302 + TabOrder = 5 + object CaseChk: TCheckBox + Left = 12 + Height = 19 + Top = 6 + Width = 138 + BorderSpacing.Left = 12 + BorderSpacing.Right = 12 + Caption = 'Casewise Deletion' + TabOrder = 0 + end + object ZScoresToGridChk: TCheckBox + AnchorSideTop.Side = asrBottom + Left = 174 + Height = 19 + Top = 6 + Width = 116 + BorderSpacing.Left = 12 + BorderSpacing.Right = 12 + Caption = 'z Scores to Grid' + TabOrder = 1 + end + object PcntileChk: TCheckBox + AnchorSideTop.Side = asrBottom + Left = 12 + Height = 19 + Top = 27 + Width = 138 + BorderSpacing.Left = 12 + BorderSpacing.Right = 12 + Caption = 'Show Percentile Ranks' + TabOrder = 2 + end + object AllQrtilesChk: TCheckBox + AnchorSideTop.Side = asrBottom + Left = 174 + Height = 19 + Top = 27 + Width = 116 + BorderSpacing.Left = 12 + BorderSpacing.Right = 12 + Caption = 'Show All Quartiles' + 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 + AnchorSideLeft.Control = Label1 + AnchorSideLeft.Side = asrBottom + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = Bevel1 + Left = 182 + Height = 23 + Top = 304 + Width = 41 + Alignment = taRightJustify + Anchors = [akLeft, akBottom] + BorderSpacing.Left = 8 + 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 end - object InBtn: TBitBtn - AnchorSideLeft.Control = Owner - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = VarList - AnchorSideRight.Side = asrBottom - Left = 212 - Height = 28 - Top = 25 - Width = 28 - Images = MainDataModule.ImageList - ImageIndex = 1 - OnClick = InBtnClick - Spacing = 0 - TabOrder = 1 - end - object OutBtn: TBitBtn - AnchorSideLeft.Control = Owner - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = InBtn - AnchorSideTop.Side = asrBottom - AnchorSideRight.Side = asrBottom - Left = 212 - Height = 28 - Top = 57 - Width = 28 - BorderSpacing.Top = 4 - Images = MainDataModule.ImageList - ImageIndex = 0 - OnClick = OutBtnClick - Spacing = 0 - TabOrder = 2 - end - object AllBtn: TBitBtn - AnchorSideLeft.Control = Owner - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = OutBtn - AnchorSideTop.Side = asrBottom - Left = 203 - Height = 25 - Top = 117 - Width = 46 - AutoSize = True - BorderSpacing.Top = 32 - Caption = 'ALL' - OnClick = AllBtnClick - TabOrder = 3 - end - object Bevel1: TBevel - AnchorSideLeft.Control = Owner - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = CloseBtn - Left = 0 - Height = 8 - Top = 344 - Width = 453 - Anchors = [akLeft, akRight, akBottom] - Shape = bsBottomLine - end - object ComputeBtn: TButton - AnchorSideRight.Control = CloseBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 306 - Height = 25 - Top = 360 - Width = 76 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick - TabOrder = 10 + object Splitter1: TSplitter + Left = 338 + Height = 384 + Top = 0 + Width = 5 + ResizeStyle = rsPattern end end diff --git a/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.pas b/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.pas index 84aa201b0..af5579a0c 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/descriptiveunit.pas @@ -5,9 +5,9 @@ unit DescriptiveUnit; interface uses - Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, Buttons, - MainUnit, Globals, FunctionsLib, OutputUnit, DataProcs, DictionaryUnit, ContextHelpUnit; + MainUnit, Globals, FunctionsLib, ReportFrameUnit, DataProcs, DictionaryUnit, ContextHelpUnit; type @@ -18,13 +18,15 @@ type Bevel1: TBevel; ComputeBtn: TButton; CaseChk: TCheckBox; - CheckBox1: TCheckBox; - AltQrtilesChk: TCheckBox; + ZScoresToGridChk: TCheckBox; + AllQrtilesChk: TCheckBox; HelpBtn: TButton; Label2: TLabel; Label3: TLabel; + ReportPanel: TPanel; + ParamsPanel: TPanel; PcntileChk: TCheckBox; - GroupBox1: TGroupBox; + OptionsGroup: TGroupBox; InBtn: TBitBtn; OutBtn: TBitBtn; AllBtn: TBitBtn; @@ -32,6 +34,7 @@ type CloseBtn: TButton; CIEdit: TEdit; Label1: TLabel; + Splitter1: TSplitter; VarList: TListBox; SelList: TListBox; procedure AllBtnClick(Sender: TObject); @@ -47,14 +50,10 @@ type 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; - Q1, Q2, Q3, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q22, Q23, Q24, Q25, Q26 : double; - Q27, Q28, Q32, Q33, Q34, Q35, Q36, Q37, Q38, IQrange : double; - ncases, noselected : integer; - cellstring, gridstring: string; - selected : IntDyneVec; procedure UpdateBtnStates; public @@ -64,26 +63,27 @@ type var DescriptiveFrm: TDescriptiveFrm; + implementation +{$R *.lfm} + uses Math; { TDescriptiveFrm } -procedure TDescriptiveFrm.ResetBtnClick(Sender: TObject); +procedure TDescriptiveFrm.AllBtnClick(Sender: TObject); var - i: integer; + i : integer; begin - CIEdit.Text := FormatFloat('0.0', DEFAULT_CONFIDENCE_LEVEL_PERCENT); + for i := 0 to VarList.Items.Count-1 do + SelList.Items.Add(VarList.Items.Strings[i]); VarList.Clear; - SelList.Clear; - for i := 1 to NoVariables do - VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); - Selected := nil; UpdateBtnStates; end; + procedure TDescriptiveFrm.FormActivate(Sender: TObject); var w: Integer; @@ -91,69 +91,65 @@ 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 := OptionsGroup.Width; + ParamsPanel.AutoSize := false; - Constraints.MinWidth := Width; - Constraints.MinHeight := Height; + Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Around*2; + Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + ParamsPanel.BorderSpacing.Around*2; FAutoSized := true; end; + procedure TDescriptiveFrm.FormCreate(Sender: TObject); begin Assert(OS3MainFrm <> nil); if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm); + + FReportFrame := TReportFrame.Create(self); + FReportFrame.Parent := ReportPanel; + FReportFrame.Align := alClient; + FReportFrame.ReportToolBar.Align := alRight; + FReportFrame.ReportToolbar.EdgeBorders := []; end; + procedure TDescriptiveFrm.FormShow(Sender: TObject); begin ResetBtnClick(self); 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; -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 TDescriptiveFrm.ComputeBtnClick(Sender: TObject); var i, j, k, m: integer; + nCases, noSelected: integer; + Q1, Q2, Q3, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q22, Q23, Q24, Q25, Q26: double; + Q27, Q28, Q32, Q33, Q34, Q35, Q36, Q37, Q38, IQrange: double; num, den, cases: double; - values, pcntrank: DblDyneVec; + values: DblDyneVec = nil; + pcntRank: DblDyneVec = nil; + selected: IntDyneVec = nil; + cellString: String; lReport: TStrings; begin - noselected := SelList.Items.Count; + NoSelected := SelList.Items.Count; if noSelected = 0 then begin MessageDlg('No variables selected.', mtError, [mbOK], 0); exit; end; - SetLength(Selected, noselected); + SetLength(selected, noSelected); // Get selected variables for i := 1 to noselected do @@ -169,9 +165,9 @@ begin lReport.Add(''); SetLength(Values, NoCases); - SetLength(pcntrank, NoCases); + SetLength(pcntRank, NoCases); - for j := 1 to noselected do + for j := 1 to noSelected do begin deviation := 0.0; devsqr := 0.0; @@ -195,13 +191,12 @@ begin CI := (1.0 - CI) / 2.0; CI := 1.0 - CI; - if CheckBox1.Checked then // add a new column to the grid + if ZScoresToGridChk.Checked then // add a new column to the grid begin - gridstring := OS3MainFrm.DataGrid.Cells[k,0]; - gridstring := Gridstring + 'z'; - DictionaryFrm.NewVar(NoVariables+1); - DictionaryFrm.DictGrid.Cells[1,NoVariables] := gridstring; - OS3MainFrm.DataGrid.Cells[NoVariables,0] := gridstring; + cellstring := OS3MainFrm.DataGrid.Cells[k,0] + 'z'; + DictionaryFrm.NewVar(NoVariables + 1); + DictionaryFrm.DictGrid.Cells[1, NoVariables] := cellstring; + OS3MainFrm.DataGrid.Cells[NoVariables, 0] := cellstring; end; // Accumulate sums of squares, sums, etc. for variable j @@ -209,15 +204,15 @@ begin max := -1.0e308; for i := 1 to NoCases do begin - if not GoodRecord(i,noselected,selected) then + if not GoodRecord(i, noSelected, selected) then continue; if CaseChk.Checked then begin - if not ValidValue(i,selected[j-1]) then + if not ValidValue(i, selected[j-1]) then continue; end - else if not GoodRecord(i,noselected,selected) then + else if not GoodRecord(i, noselected, selected) then continue; value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]); @@ -261,9 +256,9 @@ begin begin if CaseChk.Checked then begin - if not ValidValue(i,selected[j-1]) then continue; + if not ValidValue(i, selected[j-1]) then continue; end else - if not GoodRecord(i,noselected,selected) then continue; + if not GoodRecord(i, noselected, selected) then continue; value := StrToFloat(OS3MainFrm.DataGrid.Cells[k,i]); if stddev > 0.0 then @@ -274,7 +269,7 @@ begin M3 := M3 + (deviation * devsqr); M4 := M4 + (devsqr * devsqr); z := (value - mean) / stddev; - if CheckBox1.Checked then + if ZScoresToGridChk.Checked then begin cellstring := format('%8.5f',[z]); OS3MainFrm.DataGrid.Cells[NoVariables,i] := cellstring; @@ -349,7 +344,7 @@ begin lReport.Add(''); end; - if (AltQrtilesChk.Checked) then + if (AllQrtilesChk.Checked) then begin lReport.Add('Alternative Methods for Obtaining Quartiles'); lReport.Add(' Method 1 2 3 4 5 6 7 8'); @@ -381,8 +376,10 @@ begin Q37 := Quartiles(7,0.75,ncases,values); Q38 := Quartiles(8,0.75,ncases,values); lReport.Add('Q3 %8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f', [Q3,Q32,Q33,Q34,Q35,Q36,Q37,Q38]); + lReport.Add(''); lReport.Add('NOTES:'); - lReport.Add('Method 1 is the weighted average at X[np] where n is no. of cases, p is percentile / 100'); + lReport.Add('Method 1 is the weighted average at X[np] where '); + lReport.Add(' n is no. of cases, p is percentile / 100'); lReport.Add('Method 2 is the weighted average at X[(n+1)p] This is used in this program.'); lReport.Add('Method 3 is the empirical distribution function.'); lReport.Add('Method 4 is called the empirical distribution function - averaging.'); @@ -393,10 +390,10 @@ begin lReport.Add('See the internet site http://www.xycoon.com/ for the above.'); lReport.Add(''); end; // end of experimental alternatives - lReport.Add('--------------------------------------------------------------'); + lReport.Add(DIVIDER_AUTO); end; // next j variable - DisplayReport(lReport); + FReportFrame.DisplayReport(lReport); finally lReport.Free; @@ -406,6 +403,34 @@ begin end; 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; +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 TDescriptiveFrm.OutBtnClick(Sender: TObject); var i: integer; @@ -424,14 +449,17 @@ begin UpdateBtnStates; end; -procedure TDescriptiveFrm.AllBtnClick(Sender: TObject); +procedure TDescriptiveFrm.ResetBtnClick(Sender: TObject); var - i : integer; + i: integer; begin - for i := 0 to VarList.Items.Count-1 do - SelList.Items.Add(VarList.Items.Strings[i]); + 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.UpdateBtnStates; @@ -460,14 +488,12 @@ begin AllBtn.Enabled := VarList.Count > 0; end; + procedure TDescriptiveFrm.VarListSelectionChange(Sender: TObject; User: boolean); begin UpdateBtnStates; end; -initialization - {$I descriptiveunit.lrs} - end. diff --git a/applications/lazstats/source/forms/mainunit.pas b/applications/lazstats/source/forms/mainunit.pas index 53fddbc6c..c39bd5e6c 100644 --- a/applications/lazstats/source/forms/mainunit.pas +++ b/applications/lazstats/source/forms/mainunit.pas @@ -879,7 +879,7 @@ procedure TOS3MainFrm.MultXvsYClick(Sender: TObject); begin if MultXvsYFrm = nil then Application.CreateForm(TMultXvsYFrm, MultXvsYFrm); - MultXvsYFrm.ShowModal; + MultXvsYFrm.Show; end; // Menu "Analysis" > "Comparisons" > "ABC ANOVA with B Nested in A" @@ -1051,7 +1051,7 @@ procedure TOS3MainFrm.DistributionsClick(Sender: TObject); begin if DescriptiveFrm = nil then Application.CreateForm(TDescriptiveFrm, DescriptiveFrm); - DescriptiveFrm.ShowModal; + DescriptiveFrm.Show; end; diff --git a/applications/lazstats/source/frames/reportframeunit.pas b/applications/lazstats/source/frames/reportframeunit.pas index 836eb1e64..2a17f8b9a 100644 --- a/applications/lazstats/source/frames/reportframeunit.pas +++ b/applications/lazstats/source/frames/reportframeunit.pas @@ -26,6 +26,8 @@ type procedure tbSaveReportClick(Sender: TObject); private FPrintY: Integer; + FMaxLen: Integer; + function LongestLine(AReport: TStrings): Integer; protected procedure PrintText; virtual; @@ -33,7 +35,7 @@ type public constructor Create(AOwner: TComponent); override; procedure Clear; virtual; - procedure DisplayReport(AReport: TStrings); virtual; + procedure DisplayReport(AReport: TStrings; Add: Boolean = false); virtual; procedure UpdateBtnStates; virtual; end; @@ -43,8 +45,9 @@ implementation {$R *.lfm} uses - Graphics, - Printers, OSPrinters; + Graphics, StrUtils, + Printers, OSPrinters, + Globals; const LEFT_MARGIN = 200; @@ -56,6 +59,7 @@ const constructor TReportFrame.Create(AOwner: TComponent); begin inherited; + ReportPanel.Color := ReportMemo.Color; UpdateBtnStates; end; @@ -67,13 +71,37 @@ begin end; -procedure TReportFrame.DisplayReport(AReport: TStrings); +procedure TReportFrame.DisplayReport(AReport: TStrings; Add: Boolean = false); +var + maxLen: Integer; + s: String; begin - ReportMemo.Lines.AddStrings(AReport); + if not Add then + ReportMemo.Clear; + + maxLen := Longestline(AReport); + for s in AReport do + if s = DIVIDER_AUTO then + ReportMemo.Lines.Add(AddChar('-', '', maxLen)) + else + ReportMemo.Lines.Add(s); + UpdateBtnStates; end; +function TReportFrame.LongestLine(AReport: TStrings): Integer; +var + len: Integer; + s: String; +begin + len := 0; + for s in AReport do + if Length(s) > len then len := Length(s); + Result := len; +end; + + procedure TReportFrame.PrintText; var i: Integer; diff --git a/applications/lazstats/source/units/globals.pas b/applications/lazstats/source/units/globals.pas index e42162ac1..b118601eb 100644 --- a/applications/lazstats/source/units/globals.pas +++ b/applications/lazstats/source/units/globals.pas @@ -83,6 +83,7 @@ const DIVIDER = '==========================================================================='; DIVIDER_SMALL = '---------------------------------------------------------------------------'; + DIVIDER_AUTO = '@-'; GRAPH_BACK_COLOR = clCream; GRAPH_WALL_COLOR = clGray;