You've already forked lazarus-ccr
LazStats: Refactor GenSeqUnit. Add pdf to chm file.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7438 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -1,23 +1,27 @@
|
||||
object GenSeqFrm: TGenSeqFrm
|
||||
Left = 390
|
||||
Height = 192
|
||||
Height = 231
|
||||
Top = 114
|
||||
Width = 367
|
||||
AutoSize = True
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Generation of Sequential Values'
|
||||
ClientHeight = 192
|
||||
ClientHeight = 231
|
||||
ClientWidth = 367
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
OnShow = FormShow
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object Label1: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = StartAtEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = Label2
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 47
|
||||
Left = 99
|
||||
Height = 15
|
||||
Top = 96
|
||||
Top = 94
|
||||
Width = 99
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 12
|
||||
@ -26,10 +30,12 @@ object GenSeqFrm: TGenSeqFrm
|
||||
end
|
||||
object Label2: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = IncrEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = IncrEdit
|
||||
Left = 34
|
||||
Left = 86
|
||||
Height = 15
|
||||
Top = 127
|
||||
Top = 125
|
||||
Width = 112
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 12
|
||||
@ -39,11 +45,13 @@ object GenSeqFrm: TGenSeqFrm
|
||||
end
|
||||
object Label3: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = LabelEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = Label2
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 41
|
||||
Left = 93
|
||||
Height = 15
|
||||
Top = 160
|
||||
Top = 156
|
||||
Width = 105
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 12
|
||||
@ -52,11 +60,12 @@ object GenSeqFrm: TGenSeqFrm
|
||||
end
|
||||
object RadioGroup1: TRadioGroup
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 8
|
||||
Left = 71
|
||||
Height = 74
|
||||
Top = 8
|
||||
Width = 236
|
||||
Width = 225
|
||||
AutoFill = False
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
@ -69,30 +78,29 @@ object GenSeqFrm: TGenSeqFrm
|
||||
ChildSizing.Layout = cclTopToBottomThenLeftToRight
|
||||
ChildSizing.ControlsPerLine = 2
|
||||
ClientHeight = 54
|
||||
ClientWidth = 232
|
||||
ClientWidth = 221
|
||||
Items.Strings = (
|
||||
'All Current Cases'
|
||||
'Number of Cases = '
|
||||
'Number of Cases:'
|
||||
)
|
||||
OnClick = RadioGroup1Click
|
||||
TabOrder = 0
|
||||
object StaticText1: TStaticText
|
||||
Left = 140
|
||||
Left = 129
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 80
|
||||
Caption = ' '
|
||||
TabOrder = 2
|
||||
TabOrder = 1
|
||||
end
|
||||
object NoCasesEdit: TEdit
|
||||
Left = 140
|
||||
Left = 129
|
||||
Height = 23
|
||||
Top = 25
|
||||
Width = 80
|
||||
Alignment = taRightJustify
|
||||
BorderSpacing.Left = 3
|
||||
OnExit = NoCasesEditExit
|
||||
TabOrder = 3
|
||||
TabOrder = 0
|
||||
Text = 'NoCasesEdit'
|
||||
end
|
||||
end
|
||||
@ -100,7 +108,7 @@ object GenSeqFrm: TGenSeqFrm
|
||||
AnchorSideLeft.Control = LabelEdit
|
||||
AnchorSideTop.Control = RadioGroup1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 154
|
||||
Left = 206
|
||||
Height = 23
|
||||
Top = 90
|
||||
Width = 78
|
||||
@ -113,7 +121,7 @@ object GenSeqFrm: TGenSeqFrm
|
||||
AnchorSideLeft.Control = LabelEdit
|
||||
AnchorSideTop.Control = StartAtEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 154
|
||||
Left = 206
|
||||
Height = 23
|
||||
Top = 121
|
||||
Width = 78
|
||||
@ -127,100 +135,75 @@ object GenSeqFrm: TGenSeqFrm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = RadioGroup1
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 154
|
||||
Left = 206
|
||||
Height = 23
|
||||
Top = 152
|
||||
Width = 78
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Bottom = 8
|
||||
BorderSpacing.Bottom = 4
|
||||
TabOrder = 3
|
||||
Text = 'LabelEdit'
|
||||
end
|
||||
object Panel1: TPanel
|
||||
AnchorSideLeft.Control = RadioGroup1
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideBottom.Control = LabelEdit
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 260
|
||||
Height = 136
|
||||
Top = 39
|
||||
Width = 76
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 16
|
||||
BorderSpacing.Right = 8
|
||||
BevelOuter = bvNone
|
||||
ChildSizing.VerticalSpacing = 12
|
||||
ClientHeight = 136
|
||||
ClientWidth = 76
|
||||
TabOrder = 4
|
||||
object ResetBtn: TButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 76
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object CancelBtn: TButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = ResetBtn
|
||||
object CloseBtn: TButton
|
||||
AnchorSideTop.Control = Bevel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 0
|
||||
Left = 304
|
||||
Height = 25
|
||||
Top = 37
|
||||
Width = 76
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
Top = 195
|
||||
Width = 55
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 1
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Close'
|
||||
ModalResult = 11
|
||||
TabOrder = 4
|
||||
end
|
||||
object ComputeBtn: TButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = CancelBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 0
|
||||
AnchorSideTop.Control = CloseBtn
|
||||
AnchorSideRight.Control = CloseBtn
|
||||
Left = 220
|
||||
Height = 25
|
||||
Top = 74
|
||||
Top = 195
|
||||
Width = 76
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Compute'
|
||||
OnClick = ComputeBtnClick
|
||||
TabOrder = 2
|
||||
TabOrder = 5
|
||||
end
|
||||
object ReturnBtn: TButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = ComputeBtn
|
||||
object ResetBtn: TButton
|
||||
AnchorSideTop.Control = CloseBtn
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
Left = 158
|
||||
Height = 25
|
||||
Top = 195
|
||||
Width = 54
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Right = 8
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 6
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = LabelEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 111
|
||||
Width = 76
|
||||
Height = 8
|
||||
Top = 179
|
||||
Width = 367
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Return'
|
||||
ModalResult = 1
|
||||
TabOrder = 3
|
||||
end
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
end
|
||||
|
@ -15,12 +15,11 @@ type
|
||||
{ TGenSeqFrm }
|
||||
|
||||
TGenSeqFrm = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
NoCasesEdit: TEdit;
|
||||
Panel1: TPanel;
|
||||
ResetBtn: TButton;
|
||||
CancelBtn: TButton;
|
||||
ComputeBtn: TButton;
|
||||
ReturnBtn: TButton;
|
||||
CloseBtn: TButton;
|
||||
LabelEdit: TEdit;
|
||||
Label3: TLabel;
|
||||
StartAtEdit: TEdit;
|
||||
@ -30,9 +29,9 @@ type
|
||||
RadioGroup1: TRadioGroup;
|
||||
StaticText1: TStaticText;
|
||||
procedure ComputeBtnClick(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure NoCasesEditExit(Sender: TObject);
|
||||
procedure RadioGroup1Click(Sender: TObject);
|
||||
procedure ResetBtnClick(Sender: TObject);
|
||||
private
|
||||
@ -47,6 +46,9 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Math;
|
||||
|
||||
{ TGenSeqFrm }
|
||||
|
||||
procedure TGenSeqFrm.ResetBtnClick(Sender: TObject);
|
||||
@ -68,27 +70,56 @@ var
|
||||
i, col: integer;
|
||||
First, Increment: double;
|
||||
begin
|
||||
if StartAtEdit.Text = '' then
|
||||
if RadioGroup1.ItemIndex = 1 then begin
|
||||
if NoCasesEdit.Text = '' then
|
||||
begin
|
||||
ShowMessage('Error! No starting value provided.');
|
||||
NoCasesEdit.Setfocus;
|
||||
MessageDlg('Number of cases to generate not specified.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
if IncrEdit.Text = '' then
|
||||
if not TryStrToInt(NoCasesEdit.Text, NCases) or (NCases <= 0) then
|
||||
begin
|
||||
ShowMessage('Error! No increment value provided.');
|
||||
NoCasesEdit.SetFocus;
|
||||
MessageDlg('Number of cases must be a valid, positive integer.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
end else
|
||||
NCases := NoCases;
|
||||
|
||||
if (StartAtEdit.Text = '') or not TryStrToFloat(StartAtEdit.Text, First) then
|
||||
begin
|
||||
StartAtEdit.Setfocus;
|
||||
MessageDlg('No starting value provided.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if (IncrEdit.Text = '') then
|
||||
begin
|
||||
IncrEdit.SetFocus;
|
||||
MessageDlg('No increment value provided.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
if not TryStrToFloat(IncrEdit.Text, Increment) or (Increment <= 0) then
|
||||
begin
|
||||
IncrEdit.SetFocus;
|
||||
MessageDlg('No valid increment value provided.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if LabelEdit.Text = '' then
|
||||
begin
|
||||
ShowMessage('Error! No variable label provided.');
|
||||
LabelEdit.SetFocus;
|
||||
MessageDlg('No variable label provided.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if NoCases < Ncases then
|
||||
begin
|
||||
OS3MainFrm.DataGrid.RowCount := NCases + 1;
|
||||
OS3MainFrm.NoCasesEdit.Text := IntToStr(NCases);
|
||||
NoCases := Ncases;
|
||||
end;
|
||||
|
||||
if NoVariables <= 0 then // a new data file
|
||||
begin
|
||||
OS3MainFrm.DataGrid.ColCount := 2;
|
||||
@ -103,7 +134,6 @@ begin
|
||||
OS3MainFrm.DataGrid.Cells[1,0] := LabelEdit.Text;
|
||||
DictionaryFrm.DictGrid.RowCount := 2;
|
||||
NoVariables := 1;
|
||||
|
||||
end
|
||||
else // existing data file
|
||||
begin
|
||||
@ -116,12 +146,22 @@ begin
|
||||
Increment := StrToFloat(IncrEdit.Text);
|
||||
for i := 1 to Ncases do
|
||||
begin
|
||||
OS3MainFrm.DataGrid.Cells[col,i] := format('%8.3f',[First]);
|
||||
OS3MainFrm.DataGrid.Cells[col,i] := Format('%.3f', [First]);
|
||||
First := First + Increment;
|
||||
end;
|
||||
OS3MainFrm.NoVarsEdit.Text := IntToStr(NoVariables);
|
||||
end;
|
||||
|
||||
procedure TGenSeqFrm.FormActivate(Sender: TObject);
|
||||
var
|
||||
w: Integer;
|
||||
begin
|
||||
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
|
||||
ResetBtn.Constraints.MinWidth := w;
|
||||
ComputeBtn.Constraints.MinWidth := w;
|
||||
CloseBtn.Constraints.MinWidth := w;
|
||||
end;
|
||||
|
||||
procedure TGenSeqFrm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Assert(OS3MainFrm <> nil);
|
||||
@ -129,28 +169,18 @@ begin
|
||||
Application.CreateForm(TDictionaryFrm, DictionaryFrm);
|
||||
end;
|
||||
|
||||
procedure TGenSeqFrm.NoCasesEditExit(Sender: TObject);
|
||||
begin
|
||||
if RadioGroup1.ItemIndex = 1 then Ncases := StrToInt(NoCasesEdit.Text);
|
||||
if (Ncases <= 0) and (RadioGroup1.ItemIndex = 1) then
|
||||
begin
|
||||
ShowMessage('Error! No. of cases to generate not specified.');
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGenSeqFrm.RadioGroup1Click(Sender: TObject);
|
||||
begin
|
||||
if RadioGroup1.ItemIndex = 0 then
|
||||
begin
|
||||
if NoCases <= 0 then
|
||||
begin
|
||||
ShowMessage('Error! There are currently no cases!');
|
||||
MessageDlg('There are currently no cases.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end
|
||||
else Ncases := NoCases;
|
||||
end
|
||||
else NoCasesEdit.SetFocus;
|
||||
end else
|
||||
Ncases := NoCases;
|
||||
end else
|
||||
NoCasesEdit.SetFocus;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
Reference in New Issue
Block a user