expertcad/SRC/Main/U_AutoTraceConnectOrder.pas
2025-05-12 10:07:51 +03:00

249 lines
7.4 KiB
ObjectPascal

unit U_AutoTraceConnectOrder;
interface
uses
Windows, U_LNG, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxLookAndFeelPainters, StdCtrls, cxRadioGroup, cxButtons,
ExtCtrls, RzPanel, siComp, siLngLnk,
U_BaseCommon, U_Constants, cxControls, cxContainer, cxEdit, cxCheckBox, RzButton,
RzRadChk, U_SCSComponent, Mask, RzEdit, Math, RzRadGrp, cxGraphics,
cxLookAndFeels, Menus;
type
TTracingFiguresInfo = record
RackCount: Integer;
BoxCount: Integer;
WACount: Integer;
RackPortCount, BoxPortCount, WAPortCount: Integer;
end;
PTracingFiguresInfo = ^TTracingFiguresInfo;
TF_AutoTraceConnectOrder = class(TForm)
RzGroupBox1: TRzGroupBox;
bOK: TcxButton;
bCancel: TcxButton;
pnNumPanelWithNumPortExample: TRzPanel;
pnNumPanelWithNumPort: TRzPanel;
pnByOrderInPMExample: TRzPanel;
pnByOrderInPM: TRzPanel;
rbByOrderInPM: TcxRadioButton;
rbNumPanelWithNumPort: TcxRadioButton;
lbByOrderInPMExample: TLabel;
lbNumPanelWithNumPortExample: TLabel;
Label1: TLabel;
lng_Forms: TsiLangLinked;
cbNoAskParams: TRzCheckBox;
pnMain: TPanel;
pnBottom: TPanel;
pnNewComponIndex: TPanel;
lbTracingFigInfo: TLabel;
RzGroupBox3: TRzGroupBox;
rbTraceManualCable: TcxRadioButton;
rbConnectByInterface: TcxRadioButton;
neCableTraceCount: TRzNumericEdit;
RzGroupBox2: TRzGroupBox;
rbOnePortToOne: TcxRadioButton;
rbOnePortOrMoreToOne: TcxRadioButton;
StreakConnect: TCheckBox;
RzRadioGroup1: TRzRadioGroup;
ProjArea: TRzRadioButton;
ListArea: TRzRadioButton;
BeginFrom: TRzRadioButton;
neNewComponIndex: TRzNumericEdit;
cbAutoTraceByIndexes: TRzCheckBox;
procedure FormShow(Sender: TObject);
procedure rbByOrderInPMClick(Sender: TObject);
procedure rbNumPanelWithNumPortClick(Sender: TObject);
procedure Label1Click(Sender: TObject);
procedure rbTraceManualCableClick(Sender: TObject);
procedure BeginFromClick(Sender: TObject);
procedure ProjAreaClick(Sender: TObject);
procedure ListAreaClick(Sender: TObject);
private
procedure SetControls;
public
function Execute(AProjectSetting: PProjectSettingRecord; ATraceCompon: TSCSComponent; aTracingFigInfo: PTracingFiguresInfo=nil): Boolean;
end;
var
F_AutoTraceConnectOrder: TF_AutoTraceConnectOrder;
implementation
Uses U_Main;
{$R *.dfm}
{ TF_AutoTraceConnectOrder }
procedure TF_AutoTraceConnectOrder.SetControls;
begin
//lbByOrderInPMExample.Visible := rbByOrderInPM.Checked;
//lbNumPanelWithNumPortExample.Visible := rbNumPanelWithNumPort.Checked;
// pnByOrderInPMExample.Visible := rbByOrderInPM.Checked;
// pnNumPanelWithNumPortExample.Visible := rbNumPanelWithNumPort.Checked;
end;
procedure TF_AutoTraceConnectOrder.FormShow(Sender: TObject);
begin
SetControls;
{$IF Defined(SCS_PE)}
neCableTraceCount.Left := 77;
{$ELSE}
neCableTraceCount.Left := 108;
{$IFEND}
end;
procedure TF_AutoTraceConnectOrder.rbByOrderInPMClick(Sender: TObject);
begin
rbNumPanelWithNumPort.Checked := false;
SetControls;
end;
procedure TF_AutoTraceConnectOrder.rbNumPanelWithNumPortClick(
Sender: TObject);
begin
rbByOrderInPM.Checked := false;
SetControls;
end;
procedure TF_AutoTraceConnectOrder.Label1Click(Sender: TObject);
begin
rbNumPanelWithNumPort.Checked := true;
rbNumPanelWithNumPortClick(rbNumPanelWithNumPort);
end;
function TF_AutoTraceConnectOrder.Execute(AProjectSetting: PProjectSettingRecord; ATraceCompon: TSCSComponent; aTracingFigInfo: PTracingFiguresInfo): Boolean;
var
SprCompType: TNBComponentType;
MinCnt: Integer;
begin
Result := false;
if AProjectSetting <> nil then
begin
if AProjectSetting.TraceConnectOrder = ctPMOrder then
rbByOrderInPM.Checked := true
else
if AProjectSetting.TraceConnectOrder = ctNumPanelWithNumPort then
rbNumPanelWithNumPort.Checked := true;
if AProjectSetting.TraceOnePortToOne then
rbOnePortToOne.Checked := true
else
rbOnePortOrMoreToOne.Checked := true;
cbNoAskParams.Checked := AProjectSetting.TraceNoAskParams;
SprCompType := nil;
if ATraceCompon <> nil then
SprCompType := F_ProjMan.GSCSBase.CurrProject.Spravochnik.GetComponentTypeWithAssign(ATraceCompon.GUIDComponentType, F_NormBase.GSCSBase.NBSpravochnik);
pnNewComponIndex.Visible := SprCompType <> nil;
//Tolik
if SprCompType <> nil then
begin
case SprCompType.ComponentType.ComponentIndex of
-2 :
begin
ProjArea.Checked := true;
neNewComponIndex.IntValue := 1;
neNewComponIndex.Enabled := false;
end;
-3 :
begin
ListArea.Checked := true;
neNewComponIndex.IntValue := 1;
neNewComponIndex.Enabled := false;
end;
else
begin
BeginFrom.Checked := true;
neNewComponIndex.IntValue := SprCompType.ComponentType.ComponentIndex+1;
neNewComponIndex.Enabled := true;
end;
end;
//
end;
//05.07.2013
if aTracingFigInfo <> nil then
begin
lbTracingFigInfo.Caption := '';
if aTracingFigInfo^.WAPortCount > 0 then
lbTracingFigInfo.Caption := IntToStr(aTracingFigInfo^.WAPortCount) + ' '+cCommon_Mes28_1;
MinCnt := Min(aTracingFigInfo^.RackPortCount, aTracingFigInfo^.BoxPortCount);
if MinCnt > 0 then
begin
if lbTracingFigInfo.Caption <> '' then
lbTracingFigInfo.Caption := lbTracingFigInfo.Caption + ', ';
lbTracingFigInfo.Caption := lbTracingFigInfo.Caption + IntToStr(MinCnt) + ' '+cCommon_Mes28_2;
end;
lbTracingFigInfo.Visible := lbTracingFigInfo.Caption <> '';
end
else
lbTracingFigInfo.Visible := false;
Self.AutoSize := false;
Self.AutoSize := true;
if ShowModal = mrOk then
begin
Result := true;
if rbByOrderInPM.Checked then
AProjectSetting.TraceConnectOrder := ctPMOrder
else
if rbNumPanelWithNumPort.Checked then
AProjectSetting.TraceConnectOrder := ctNumPanelWithNumPort;
if rbOnePortToOne.Checked then
AProjectSetting.TraceOnePortToOne := true
else
if rbOnePortOrMoreToOne.Checked then
AProjectSetting.TraceOnePortToOne := false;
AProjectSetting.TraceNoAskParams := cbNoAskParams.Checked;
if SprCompType <> nil then
begin
if BeginFrom.Checked then
begin
if neNewComponIndex.Value > 0 then
SprCompType.ComponentType.ComponentIndex := neNewComponIndex.IntValue-1;
end;
if ProjArea.Checked then
SprCompType.ComponentType.ComponentIndex := -2;
if ListArea.Checked then
SprCompType.ComponentType.ComponentIndex := -3;
end;
end;
end;
end;
procedure TF_AutoTraceConnectOrder.rbTraceManualCableClick(
Sender: TObject);
begin
rbOnePortToOne.Checked := True;
end;
procedure TF_AutoTraceConnectOrder.BeginFromClick(Sender: TObject);
begin
neNewComponIndex.Enabled := true;
end;
procedure TF_AutoTraceConnectOrder.ProjAreaClick(Sender: TObject);
begin
neNewComponIndex.Enabled := false;
end;
procedure TF_AutoTraceConnectOrder.ListAreaClick(Sender: TObject);
begin
neNewComponIndex.Enabled := false;
end;
end.