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
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Printers, ComCtrls, Buttons,
MainUnit, Globals, DataProcs, ContextHelpUnit,
BasicStatsReportAndChartFormUnit, ReportFrameUnit, ChartFrameUnit;
MainUnit, Globals, DataProcs, ReportFrameUnit, ChartFrameUnit,
BasicStatsReportAndChartFormUnit;
type

View File

@ -1,4 +1,4 @@
object BubbleForm: TBubbleForm
inherited BubbleForm: TBubbleForm
Left = 476
Height = 465
Top = 224
@ -8,25 +8,33 @@ object BubbleForm: TBubbleForm
Caption = 'Repeated Measures Bubble Plot'
ClientHeight = 465
ClientWidth = 937
OnActivate = FormActivate
OnCreate = FormCreate
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object ParamsPanel: TPanel
Left = 8
inherited ParamsPanel: TPanel
Height = 449
Top = 8
Width = 376
Align = alLeft
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 4
BorderSpacing.Bottom = 8
BevelOuter = bvNone
ClientHeight = 449
ClientWidth = 376
TabOrder = 0
object Panel1: TPanel
inherited CloseBtn: TButton
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
AnchorSideTop.Control = ParamsPanel
AnchorSideRight.Control = ParamsPanel
@ -314,89 +322,7 @@ object BubbleForm: TBubbleForm
Text = 'SizeEdit'
end
end
object CloseBtn: TButton
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
object Label6: TLabel[6]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = TitleEdit
AnchorSideTop.Side = asrCenter
@ -407,7 +333,7 @@ object BubbleForm: TBubbleForm
Caption = 'Main Title:'
ParentColor = False
end
object Label7: TLabel
object Label7: TLabel[7]
AnchorSideTop.Control = XLabelEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = XLabelEdit
@ -420,7 +346,7 @@ object BubbleForm: TBubbleForm
Caption = 'X Label:'
ParentColor = False
end
object Label8: TLabel
object Label8: TLabel[8]
AnchorSideTop.Control = YLabelEdit
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = YLabelEdit
@ -433,7 +359,7 @@ object BubbleForm: TBubbleForm
Caption = 'Y Label:'
ParentColor = False
end
object TitleEdit: TEdit
object TitleEdit: TEdit[9]
AnchorSideLeft.Control = Label6
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Side = asrBottom
@ -449,7 +375,7 @@ object BubbleForm: TBubbleForm
TabOrder = 5
TextHint = 'Title of the Diagram'
end
object XLabelEdit: TEdit
object XLabelEdit: TEdit[10]
AnchorSideLeft.Control = TitleEdit
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
@ -463,7 +389,7 @@ object BubbleForm: TBubbleForm
TabOrder = 6
TextHint = 'X Axis Title'
end
object YLabelEdit: TEdit
object YLabelEdit: TEdit[11]
AnchorSideLeft.Control = TitleEdit
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
@ -477,10 +403,10 @@ object BubbleForm: TBubbleForm
TabOrder = 7
TextHint = 'Y Axis Title'
end
object TransformChk: TCheckBox
object TransformChk: TCheckBox[12]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = Bevel1
AnchorSideBottom.Control = ButtonBevel
Left = 0
Height = 19
Top = 385
@ -492,31 +418,13 @@ object BubbleForm: TBubbleForm
TabOrder = 8
end
end
object ParamsSplitter: TSplitter
inherited ParamsSplitter: TSplitter
Left = 388
Height = 465
Top = 0
Width = 5
ResizeStyle = rsPattern
end
object PageControl: TPageControl
inherited PageControl: TPageControl
Left = 397
Height = 449
Top = 8
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

View File

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