You've already forked lazarus-ccr
LazStats: Inherit form of BoxPlotUnit from TBasicStatsReportAndChartForm.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7745 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -10,59 +10,43 @@ uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ExtCtrls, Printers, ComCtrls, Buttons,
|
||||
MainUnit, Globals, DataProcs, ContextHelpUnit,
|
||||
BasicStatsFormUnit, ReportFrameUnit, ChartFrameUnit;
|
||||
BasicStatsReportAndChartFormUnit, ReportFrameUnit, ChartFrameUnit;
|
||||
|
||||
|
||||
type
|
||||
|
||||
{ TBoxPlotFrm }
|
||||
|
||||
TBoxPlotFrm = class(TBasicStatsForm)
|
||||
Bevel2: TBevel;
|
||||
HelpBtn: TButton;
|
||||
PageControl1: TPageControl;
|
||||
ParamsPanel: TPanel;
|
||||
ResetBtn: TButton;
|
||||
ComputeBtn: TButton;
|
||||
CloseBtn: TButton;
|
||||
TBoxPlotFrm = class(TBasicStatsReportAndChartForm)
|
||||
MeasEdit: TEdit;
|
||||
GroupEdit: TEdit;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
Label3: TLabel;
|
||||
ParamsSplitter: TSplitter;
|
||||
ReportPage: TTabSheet;
|
||||
ChartPage: TTabSheet;
|
||||
VarList: TListBox;
|
||||
GrpInBtn: TBitBtn;
|
||||
GrpOutBtn: TBitBtn;
|
||||
MeasInBtn: TBitBtn;
|
||||
MeasOutBtn: TBitBtn;
|
||||
procedure CloseBtnClick(Sender: TObject);
|
||||
procedure ComputeBtnClick(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure GrpOutBtnClick(Sender: TObject);
|
||||
procedure GrpInBtnClick(Sender: TObject);
|
||||
procedure HelpBtnClick(Sender: TObject);
|
||||
procedure MeasInBtnClick(Sender: TObject);
|
||||
procedure MeasOutBtnClick(Sender: TObject);
|
||||
procedure ResetBtnClick(Sender: TObject);
|
||||
procedure VarListDblClick(Sender: TObject);
|
||||
procedure VarListSelectionChange(Sender: TObject; User: boolean);
|
||||
procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean);
|
||||
|
||||
private
|
||||
{ private declarations }
|
||||
FAutoSized: Boolean;
|
||||
FReportFrame: TReportFrame;
|
||||
FChartFrame: TChartFrame;
|
||||
procedure BoxPlot(const LowQrtl, HiQrtl, TenPcnt, NinetyPcnt, Medians: DblDyneVec);
|
||||
function Percentile(nScoreGrps: integer; APercentile: Double;
|
||||
const Freq, CumFreq, Scores: DblDyneVec): 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;
|
||||
|
||||
@ -83,6 +67,16 @@ const
|
||||
|
||||
{ TBoxPlotFrm }
|
||||
|
||||
constructor TBoxPlotFrm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
FChartFrame.Chart.Legend.Alignment := laBottomCenter;
|
||||
FChartFrame.Chart.Legend.ColumnCount := 3;
|
||||
FChartFrame.Chart.Legend.TextFormat := tfHTML;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.BoxPlot(const LowQrtl, HiQrtl, TenPcnt, NinetyPcnt, Medians: DblDyneVec);
|
||||
var
|
||||
i: Integer;
|
||||
@ -120,13 +114,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.CloseBtnClick(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.ComputeBtnClick(Sender: TObject);
|
||||
procedure TBoxPlotFrm.Compute;
|
||||
var
|
||||
lReport: TStrings;
|
||||
i, j, k, GrpVar, MeasVar, mingrp, maxgrp, G, NoGrps, cnt: integer;
|
||||
@ -146,7 +134,7 @@ var
|
||||
TenPcntile: DblDyneVec = nil;
|
||||
NinetyPcntile: DblDyneVec = nil;
|
||||
Median: DblDyneVec = nil;
|
||||
ColNoSelected: IntDyneVec;
|
||||
ColNoSelected: IntDyneVec = nil;
|
||||
begin
|
||||
lReport := TStringList.Create;
|
||||
try
|
||||
@ -337,73 +325,23 @@ begin
|
||||
BoxPlot(LowQrtl, HiQrtl, TenPcntile, NinetyPcntile, Median);
|
||||
finally
|
||||
lReport.Free;
|
||||
|
||||
// Clean up
|
||||
Median := nil;
|
||||
NinetyPcntile := nil;
|
||||
TenPcntile := nil;
|
||||
HiQrtl := nil;
|
||||
LowQrtl := nil;
|
||||
Means := nil;
|
||||
GrpSize := nil;
|
||||
CumFreq := nil;
|
||||
Scores := nil;
|
||||
Freq := nil;
|
||||
ColNoSelected := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.FormActivate(Sender: TObject);
|
||||
var
|
||||
w: Integer;
|
||||
procedure TBoxPlotFrm.AdjustConstraints;
|
||||
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;
|
||||
inherited;
|
||||
|
||||
ParamsPanel.Constraints.MinWidth := Max(
|
||||
4*w + 3*HelpBtn.BorderSpacing.Right,
|
||||
4*CloseBtn.Width + 3*HelpBtn.BorderSpacing.Right,
|
||||
Max(Label1.Width, Label3.Width) * 2 + MeasInBtn.Width + 2 * MeasInBtn.BorderSpacing.Left
|
||||
);
|
||||
ParamsPanel.Constraints.MinHeight := VarList.Top + VarList.Constraints.MinHeight +
|
||||
Bevel2.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top;
|
||||
ButtonBevel.Height + CloseBtn.Height + CloseBtn.BorderSpacing.Top;
|
||||
|
||||
Constraints.MinHeight := ParamsPanel.Constraints.MinHeight + ParamsPanel.BorderSpacing.Around*2;
|
||||
Constraints.MinWidth := ParamsPanel.Constraints.MinWidth + 200;
|
||||
if Height < Constraints.MinHeight then Height := 1; // enforce auto-sizing
|
||||
if Width < Constraints.MiNWidth then Width := 1;
|
||||
|
||||
Position := poDesigned;
|
||||
FAutoSized := true;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.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.Alignment := laBottomCenter;
|
||||
FChartFrame.Chart.Legend.ColumnCount := 3;
|
||||
FChartFrame.Chart.Legend.TextFormat := tfHTML;
|
||||
FChartFrame.Chart.BottomAxis.Intervals.MaxLength := 80;
|
||||
FChartFrame.Chart.BottomAxis.Intervals.MinLength := 30;
|
||||
|
||||
Reset;
|
||||
end;
|
||||
|
||||
|
||||
@ -432,14 +370,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.HelpBtnClick(Sender: TObject);
|
||||
begin
|
||||
if ContextHelpForm = nil then
|
||||
Application.CreateForm(TContextHelpForm, ContextHelpForm);
|
||||
ContextHelpForm.HelpMessage((Sender as TButton).Tag);
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.MeasInBtnClick(Sender: TObject);
|
||||
var
|
||||
index: integer;
|
||||
@ -453,6 +383,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.MeasOutBtnClick(Sender: TObject);
|
||||
begin
|
||||
if MeasEdit.Text <> '' then
|
||||
@ -505,31 +436,36 @@ procedure TBoxPlotFrm.Reset;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
VarList.Clear;
|
||||
GroupEdit.Text := '';
|
||||
MeasEdit.Text := '';
|
||||
for i := 1 to NoVariables do
|
||||
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.ResetBtnClick(Sender: TObject);
|
||||
begin
|
||||
Reset;
|
||||
if Assigned(FReportFrame) then
|
||||
FReportFrame.Clear;
|
||||
if Assigned(FChartFrame) then
|
||||
FChartFrame.Clear;
|
||||
end;
|
||||
|
||||
|
||||
procedure TBoxPlotFrm.UpdateBtnStates;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
MeasinBtn.Enabled := (VarList.ItemIndex > -1) and (MeasEdit.Text = '');
|
||||
MeasoutBtn.Enabled := (MeasEdit.Text <> '');
|
||||
|
||||
GrpinBtn.Enabled := (VarList.ItemIndex > -1) and (GroupEdit.Text = '');
|
||||
grpoutBtn.Enabled := (GroupEdit.Text <> '');
|
||||
|
||||
FReportFrame.UpdateBtnStates;
|
||||
FChartFrame.UpdateBtnStates;
|
||||
if Assigned(FReportFrame) then
|
||||
FReportFrame.UpdateBtnStates;
|
||||
if Assigned(FChartFrame) then
|
||||
FChartFrame.UpdateBtnStates;
|
||||
end;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user