LazStats: Inherit form of BubblePlotUnit from TBasicStatsReportAndChartForm.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7746 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-05 19:11:01 +00:00
parent 04db6bd5ee
commit 753a46f4af
3 changed files with 93 additions and 234 deletions

View File

@ -9,8 +9,8 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Printers, ComCtrls, Buttons, StdCtrls, ExtCtrls, Printers, ComCtrls, Buttons,
MainUnit, Globals, DataProcs, ContextHelpUnit, MainUnit, Globals, DataProcs, ReportFrameUnit, ChartFrameUnit,
BasicStatsReportAndChartFormUnit, ReportFrameUnit, ChartFrameUnit; BasicStatsReportAndChartFormUnit;
type type

View File

@ -1,4 +1,4 @@
object BubbleForm: TBubbleForm inherited BubbleForm: TBubbleForm
Left = 476 Left = 476
Height = 465 Height = 465
Top = 224 Top = 224
@ -8,25 +8,33 @@ object BubbleForm: TBubbleForm
Caption = 'Repeated Measures Bubble Plot' Caption = 'Repeated Measures Bubble Plot'
ClientHeight = 465 ClientHeight = 465
ClientWidth = 937 ClientWidth = 937
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ParamsPanel: TPanel
Left = 8
Height = 449 Height = 449
Top = 8
Width = 376 Width = 376
Align = alLeft
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 4
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 449 ClientHeight = 449
ClientWidth = 376 ClientWidth = 376
TabOrder = 0 inherited CloseBtn: TButton
object Panel1: TPanel Left = 321
Top = 424
TabOrder = 4
end
inherited ComputeBtn: TButton
Left = 238
Top = 424
end
inherited ResetBtn: TButton
Left = 176
Top = 424
end
inherited HelpBtn: TButton
Left = 117
Top = 424
end
inherited ButtonBevel: TBevel
Top = 408
Width = 376
end
object Panel1: TPanel[5]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel AnchorSideRight.Control = ParamsPanel
@ -314,89 +322,7 @@ object BubbleForm: TBubbleForm
Text = 'SizeEdit' Text = 'SizeEdit'
end end
end end
object CloseBtn: TButton object Label6: TLabel[6]
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 321
Height = 25
Top = 424
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Close'
ModalResult = 11
OnClick = CloseBtnClick
TabOrder = 1
end
object ComputeBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 237
Height = 25
Top = 424
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 2
end
object ResetBtn: TButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 175
Height = 25
Top = 424
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 3
end
object HelpBtn: TButton
Tag = 110
AnchorSideRight.Control = ResetBtn
AnchorSideBottom.Control = ParamsPanel
AnchorSideBottom.Side = asrBottom
Left = 116
Height = 25
Top = 424
Width = 51
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Help'
OnClick = HelpBtnClick
TabOrder = 4
end
object Bevel1: TBevel
AnchorSideLeft.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 408
Width = 376
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end
object Label6: TLabel
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = TitleEdit AnchorSideTop.Control = TitleEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
@ -407,7 +333,7 @@ object BubbleForm: TBubbleForm
Caption = 'Main Title:' Caption = 'Main Title:'
ParentColor = False ParentColor = False
end end
object Label7: TLabel object Label7: TLabel[7]
AnchorSideTop.Control = XLabelEdit AnchorSideTop.Control = XLabelEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = XLabelEdit AnchorSideRight.Control = XLabelEdit
@ -420,7 +346,7 @@ object BubbleForm: TBubbleForm
Caption = 'X Label:' Caption = 'X Label:'
ParentColor = False ParentColor = False
end end
object Label8: TLabel object Label8: TLabel[8]
AnchorSideTop.Control = YLabelEdit AnchorSideTop.Control = YLabelEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = YLabelEdit AnchorSideRight.Control = YLabelEdit
@ -433,7 +359,7 @@ object BubbleForm: TBubbleForm
Caption = 'Y Label:' Caption = 'Y Label:'
ParentColor = False ParentColor = False
end end
object TitleEdit: TEdit object TitleEdit: TEdit[9]
AnchorSideLeft.Control = Label6 AnchorSideLeft.Control = Label6
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
@ -449,7 +375,7 @@ object BubbleForm: TBubbleForm
TabOrder = 5 TabOrder = 5
TextHint = 'Title of the Diagram' TextHint = 'Title of the Diagram'
end end
object XLabelEdit: TEdit object XLabelEdit: TEdit[10]
AnchorSideLeft.Control = TitleEdit AnchorSideLeft.Control = TitleEdit
AnchorSideRight.Control = TitleEdit AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -463,7 +389,7 @@ object BubbleForm: TBubbleForm
TabOrder = 6 TabOrder = 6
TextHint = 'X Axis Title' TextHint = 'X Axis Title'
end end
object YLabelEdit: TEdit object YLabelEdit: TEdit[11]
AnchorSideLeft.Control = TitleEdit AnchorSideLeft.Control = TitleEdit
AnchorSideRight.Control = TitleEdit AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -477,10 +403,10 @@ object BubbleForm: TBubbleForm
TabOrder = 7 TabOrder = 7
TextHint = 'Y Axis Title' TextHint = 'Y Axis Title'
end end
object TransformChk: TCheckBox object TransformChk: TCheckBox[12]
AnchorSideLeft.Control = ParamsPanel AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = Bevel1 AnchorSideBottom.Control = ButtonBevel
Left = 0 Left = 0
Height = 19 Height = 19
Top = 385 Top = 385
@ -492,31 +418,13 @@ object BubbleForm: TBubbleForm
TabOrder = 8 TabOrder = 8
end end
end end
object ParamsSplitter: TSplitter inherited ParamsSplitter: TSplitter
Left = 388 Left = 388
Height = 465 Height = 465
Top = 0
Width = 5
ResizeStyle = rsPattern
end end
object PageControl: TPageControl inherited PageControl: TPageControl
Left = 397 Left = 397
Height = 449 Height = 449
Top = 8
Width = 532 Width = 532
ActivePage = ReportPage
Align = alClient
BorderSpacing.Left = 4
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
TabIndex = 0
TabOrder = 2
object ReportPage: TTabSheet
Caption = 'Report'
end
object ChartPage: TTabSheet
Caption = 'Chart'
end
end end
end end

