From 8897b1c219c5cf85dd17461c3d978b7291c8b479 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 10 Oct 2020 22:18:07 +0000 Subject: [PATCH] LazStats: Inherit the SPC forms from TBasicStatsResultAndChartForm. Not all verified, yet. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7765 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../basicspcunit.lfm | 224 +++++------------- .../basicspcunit.pas | 178 ++++---------- .../cchartunit.lfm | 33 +-- .../cchartunit.pas | 4 +- .../statistical_process_control/cusumunit.lfm | 33 +-- .../statistical_process_control/cusumunit.pas | 4 +- .../pchartunit.lfm | 30 +-- .../pchartunit.pas | 4 +- .../rchartunit.lfm | 2 +- .../uchartunit.lfm | 23 +- .../uchartunit.pas | 4 +- .../xbarchartunit.lfm | 110 ++++----- .../xbarchartunit.pas | 59 ++--- .../forms/misc/basicstatsparamsformunit.pas | 1 + 14 files changed, 197 insertions(+), 512 deletions(-) diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm index 8b431bb56..57ce5f726 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.lfm @@ -1,4 +1,4 @@ -object BasicSPCForm: TBasicSPCForm +inherited BasicSPCForm: TBasicSPCForm Left = 535 Height = 438 Top = 241 @@ -6,129 +6,53 @@ object BasicSPCForm: TBasicSPCForm Caption = 'SPC Form' ClientHeight = 438 ClientWidth = 927 - OnActivate = FormActivate - OnCreate = FormCreate - Position = poMainFormCenter - LCLVersion = '2.1.0.0' - object SpecsPanel: TPanel - Left = 8 - Height = 438 - Top = 0 + inherited ParamsPanel: TPanel + Height = 422 Width = 357 - Align = alLeft - BorderSpacing.Left = 8 - BorderSpacing.Right = 3 - BevelOuter = bvNone - ClientHeight = 438 + ClientHeight = 422 ClientWidth = 357 - TabOrder = 0 - object ButtonPanel: TPanel - Left = 0 - Height = 42 - Top = 396 - Width = 357 - Align = alBottom - AutoSize = True - BevelOuter = bvNone - ClientHeight = 42 - ClientWidth = 357 - TabOrder = 3 - object CloseBtn: TButton - AnchorSideTop.Control = ButtonPanel - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = ButtonPanel - AnchorSideRight.Side = asrBottom - Left = 302 - Height = 25 - Top = 9 - Width = 55 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Top = 8 - BorderSpacing.Bottom = 8 - Caption = 'Close' - ModalResult = 11 - OnClick = CloseBtnClick - TabOrder = 3 - end - object ComputeBtn: TButton - AnchorSideTop.Control = ButtonPanel - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = CloseBtn - Left = 218 - Height = 25 - Top = 9 - Width = 76 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Around = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick - TabOrder = 2 - end - object ResetBtn: TButton - AnchorSideTop.Control = ButtonPanel - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = ComputeBtn - Left = 156 - Height = 25 - Top = 9 - Width = 54 - Anchors = [akTop, akRight] - AutoSize = True - BorderSpacing.Around = 8 - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 1 - end - object HelpBtn: TButton - AnchorSideTop.Control = ButtonPanel - AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = ResetBtn - Left = 105 - Height = 25 - Top = 9 - Width = 43 - Anchors = [akTop, akRight] - BorderSpacing.Around = 8 - Caption = 'Help' - OnClick = HelpBtnClick - TabOrder = 0 - end - object Bevel1: TBevel - AnchorSideLeft.Control = ButtonPanel - AnchorSideTop.Control = ButtonPanel - AnchorSideRight.Control = ButtonPanel - AnchorSideRight.Side = asrBottom - Left = 8 - Height = 4 - Top = 0 - Width = 349 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Left = 8 - Shape = bsTopLine - end + inherited CloseBtn: TButton + Left = 302 + Top = 397 + TabOrder = 4 end - object VarListLabel: TLabel - AnchorSideLeft.Control = SpecsPanel - AnchorSideTop.Control = SpecsPanel + inherited ComputeBtn: TButton + Left = 218 + Top = 397 + TabOrder = 5 + end + inherited ResetBtn: TButton + Left = 156 + Top = 397 + TabOrder = 6 + end + inherited HelpBtn: TButton + Left = 97 + Top = 397 + end + inherited ButtonBevel: TBevel + Top = 381 + Width = 357 + end + object VarListLabel: TLabel[5] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = ParamsPanel Left = 0 Height = 15 - Top = 8 + Top = 0 Width = 97 - BorderSpacing.Top = 8 Caption = 'Selection Variables' ParentColor = False end - object VarList: TListBox - AnchorSideLeft.Control = SpecsPanel + object VarList: TListBox[6] + AnchorSideLeft.Control = ParamsPanel AnchorSideTop.Control = VarListLabel AnchorSideTop.Side = asrBottom AnchorSideRight.Control = MeasInBtn - AnchorSideBottom.Control = ButtonPanel + AnchorSideBottom.Control = ButtonBevel Left = 0 - Height = 363 - Top = 25 + Height = 356 + Top = 17 Width = 157 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Top = 2 @@ -139,28 +63,28 @@ object BasicSPCForm: TBasicSPCForm OnDblClick = VarListDblClick TabOrder = 0 end - object GroupLabel: TLabel + object GroupLabel: TLabel[7] AnchorSideLeft.Control = GroupEdit AnchorSideTop.Control = GroupInBtn Left = 199 Height = 15 - Top = 99 + Top = 91 Width = 105 BorderSpacing.Top = 2 BorderSpacing.Bottom = 2 Caption = 'Group (Lot) Variable' ParentColor = False end - object GroupEdit: TEdit + object GroupEdit: TEdit[8] AnchorSideLeft.Control = GroupInBtn AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = GroupLabel AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = SpecsPanel + AnchorSideRight.Control = ParamsPanel AnchorSideRight.Side = asrBottom Left = 199 Height = 23 - Top = 116 + Top = 108 Width = 158 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 @@ -170,28 +94,28 @@ object BasicSPCForm: TBasicSPCForm TabOrder = 2 Text = 'GroupEdit' end - object MeasLabel: TLabel + object MeasLabel: TLabel[9] AnchorSideLeft.Control = MeasEdit AnchorSideTop.Control = MeasInBtn Left = 199 Height = 15 - Top = 27 + Top = 19 Width = 117 BorderSpacing.Top = 2 BorderSpacing.Bottom = 2 Caption = 'Measurement Variable' ParentColor = False end - object MeasEdit: TEdit + object MeasEdit: TEdit[10] AnchorSideLeft.Control = MeasInBtn AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = MeasLabel AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = SpecsPanel + AnchorSideRight.Control = ParamsPanel AnchorSideRight.Side = asrBottom Left = 199 Height = 23 - Top = 44 + Top = 36 Width = 158 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 @@ -201,8 +125,8 @@ object BasicSPCForm: TBasicSPCForm TabOrder = 1 Text = 'MeasEdit' end - object Bevel2: TBevel - AnchorSideLeft.Control = SpecsPanel + object Bevel2: TBevel[11] + AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter Left = 167 Height = 9 @@ -210,54 +134,54 @@ object BasicSPCForm: TBasicSPCForm Width = 23 Shape = bsSpacer end - object MeasInBtn: TSpeedButton - AnchorSideLeft.Control = SpecsPanel + object MeasInBtn: TSpeedButton[12] + AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = VarList Left = 165 Height = 26 - Top = 25 + Top = 17 Width = 26 Images = MainDataModule.ImageList ImageIndex = 1 OnClick = MeasInBtnClick end - object MeasOutBtn: TSpeedButton - AnchorSideLeft.Control = SpecsPanel + object MeasOutBtn: TSpeedButton[13] + AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = MeasInBtn AnchorSideTop.Side = asrBottom Left = 165 Height = 26 - Top = 55 + Top = 47 Width = 26 BorderSpacing.Top = 4 Images = MainDataModule.ImageList ImageIndex = 0 OnClick = MeasOutBtnClick end - object GroupInBtn: TSpeedButton - AnchorSideLeft.Control = SpecsPanel + object GroupInBtn: TSpeedButton[14] + AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = MeasOutBtn AnchorSideTop.Side = asrBottom Left = 165 Height = 26 - Top = 97 + Top = 89 Width = 26 BorderSpacing.Top = 16 Images = MainDataModule.ImageList ImageIndex = 1 OnClick = GroupInBtnClick end - object GroupOutBtn: TSpeedButton - AnchorSideLeft.Control = SpecsPanel + object GroupOutBtn: TSpeedButton[15] + AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = GroupInBtn AnchorSideTop.Side = asrBottom Left = 165 Height = 26 - Top = 127 + Top = 119 Width = 26 BorderSpacing.Top = 4 Images = MainDataModule.ImageList @@ -265,31 +189,13 @@ object BasicSPCForm: TBasicSPCForm OnClick = GroupOutBtnClick end end - object SpecsSplitter: TSplitter - Left = 368 + inherited ParamsSplitter: TSplitter + Left = 369 Height = 438 - Top = 0 - Width = 5 - ResizeStyle = rsPattern end - object PageControl: TPageControl - Left = 376 - Height = 426 - Top = 6 - Width = 545 - ActivePage = ChartPage - Align = alClient - BorderSpacing.Left = 3 - BorderSpacing.Top = 6 - BorderSpacing.Right = 6 - BorderSpacing.Bottom = 6 - TabIndex = 1 - TabOrder = 2 - object ReportPage: TTabSheet - Caption = 'Report' - end - object ChartPage: TTabSheet - Caption = 'Chart' - end + inherited PageControl: TPageControl + Left = 378 + Height = 422 + Width = 541 end end diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas index 6641da781..225fd26b0 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/basicspcunit.pas @@ -8,66 +8,46 @@ uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, Globals, MainUnit, ContextHelpUnit, - BasicStatsFormUnit, ReportFrameUnit, ChartFrameUnit; + BasicStatsReportAndChartFormUnit, ReportFrameUnit, ChartFrameUnit; type { TBasicSPCForm } - TBasicSPCForm = class(TBasicStatsForm) - Bevel1: TBevel; + TBasicSPCForm = class(TBasicStatsReportAndChartForm) Bevel2: TBevel; GroupEdit: TEdit; - HelpBtn: TButton; GroupLabel: TLabel; MeasLabel: TLabel; MeasEdit: TEdit; - PageControl: TPageControl; - ResetBtn: TButton; - ComputeBtn: TButton; - CloseBtn: TButton; - SpecsPanel: TPanel; - ButtonPanel: TPanel; - SpecsSplitter: TSplitter; - ReportPage: TTabSheet; - ChartPage: TTabSheet; MeasInBtn: TSpeedButton; MeasOutBtn: TSpeedButton; GroupInBtn: TSpeedButton; GroupOutBtn: TSpeedButton; VarList: TListBox; VarListLabel: TLabel; - procedure CloseBtnClick(Sender: TObject); - procedure ComputeBtnClick(Sender: TObject); - procedure FormActivate(Sender: TObject); - procedure FormCreate(Sender: TObject); procedure GroupInBtnClick(Sender: TObject); procedure GroupOutBtnClick(Sender: TObject); - procedure HelpBtnClick(Sender: TObject); procedure MeasInBtnClick(Sender: TObject); procedure MeasOutBtnClick(Sender: TObject); - procedure ResetBtnClick(Sender: TObject); procedure VarListClick(Sender: TObject); procedure VarListDblClick(Sender: TObject); private FGroupsNeeded: Boolean; protected - FAutoSized: Boolean; GrpVar: Integer; MeasVar: Integer; - procedure Compute; virtual; function GetGroups: StrDyneVec; function GetFileName: String; procedure PlotMeans(ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String; const Groups: StrDyneVec; const Means: DblDyneVec; UCL, LCL, GrandMean, TargetSpec, LowerSpec, UpperSpec: double); virtual; - procedure UpdateBtnStates; virtual; - function Validate(out AMsg: String; out AControl: TWinControl): Boolean; virtual; + procedure UpdateBtnStates; override; + function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; public - FReportFrame: TReportFrame; - FChartFrame: TChartFrame; + constructor Create(AOwner: TComponent); override; procedure Reset; override; property GroupsNeeded: Boolean read FgroupsNeeded write FGroupsNeeded; @@ -84,7 +64,7 @@ implementation uses Math, TAChartUtils, TALegend, TAChartAxisUtils, TASources, TACustomSeries, TASeries, - Utils, DataProcs; + Utils, GridProcs; const FORMAT_MASK = '0.000'; @@ -92,95 +72,10 @@ const { TBasicSPCForm } -procedure TBasicSPCForm.CloseBtnClick(Sender: TObject); +constructor TBasicSPCForm.Create(AOwner: TComponent); begin - Close; -end; + inherited; - -// To be overridden by descendant forms -procedure TBasicSPCForm.Compute; -begin - // -end; - - -procedure TBasicSPCForm.ComputeBtnClick(Sender: TObject); -var - msg: String; - C: TWinControl; - i: Integer; - cellString: String; -begin - if not Validate(msg, C) then begin - C.SetFocus; - MessageDlg(msg, mtError, [mbOK], 0); - exit; - end; - - GrpVar := -1; - MeasVar := -1; - for i := 1 to NoVariables do - begin - cellstring := OS3MainFrm.DataGrid.Cells[i, 0]; - if GroupEdit.Visible and (cellstring = GroupEdit.Text) then GrpVar := i; - if MeasEdit.Visible and (cellstring = MeasEdit.Text) then MeasVar := i; - end; - if GroupsNeeded and GroupEdit.Visible and (GrpVar = -1) then - begin - GroupEdit.SetFocus; - ErrorMsg('Group variable not found.'); - exit; - end; - if MeasEdit.Visible and (MeasVar = -1) then - begin - MeasEdit.SetFocus; - ErrorMsg('Measurement variable not found.'); - exit; - end; - - Compute; - - UpdateBtnStates; -end; - -procedure TBasicSPCForm.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; - - SpecsPanel.Constraints.MinWidth := Max( - VarListLabel.Left + VarListLabel.Width + Varlist.BorderSpacing.Right * 2 + MeasInBtn.Width + MeasLabel.Width, - CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around - ); - Constraints.MinHeight := MeasEdit.Top + MeasEdit.Height + MeasEdit.BorderSpacing.Bottom + ButtonPanel.Height; - - Position := poDesigned; - FAutoSized := true; -end; - - -procedure TBasicSPCForm.FormCreate(Sender: TObject); -begin - Assert(OS3MainFrm <> nil); - - InitForm(Self); - - FReportFrame := TReportFrame.Create(self); - FReportFrame.Parent := ReportPage; - FReportFrame.Align := alClient; - - FChartFrame := TChartFrame.Create(self); - FChartFrame.Parent := ChartPage; - FChartFrame.Align := alClient; FChartFrame.Chart.Legend.SymbolWidth := Scale96ToFont(30); FChartFrame.Chart.Legend.Alignment := laBottomCenter; FChartFrame.Chart.Legend.ColumnCount := 3; @@ -191,9 +86,6 @@ begin Marks.Source := TListChartSource.Create(self); Marks.Style := smsLabel; end; - InitToolbar(FChartFrame.ChartToolbar, tpTop); - - Reset; end; @@ -212,7 +104,7 @@ begin SetLength(Result, NoCases); for i := 1 to NoCases do begin - if not GoodRecord(i, Length(ColNoSelected), ColNoSelected) then + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; grp := Trim(OS3MainFrm.DataGrid.Cells[GrpVar, i]); if IndexOfString(Result, grp) = -1 then @@ -256,14 +148,6 @@ begin end; -procedure TBasicSPCForm.HelpBtnClick(Sender: TObject); -begin - if ContextHelpForm = nil then - Application.CreateForm(TContextHelpForm, ContextHelpForm); - ContextHelpForm.HelpMessage((Sender as TButton).Tag); -end; - - procedure TBasicSPCForm.MeasInBtnClick(Sender: TObject); var index: integer; @@ -371,51 +255,67 @@ procedure TBasicSPCForm.Reset; var i : integer; begin - VarList.Clear; + inherited; + GroupEdit.Text := ''; MeasEdit.Text := ''; + + VarList.Clear; for i := 1 to NoVariables do VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); - FReportFrame.Clear; - FChartFrame.Clear; - (FChartFrame.Chart.AxisList[2].Marks.Source as TListChartSource).Clear; + if Assigned(FChartFrame) and (FChartFrame.Chart.AxisList.Count > 2) then + (FChartFrame.Chart.AxisList[2].Marks.Source as TListChartSource).Clear; + UpdateBtnStates; end; -procedure TBasicSPCForm.ResetBtnClick(Sender: TObject); -begin - Reset; -end; - - procedure TBasicSPCForm.UpdateBtnStates; begin + inherited; + MeasInBtn.Enabled := (VarList.ItemIndex <> -1) and (MeasEdit.Text = ''); MeasOutBtn.Enabled := (MeasEdit.Text <> ''); GroupInBtn.Enabled := (VarList.ItemIndex <> -1) and (GroupEdit.Text = ''); GroupOutBtn.Enabled := (GroupEdit.Text <> ''); - - FReportFrame.UpdateBtnStates; - FChartFrame.UpdateBtnStates; end; function TBasicSPCForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; begin Result := false; + if GroupEdit.Visible and (GroupEdit.Text = '') then begin AMsg := 'Group variable not specified.'; AControl := GroupEdit; exit; end; + if MeasEdit.Visible and (MeasEdit.Text = '') then begin AMsg := 'Measurement variable not specified.'; AControl := MeasEdit; exit; end; + + GrpVar := GetVariableIndex(OS3MainFrm.DataGrid, GroupEdit.Text); + MeasVar := GetVariableIndex(OS3MainFrm.DataGrid, MeasEdit.Text); + + if GroupsNeeded and GroupEdit.Visible and (GrpVar = -1) then + begin + AMsg := 'Group variable not found.'; + AControl := GroupEdit; + exit; + end; + + if MeasEdit.Visible and (MeasVar = -1) then + begin + AMsg := 'Measurement variable not found.'; + AControl := MeasEdit; + exit; + end; + Result := true; end; @@ -425,6 +325,7 @@ begin UpdateBtnStates; end; + procedure TBasicSPCForm.VarListDblClick(Sender: TObject); var index: integer; @@ -441,5 +342,6 @@ begin UpdateBtnStates; end; + end. 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 ba1d5dd79..92ad89cdf 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.lfm @@ -4,33 +4,11 @@ inherited CChartForm: TCChartForm HelpKeyword = 'html/DefectnonconformitycChart.htm' Caption = 'Defects C Chart' ClientHeight = 420 - OnActivate = FormActivate - inherited SpecsPanel: TPanel + inherited ParamsPanel: TPanel Height = 420 Width = 440 ClientHeight = 420 ClientWidth = 440 - inherited ButtonPanel: TPanel - Top = 378 - Width = 440 - ClientWidth = 440 - TabOrder = 4 - inherited CloseBtn: TButton - Left = 385 - end - inherited ComputeBtn: TButton - Left = 301 - end - inherited ResetBtn: TButton - Left = 239 - end - inherited HelpBtn: TButton - Left = 188 - end - inherited Bevel1: TBevel - Width = 432 - end - end inherited VarList: TListBox Height = 345 Width = 200 @@ -122,13 +100,4 @@ inherited CChartForm: TCChartForm end end end - inherited SpecsSplitter: TSplitter - Left = 451 - Height = 420 - end - inherited PageControl: TPageControl - Left = 459 - Height = 408 - Width = 462 - 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 a442a8bed..9c7948989 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cchartunit.pas @@ -125,11 +125,11 @@ begin try SigmaOptns.AnchorSideRight.Control := nil; VarList.Constraints.MinWidth := VarListLabel.Width; - SpecsPanel.Constraints.MinWidth := Max( + 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; +// Constraints.MinHeight := SigmaOptns.Top + SigmaOptns.Height + SigmaOptns.BorderSpacing.Bottom + ButtonPanel.Height; SigmaOptns.AnchorSideRight.Control := MeasEdit; SigmaOptns.AnchorSideRight.Side := asrBottom; 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 662067391..5afc9958c 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.lfm @@ -6,34 +6,12 @@ inherited CUSUMChartForm: TCUSUMChartForm Caption = 'Cumulative Sum Control Chart' ClientHeight = 503 ClientWidth = 1000 - OnActivate = FormActivate ShowHint = True - inherited SpecsPanel: TPanel + inherited ParamsPanel: TPanel Height = 503 Width = 432 ClientHeight = 503 ClientWidth = 432 - inherited ButtonPanel: TPanel - Top = 461 - Width = 432 - ClientWidth = 432 - TabOrder = 5 - inherited CloseBtn: TButton - Left = 377 - end - inherited ComputeBtn: TButton - Left = 293 - end - inherited ResetBtn: TButton - Left = 231 - end - inherited HelpBtn: TButton - Left = 180 - end - inherited Bevel1: TBevel - Width = 424 - end - end inherited VarList: TListBox Height = 428 Width = 196 @@ -433,13 +411,4 @@ inherited CUSUMChartForm: TCUSUMChartForm end end end - inherited SpecsSplitter: TSplitter - Left = 443 - Height = 503 - end - inherited PageControl: TPageControl - Left = 451 - Height = 491 - Width = 543 - 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 cc7b09063..2e64cbbd8 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/cusumunit.pas @@ -365,7 +365,7 @@ begin try // VMaskGroup.Anchors := VMaskGroup.Anchors - [akRight]; VarList.Constraints.MinWidth := VarListLabel.Width; - SpecsPanel.Constraints.MinWidth := Max( + ParamsPanel.Constraints.MinWidth := Max( CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around, GroupBox2.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left ); @@ -373,7 +373,7 @@ begin 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; +// 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]; 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 af25feaec..6275eb696 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.lfm @@ -4,30 +4,9 @@ inherited PChartForm: TPChartForm HelpType = htKeyword HelpKeyword = 'html/PControlChart.htm' Caption = 'P Control Chart' - OnActivate = FormActivate - inherited SpecsPanel: TPanel + inherited ParamsPanel: TPanel Width = 456 ClientWidth = 456 - inherited ButtonPanel: TPanel - Width = 456 - ClientWidth = 456 - TabOrder = 6 - inherited CloseBtn: TButton - Left = 401 - end - inherited ComputeBtn: TButton - Left = 317 - end - inherited ResetBtn: TButton - Left = 255 - end - inherited HelpBtn: TButton - Left = 204 - end - inherited Bevel1: TBevel - Width = 448 - end - end inherited VarList: TListBox Width = 208 end @@ -175,11 +154,4 @@ inherited PChartForm: TPChartForm end end end - inherited SpecsSplitter: TSplitter - Left = 467 - end - inherited PageControl: TPageControl - Left = 475 - Width = 446 - 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 57470db63..f0369ba6b 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/pchartunit.pas @@ -139,11 +139,11 @@ begin try SigmaOpts.AnchorSideRight.Control := nil; VarList.Constraints.MinWidth := VarListLabel.Width; - SpecsPanel.Constraints.MinWidth := Max( + 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; +// Constraints.MinHeight := SigmaOpts.Top + SigmaOpts.Height + SigmaOpts.BorderSpacing.Bottom + ButtonPanel.Height; SigmaOpts.AnchorSideRight.Control := MeasEdit; SigmaOpts.AnchorSideRight.Side := asrBottom; diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.lfm index 29158f0a3..a7316f9c0 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/rchartunit.lfm @@ -2,7 +2,7 @@ inherited RChartForm: TRChartForm HelpType = htKeyword HelpKeyword = 'html/RangeChart.htm' Caption = 'Range Control Chart' - inherited SpecsPanel: TPanel + inherited ParamsPanel: TPanel HelpType = htKeyword HelpKeyword = 'html/RangeChart.htm' end 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 9597da85e..3700c47ea 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.lfm @@ -2,30 +2,9 @@ inherited UChartForm: TUChartForm HelpType = htKeyword HelpKeyword = 'html/DefectsperUnituChart.htm' Caption = 'Defects per unit U Control Chart' - OnActivate = FormActivate - inherited SpecsPanel: TPanel + inherited ParamsPanel: TPanel Width = 432 ClientWidth = 432 - inherited ButtonPanel: TPanel - Width = 432 - ClientWidth = 432 - TabOrder = 5 - inherited CloseBtn: TButton - Left = 377 - end - inherited ComputeBtn: TButton - Left = 293 - end - inherited ResetBtn: TButton - Left = 231 - end - inherited HelpBtn: TButton - Left = 180 - end - inherited Bevel1: TBevel - Width = 424 - end - end inherited VarList: TListBox Width = 188 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 42725169f..c3388d40c 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/uchartunit.pas @@ -131,11 +131,11 @@ begin try SigmaOpts.AnchorSideRight.Control := nil; VarList.Constraints.MinWidth := VarListLabel.Width; - SpecsPanel.Constraints.MinWidth := Max( + 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; +// Constraints.MinHeight := SigmaOpts.Top + SigmaOpts.Height + SigmaOpts.BorderSpacing.Bottom + ButtonPanel.Height; SigmaOpts.AnchorSideRight.Control := MeasEdit; SigmaOpts.AnchorSideRight.Side := asrBottom; diff --git a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm index 8c794740d..0753f7856 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.lfm @@ -6,77 +6,77 @@ inherited XBarChartForm: TXBarChartForm HelpKeyword = 'html/XBarChart.htm' Caption = 'X-Bar Control Chart' ClientHeight = 476 - OnActivate = FormActivate - inherited SpecsPanel: TPanel - Height = 476 - Width = 379 - ClientHeight = 476 - ClientWidth = 379 - inherited ButtonPanel: TPanel - Top = 434 - Width = 379 - ClientWidth = 379 - TabOrder = 5 - inherited CloseBtn: TButton - Left = 324 - end - inherited ComputeBtn: TButton - Left = 240 - end - inherited ResetBtn: TButton - Left = 178 - end - inherited HelpBtn: TButton - Left = 127 - end - inherited Bevel1: TBevel - Width = 371 - end + inherited ParamsPanel: TPanel + Height = 460 + Width = 424 + ClientHeight = 460 + ClientWidth = 424 + inherited CloseBtn: TButton + Left = 369 + Top = 435 + TabOrder = 8 + end + inherited ComputeBtn: TButton + Left = 285 + Top = 435 + end + inherited ResetBtn: TButton + Left = 223 + Top = 435 + end + inherited HelpBtn: TButton + Left = 164 + Top = 435 + TabOrder = 7 + end + inherited ButtonBevel: TBevel + Top = 419 + Width = 424 end inherited VarList: TListBox - Height = 401 - Width = 169 + Height = 394 + Width = 191 end inherited GroupLabel: TLabel - Left = 209 + Left = 233 end inherited GroupEdit: TEdit - Left = 209 - Width = 170 + Left = 233 + Width = 191 end inherited MeasLabel: TLabel - Left = 209 + Left = 233 end inherited MeasEdit: TEdit AnchorSideRight.Control = LevelOptns - Left = 209 - Width = 170 + Left = 233 + Width = 191 end inherited Bevel2: TBevel - Left = 178 + Left = 201 end inherited MeasInBtn: TSpeedButton - Left = 177 + Left = 199 end inherited MeasOutBtn: TSpeedButton - Left = 178 + Left = 199 end inherited GroupInBtn: TSpeedButton - Left = 177 + Left = 199 end inherited GroupOutBtn: TSpeedButton - Left = 178 + Left = 199 end - object SigmaOpts: TRadioGroup[12] + object SigmaOpts: TRadioGroup[16] AnchorSideLeft.Control = MeasInBtn AnchorSideTop.Control = GroupOutBtn AnchorSideTop.Side = asrBottom AnchorSideRight.Control = LevelOptns AnchorSideRight.Side = asrBottom - Left = 177 + Left = 199 Height = 128 - Top = 153 - Width = 202 + Top = 157 + Width = 225 Anchors = [akTop, akLeft, akRight] AutoFill = True BorderSpacing.Top = 12 @@ -90,7 +90,7 @@ inherited XBarChartForm: TXBarChartForm ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 ClientHeight = 108 - ClientWidth = 198 + ClientWidth = 221 ItemIndex = 0 Items.Strings = ( '3 Sigma' @@ -106,7 +106,7 @@ inherited XBarChartForm: TXBarChartForm Left = 128 Height = 23 Top = 80 - Width = 58 + Width = 81 Alignment = taRightJustify Anchors = [akLeft, akRight, akBottom] BorderSpacing.Right = 8 @@ -114,23 +114,23 @@ inherited XBarChartForm: TXBarChartForm Text = 'XSigmaEdit' end end - object LevelOptns: TGroupBox[13] + object LevelOptns: TGroupBox[17] AnchorSideLeft.Control = MeasInBtn AnchorSideTop.Control = SigmaOpts AnchorSideTop.Side = asrBottom AnchorSideRight.Control = MeasEdit AnchorSideRight.Side = asrBottom - Left = 177 + Left = 199 Height = 128 - Top = 293 - Width = 202 + Top = 297 + Width = 225 Anchors = [akTop, akLeft, akRight] AutoSize = True BorderSpacing.Top = 12 BorderSpacing.Bottom = 8 Caption = 'Show...' ClientHeight = 108 - ClientWidth = 198 + ClientWidth = 221 TabOrder = 4 object UpperSpecChk: TCheckBox AnchorSideLeft.Control = LevelOptns @@ -232,13 +232,13 @@ inherited XBarChartForm: TXBarChartForm end end end - inherited SpecsSplitter: TSplitter - Left = 390 + inherited ParamsSplitter: TSplitter + Left = 436 Height = 476 end inherited PageControl: TPageControl - Left = 398 - Height = 464 - Width = 523 + Left = 445 + Height = 460 + Width = 474 end end 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 e2996663a..7031bb581 100644 --- a/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas +++ b/applications/lazstats/source/forms/analysis/statistical_process_control/xbarchartunit.pas @@ -41,16 +41,19 @@ type UpperSpecChk: TCheckBox; UpperSpecEdit: TEdit; XSigmaEdit: TEdit; - procedure FormActivate(Sender: TObject); + private FAveStdDev: Double; + protected + procedure AdjustConstraints; override; procedure Compute; override; procedure PlotMeans(ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String; const Groups: StrDyneVec; const Means: DblDyneVec; UCL, LCL, GrandMean, TargetSpec, LowerSpec, UpperSpec: double); override; function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; - public + + public procedure Reset; override; end; @@ -66,40 +69,15 @@ uses {$R *.lfm} -procedure TXBarChartForm.FormActivate(Sender: TObject); -var - w: Integer; +procedure TXBarChartForm.AdjustConstraints; begin - if FAutoSized then - exit; + ParamsPanel.Constraints.MinWidth := Max( + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, + LevelOptns.Width * 2 - MeasInBtn.Width); - 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 - LevelOptns.AnchorSideRight.Control := nil; - VarList.Constraints.MinWidth := VarListLabel.Width; - SpecsPanel.Constraints.MinWidth := Max( - CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around, - LevelOptns.Width * 2 + VarList.BorderSpacing.Right //* 2 + MeasInBtn.Width - ); - Constraints.MinHeight := LevelOptns.Top + LevelOptns.Height + LevelOptns.BorderSpacing.Bottom + ButtonPanel.Height; - - LevelOptns.AnchorSideRight.Control := MeasEdit; - LevelOptns.AnchorSideRight.Side := asrBottom; - - if Height < Constraints.MinHeight then - Height := 1; // enforce height autosizing - finally - EnableAutoSizing; - end; - - Position := poDesigned; - FAutoSized := true; + ParamsPanel.Constraints.MinHeight := + LevelOptns.Top + LevelOptns.Height + LevelOptns.BorderSpacing.Bottom + + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height; end; @@ -123,7 +101,6 @@ var grp: String; X, Xsq, prevX: Double; sigma, UCL, LCL, grandMean, grandSD, SEMean: Double; - //C4Value: Double; individualsChart: Boolean; lReport: TStrings; begin @@ -345,6 +322,7 @@ begin ); end; + procedure TXBarChartForm.PlotMeans( ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String; const Groups: StrDyneVec; const Means: DblDyneVec; @@ -377,29 +355,38 @@ end; procedure TXBarChartForm.Reset; begin inherited; + UpperSpecEdit.Text := ''; LowerSpecEdit.Text := ''; TargetSpecEdit.Text := ''; XSigmaEdit.Text := ''; + UpperSpecChk.Checked := false; LowerSpecChk.Checked := false; TargetChk.Checked := false; ZonesChk.Checked := false; end; + function TXBarChartForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; var x: Double; begin Result := inherited; + + if not Result then + exit; + + { if (not Result) then begin // This particular chart will handle individual data if GroupEdit is empty. if GroupEdit.Visible and (GroupEdit.Text = '') then - Result := true + Result := true // wp: ??? will be reset after the "if" else exit; end; + } Result := false; diff --git a/applications/lazstats/source/forms/misc/basicstatsparamsformunit.pas b/applications/lazstats/source/forms/misc/basicstatsparamsformunit.pas index a7f4f220d..597609082 100644 --- a/applications/lazstats/source/forms/misc/basicstatsparamsformunit.pas +++ b/applications/lazstats/source/forms/misc/basicstatsparamsformunit.pas @@ -133,6 +133,7 @@ begin end; Compute; + UpdateBtnStates; end;