From b33f2006fc64a928e08e457d5bacd566410ebfa5 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 11 Oct 2020 10:19:27 +0000 Subject: [PATCH] LazStats: All SPC forms updated to new form inheritance. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7766 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../cchartunit.lfm | 106 ++++++++----- .../cchartunit.pas | 59 +++----- .../statistical_process_control/cusumunit.lfm | 143 +++++++++++------- .../statistical_process_control/cusumunit.pas | 89 ++++++----- .../pchartunit.lfm | 128 ++++++++++------ .../pchartunit.pas | 73 ++++----- .../rchartunit.pas | 11 +- .../schartunit.pas | 5 +- .../uchartunit.lfm | 93 +++++++----- .../uchartunit.pas | 67 ++++---- .../xbarchartunit.pas | 3 + 11 files changed, 439 insertions(+), 338 deletions(-) diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm index 92ad89cdf..7586cf2a7 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm @@ -5,78 +5,100 @@ inherited CChartForm: TCChartForm Caption = 'Defects C Chart' ClientHeight = 420 inherited ParamsPanel: TPanel - Height = 420 - Width = 440 - ClientHeight = 420 - ClientWidth = 440 + Height = 404 + Width = 451 + ClientHeight = 404 + ClientWidth = 451 + inherited CloseBtn: TButton + Left = 396 + Top = 379 + end + inherited ComputeBtn: TButton + Left = 312 + Top = 379 + end + inherited ResetBtn: TButton + Left = 250 + Top = 379 + end + inherited HelpBtn: TButton + Left = 191 + Top = 379 + TabOrder = 7 + end + inherited ButtonBevel: TBevel + Top = 363 + Width = 451 + end inherited VarList: TListBox - Height = 345 - Width = 200 + Height = 338 + Width = 204 end inherited GroupLabel: TLabel - Left = 240 - Top = 274 + Left = 246 + Top = 237 Visible = False end inherited GroupEdit: TEdit - Left = 240 - Top = 291 - Width = 200 + Left = 246 + Top = 254 + Width = 205 TabOrder = 3 Visible = False end inherited MeasLabel: TLabel - Left = 240 + Left = 246 end inherited MeasEdit: TEdit - Left = 240 - Width = 200 + Left = 246 + Width = 205 end inherited Bevel2: TBevel - Left = 209 + Left = 214 end inherited MeasInBtn: TSpeedButton - Left = 208 + Left = 212 end inherited MeasOutBtn: TSpeedButton - Left = 209 + Left = 212 end inherited GroupInBtn: TSpeedButton - Left = 208 - Top = 272 - Anchors = [akLeft] + AnchorSideTop.Control = SigmaOptns + Left = 212 + Top = 235 + BorderSpacing.Top = 24 Visible = False end inherited GroupOutBtn: TSpeedButton - Left = 209 - Top = 300 + Left = 212 + Top = 265 Visible = False end - object SigmaOptns: TRadioGroup[12] - AnchorSideLeft.Control = MeasEdit - AnchorSideTop.Control = MeasEdit + object SigmaOptns: TRadioGroup[16] + AnchorSideLeft.Control = MeasInBtn + AnchorSideTop.Control = MeasOutBtn AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = SpecsPanel AnchorSideRight.Side = asrBottom - Left = 240 - Height = 128 - Top = 99 - Width = 200 - Anchors = [akTop, akLeft, akRight] + Left = 212 + Height = 114 + Top = 97 + Width = 171 AutoFill = True - BorderSpacing.Top = 32 + AutoSize = True + BorderSpacing.Top = 24 BorderSpacing.Bottom = 8 Caption = 'Sigma Units for UCL and LCL' ChildSizing.LeftRightSpacing = 12 ChildSizing.TopBottomSpacing = 6 + ChildSizing.VerticalSpacing = 2 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 108 - ClientWidth = 196 + ClientHeight = 94 + ClientWidth = 167 ItemIndex = 0 Items.Strings = ( '3 Sigma' @@ -89,15 +111,25 @@ inherited CChartForm: TCChartForm AnchorSideRight.Control = SigmaOptns AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom - Left = 128 + Left = 132 Height = 23 - Top = 80 - Width = 56 + Top = 66 + Width = 36 Alignment = taRightJustify Anchors = [akLeft, akRight, akBottom] + Constraints.MinWidth = 36 TabOrder = 0 Text = 'XSigmaEdit' end end end + inherited ParamsSplitter: TSplitter + Left = 463 + Height = 420 + end + inherited PageControl: TPageControl + Left = 472 + Height = 404 + Width = 447 + end end diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas index 9c7948989..4de5a7380 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas @@ -15,8 +15,8 @@ type TCChartForm = class(TBasicSPCForm) SigmaOptns: TRadioGroup; XSigmaEdit: TEdit; - procedure FormActivate(Sender: TObject); protected + procedure AdjustConstraints; override; procedure Compute; override; function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; @@ -38,6 +38,30 @@ uses { TCChartForm } +procedure TCChartForm.AdjustConstraints; +var + y: Integer; +begin + inherited; + + ParamsPanel.Constraints.MinWidth := Max( + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, + SigmaOptns.Width*2 - MeasInBtn.Width + ); + + if GroupOutBtn.Visible then + y := GroupOutBtn.Top + GroupOutBtn.Height + else + y := SigmaOptns.Top + SigmaOptns.Height; + ParamsPanel.Constraints.MinHeight := y + + VarList.BorderSpacing.Bottom + ButtonBevel.Height + + CloseBtn.BorderSpacing.Top + CloseBtn.Height; + + SigmaOptns.Anchors := SigmaOptns.Anchors + [akRight]; + SigmaOptns.AnchorSideRight.Control := ParamsPanel; +end; + + procedure TCChartForm.Compute; var i: Integer; @@ -108,39 +132,6 @@ begin ); end; -procedure TCChartForm.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; - - DisableAutoSizing; - try - SigmaOptns.AnchorSideRight.Control := nil; - VarList.Constraints.MinWidth := VarListLabel.Width; - ParamsPanel.Constraints.MinWidth := Max( - CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around, - SigmaOptns.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left - ); -// Constraints.MinHeight := SigmaOptns.Top + SigmaOptns.Height + SigmaOptns.BorderSpacing.Bottom + ButtonPanel.Height; - - SigmaOptns.AnchorSideRight.Control := MeasEdit; - SigmaOptns.AnchorSideRight.Side := asrBottom; - finally - EnableAutoSizing; - end; - - Position := poDesigned; - FAutoSized := true; -end; - procedure TCChartForm.Reset; begin diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.lfm index 5afc9958c..9b986ab78 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.lfm @@ -8,66 +8,87 @@ inherited CUSUMChartForm: TCUSUMChartForm ClientWidth = 1000 ShowHint = True inherited ParamsPanel: TPanel - Height = 503 - Width = 432 - ClientHeight = 503 - ClientWidth = 432 + Height = 487 + Width = 441 + ClientHeight = 487 + ClientWidth = 441 + inherited CloseBtn: TButton + Left = 386 + Top = 462 + TabOrder = 8 + end + inherited ComputeBtn: TButton + Left = 302 + Top = 462 + end + inherited ResetBtn: TButton + Left = 240 + Top = 462 + end + inherited HelpBtn: TButton + Left = 181 + Top = 462 + TabOrder = 7 + end + inherited ButtonBevel: TBevel + Top = 446 + Width = 441 + end inherited VarList: TListBox - Height = 428 - Width = 196 + Height = 421 + Width = 199 end inherited GroupLabel: TLabel - Left = 236 + Left = 241 end inherited GroupEdit: TEdit - Left = 236 - Width = 196 + Left = 241 + Width = 200 end inherited MeasLabel: TLabel - Left = 236 + Left = 241 end inherited MeasEdit: TEdit - Left = 236 - Width = 196 + Left = 241 + Width = 200 end inherited Bevel2: TBevel - Left = 205 + Left = 209 end inherited MeasInBtn: TSpeedButton - Left = 204 + Left = 207 end inherited MeasOutBtn: TSpeedButton - Left = 205 + Left = 207 end inherited GroupInBtn: TSpeedButton AnchorSideLeft.Control = MeasInBtn AnchorSideLeft.Side = asrTop - Left = 204 + Left = 207 end inherited GroupOutBtn: TSpeedButton AnchorSideLeft.Control = GroupInBtn - Left = 205 + Left = 207 end - object GroupBox2: TGroupBox[12] + object OptionsGroup: TGroupBox[16] AnchorSideLeft.Control = MeasInBtn AnchorSideTop.Control = GroupEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = MeasEdit + AnchorSideRight.Control = ParamsPanel AnchorSideRight.Side = asrBottom - Left = 204 + Left = 207 Height = 134 - Top = 153 - Width = 228 + Top = 151 + Width = 234 Anchors = [akTop, akLeft, akRight] - AutoSize = True BorderSpacing.Top = 20 BorderSpacing.Bottom = 8 Caption = 'Options:' ClientHeight = 114 - ClientWidth = 224 + ClientWidth = 230 TabOrder = 3 object TargetChk: TCheckBox - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = OptionsGroup AnchorSideTop.Control = TargetEdit AnchorSideTop.Side = asrCenter Left = 12 @@ -81,18 +102,17 @@ inherited CUSUMChartForm: TCUSUMChartForm end object TargetEdit: TEdit AnchorSideLeft.Control = StdDevEdit - AnchorSideTop.Control = GroupBox2 - AnchorSideRight.Control = GroupBox2 + AnchorSideTop.Control = OptionsGroup + AnchorSideRight.Control = OptionsGroup AnchorSideRight.Side = asrBottom Left = 132 Height = 23 Top = 0 - Width = 84 + Width = 90 Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Right = 8 BorderSpacing.Bottom = 4 - Constraints.MinWidth = 64 TabOrder = 1 Text = 'TargetEdit' end @@ -112,15 +132,15 @@ inherited CUSUMChartForm: TCUSUMChartForm TabStop = True end object Bevel3: TBevel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = OptionsGroup AnchorSideTop.Control = StdDevEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = OptionsGroup AnchorSideRight.Side = asrBottom Left = 8 Height = 4 Top = 58 - Width = 208 + Width = 214 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 BorderSpacing.Top = 8 @@ -142,7 +162,7 @@ inherited CUSUMChartForm: TCUSUMChartForm TabOrder = 5 end object StdDevChk: TCheckBox - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = OptionsGroup AnchorSideTop.Control = StdDevEdit AnchorSideTop.Side = asrCenter Left = 12 @@ -159,33 +179,32 @@ inherited CUSUMChartForm: TCUSUMChartForm AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = TargetEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = OptionsGroup AnchorSideRight.Side = asrBottom Left = 132 Height = 23 Top = 27 - Width = 84 + Width = 90 Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 BorderSpacing.Right = 8 BorderSpacing.Bottom = 4 - Constraints.MinWidth = 64 TabOrder = 3 Text = 'StdDevEdit' end end - object Notebook: TNotebook[13] - AnchorSideLeft.Control = GroupBox2 - AnchorSideTop.Control = GroupBox2 + object Notebook: TNotebook[17] + AnchorSideLeft.Control = MeasInBtn + AnchorSideTop.Control = OptionsGroup AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = ParamsPanel AnchorSideRight.Side = asrBottom - Left = 204 + Left = 207 Height = 153 - Top = 295 - Width = 228 - PageIndex = 0 + Top = 293 + Width = 234 + PageIndex = 1 Anchors = [akTop, akLeft, akRight] BorderSpacing.Bottom = 8 TabOrder = 4 @@ -198,12 +217,12 @@ inherited CUSUMChartForm: TCUSUMChartForm Left = 0 Height = 80 Top = 0 - Width = 228 + Width = 193 Anchors = [akTop, akLeft, akRight] AutoSize = True Caption = 'Tabulated CUSUM Parameters' ClientHeight = 60 - ClientWidth = 224 + ClientWidth = 189 TabOrder = 0 object Label7: TLabel AnchorSideTop.Control = kEdit @@ -225,7 +244,7 @@ inherited CUSUMChartForm: TCUSUMChartForm Height = 23 Hint = 'Detection level for a shift in the process mean, '#13#10'expressed in data units (default), or'#13#10'as a multiple of the standard deviation of the '#13#10'data points (when "Normalized CUSUM" is checked).' Top = 2 - Width = 99 + Width = 64 Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 2 @@ -245,7 +264,7 @@ inherited CUSUMChartForm: TCUSUMChartForm Height = 23 Hint = 'Probability of concluding that a shift in the process has occurred, when in fact it did not. ' Top = 29 - Width = 99 + Width = 64 Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 @@ -278,12 +297,12 @@ inherited CUSUMChartForm: TCUSUMChartForm Left = 0 Height = 153 Top = 0 - Width = 228 + Width = 234 Anchors = [akTop, akLeft, akRight] AutoSize = True Caption = 'V-Mask Specifications' ClientHeight = 133 - ClientWidth = 224 + ClientWidth = 230 TabOrder = 0 object Label4: TLabel AnchorSideLeft.Control = VMaskGroup @@ -330,7 +349,7 @@ inherited CUSUMChartForm: TCUSUMChartForm Height = 23 Hint = 'Detection level for a shift in the process mean, '#13#10'expressed in data units (default), or'#13#10'as a multiple of the standard deviation of the '#13#10'data points (when "Normalized CUSUM" is checked).' Top = 2 - Width = 102 + Width = 108 Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 2 @@ -350,7 +369,7 @@ inherited CUSUMChartForm: TCUSUMChartForm Height = 23 Hint = 'Probability of concluding that a shift in the process has occurred, when in fact it did not. ' Top = 29 - Width = 102 + Width = 108 Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 @@ -370,7 +389,7 @@ inherited CUSUMChartForm: TCUSUMChartForm Height = 23 Hint = 'Probability of not detecting that a shift in the process mean has, in fact, occurred' Top = 56 - Width = 102 + Width = 108 Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 4 @@ -381,22 +400,23 @@ inherited CUSUMChartForm: TCUSUMChartForm Text = 'BetaEdit' end object VMaskScrollbar: TScrollBar - AnchorSideLeft.Control = Label1 - AnchorSideTop.Control = Label1 + AnchorSideLeft.Control = VMaskPositionLabel + AnchorSideTop.Control = VMaskPositionLabel AnchorSideTop.Side = asrBottom AnchorSideRight.Control = BetaEdit AnchorSideRight.Side = asrBottom Left = 12 Height = 17 Top = 104 - Width = 204 + Width = 210 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 2 BorderSpacing.Bottom = 12 PageSize = 0 TabOrder = 3 + OnChange = VMaskScrollbarChange end - object Label1: TLabel + object VMaskPositionLabel: TLabel AnchorSideLeft.Control = Label4 AnchorSideTop.Control = BetaEdit AnchorSideTop.Side = asrBottom @@ -411,4 +431,13 @@ inherited CUSUMChartForm: TCUSUMChartForm end end end + inherited ParamsSplitter: TSplitter + Left = 453 + Height = 503 + end + inherited PageControl: TPageControl + Left = 462 + Height = 487 + Width = 530 + end end diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.pas index 2e64cbbd8..4e7d2cf03 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.pas @@ -19,7 +19,7 @@ type Bevel3: TBevel; kEdit: TEdit; TabularGroup: TGroupBox; - Label1: TLabel; + VMaskPositionLabel: TLabel; Label7: TLabel; Label8: TLabel; Notebook: TNotebook; @@ -32,23 +32,29 @@ type VMaskScrollbar: TScrollBar; DeltaEdit: TEdit; VMaskGroup: TGroupBox; - GroupBox2: TGroupBox; + OptionsGroup: TGroupBox; Label4: TLabel; Label5: TLabel; Label6: TLabel; TargetChk: TCheckBox; TargetEdit: TEdit; - procedure FormActivate(Sender: TObject); procedure rbTabularChange(Sender: TObject); + procedure VMaskScrollbarChange(Sender: TObject); + private CUSums, CUSumsUpper, CUSumsLower: DblDyneVec; SEMean: Double; k, h: Double; + protected + procedure AdjustConstraints; override; + procedure Compute; override; + procedure PlotMeans(ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String; const Groups: StrDyneVec; const {%H-}Means: DblDyneVec; UCL, LCL, GrandMean, TargetSpec, LowerSpec, UpperSpec: double); override; + function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; public @@ -67,8 +73,25 @@ uses Math, TAChartUtils, TATypes, TASeries, Utils, MainUnit, ChartFrameUnit, DataProcs; + +const + VMASK_POSITION_LABEL = 'Position of V-Mask: %s'; + DEFAULT_VMASK_SCROLLBAR_MAX = 10000; + { TCUSUMChartForm } +procedure TCUSUMChartForm.AdjustConstraints; +begin + Notebook.Constraints.MinWidth := Max(TabularGroup.Width, VMaskGroup.Width); + Notebook.Constraints.MinHeight := VMaskGroup.Height; + + ParamsPanel.Constraints.MinWidth := Notebook.Constraints.MinWidth * 2 - MeasInBtn.Width; + ParamsPanel.Constraints.MinHeight := Notebook.Top + Notebook.Constraints.MinHeight + + VarList.BorderSpacing.Bottom + ButtonBevel.Height + + CloseBtn.Height + CloseBtn.BorderSpacing.Top; +end; + + procedure TCUSUMChartForm.Compute; var i, j, grpIndex, numGrps, grpSize, oldGrpSize, numValues: Integer; @@ -82,7 +105,6 @@ var groups: StrDyneVec = nil; means: DblDyneVec = nil; stdDevs: DblDyneVec = nil; -// count: Integer; //: IntDyneVec = nil; ColNoSelected: IntDyneVec = nil; lReport: TStrings; @@ -262,9 +284,9 @@ begin CUSums[j] := CUSums[j-1] + diff; if rbTabular.Checked then begin - CUSumsUpper[j] := Max(0, diff - k + CUSumsUpper[j-1]); - CUSumsLower[j] := Min(0, diff + k + CUSumsLower[j-1]); - // wp: There's a lot of garbage in the internet on these formulas! + CUSumsUpper[j] := Max(0, diff + CUSumsUpper[j-1] - k); + CUSumsLower[j] := Min(0, diff + CUSumsLower[j-1] + k); + // wp: There's a lot of garbage in the internet about these formulas! end; end; @@ -348,44 +370,6 @@ begin end; -procedure TCUSUMChartForm.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; - - DisableAutoSizing; - try -// VMaskGroup.Anchors := VMaskGroup.Anchors - [akRight]; - VarList.Constraints.MinWidth := VarListLabel.Width; - ParamsPanel.Constraints.MinWidth := Max( - CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around, - GroupBox2.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left - ); - TabularGroup.Constraints.MinHeight := VMaskScrollbar.Top + VMaskScrollbar.Height + - VMaskScrollbar.BorderSpacing.Bottom + TabularGroup.Height - TabularGroup.ClientHeight; - Notebook.Constraints.MinHeight := TabularGroup.Constraints.MinHeight; - Notebook.Height := 1; // Enforce notebook autosizing -// Constraints.MinHeight := Notebook.Top + Notebook.Height + Notebook.BorderSpacing.Bottom + ButtonPanel.Height; - if Height < Constraints.MinHeight then - Height := 1; // enforce height autosizing - // VMaskGroup.Anchors := VMaskGroup.Anchors + [akRight]; - finally - EnableAutoSizing; - end; - - Position := poDesigned; - FAutoSized := true; -end; - - procedure TCUSUMChartForm.rbTabularChange(Sender: TObject); begin if (Sender = rbTabular) and rbTabular.Checked then @@ -464,7 +448,7 @@ begin AlphaEdit.Text := FormatFloat('0.00', DEFAULT_ALPHA_LEVEL); BetaEdit.Text := FormatFloat('0.00', DEFAULT_BETA_LEVEL); VMaskScrollbar.Min := 2; - VMaskScrollbar.Max := 1000; + VMaskScrollbar.Max := DEFAULT_VMASK_SCROLLBAR_MAX; VMaskScrollbar.Position := VMaskScrollbar.Max; end; @@ -585,5 +569,18 @@ begin Result := true; end; + +procedure TCUSUMChartForm.VMaskScrollbarChange(Sender: TObject); +var + s: String; +begin + if VMaskScrollbar.Max = DEFAULT_VMASK_SCROLLBAR_MAX then + s := '-' + else + s := IntToStr(VMaskScrollbar.Position); + VMaskPositionLabel.Caption := Format(VMASK_POSITION_LABEL, [s]); +end; + + end. diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.lfm index 6275eb696..d74c4331d 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.lfm @@ -1,76 +1,104 @@ inherited PChartForm: TPChartForm Left = 556 + Height = 428 Top = 220 HelpType = htKeyword HelpKeyword = 'html/PControlChart.htm' Caption = 'P Control Chart' + ClientHeight = 428 inherited ParamsPanel: TPanel - Width = 456 - ClientWidth = 456 + Height = 412 + Width = 352 + ClientHeight = 412 + ClientWidth = 352 + inherited CloseBtn: TButton + Left = 297 + Top = 387 + TabOrder = 8 + end + inherited ComputeBtn: TButton + Left = 213 + Top = 387 + TabOrder = 9 + end + inherited ResetBtn: TButton + Left = 151 + Top = 387 + end + inherited HelpBtn: TButton + Left = 92 + Top = 387 + TabOrder = 7 + end + inherited ButtonBevel: TBevel + Top = 371 + Width = 352 + end inherited VarList: TListBox - Width = 208 + Height = 346 + Width = 155 end inherited GroupLabel: TLabel - Left = 248 - Top = 328 + Left = 197 + Top = 293 Visible = False end inherited GroupEdit: TEdit - Left = 248 - Top = 345 - Width = 208 + Left = 197 + Top = 310 + Width = 155 TabOrder = 5 Visible = False end inherited MeasLabel: TLabel - Left = 248 + Left = 197 end inherited MeasEdit: TEdit - Left = 248 - Width = 208 + Left = 197 + Width = 155 end inherited Bevel2: TBevel - Left = 217 + Left = 165 end inherited MeasInBtn: TSpeedButton - Left = 216 + Left = 163 end inherited MeasOutBtn: TSpeedButton - Left = 217 + Left = 163 end inherited GroupInBtn: TSpeedButton - Left = 216 - Top = 326 - Anchors = [akLeft] + AnchorSideTop.Control = SigmaOptns + Left = 163 + Top = 291 Visible = False end inherited GroupOutBtn: TSpeedButton - Left = 217 - Top = 354 + Left = 163 + Top = 321 Visible = False end - object Label3: TLabel[12] - AnchorSideLeft.Control = Label4 + object Label3: TLabel[16] + AnchorSideLeft.Control = PLabel AnchorSideTop.Control = NEdit AnchorSideTop.Side = asrCenter AnchorSideRight.Control = NEdit - Left = 270 + Left = 166 Height = 15 - Top = 95 + Top = 87 Width = 114 Anchors = [akTop, akRight] BorderSpacing.Right = 8 Caption = 'No. of Parts Sampled:' ParentColor = False end - object NEdit: TEdit[13] + object NEdit: TEdit[17] AnchorSideTop.Control = MeasEdit AnchorSideTop.Side = asrBottom AnchorSideRight.Control = MeasEdit AnchorSideRight.Side = asrBottom - Left = 392 + Left = 288 Height = 23 - Top = 91 + Top = 83 Width = 64 Alignment = taRightJustify Anchors = [akTop, akRight] @@ -78,12 +106,12 @@ inherited PChartForm: TPChartForm TabOrder = 2 Text = 'NEdit' end - object Label4: TLabel[14] + object PLabel: TLabel[18] AnchorSideTop.Control = PEdit AnchorSideTop.Side = asrCenter - Left = 272 + Left = 168 Height = 30 - Top = 118 + Top = 110 Width = 108 Alignment = taRightJustify Anchors = [akTop, akRight] @@ -91,14 +119,14 @@ inherited PChartForm: TPChartForm Caption = 'Expected Proportion'#13#10'of Defects:' ParentColor = False end - object PEdit: TEdit[15] + object PEdit: TEdit[19] AnchorSideTop.Control = NEdit AnchorSideTop.Side = asrBottom AnchorSideRight.Control = MeasEdit AnchorSideRight.Side = asrBottom - Left = 392 + Left = 288 Height = 23 - Top = 122 + Top = 114 Width = 64 Alignment = taRightJustify Anchors = [akTop, akRight] @@ -106,31 +134,31 @@ inherited PChartForm: TPChartForm TabOrder = 3 Text = 'PEdit' end - object SigmaOpts: TRadioGroup[16] - AnchorSideLeft.Control = MeasEdit + object SigmaOptns: TRadioGroup[20] + AnchorSideLeft.Control = MeasInBtn AnchorSideTop.Control = PEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = SpecsPanel AnchorSideRight.Side = asrBottom - Left = 248 - Height = 128 - Top = 169 - Width = 208 - Anchors = [akTop, akLeft, akRight] + Left = 163 + Height = 114 + Top = 161 + Width = 171 AutoFill = True + AutoSize = True BorderSpacing.Top = 24 BorderSpacing.Bottom = 8 Caption = 'Sigma Units for UCL and LCL' ChildSizing.LeftRightSpacing = 12 ChildSizing.TopBottomSpacing = 6 + ChildSizing.VerticalSpacing = 2 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 108 - ClientWidth = 204 + ClientHeight = 94 + ClientWidth = 167 ItemIndex = 0 Items.Strings = ( '3 Sigma' @@ -140,18 +168,28 @@ inherited PChartForm: TPChartForm ) TabOrder = 4 object XSigmaEdit: TEdit - AnchorSideRight.Control = SigmaOpts + AnchorSideRight.Control = SigmaOptns AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom Left = 128 Height = 23 - Top = 80 - Width = 64 + Top = 64 + Width = 36 Alignment = taRightJustify Anchors = [akLeft, akRight, akBottom] + Constraints.MinWidth = 36 TabOrder = 0 Text = 'XSigmaEdit' end end end + inherited ParamsSplitter: TSplitter + Left = 364 + Height = 428 + end + inherited PageControl: TPageControl + Left = 373 + Height = 412 + Width = 546 + end end diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.pas index f0369ba6b..ae0b3da86 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.pas @@ -14,13 +14,14 @@ type TPChartForm = class(TBasicSPCForm) Label3: TLabel; - Label4: TLabel; + PLabel: TLabel; NEdit: TEdit; PEdit: TEdit; - SigmaOpts: TRadioGroup; + SigmaOptns: TRadioGroup; XSigmaEdit: TEdit; - procedure FormActivate(Sender: TObject); + protected + procedure AdjustConstraints; override; procedure Compute; override; function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; @@ -39,6 +40,30 @@ implementation uses Math, Globals, Utils, MainUnit, DataProcs; + +{ TPChartForm } + +procedure TPChartForm.AdjustConstraints; +var + y: Integer; +begin + if GroupOutBtn.Visible then + y := GroupOutBtn.Top + GroupOutBtn.Height + else + y := SigmaOptns.Top + SigmaOptns.Height; + ParamsPanel.Constraints.MinHeight := y + VarList.BorderSpacing.Bottom + + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height; + + ParamsPanel.Constraints.MinWidth := Max( + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, + Max(SigmaOptns.Width, PLabel.Width + PLabel.BorderSpacing.Right + PEdit.Width) * 2 - MeasInBtn.Width + ); + + SigmaOptns.Anchors := SigmaOptns.Anchors + [akRight]; + SigmaOptns.AnchorSideRight.Control := ParamsPanel; +end; + + procedure TPChartForm.Compute; var ColNoSelected: IntDyneVec = nil; @@ -50,7 +75,7 @@ begin SetLength(ColNoSelected, 1); ColNoSelected[0] := MeasVar; - case SigmaOpts.ItemIndex of + case SigmaOptns.ItemIndex of 0: sigma := 3.0; 1: sigma := 2.0; 2: sigma := 1.0; @@ -122,39 +147,6 @@ begin ); end; -procedure TPChartForm.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; - - DisableAutoSizing; - try - SigmaOpts.AnchorSideRight.Control := nil; - VarList.Constraints.MinWidth := VarListLabel.Width; - ParamsPanel.Constraints.MinWidth := Max( - CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around, - SigmaOpts.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left - ); -// Constraints.MinHeight := SigmaOpts.Top + SigmaOpts.Height + SigmaOpts.BorderSpacing.Bottom + ButtonPanel.Height; - - SigmaOpts.AnchorSideRight.Control := MeasEdit; - SigmaOpts.AnchorSideRight.Side := asrBottom; - finally - EnableAutoSizing; - end; - - Position := poDesigned; - FAutoSized := true; -end; - procedure TPChartForm.Reset; begin @@ -204,14 +196,14 @@ begin exit; end; - if SigmaOpts.ItemIndex = -1 then + if SigmaOptns.ItemIndex = -1 then begin AMsg := 'Number of sigma units for UCL and LCL not specified.'; - AControl := SigmaOpts; + AControl := SigmaOptns; exit; end; - if SigmaOpts.ItemIndex = 3 then + if SigmaOptns.ItemIndex = 3 then begin if (XSigmaEdit.Text = '') then begin @@ -230,6 +222,7 @@ begin Result := true; end; + end. diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.pas index 6157a31f0..e28554d98 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.pas @@ -31,16 +31,19 @@ uses // Constants for correction of standard deviation const D3: array[2..25] of double = ( - 0, 0, 0, 0, 0, 0.076, 0.136, 0.184, 0.223, // 2..10 + 0, 0, 0, 0, 0, 0.076, 0.136, 0.184, 0.223, // 2..10 0.256, 0.283, 0.307, 0.328, 0.347, 0.363, 0.378, 0.391, 0.403, 0.415, // 11..20 - 0.425, 0.434, 0.443, 0.451, 0.459 // 21..25 + 0.425, 0.434, 0.443, 0.451, 0.459 // 21..25 ); D4: array[2..25] of double = ( - 3.267, 2.574, 2.282, 2.114, 2.004, 1.924, 1.864, 1.816, 1.777, // 2..10 + 3.267, 2.574, 2.282, 2.114, 2.004, 1.924, 1.864, 1.816, 1.777, // 2..10 1.744, 1.717, 1.693, 1.672, 1.653, 1.637, 1.622, 1.608, 1.597, 1.585, // 11..20 - 1.575, 1.566, 1.557, 1.548, 1.541 // 21..25 + 1.575, 1.566, 1.557, 1.548, 1.541 // 21..25 ); + +{ TRChartForm } + procedure TRChartForm.Compute; var i, j: Integer; diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/schartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/schartunit.pas index 4f6798480..115f0fdd8 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/schartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/schartunit.pas @@ -35,6 +35,9 @@ implementation uses Math, Globals, MathUnit, Utils, MainUnit, DataProcs; + +{ TSChartForm } + procedure TSChartForm.Compute; var UCL, LCL: Double; @@ -79,7 +82,7 @@ begin for j := 0 to numGrps-1 do // groups begin xmin := Infinity; - xmax := -Infinity; + xmax := NegInfinity; for i := 1 to NoCases do begin if not GoodRecord(i, Length(ColNoSelected), ColNoSelected) then continue; diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm index 3700c47ea..2766b84b8 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm @@ -3,57 +3,74 @@ inherited UChartForm: TUChartForm HelpKeyword = 'html/DefectsperUnituChart.htm' Caption = 'Defects per unit U Control Chart' inherited ParamsPanel: TPanel - Width = 432 - ClientWidth = 432 + Width = 320 + ClientWidth = 320 + inherited CloseBtn: TButton + Left = 265 + TabOrder = 8 + end + inherited ComputeBtn: TButton + Left = 181 + end + inherited ResetBtn: TButton + Left = 119 + end + inherited HelpBtn: TButton + Left = 60 + TabOrder = 7 + end + inherited ButtonBevel: TBevel + Width = 320 + end inherited VarList: TListBox - Width = 188 + Width = 139 end inherited GroupLabel: TLabel - Left = 236 + Left = 181 Top = 302 Visible = False end inherited GroupEdit: TEdit - Left = 236 + Left = 181 Top = 319 - Width = 196 + Width = 139 TabOrder = 4 Visible = False end inherited MeasLabel: TLabel - Left = 236 + Left = 181 end inherited MeasEdit: TEdit - Left = 236 - Width = 196 + Left = 181 + Width = 139 end inherited Bevel2: TBevel - Left = 205 + Left = 149 end inherited MeasInBtn: TSpeedButton - Left = 204 + Left = 147 end inherited MeasOutBtn: TSpeedButton - Left = 205 + Left = 147 end inherited GroupInBtn: TSpeedButton - Left = 204 + Left = 147 Top = 300 Anchors = [akLeft] Visible = False end inherited GroupOutBtn: TSpeedButton - Left = 205 - Top = 328 + Left = 147 + Top = 330 Visible = False end - object Label3: TLabel[12] + object Label3: TLabel[16] AnchorSideTop.Control = NoInspEdit AnchorSideTop.Side = asrCenter AnchorSideRight.Control = NoInspEdit - Left = 288 + Left = 176 Height = 30 - Top = 83 + Top = 75 Width = 73 Alignment = taRightJustify Anchors = [akTop, akRight] @@ -61,14 +78,14 @@ inherited UChartForm: TUChartForm Caption = 'No. inspected'#13#10'per group:' ParentColor = False end - object NoInspEdit: TEdit[13] + object NoInspEdit: TEdit[17] AnchorSideTop.Control = MeasEdit AnchorSideTop.Side = asrBottom AnchorSideRight.Control = MeasEdit AnchorSideRight.Side = asrBottom - Left = 369 + Left = 257 Height = 23 - Top = 87 + Top = 79 Width = 63 Alignment = taRightJustify Anchors = [akTop, akRight] @@ -76,31 +93,31 @@ inherited UChartForm: TUChartForm TabOrder = 2 Text = 'NoInspEdit' end - object SigmaOpts: TRadioGroup[14] - AnchorSideLeft.Control = MeasEdit + object SigmaOptns: TRadioGroup[18] + AnchorSideLeft.Control = MeasInBtn AnchorSideTop.Control = NoInspEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = SpecsPanel AnchorSideRight.Side = asrBottom - Left = 236 - Height = 128 - Top = 134 - Width = 196 - Anchors = [akTop, akLeft, akRight] + Left = 147 + Height = 114 + Top = 126 + Width = 171 AutoFill = True + AutoSize = True BorderSpacing.Top = 24 BorderSpacing.Bottom = 8 Caption = 'Sigma Units for UCL and LCL' ChildSizing.LeftRightSpacing = 12 ChildSizing.TopBottomSpacing = 6 + ChildSizing.VerticalSpacing = 2 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 108 - ClientWidth = 192 + ClientHeight = 94 + ClientWidth = 167 ItemIndex = 0 Items.Strings = ( '3 Sigma' @@ -110,18 +127,26 @@ inherited UChartForm: TUChartForm ) TabOrder = 3 object XSigmaEdit: TEdit - AnchorSideRight.Control = SigmaOpts + AnchorSideRight.Control = SigmaOptns AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom Left = 128 Height = 23 - Top = 80 - Width = 52 + Top = 66 + Width = 36 Alignment = taRightJustify Anchors = [akLeft, akRight, akBottom] + Constraints.MinWidth = 36 TabOrder = 0 Text = 'XSigmaEdit' end end end + inherited ParamsSplitter: TSplitter + Left = 332 + end + inherited PageControl: TPageControl + Left = 341 + Width = 578 + end end diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.pas index c3388d40c..91cbc99ca 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.pas @@ -15,10 +15,10 @@ type TUChartForm = class(TBasicSPCForm) Label3: TLabel; NoInspEdit: TEdit; - SigmaOpts: TRadioGroup; + SigmaOptns: TRadioGroup; XSigmaEdit: TEdit; - procedure FormActivate(Sender: TObject); protected + procedure AdjustConstraints; override; procedure Compute; override; function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; @@ -37,8 +37,29 @@ implementation uses Math, Globals, MainUnit, DataProcs; + { TUChartForm } +procedure TUChartForm.AdjustConstraints; +var + y: Integer; +begin + if GroupOutBtn.Visible then + y := GroupOutBtn.Top + GroupOutBtn.Height + else + y := SigmaOptns.Top + SigmaOptns.Height; + ParamsPanel.Constraints.MinHeight := y + VarList.BorderSpacing.Bottom + + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height; + + ParamsPanel.Constraints.MinWidth := Max( + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, + SigmaOptns.Width * 2 - MeasInBtn.Width + ); + + SigmaOptns.Anchors := SigmaOptns.Anchors + [akRight]; + SigmaOptns.AnchorSideRight.Control := ParamsPanel; +end; + procedure TUChartForm.Compute; var ColNoSelected: IntDyneVec = nil; @@ -51,7 +72,7 @@ begin SetLength(ColNoSelected, 1); ColNoSelected[0] := MeasVar; - case SigmaOpts.ItemIndex of + case SigmaOptns.ItemIndex of 0: sigma := 3.0; 1: sigma := 2.0; 2: sigma := 1.0; @@ -114,40 +135,6 @@ begin end; -procedure TUChartForm.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; - - DisableAutoSizing; - try - SigmaOpts.AnchorSideRight.Control := nil; - VarList.Constraints.MinWidth := VarListLabel.Width; - ParamsPanel.Constraints.MinWidth := Max( - CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around, - SigmaOpts.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left - ); -// Constraints.MinHeight := SigmaOpts.Top + SigmaOpts.Height + SigmaOpts.BorderSpacing.Bottom + ButtonPanel.Height; - - SigmaOpts.AnchorSideRight.Control := MeasEdit; - SigmaOpts.AnchorSideRight.Side := asrBottom; - finally - EnableAutoSizing; - end; - - Position := poDesigned; - FAutoSized := true; -end; - - procedure TUChartForm.Reset; begin inherited; @@ -181,14 +168,14 @@ begin exit; end; - if SigmaOpts.ItemIndex = -1 then + if SigmaOptns.ItemIndex = -1 then begin AMsg := 'Number of sigma units for UCL and LCL not specified.'; - AControl := SigmaOpts; + AControl := SigmaOptns; exit; end; - if SigmaOpts.ItemIndex = 3 then + if SigmaOptns.ItemIndex = 3 then begin if (XSigmaEdit.Text = '') then begin diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas index 7031bb581..4236eafab 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas @@ -69,6 +69,9 @@ uses {$R *.lfm} + +{ TXBarChartForm } + procedure TXBarChartForm.AdjustConstraints; begin ParamsPanel.Constraints.MinWidth := Max(