View File

@ -9,23 +9,16 @@ interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Clipbrd, Buttons, ExtCtrls, ComCtrls, Math, StdCtrls, Clipbrd, Buttons, ExtCtrls, ComCtrls, Math,
MainUnit, Globals, DataProcs, DictionaryUnit, ContextHelpUnit, MainUnit, Globals, DataProcs, DictionaryUnit,
BasicStatsFormUnit, ChartFrameUnit, ReportFrameUnit; BasicStatsReportAndChartFormUnit, ChartFrameUnit, ReportFrameUnit;
type type
{ TBubbleForm } { TBubbleForm }
TBubbleForm = class(TBasicStatsForm) TBubbleForm = class(TBasicStatsReportAndChartForm)
Bevel1: TBevel;
HelpBtn: TButton;
PageControl: TPageControl;
Panel1: TPanel; Panel1: TPanel;
ParamsPanel: TPanel;
ParamsSplitter: TSplitter;
ReportPage: TTabSheet;
ChartPage: TTabSheet;
TransformChk: TCheckBox; TransformChk: TCheckBox;
YLabelEdit: TEdit; YLabelEdit: TEdit;
Label8: TLabel; Label8: TLabel;
@ -33,9 +26,6 @@ type
Label7: TLabel; Label7: TLabel;
TitleEdit: TEdit; TitleEdit: TEdit;
Label6: TLabel; Label6: TLabel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
IDInBtn: TBitBtn; IDInBtn: TBitBtn;
IDOutBtn: TBitBtn; IDOutBtn: TBitBtn;
XInBtn: TBitBtn; XInBtn: TBitBtn;
@ -54,14 +44,8 @@ type
Label4: TLabel; Label4: TLabel;
Label5: TLabel; Label5: TLabel;
VarList: TListBox; VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure HelpBtnClick(Sender: TObject);
procedure IDInBtnClick(Sender: TObject); procedure IDInBtnClick(Sender: TObject);
procedure IDOutBtnClick(Sender: TObject); procedure IDOutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure CloseBtnClick(Sender: TObject);
procedure SizeInBtnClick(Sender: TObject); procedure SizeInBtnClick(Sender: TObject);
procedure SizeOutBtnClick(Sender: TObject); procedure SizeOutBtnClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject); procedure VarListDblClick(Sender: TObject);
@ -70,16 +54,18 @@ type
procedure XOutBtnClick(Sender: TObject); procedure XOutBtnClick(Sender: TObject);
procedure YInBtnClick(Sender: TObject); procedure YInBtnClick(Sender: TObject);
procedure YOutBtnClick(Sender: TObject); procedure YOutBtnClick(Sender: TObject);
private private
{ private declarations }
BubbleCol, XCol, YCol, SizeCol: Integer; BubbleCol, XCol, YCol, SizeCol: Integer;
FAutoSized: boolean;
FReportFrame: TReportFrame;
FChartFrame: TChartFrame;
procedure PlotBubbles(YMax, YMin, BubMax, BubMin: Double); procedure PlotBubbles(YMax, YMin, BubMax, BubMin: Double);
procedure UpdateBtnStates;
protected
procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
public public
{ public declarations } constructor Create(AOwner: TComponent); override;
procedure Reset; override; procedure Reset; override;
end; end;
@ -91,12 +77,38 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
TAChartUtils, TALegend, TAMultiSeries, TAChartUtils, TALegend, TAMultiSeries;
Utils;
{ TBubbleForm } { TBubbleForm }
procedure TBubbleForm.ComputeBtnClick(Sender: TObject); constructor TBubbleForm.Create(AOwner: TComponent);
begin
inherited;
FChartFrame.Chart.Margins.Left := 50;
FChartFrame.Chart.Margins.Right := 50;
end;
procedure TBubbleForm.AdjustConstraints;
begin
inherited;
Panel1.Constraints.MinHeight := SizeOutBtn.Top + SizeOutBtn.Height;
ParamsPanel.Constraints.MinHeight := Panel1.Height + Panel1.BorderSpacing.Bottom +
3*TitleEdit.Height + 2*XLabelEdit.BorderSpacing.Top +
TransformChk.BorderSpacing.Top + TransformChk.Height + TransformChk.BorderSpacing.Bottom +
ButtonBevel.Height +
CloseBtn.Height + CloseBtn.BorderSpacing.Top;
ParamsPanel.Constraints.MinWidth := Max(TransformChk.Width, 4*CloseBtn.Width + 3*HelpBtn.BorderSpacing.Right);
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 200;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + 2*ParamsPanel.BorderSpacing.Top;
end;
procedure TBubbleForm.Compute;
var var
i, j, cell: integer; i, j, cell: integer;
Xmin, Xmax, intcell, noreplications, minrep, maxrep: integer; Xmin, Xmax, intcell, noreplications, minrep, maxrep: integer;
@ -115,6 +127,8 @@ var
labels: StrDyneVec = nil; labels: StrDyneVec = nil;
lReport: TStrings; lReport: TStrings;
begin begin
inherited;
BubbleCol := 0; BubbleCol := 0;
XCol := 0; XCol := 0;
YCol := 0; YCol := 0;
@ -263,10 +277,6 @@ begin
finally finally
lReport.Free; lReport.Free;
SizeMeans := nil;
Ymeans := nil;
CaseSizeMeans := nil;
CaseYMeans := nil;
end; end;
// Transform data matrix if elected // Transform data matrix if elected
@ -365,58 +375,6 @@ begin
end; end;
procedure TBubbleForm.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;
Panel1.Constraints.MinHeight := SizeOutBtn.Top + SizeOutBtn.Height;
ParamsPanel.Constraints.MinHeight := Panel1.Height + Panel1.BorderSpacing.Bottom +
3*TitleEdit.Height + 2*XLabelEdit.BorderSpacing.Top +
TransformChk.BorderSpacing.Top + TransformChk.Height + TransformChk.BorderSpacing.Bottom +
Bevel1.Height +
CloseBtn.Height + CloseBtn.BorderSpacing.Top;
ParamsPanel.Constraints.MinWidth := Max(TransformChk.Width, 4*w + 3*HelpBtn.BorderSpacing.Right);
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 200;
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + 2*ParamsPanel.BorderSpacing.Top;
if Height < Constraints.MinHeight then Height := 1; // enforce auto-sizing
if Width < Constraints.MiNWidth then Width := 1;
Position := poDesigned;
FAutoSized := True;
end;
procedure TBubbleForm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm);
InitForm(self);
FReportFrame := TReportFrame.Create(self);
FReportFrame.Parent := ReportPage;
FReportFrame.Align := alClient;
FChartFrame := TChartFrame.Create(self);
FChartFrame.Parent := ChartPage;
FChartFrame.Align := alClient;
FChartFrame.Chart.BottomAxis.Intervals.MaxLength := 80;
FChartFrame.Chart.BottomAxis.Intervals.MinLength := 30;
Reset;
end;
procedure TBubbleForm.IDInBtnClick(Sender: TObject); procedure TBubbleForm.IDInBtnClick(Sender: TObject);
var var
i: integer; i: integer;
@ -444,14 +402,6 @@ begin
end; end;
procedure TBubbleForm.HelpBtnClick(Sender: TObject);
begin
if ContextHelpForm = nil then
Application.CreateForm(TContextHelpForm, ContextHelpForm);
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
end;
procedure TBubbleForm.PlotBubbles(YMax, YMin, BubMax, BubMin: Double); procedure TBubbleForm.PlotBubbles(YMax, YMin, BubMax, BubMin: Double);
var var
ser: TBubbleSeries; ser: TBubbleSeries;
@ -530,6 +480,8 @@ procedure TBubbleForm.Reset;
var var
i: integer; i: integer;
begin begin
inherited;
BubbleEdit.Text := ''; BubbleEdit.Text := '';
XEdit.Text := ''; XEdit.Text := '';
YEdit.Text := ''; YEdit.Text := '';
@ -538,17 +490,11 @@ begin
for i := 1 to NoVariables do for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates; UpdateBtnStates;
end;
if Assigned(FReportFrame) then
procedure TBubbleForm.ResetBtnClick(Sender: TObject); FReportFrame.Clear;
begin if Assigned(FChartFrame) then
Reset; FChartFrame.Clear;
end;
procedure TBubbleForm.CloseBtnClick(Sender: TObject);
begin
Close;
end; end;
@ -578,6 +524,7 @@ begin
UpdateBtnStates; UpdateBtnStates;
end; end;
procedure TBubbleForm.VarListDblClick(Sender: TObject); procedure TBubbleForm.VarListDblClick(Sender: TObject);
var var
index: integer; index: integer;
@ -604,6 +551,8 @@ var
i: Integer; i: Integer;
lSelected: Boolean; lSelected: Boolean;
begin begin
inherited;
lSelected := false; lSelected := false;
for i:=0 to VarList.Count-1 do for i:=0 to VarList.Count-1 do
if VarList.Selected[i] then if VarList.Selected[i] then
@ -621,7 +570,9 @@ begin
YOutBtn.Enabled := YEdit.Text <> ''; YOutBtn.Enabled := YEdit.Text <> '';
SizeOutBtn.Enabled := SizeEdit.Text <> ''; SizeOutBtn.Enabled := SizeEdit.Text <> '';
if Assigned(FReportFrame) then
FReportFrame.UpdateBtnStates; FReportFrame.UpdateBtnStates;
if Assigned(FChartFrame) then
FChartFrame.UpdateBtnStates; FChartFrame.UpdateBtnStates;
end; end;