unit U_ChooseSCSObjectsProp; interface uses Windows, U_LNG, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxControls, cxContainer, cxEdit, cxLabel, ExtCtrls, RzPanel, StdCtrls, cxRadioGroup, cxLookAndFeelPainters, cxButtons, /// PowerCad PCPanel, PCDrawBox, PCDrawing, PowerCad, PCTypesUtils, DrawObjects, ExtDlgs, PCLayerDlg, OleCtnrs, PCgui, GuiStrings, DrawEngine, U_ESCadClasess, U_SCSEngineTest, cxImage, cxMaskEdit, RzButton, ToolWin, cxDropDownEdit, cxColorComboBox, Mask, cxImageComboBox, RzCmboBx, RzEdit, RzSpnEdt, Contnrs, siComp, siLngLnk, U_Common, cxGraphics, cxLookAndFeels, Menus; type TF_ChooseSCSObjectsProp = class(TForm) cxLabel1: TcxLabel; gbTypes: TRzGroupBox; cxLabel2: TcxLabel; cxLabel3: TcxLabel; cbConnObjects: TcxRadioButton; cbConnConnectors: TcxRadioButton; cbConnRaises: TcxRadioButton; cbLineTraces: TcxRadioButton; cbLineRaises: TcxRadioButton; RzPanel1: TRzPanel; bOK: TcxButton; bCancel: TcxButton; lng_Forms: TsiLangLinked; procedure FormKeyPress(Sender: TObject; var Key: Char); private { Private declarations } public { Public declarations } function Execute(aSCSObject: TFigure): Boolean; function FindFirstByObjectsType(aObjectsTypeProp: TObjectsTypeProp): TFigure; end; var F_ChooseSCSObjectsProp: TF_ChooseSCSObjectsProp; implementation uses USCS_main, U_BaseCommon, U_Constants, U_CAD, U_SCSObjectsProp; {$R *.dfm} { TF_ChooseSCSObjectsProp } function TF_ChooseSCSObjectsProp.Execute(aSCSObject: TFigure): Boolean; var i, j: Integer; FFigure: TFigure; FObjectsTypeProp: TObjectsTypeProp; begin try // ОБЪЕКТ ОДИН if GCadForm.PCad.SelectedCount = 1 then begin F_SCSObjectsProp.FObjectsTypeProp := otp_Single; if CheckFigureByClassName(aSCSObject, cTOrthoLine) then begin F_SCSObjectsProp.Show; F_SCSObjectsProp.PageSCSObjects.ActivePageIndex := 1; // если это с-п if TOrthoLine(aSCSObject).FIsRaiseUpDown then F_SCSObjectsProp.OrtholinePropertiesForRaise else // если это трасса F_SCSObjectsProp.OrtholinePropertiesForNormal; F_SCSObjectsProp.LoadOrtholineProperties(TOrthoLine(aSCSObject)); F_SCSObjectsProp.bLineOK.Enabled := True; end else if CheckFigureByClassName(aSCSObject, cTConnectorObject) then begin F_SCSObjectsProp.Show; F_SCSObjectsProp.PageSCSObjects.ActivePageIndex := 0; // если это вершина с-п if TConnectorObject(aSCSObject).FConnRaiseType <> crt_None then F_SCSObjectsProp.ConnectorPropertiesForRaise else // если это обычный объект (РТ или соединитель) F_SCSObjectsProp.ConnectorPropertiesForNormal(TConnectorObject(aSCSObject).ConnectorType); F_SCSObjectsProp.LoadConnectorProperties(TConnectorObject(aSCSObject)); F_SCSObjectsProp.bConnOK.Enabled := True; end; end else // ЕСТЬ ГРУППА ОБЪЕКТОВ begin // выставить присутствующие объекты cbConnObjects.Enabled := False; cbConnConnectors.Enabled := False; cbConnRaises.Enabled := False; cbLineTraces.Enabled := False; cbLineRaises.Enabled := False; for i := 0 to GCadForm.PCad.SelectedCount - 1 do begin FFigure := TFigure(GCadForm.PCad.Selection[i]); // ТО if CheckFigureByClassName(FFigure, cTConnectorObject) then begin // Вершина с-п if TConnectorObject(FFigure).FConnRaiseType <> crt_None then begin cbConnRaises.Enabled := True; if TConnectorObject(FFigure) = aSCSObject then cbConnRaises.Checked := True; end else begin // соединитель if TConnectorObject(FFigure).ConnectorType = ct_Clear then begin cbConnConnectors.Enabled := True; if TConnectorObject(FFigure) = aSCSObject then cbConnConnectors.Checked := True; end else // Объект begin cbConnObjects.Enabled := True; if TConnectorObject(FFigure) = aSCSObject then cbConnObjects.Checked := True; end; end; end // ЛО else if CheckFigureByClassName(FFigure, cTOrthoLine) then begin // c-п if TOrthoLine(FFigure).FIsRaiseUpDown then begin cbLineRaises.Enabled := True; if TOrthoLine(FFigure) = aSCSObject then cbLineRaises.Checked := True; end else // Трасса begin cbLineTraces.Enabled := True; if TOrthoLine(FFigure) = aSCSObject then cbLineTraces.Checked := True; end; end; end; // ВЫВЕСТИ СВОЙСТВА ДЛЯ НУЖНОЙ ГРУППЫ if ShowModal = mrOK then begin // группа if cbConnObjects.Checked then FObjectsTypeProp := otp_ConnObjects; if cbConnConnectors.Checked then FObjectsTypeProp := otp_ConnConnectors; if cbConnRaises.Checked then FObjectsTypeProp := otp_ConnRaises; if cbLineTraces.Checked then FObjectsTypeProp := otp_LineTraces; if cbLineRaises.Checked then FObjectsTypeProp := otp_LineRaises; // найти объект данной группы FFigure := FindFirstByObjectsType(FObjectsTypeProp); // от него показать свойства F_SCSObjectsProp.FObjectsTypeProp := FObjectsTypeProp; if CheckFigureByClassName(FFigure, cTOrthoLine) then begin F_SCSObjectsProp.Show; F_SCSObjectsProp.PageSCSObjects.ActivePageIndex := 1; // если это с-п if TOrthoLine(FFigure).FIsRaiseUpDown then F_SCSObjectsProp.OrtholinePropertiesForRaise else // если это трасса F_SCSObjectsProp.OrtholinePropertiesForNormal; F_SCSObjectsProp.LoadOrtholineProperties(TOrthoLine(FFigure)); F_SCSObjectsProp.bLineOK.Enabled := True; end else if CheckFigureByClassName(FFigure, cTConnectorObject) then begin F_SCSObjectsProp.Show; F_SCSObjectsProp.PageSCSObjects.ActivePageIndex := 0; // если это вершина с-п if TConnectorObject(FFigure).FConnRaiseType <> crt_None then F_SCSObjectsProp.ConnectorPropertiesForRaise else // если это обычный объект (РТ или соединитель) F_SCSObjectsProp.ConnectorPropertiesForNormal(TConnectorObject(FFigure).ConnectorType); F_SCSObjectsProp.LoadConnectorProperties(TConnectorObject(FFigure)); F_SCSObjectsProp.bConnOK.Enabled := True; end; end; end; except on E: Exception do AddExceptionToLogEx('TF_ChooseSCSObjectsProp.Execute', E.Message); end; end; function TF_ChooseSCSObjectsProp.FindFirstByObjectsType(aObjectsTypeProp: TObjectsTypeProp): TFigure; var i, j: Integer; FFigure: TFigure; begin try Result := nil; if aObjectsTypeProp = otp_ConnObjects then begin for i := 0 to GCadForm.PCad.SelectedCount - 1 do begin FFigure := TFigure(GCadForm.PCad.Selection[i]); if CheckFigureByClassName(FFigure, cTConnectorObject) then if TConnectorObject(FFigure).FConnRaiseType = crt_None then if TConnectorObject(FFigure).ConnectorType <> ct_Clear then begin Result := TConnectorObject(FFigure); exit; end; end; end; if aObjectsTypeProp = otp_ConnConnectors then begin for i := 0 to GCadForm.PCad.SelectedCount - 1 do begin FFigure := TFigure(GCadForm.PCad.Selection[i]); if CheckFigureByClassName(FFigure, cTConnectorObject) then if TConnectorObject(FFigure).FConnRaiseType = crt_None then if TConnectorObject(FFigure).ConnectorType = ct_Clear then begin Result := TConnectorObject(FFigure); exit; end; end; end; if aObjectsTypeProp = otp_ConnRaises then begin for i := 0 to GCadForm.PCad.SelectedCount - 1 do begin FFigure := TFigure(GCadForm.PCad.Selection[i]); if CheckFigureByClassName(FFigure, cTConnectorObject) then if TConnectorObject(FFigure).FConnRaiseType <> crt_None then begin Result := TConnectorObject(FFigure); exit; end; end; end; if aObjectsTypeProp = otp_LineTraces then begin for i := 0 to GCadForm.PCad.SelectedCount - 1 do begin FFigure := TFigure(GCadForm.PCad.Selection[i]); if CheckFigureByClassName(FFigure, cTOrthoLine) then if not TOrthoLine(FFigure).FIsRaiseUpDown then begin Result := TOrthoLine(FFigure); exit; end; end; end; if aObjectsTypeProp = otp_LineRaises then begin for i := 0 to GCadForm.PCad.SelectedCount - 1 do begin FFigure := TFigure(GCadForm.PCad.Selection[i]); if CheckFigureByClassName(FFigure, cTOrthoLine) then if TOrthoLine(FFigure).FIsRaiseUpDown then begin Result := TOrthoLine(FFigure); exit; end; end; end; except on E: Exception do AddExceptionToLogEx('TF_ChooseSCSObjectsProp.FindFirstByObjectsType', E.Message); end; end; procedure TF_ChooseSCSObjectsProp.FormKeyPress(Sender: TObject; var Key: Char); begin // if Key = #13 then // begin // bOK.SetFocus; // bOK.Click; // end; if Key = #27 then Close; end; end.