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 declarations }
|
||||
FAutoSized: Boolean;
|
||||
procedure plotxy(VAR Xpoints : DblDyneVec;
|
||||
procedure PlotXY(VAR Xpoints : DblDyneVec;
|
||||
VAR Ypoints : DblDyneVec;
|
||||
VAR UpConf : DblDyneVec;
|
||||
VAR LowConf : DblDyneVec;
|
||||
@ -112,19 +112,22 @@ var
|
||||
index: integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if index > -1 then
|
||||
if (index > -1) and (XEdit.Text = '') then
|
||||
begin
|
||||
XEdit.Text := VarList.Items[index];
|
||||
VarList.Items.Delete(index);
|
||||
end;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPlotXYFrm.XOutBtnClick(Sender: TObject);
|
||||
begin
|
||||
if XEdit.Text <> '' then
|
||||
begin
|
||||
VarList.Items.Add(XEdit.Text);
|
||||
XEdit.Text := '';
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPlotXYFrm.YInBtnClick(Sender: TObject);
|
||||
@ -132,19 +135,22 @@ var
|
||||
index: integer;
|
||||
begin
|
||||
index := VarList.ItemIndex;
|
||||
if index > -1 then
|
||||
if (index > -1) and (YEdit.Text = '') then
|
||||
begin
|
||||
YEdit.Text := VarList.Items[index];
|
||||
VarList.Items.Delete(index);
|
||||
end;
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPlotXYFrm.YOutBtnClick(Sender: TObject);
|
||||
begin
|
||||
if YEdit.Text <> '' then
|
||||
begin
|
||||
VarList.Items.Add(YEdit.Text);
|
||||
YEdit.Text := '';
|
||||
UpdateBtnStates;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPlotXYFrm.FormShow(Sender: TObject);
|
||||
@ -454,7 +460,7 @@ begin
|
||||
BlankFrm.Image1.Canvas.MoveTo(xpos,ypos);
|
||||
ypos := ypos + 10;
|
||||
BlankFrm.Image1.Canvas.LineTo(xpos,ypos);
|
||||
Title := format('%6.2f',[Xvalue]);
|
||||
Title := format('%.2f',[Xvalue]);
|
||||
offset := BlankFrm.Image1.Canvas.TextWidth(Title) div 2;
|
||||
xpos := xpos - offset;
|
||||
BlankFrm.Image1.Canvas.Pen.Color := clBlack;
|
||||
|
@ -160,12 +160,12 @@ object DataSmoothingForm: TDataSmoothingForm
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 316
|
||||
Width = 188
|
||||
Width = 122
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Bottom = 4
|
||||
Caption = 'Repeat Smoothing No. Times = '
|
||||
Caption = 'Execute smoothing'
|
||||
TabOrder = 7
|
||||
end
|
||||
object RepeatEdit: TEdit
|
||||
@ -173,7 +173,7 @@ object DataSmoothingForm: TDataSmoothingForm
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = RepeatChk
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 204
|
||||
Left = 138
|
||||
Height = 23
|
||||
Top = 314
|
||||
Width = 32
|
||||
@ -212,4 +212,17 @@ object DataSmoothingForm: TDataSmoothingForm
|
||||
ParentColor = False
|
||||
WordWrap = True
|
||||
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
|
||||
|
@ -15,6 +15,7 @@ type
|
||||
|
||||
TDataSmoothingForm = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
Label3: TLabel;
|
||||
Memo1: TLabel;
|
||||
RepeatEdit: TEdit;
|
||||
RepeatChk: TCheckBox;
|
||||
@ -66,23 +67,40 @@ end;
|
||||
|
||||
procedure TDataSmoothingForm.ComputeBtnClick(Sender: TObject);
|
||||
var
|
||||
DataPts, OutPts : DblDyneVec;
|
||||
avalue, avg : double;
|
||||
N, Reps, i, j, VarCol : integer;
|
||||
VarLabel, strvalue : string;
|
||||
DataPts, OutPts: DblDyneVec;
|
||||
N, Reps, i, j, VarCol: integer;
|
||||
VarLabel, strValue: string;
|
||||
begin
|
||||
if SelectedEdit.Text = '' then
|
||||
begin
|
||||
MessageDlg('No variable selected.', mtError, [mbOk], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if RepeatChk.Checked then
|
||||
begin
|
||||
if RepeatEdit.Text = '' then
|
||||
begin
|
||||
MessageDlg('Repeat count not specified.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
if not TryStrToInt(RepeatEdit.Text, Reps) and (Reps < 1) then
|
||||
begin
|
||||
MessageDlg('Repeat count must be >= 1.', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
end else
|
||||
Reps := 1;
|
||||
|
||||
N := NoCases;
|
||||
SetLength(DataPts,N);
|
||||
SetLength(OutPts,N);
|
||||
Reps := StrToInt(RepeatEdit.Text);
|
||||
|
||||
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
|
||||
begin
|
||||
avalue := StrToFloat(OS3MainFrm.DataGrid.Cells[VarCol,i+1]);
|
||||
DataPts[i] := avalue;
|
||||
end;
|
||||
DataPts[i] := StrToFloat(OS3MainFrm.DataGrid.Cells[VarCol,i+1]);
|
||||
|
||||
// repeat smoothing for number of times elected
|
||||
OutPts[0] := DataPts[0];
|
||||
@ -90,23 +108,21 @@ begin
|
||||
for j := 1 to Reps do
|
||||
begin
|
||||
for i := 1 to N - 2 do
|
||||
begin
|
||||
avg := (DataPts[i-1] + DataPts[i] + DataPts[i+1]) / 3.0;
|
||||
OutPts[i] := avg;
|
||||
end;
|
||||
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
|
||||
strvalue := 'Smoothed' + VarLabel;
|
||||
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
|
||||
begin
|
||||
strvalue := format('%9.3f',[OutPts[i]]);
|
||||
OS3MainFrm.DataGrid.Cells[NoVariables,i+1] := strvalue;
|
||||
end;
|
||||
OS3MainFrm.DataGrid.Cells[NoVariables,i+1] := Format('%0.3f', [OutPts[i]]);
|
||||
|
||||
// clean up
|
||||
OutPts := nil;
|
||||
|
@ -64,7 +64,7 @@ var
|
||||
implementation
|
||||
|
||||
uses
|
||||
Math;
|
||||
Math, Utils;
|
||||
|
||||
{ TXvsMultYForm }
|
||||
|
||||
@ -439,7 +439,14 @@ begin
|
||||
end;
|
||||
|
||||
procedure TXvsMultYForm.UpdateBtnStates;
|
||||
var
|
||||
lSelected: Boolean;
|
||||
begin
|
||||
lSelected := AnySelected(VarList);
|
||||
XInBtn.Enabled := lSelected and (XEdit.Text = '');
|
||||
YInBtn.Enabled := lSelected;
|
||||
xOutBtn.Enabled := (XEdit.Text <> '');
|
||||
YOutBtn.Enabled := AnySelected(YBox);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
Reference in New Issue
Block a user