Skip to content

Commit

Permalink
* Fixed: benchmark abort
Browse files Browse the repository at this point in the history
+ EditNext
* Minor fixes
* Fixed lambda Calc
* Fixed wrong config property
* Bug fixes (wrong FFitParams assignment)
*  Refactoring
+ IrregularSmooth
  • Loading branch information
Oleksiy Penkov committed Oct 24, 2023
1 parent b8c9d7d commit c40fa7c
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 60 deletions.
2 changes: 1 addition & 1 deletion LFPSO/unit_LFPSO_Base.pas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(* *****************************************************************************
(* *****************************************************************************
*
* X-Ray Calc 3
*
Expand Down
3 changes: 3 additions & 0 deletions components/editor_Layer.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ object edtrLayer: TedtrLayer
ParentColor = True
TabOrder = 2
TabStop = False
OnClick = btnOKClick
Kind = bkOK
end
object btnCancel: TRzBitBtn
Expand All @@ -151,6 +152,7 @@ object edtrLayer: TedtrLayer
ParentColor = True
TabOrder = 0
TabStop = False
OnClick = btnPrevClick
end
object btnNext: TRzBitBtn
Tag = 1
Expand All @@ -161,6 +163,7 @@ object edtrLayer: TedtrLayer
ParentColor = True
TabOrder = 1
TabStop = False
OnClick = btnNextClick
end
end
end
73 changes: 52 additions & 21 deletions components/editor_Layer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,47 @@ TedtrLayer = class(TForm)
btnPrev: TRzBitBtn;
btnNext: TRzBitBtn;
procedure edMaterialButtonClick(Sender: TObject);
procedure btnNextClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure btnPrevClick(Sender: TObject);

private
{ Private declarations }
FData: TLayerData;
FSeq: boolean;
public
{ Public declarations }
function ShowEditor(const IsSubstrate: Boolean; var Data: TLayerData): boolean;
procedure SetData(const IsSubstrate: Boolean; Data: TLayerData);
function GetData: TLayerData;
property Seq: boolean read FSeq;
end;

var
edtrLayer: TedtrLayer;

implementation

uses
unit_SMessages;

//uses frm_MList;

{$R *.dfm}


function TedtrLayer.ShowEditor(const IsSubstrate: Boolean; var Data: TLayerData): boolean;
procedure TedtrLayer.btnNextClick(Sender: TObject);
begin
Result := False;
edMaterial.Text := Data.Material;
edH.Value := Data.P[1].V;
edSigma.Value := Data.P[2].V;
edRo.Value := Data.P[3].V;

edH.Visible := not IsSubstrate;
Label2.Visible := not IsSubstrate;


ActiveControl := edMaterial;
LayerEditNext(FData.StackID, FData.LayerID);
end;

if ShowModal = mrOk then
begin
Data.Material := edMaterial.Text;
Data.P[1].V := edH.Value;
Data.P[2].V := edSigma.Value;
Data.P[3].V := edRo.Value;
Result := True;
end;
procedure TedtrLayer.btnOKClick(Sender: TObject);
begin
FSeq := False;
end;

procedure TedtrLayer.btnPrevClick(Sender: TObject);
begin
LayerEditPrev(FData.StackID, FData.LayerID);
end;

procedure TedtrLayer.edMaterialButtonClick(Sender: TObject);
Expand All @@ -84,4 +84,35 @@ procedure TedtrLayer.edMaterialButtonClick(Sender: TObject);
edMaterial.Text := S;
end;

function TedtrLayer.GetData: TLayerData;
begin
Result := FData;

Result.Material := edMaterial.Text;
Result.P[1].V := edH.Value;
Result.P[2].V := edSigma.Value;
Result.P[3].V := edRo.Value;

end;

procedure TedtrLayer.SetData(const IsSubstrate: Boolean; Data: TLayerData);
begin
FSeq := Self.Showing;

FData := Data;

edMaterial.Text := Data.Material;
edH.Value := Data.P[1].V;
edSigma.Value := Data.P[2].V;
edRo.Value := Data.P[3].V;

edH.Visible := not IsSubstrate;
Label2.Visible := not IsSubstrate;

btnPrev.Visible := not IsSubstrate;
btnNext.Visible := not IsSubstrate;

ActiveControl := edMaterial;
end;

end.
41 changes: 39 additions & 2 deletions components/unit_SMessages.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ interface
WM_RECALC = WM_STR_BASE + 2;
WM_STR_LAYER_CLICK = WM_STR_BASE + 3;
WM_STR_LINKED_CLICK = WM_STR_BASE + 4;
WM_STR_EDIT_NEXT = WM_STR_BASE + 5;
WM_STR_EDIT_PREV = WM_STR_BASE + 6;
WM_STR_LAYER_DOUBLECLICK = WM_STR_BASE + 7;

WM_STR_LAYER_UP = WM_STR_BASE + 20;
WM_STR_LAYER_DOWN = WM_STR_BASE + 21;
Expand All @@ -35,9 +38,11 @@ interface
procedure StackDoubleClick(const ID: integer);
procedure SendRecalcMessage;
procedure LayerClick(const StackID, ID: integer);
procedure LayerDoubleClick(const StackID, ID: integer);
procedure LinkedClick(const StackID, ID: integer);
procedure ArrangeLayer(const Msg: Cardinal; const StackID, ID: integer);

procedure LayerEditNext(const StackID, ID: integer);
procedure LayerEditPrev(const StackID, ID: integer);

implementation

Expand Down Expand Up @@ -68,7 +73,39 @@ procedure LayerClick(const StackID, ID: integer);
begin
PostMessage(
Application.MainFormHandle,
WM_STR_LAYER_CLICK ,
WM_STR_LAYER_CLICK,
StackID,
ID
);
end;

procedure LayerDoubleClick(const StackID, ID: integer);
begin
PostMessage(
Application.MainFormHandle,
WM_STR_LAYER_DOUBLECLICK,
StackID,
ID
);
end;

procedure LayerEditNext(const StackID, ID: integer);
begin
PostMessage(
Application.MainFormHandle,
WM_STR_EDIT_NEXT,
StackID,
ID
);
end;



procedure LayerEditPrev(const StackID, ID: integer);
begin
PostMessage(
Application.MainFormHandle,
WM_STR_EDIT_PREV,
StackID,
ID
);
Expand Down
15 changes: 11 additions & 4 deletions components/unit_XRCLayerControl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,17 @@ destructor TXRCLayerControl.Destroy;

procedure TXRCLayerControl.Edit;
begin
if edtrLayer.ShowEditor(FSubstrate, FData) then
edtrLayer.SetData(FSubstrate, FData);


if edtrLayer.ShowModal = mrOk then
begin
Name.Caption := Data.Material;
SetLayerData(FData);
if not edtrLayer.Seq then
begin
FData := edtrLayer.GetData;
Name.Caption := FData.Material;
SetLayerData(FData);
end;
end;

SetSlected(False);
Expand Down Expand Up @@ -331,7 +338,7 @@ procedure TXRCLayerControl.InternalOnClick(Sender: TObject);

procedure TXRCLayerControl.InternalOnDblClick(Sender: TObject);
begin
Edit;
LayerDoubleClick(FData.StackID, FData.LayerID);
end;

procedure TXRCLayerControl.LinkedOnClick(Sender: TObject);
Expand Down
3 changes: 3 additions & 0 deletions components/unit_XRCStackControl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ procedure TXRCStack.AddSubstrate(const Material: string; s, rho: single);
Data: TLayerData;
begin
SetLength(FLayers, 1);
Data.StackID := 65535;
Data.LayerID := 65535;

Data.Material := Material;
Data.P[1].V := 1E8;
Data.P[2].V := s;
Expand Down
59 changes: 58 additions & 1 deletion components/unit_XRCStructure.pas
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ TXRCStructure = class (TRzPanel)
function FindStrValue(const Value: string): string;
function GetSelectedLayer: Integer;
procedure SetPeriodicMode(const Value: boolean);
function GetCurrentLayerData: TLayerData;
procedure SetCurrentLayerData(const Value: TLayerData);
function GetSubstrateData: TLayerData;
procedure SetSubstrateData(const Value: TLayerData);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
Expand All @@ -72,6 +76,8 @@ TXRCStructure = class (TRzPanel)
procedure Select(const ID: Integer);
procedure ClearSelection(const Reset:boolean = False); inline;
procedure SelectLayer(const StackID, LayerID: Integer);
procedure EditNextLayer(const StackID, LayerID: Integer; Frwrd: boolean);

procedure LinkLayer(const StackID, LayerID: Integer);
procedure MoveLayer(const StackID, LayerID, Direction: Integer);
procedure EditStack(const ID: Integer);
Expand Down Expand Up @@ -102,6 +108,8 @@ TXRCStructure = class (TRzPanel)
// procedure EnablePairing;
function IfValidLayerSelected: Boolean; inline;
property RealHeight: Integer read FRealHeight;
property LayerData: TLayerData read GetCurrentLayerData write SetCurrentLayerData;
property SubstrateData: TLayerData read GetSubstrateData write SetSubstrateData;
published
property Increment: single read FIncrement write SetIncrement;
end;
Expand All @@ -112,7 +120,7 @@ TXRCStructure = class (TRzPanel)
implementation

uses
unit_consts;
unit_consts, editor_Layer;

{ TXRCStructure }

Expand Down Expand Up @@ -340,6 +348,35 @@ destructor TXRCStructure.Destroy;
inherited Destroy;
end;

procedure TXRCStructure.EditNextLayer(const StackID, LayerID: Integer;
Frwrd: boolean);
begin
Stacks[StackID].UpdateLayer(LayerID, edtrLayer.GetData);

if Frwrd then
begin
if LayerID < High(Stacks[StackID].Layers) then
begin
edtrLayer.SetData(False, Stacks[StackID].Layers[LayerID + 1].Data);
end
else if StackID < High(Stacks) then
begin
edtrLayer.SetData(False, Stacks[StackID + 1].Layers[0].Data);
end;
end
else begin
if LayerID > 0 then
begin
edtrLayer.SetData(False, Stacks[StackID].Layers[LayerID - 1].Data);
end
else if StackID > 0 then
begin
edtrLayer.SetData(False, Stacks[StackID - 1].Layers[High(Stacks[StackID - 1].Layers)].Data);
end;
end;

end;

procedure TXRCStructure.EditStack;
begin
FStacks[ID].Edit;
Expand Down Expand Up @@ -493,6 +530,11 @@ procedure TXRCStructure.SelectLayer(const StackID, LayerID: Integer);
end;
end;

procedure TXRCStructure.SetCurrentLayerData(const Value: TLayerData);
begin
Stacks[Value.StackID].UpdateLayer(Value.LayerID, Value);
end;

procedure TXRCStructure.SetIncrement(const Value: single);
var
i: Integer;
Expand All @@ -510,6 +552,11 @@ procedure TXRCStructure.SetPeriodicMode(const Value: boolean);
Stack.EnablePairing(not Value);
end;

procedure TXRCStructure.SetSubstrateData(const Value: TLayerData);
begin
Substrate.UpdateLayer(0, Value);
end;

procedure TXRCStructure.UpdateInterfaceNP(const Inp: TFitStructure);
var
i, j: integer;
Expand Down Expand Up @@ -784,6 +831,11 @@ procedure TXRCStructure.FromString(const S: string);
Visible := True;
end;

function TXRCStructure.GetCurrentLayerData: TLayerData;
begin

end;

procedure TXRCStructure.GetLayersList(const ID: integer; List: TStrings);
var
j: Integer;
Expand Down Expand Up @@ -833,4 +885,9 @@ procedure TXRCStructure.GetStacksList(PeriodicOnly: Boolean; List: TStrings; var
end;
end;

function TXRCStructure.GetSubstrateData: TLayerData;
begin
Result := Substrate.Layers[0].Data;
end;

end.
20 changes: 11 additions & 9 deletions forms/frm_Benchmark.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,30 @@ object frmBenchmark: TfrmBenchmark
BorderWidth = 2
Color = 15987699
TabOrder = 0
object BitBtn1: TBitBtn
Left = 896
Top = 363
ExplicitWidth = 969
ExplicitHeight = 379
object btnCancel: TBitBtn
Left = 895
Top = 354
Width = 75
Height = 25
Caption = 'Close'
Caption = 'Cancel'
TabOrder = 0
OnClick = BitBtn1Click
OnClick = btnCancelClick
end
object Grid: TXRCGrid
AlignWithMargins = True
Left = 7
Top = 7
Width = 971
Height = 342
Width = 963
Height = 330
Margins.Bottom = 50
Align = alClient
TabOrder = 1
AutoFit = False
Text = #9#9#9#9
ExplicitWidth = 963
ExplicitHeight = 330
ExplicitWidth = 955
ExplicitHeight = 318
end
end
end
Loading

0 comments on commit c40fa7c

Please sign in to comment.