You've already forked lazarus-ccr
LazStats: Minor improvements in XVsMultYUnit and PlotXYUnit. Input validation in SmoothDataUnit. Add hyperlinks to Analysis topic in chm file.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7380 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -50,7 +50,7 @@ type
|
|||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
FAutoSized: Boolean;
|
FAutoSized: Boolean;
|
||||||
procedure plotxy(VAR Xpoints : DblDyneVec;
|
procedure PlotXY(VAR Xpoints : DblDyneVec;
|
||||||
VAR Ypoints : DblDyneVec;
|
VAR Ypoints : DblDyneVec;
|
||||||
VAR UpConf : DblDyneVec;
|
VAR UpConf : DblDyneVec;
|
||||||
VAR LowConf : DblDyneVec;
|
VAR LowConf : DblDyneVec;
|
||||||
@ -112,19 +112,22 @@ var
|
|||||||
index: integer;
|
index: integer;
|
||||||
begin
|
begin
|
||||||
index := VarList.ItemIndex;
|
index := VarList.ItemIndex;
|
||||||
if index > -1 then
|
if (index > -1) and (XEdit.Text = '') then
|
||||||
begin
|
begin
|
||||||
XEdit.Text := VarList.Items[index];
|
XEdit.Text := VarList.Items[index];
|
||||||
VarList.Items.Delete(index);
|
VarList.Items.Delete(index);
|
||||||
|
UpdateBtnStates;
|
||||||
end;
|
end;
|
||||||
UpdateBtnStates;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPlotXYFrm.XOutBtnClick(Sender: TObject);
|
procedure TPlotXYFrm.XOutBtnClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
VarList.Items.Add(XEdit.Text);
|
if XEdit.Text <> '' then
|
||||||
XEdit.Text := '';
|
begin
|
||||||
UpdateBtnStates;
|
VarList.Items.Add(XEdit.Text);
|
||||||
|
XEdit.Text := '';
|
||||||
|
UpdateBtnStates;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPlotXYFrm.YInBtnClick(Sender: TObject);
|
procedure TPlotXYFrm.YInBtnClick(Sender: TObject);
|
||||||
@ -132,19 +135,22 @@ var
|
|||||||
index: integer;
|
index: integer;
|
||||||
begin
|
begin
|
||||||
index := VarList.ItemIndex;
|
index := VarList.ItemIndex;
|
||||||
if index > -1 then
|
if (index > -1) and (YEdit.Text = '') then
|
||||||
begin
|
begin
|
||||||
YEdit.Text := VarList.Items[index];
|
YEdit.Text := VarList.Items[index];
|
||||||
VarList.Items.Delete(index);
|
VarList.Items.Delete(index);
|
||||||
|
UpdateBtnStates;
|
||||||
end;
|
end;
|
||||||
UpdateBtnStates;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPlotXYFrm.YOutBtnClick(Sender: TObject);
|
procedure TPlotXYFrm.YOutBtnClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
VarList.Items.Add(YEdit.Text);
|
if YEdit.Text <> '' then
|
||||||
YEdit.Text := '';
|
begin
|
||||||
UpdateBtnStates;
|
VarList.Items.Add(YEdit.Text);
|
||||||
|
YEdit.Text := '';
|
||||||
|
UpdateBtnStates;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPlotXYFrm.FormShow(Sender: TObject);
|
procedure TPlotXYFrm.FormShow(Sender: TObject);
|
||||||
@ -454,7 +460,7 @@ begin
|
|||||||
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
|
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
|
||||||
ypos := ypos + 10;
|
ypos := ypos + 10;
|
||||||
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
|
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
|
||||||
Title := format('%6.2f',[Xvalue]);
|
Title := format('%.2f',[Xvalue]);
|
||||||
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
|
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
|
||||||
xpos := xpos - offset;
|
xpos := xpos - offset;
|
||||||
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
|
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
|
||||||
|
@ -160,12 +160,12 @@ object DataSmoothingForm: TDataSmoothingForm
|
|||||||
Left = 8
|
Left = 8
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 316
|
Top = 316
|
||||||
Width = 188
|
Width = 122
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Bottom = 4
|
BorderSpacing.Bottom = 4
|
||||||
Caption = 'Repeat Smoothing No. Times = '
|
Caption = 'Execute smoothing'
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
end
|
end
|
||||||
object RepeatEdit: TEdit
|
object RepeatEdit: TEdit
|
||||||
@ -173,7 +173,7 @@ object DataSmoothingForm: TDataSmoothingForm
|
|||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = RepeatChk
|
AnchorSideTop.Control = RepeatChk
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 204
|
Left = 138
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 314
|
Top = 314
|
||||||
Width = 32
|
Width = 32
|
||||||
@ -212,4 +212,17 @@ object DataSmoothingForm: TDataSmoothingForm
|
|||||||
ParentColor = False
|
ParentColor = False
|
||||||
WordWrap = True
|
WordWrap = True
|
||||||
end
|
end
|
||||||
|
object Label3: TLabel
|
||||||
|
AnchorSideLeft.Control = RepeatEdit
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = RepeatEdit
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 178
|
||||||
|
Height = 15
|
||||||
|
Top = 318
|
||||||
|
Width = 29
|
||||||
|
BorderSpacing.Left = 8
|
||||||
|
Caption = 'times'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,6 +15,7 @@ type
|
|||||||
|
|
||||||
TDataSmoothingForm = class(TForm)
|
TDataSmoothingForm = class(TForm)
|
||||||
Bevel1: TBevel;
|
Bevel1: TBevel;
|
||||||
|
Label3: TLabel;
|
||||||
Memo1: TLabel;
|
Memo1: TLabel;
|
||||||
RepeatEdit: TEdit;
|
RepeatEdit: TEdit;
|
||||||
RepeatChk: TCheckBox;
|
RepeatChk: TCheckBox;
|
||||||
@ -66,51 +67,66 @@ end;
|
|||||||
|
|
||||||
procedure TDataSmoothingForm.ComputeBtnClick(Sender: TObject);
|
procedure TDataSmoothingForm.ComputeBtnClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
DataPts, OutPts : DblDyneVec;
|
DataPts, OutPts: DblDyneVec;
|
||||||
avalue, avg : double;
|
N, Reps, i, j, VarCol: integer;
|
||||||
N, Reps, i, j, VarCol : integer;
|
VarLabel, strValue: string;
|
||||||
VarLabel, strvalue : string;
|
|
||||||
begin
|
begin
|
||||||
N := NoCases;
|
if SelectedEdit.Text = '' then
|
||||||
SetLength(DataPts,N);
|
begin
|
||||||
SetLength(OutPts,N);
|
MessageDlg('No variable selected.', mtError, [mbOk], 0);
|
||||||
Reps := StrToInt(RepeatEdit.Text);
|
exit;
|
||||||
Varlabel := SelectedEdit.Text;
|
end;
|
||||||
for i := 1 to NoVariables do
|
|
||||||
if VarLabel = OS3MainFrm.DataGrid.Cells[i,0] then VarCol := i;
|
|
||||||
for i := 0 to N - 1 do
|
|
||||||
begin
|
|
||||||
avalue := StrToFloat(OS3MainFrm.DataGrid.Cells[VarCol,i+1]);
|
|
||||||
DataPts[i] := avalue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// repeat smoothing for number of times elected
|
if RepeatChk.Checked then
|
||||||
OutPts[0] := DataPts[0];
|
begin
|
||||||
OutPts[N-1] := DataPts[N-1];
|
if RepeatEdit.Text = '' then
|
||||||
for j := 1 to Reps do
|
begin
|
||||||
begin
|
MessageDlg('Repeat count not specified.', mtError, [mbOK], 0);
|
||||||
for i := 1 to N - 2 do
|
exit;
|
||||||
begin
|
end;
|
||||||
avg := (DataPts[i-1] + DataPts[i] + DataPts[i+1]) / 3.0;
|
if not TryStrToInt(RepeatEdit.Text, Reps) and (Reps < 1) then
|
||||||
OutPts[i] := avg;
|
begin
|
||||||
end;
|
MessageDlg('Repeat count must be >= 1.', mtError, [mbOK], 0);
|
||||||
if j < reps then
|
exit;
|
||||||
for i := 0 to N - 1 do DataPts[i] := OutPts[i];
|
end;
|
||||||
end;
|
end else
|
||||||
// create a new variable and copy smoothed data into it
|
Reps := 1;
|
||||||
strvalue := 'Smoothed' + VarLabel;
|
|
||||||
DictionaryFrm.NewVar(NoVariables+1);
|
|
||||||
DictionaryFrm.DictGrid.Cells[1,NoVariables] := strvalue;
|
|
||||||
OS3MainFrm.DataGrid.Cells[NoVariables,0] := strvalue;
|
|
||||||
for i := 0 to N - 1 do
|
|
||||||
begin
|
|
||||||
strvalue := format('%9.3f',[OutPts[i]]);
|
|
||||||
OS3MainFrm.DataGrid.Cells[NoVariables,i+1] := strvalue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// clean up
|
N := NoCases;
|
||||||
OutPts := nil;
|
SetLength(DataPts,N);
|
||||||
DataPts := nil;
|
SetLength(OutPts,N);
|
||||||
|
|
||||||
|
Varlabel := SelectedEdit.Text;
|
||||||
|
for i := 1 to NoVariables do
|
||||||
|
if VarLabel = OS3MainFrm.DataGrid.Cells[i,0] then VarCol := i;
|
||||||
|
for i := 0 to N - 1 do
|
||||||
|
DataPts[i] := StrToFloat(OS3MainFrm.DataGrid.Cells[VarCol,i+1]);
|
||||||
|
|
||||||
|
// repeat smoothing for number of times elected
|
||||||
|
OutPts[0] := DataPts[0];
|
||||||
|
OutPts[N-1] := DataPts[N-1];
|
||||||
|
for j := 1 to Reps do
|
||||||
|
begin
|
||||||
|
for i := 1 to N - 2 do
|
||||||
|
OutPts[i] := (DataPts[i-1] + DataPts[i] + DataPts[i+1]) / 3.0;
|
||||||
|
if j < reps then
|
||||||
|
for i := 0 to N - 1 do DataPts[i] := OutPts[i];
|
||||||
|
end;
|
||||||
|
|
||||||
|
// create a new variable and copy smoothed data into it
|
||||||
|
if Reps = 1 then
|
||||||
|
strvalue := Format('%s_Smoothed', [VarLabel])
|
||||||
|
else
|
||||||
|
strvalue := Format('%s_Smoothed_%dx', [VarLabel, Reps]);
|
||||||
|
DictionaryFrm.NewVar(NoVariables+1);
|
||||||
|
DictionaryFrm.DictGrid.Cells[1,NoVariables] := strvalue;
|
||||||
|
OS3MainFrm.DataGrid.Cells[NoVariables,0] := strvalue;
|
||||||
|
for i := 0 to N - 1 do
|
||||||
|
OS3MainFrm.DataGrid.Cells[NoVariables,i+1] := Format('%0.3f', [OutPts[i]]);
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
OutPts := nil;
|
||||||
|
DataPts := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDataSmoothingForm.FormActivate(Sender: TObject);
|
procedure TDataSmoothingForm.FormActivate(Sender: TObject);
|
||||||
|
@ -64,7 +64,7 @@ var
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math;
|
Math, Utils;
|
||||||
|
|
||||||
{ TXvsMultYForm }
|
{ TXvsMultYForm }
|
||||||
|
|
||||||
@ -439,7 +439,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TXvsMultYForm.UpdateBtnStates;
|
procedure TXvsMultYForm.UpdateBtnStates;
|
||||||
|
var
|
||||||
|
lSelected: Boolean;
|
||||||
begin
|
begin
|
||||||
|
lSelected := AnySelected(VarList);
|
||||||
|
XInBtn.Enabled := lSelected and (XEdit.Text = '');
|
||||||
|
YInBtn.Enabled := lSelected;
|
||||||
|
xOutBtn.Enabled := (XEdit.Text <> '');
|
||||||
|
YOutBtn.Enabled := AnySelected(YBox);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
Reference in New Issue
Block a user