unit U_InterfaceInfo; interface uses Windows, U_LNG, Messages, SysUtils, Variants, Classes, Graphics, Controls, Contnrs, Forms, Dialogs, ExtDlgs, ExtCtrls, RzPanel, ComCtrls, U_BaseConstants, U_SCSComponent, U_SCSLists, U_SCSClasses, U_BaseCommon, U_Common, cxLookAndFeelPainters, StdCtrls, cxButtons, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, RzSplit, cxCheckBox, cxSpinEdit, cxCurrencyEdit, cxColorComboBox, kbmMemTable, siComp, siLngLnk, exgrid, RapTree, RzTabs, FlytreePro, RzButton, RzRadChk, cxImage, cxTextEdit, cxMemo, cxGridBandedTableView, cxGridDBBandedTableView, cxDBLookupComboBox, ToolWin, ActnList, Menus, XPMenu, ImgList, XLSFile, XLSWorkbook, XLSFormat, ShellApi, U_Cad, DrawObjects, U_FilterConfigurator, {Tolik -- 13/05/2017 }U_Constants, cxLookAndFeels, cxNavigator, FlyTree; const //*** Band Index biNormData = 0; biComponData = 1; {// FilterFieldIndexes ffFunctionalInterface = 1; ffPort = 2; ffConnected = 3; ffNoConnected = 4; } type TInterfaceInfoMode = (iimNone, iimConnectedLineCompons, iimDisconnectedLineCompons, iimConnectedConObjects, iimDisconnectedConObjects, iimCablesNoInCanals, iimNormComponents, // added by Tolik iimCableSwerves, iimNoConnectedRoutes); //14.11.2013 //TNormNodeData = class // public // FGUIDNorm: string; // FNormComponents: TSCSObjectList; // constructor Create; // destructor Destroy; override; //end; TF_InterfaceInfo = class(TForm) Panel_Bottom: TRzPanel; gbTreeView: TRzGroupBox; Button_Close: TcxButton; MemTable_Interfaces: TkbmMemTable; DataSource_Interfaces: TDataSource; Splitter: TSplitter; lng_Forms: TsiLangLinked; pcTreeData: TRzPageControl; tsInterfaces: TRzTabSheet; tsComponents: TRzTabSheet; GroupBox_Interfaces: TRzGroupBox; Grid_Interfaces: TcxGrid; GT_Interfaces: TcxGridDBTableView; GT_InterfacesNpp: TcxGridDBColumn; GT_InterfacesName: TcxGridDBColumn; GT_InterfacesKolvo: TcxGridDBColumn; GT_InterfacesKolvoBusy: TcxGridDBColumn; GT_InterfacesType: TcxGridDBColumn; GT_InterfacesGender: TcxGridDBColumn; GT_InterfacesisBusy: TcxGridDBColumn; GT_InterfacesMultiple: TcxGridDBColumn; GT_InterfacesValueI: TcxGridDBColumn; GT_InterfacesCoordZ: TcxGridDBColumn; GT_InterfacesNumPair: TcxGridDBColumn; GT_InterfacesColor: TcxGridDBColumn; GT_InterfacesSide: TcxGridDBColumn; GT_InterfacesSignType: TcxGridDBColumn; GL_Interfaces: TcxGridLevel; RzGroupBox1: TRzGroupBox; Grid_Components: TcxGrid; GT_Components_: TcxGridDBTableView; GL_Components_: TcxGridLevel; GT_Components_IsOn: TcxGridDBColumn; GT_Components_Name: TcxGridDBColumn; GT_Components_SignType: TcxGridDBColumn; GT_Components_IsDismount: TcxGridDBColumn; GT_Components_IsUseDismounted: TcxGridDBColumn; mtComponents: TkbmMemTable; dsrcComponents: TDataSource; RzPanel1: TRzPanel; cbSelectComponInCAD: TRzCheckBox; GL_Components: TcxGridLevel; GT_Components: TcxGridDBBandedTableView; GT_ComponentsIsOn: TcxGridDBBandedColumn; GT_ComponentsName: TcxGridDBBandedColumn; GT_ComponentsSignType: TcxGridDBBandedColumn; GT_ComponentsIsDismount: TcxGridDBBandedColumn; GT_ComponentsIsUseDismounted: TcxGridDBBandedColumn; GT_ComponentsKolvo: TcxGridDBBandedColumn; GT_ComponentsExpenseForLength: TcxGridDBBandedColumn; mtSignTypes: TkbmMemTable; dsrcSignTypes: TDataSource; Timer_PostNormComponents: TTimer; Timer_TreeViewChange: TTimer; tbNormCompons: TToolBar; ToolButton1: TToolButton; ToolButton2: TToolButton; ActionList: TActionList; Act_AddNorm: TAction; Act_DelNorm: TAction; pmNormCompons: TPopupMenu; N1: TMenuItem; N2: TMenuItem; tbTreeView: TToolBar; ToolButton3: TToolButton; Act_Filter: TAction; spTreeWithFilter: TRzSplitter; ilState: TImageList; ToolButton4: TToolButton; Act_FilterProperties: TAction; ToolButton5: TToolButton; ToolButton6: TToolButton; gbFilter: TRzGroupBox; lbFilter: TLabel; Act_SaveToExcel: TAction; ToolButton7: TToolButton; GT_ComponentsCountForPoint: TcxGridDBBandedColumn; GT_ComponentsStepOfPoint: TcxGridDBBandedColumn; pnUseFilterInCAD: TPanel; cbUseFilterInCAD: TRzCheckBox; GT_ComponentsLaborTime: TcxGridDBBandedColumn; GT_ComponentsPricePerTime: TcxGridDBBandedColumn; GT_ComponentsCost: TcxGridDBBandedColumn; RzPanel2: TRzPanel; RzPageControl1: TRzPageControl; TabSheet1: TRzTabSheet; TreeView2: TFlyTreeViewPro; TabSheet2: TRzTabSheet; TreeView1: TFlyTreeViewPro; TreeView: TFlyTreeViewPro; Act_DelCompons: TAction; Act_DeleteAllCompons: TAction; PopupMenu1: TPopupMenu; N3: TMenuItem; N4: TMenuItem; ToolButton8: TToolButton; ToolButton9: TToolButton; procedure TreeView_GetSelectedIndex(Sender: TObject; Node: TTreeNode); procedure FormHide(Sender: TObject); procedure FormCreate(Sender: TObject); procedure TreeView_Change(Sender: TObject; Node: TTreeNode); procedure GT_InterfacesTypeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_InterfacesGenderGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_InterfacesCoordZGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_InterfacesNumPairGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_InterfacesSideGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_InterfacesFocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure Panel_BottomResize(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure TreeViewChange(Sender: TObject; Node: TFlyNode); procedure TreeViewGetNodeAttributes(Node: TFlyNode; Column: Integer; aFont: TFont; var BackColor: TColor; var Alignment: TAlignment); procedure GT_Components_SignTypeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_Components_FocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure GT_ComponentsSignTypeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_ComponentsEditValueChanged(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem); procedure GT_ComponentsFocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure Timer_PostNormComponentsTimer(Sender: TObject); procedure Timer_TreeViewChangeTimer(Sender: TObject); procedure Act_AddNormExecute(Sender: TObject); procedure Act_DelNormExecute(Sender: TObject); procedure TreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); procedure TreeViewDragDrop(Sender, Source: TObject; X, Y: Integer); procedure GT_ComponentsExpenseForLengthGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_ComponentsExpenseForLengthPropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure GT_ComponentsInitEdit(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit); procedure Act_FilterExecute(Sender: TObject); procedure Act_FilterPropertiesExecute(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure TreeViewExpanding(Sender: TObject; Node: TFlyNode; var AllowExpansion: Boolean); procedure Act_SaveToExcelExecute(Sender: TObject); procedure GT_ComponentsCountForPointPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure GT_ComponentsStepOfPointGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_ComponentsStepOfPointPropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure GT_ComponentsKolvoPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure cbUseFilterInCADClick(Sender: TObject); procedure GT_ComponentsLaborTimePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure GT_ComponentsLaborTimeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); procedure GT_ComponentsCostPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure GT_ComponentsPricePerTimePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure FormShow(Sender: TObject); procedure TabSheet1Enter(Sender: TObject); procedure TabSheet2Enter(Sender: TObject); procedure RzPageControl1Change(Sender: TObject); procedure Act_DelComponsExecute(Sender: TObject); procedure Act_DeleteAllComponsExecute(Sender: TObject); private { Private declarations } FEditedBandIndex: Integer; FEditedFieldName: string; FSimpleCaption: String; FObject: TObject; FChanged: Boolean; FFilteType: Integer; FFilteTypeFile: Integer; FFilterBlock: TFilterBlock; FFilterFieldValues: TObjectList; //FFilterInfo: TFilterInfo; FOldFilterValue: string; FOldFilterUseInCAD: Boolean; procedure AddNormSCSObjComponToMT(ASCSObjCompon: TSCSComponCatalogClass; ANorm: TSCSNorm); procedure AddNormToCurrComponInMT(ANorm: TSCSNorm); procedure ApplyFilter(AOldFilterBlock: TFilterBlock); procedure ApplyFilterToCAD(AFormMode: TInterfaceInfoMode); procedure ClearTree; function GetFilterTypeByFormMode(AForFile: Boolean): Integer; function GetNodeByNormGUIDNB(AGUID: String): TFlyNode; function GetNodeWithComponsWithoutNorms: TFlyNode; function IsVisibleComponByFilter(AComponent: TSCSComponent): Boolean; function IsVisibleNodeByFilter(ANode: TFlyNode; ARecursive: Boolean): Boolean; procedure LoadFilterBlockFromProject; procedure LoadFilterFieldValues; procedure ReloadNodes; procedure SaveFilterToProject; procedure SaveSelectedNormResource; procedure SetControls; procedure SetFilterControls; procedure ShowPCTreeData(AShow: Boolean; AActivePage: TRzTabSheet); procedure UpdateComponentsParamsInMT; public GForm: TForm; GFormMode: TInterfaceInfoMode; constructor Create(AOwner: TComponent; AForm: TForm); destructor Destroy; override; procedure Execute(AFormMode: TInterfaceInfoMode; AObject: TObject); procedure LoadNormObjects(AGroupNorm: TSCSNorm; AObjsCompons: TSCSObjectList); procedure LoadInterfaces(ALineComponent: TIntList); procedure EnableDisableTreeViewPopup; end; //var //F_InterfaceInfo: TF_InterfaceInfo; implementation Uses U_Main, Unit_DM_SCS, USCS_Main; {$R *.dfm} { TNormNodeData } //constructor TNormNodeData.Create; //begin //end; //destructor TNormNodeData.Destroy; //begin // inherited; //end; { TF_InterfaceInfo } procedure TF_InterfaceInfo.AddNormSCSObjComponToMT(ASCSObjCompon: TSCSComponCatalogClass; ANorm: TSCSNorm); var NormIsOn: Integer; NormKolvo: Double; NormExpenseForLength: Double; NormCountForPoint: Double; NormStepOfPoint: Double; NormIsFromInterface: Integer; SCSComponent: TSCSComponent; SCSCatalog: TSCSCatalog; Norm: TSCSNorm; begin SCSComponent := nil; SCSCatalog := nil; if ASCSObjCompon is TSCSComponent then SCSComponent := TSCSComponent(ASCSObjCompon) else if ASCSObjCompon is TSCSCatalog then SCSCatalog := TSCSCatalog(ASCSObjCompon); Norm := ANorm; NormIsOn := biFalse; NormKolvo := 0; NormExpenseForLength := 0; NormCountForPoint := 0; NormStepOfPoint := 0; NormIsFromInterface := biFalse; if Norm <> nil then begin NormIsOn := Norm.IsOn; NormKolvo := Norm.Kolvo; NormExpenseForLength := Norm.ExpenseForLength; NormCountForPoint := Norm.CountForPoint; NormStepOfPoint := Norm.StepOfPoint; NormIsFromInterface := Norm.IsFromInterface end; mtComponents.Append; mtComponents.FieldByName(fnIsOn).AsInteger := NormIsOn; mtComponents.FieldByName(fnKolvo).AsFloat := RoundX(NormKolvo, PrecisionNormKolvo); mtComponents.FieldByName(fnExpenseForLength).AsFloat := RoundCP(NormExpenseForLength); mtComponents.FieldByName(fnCountForPoint).AsFloat := RoundCP(NormCountForPoint); mtComponents.FieldByName(fnStepOfPoint).AsFloat := RoundCP(NormStepOfPoint); mtComponents.FieldByName(fnIsFromInterface).AsInteger := NormIsFromInterface; //15.11.2013 if Norm <> nil then begin mtComponents.FieldByName(fnLaborTime).AsInteger := Norm.LaborTime; mtComponents.FieldByName(fnPricePerTime).AsFloat := RoundCP(Norm.PricePerTime); mtComponents.FieldByName(fnCost).AsFloat := RoundCP(Norm.Price); end; if SCSComponent <> nil then begin mtComponents.FieldByName(fnID).AsInteger := SCSComponent.ID; mtComponents.FieldByName(fnName).AsString := SCSComponent.GetNameForVisible; mtComponents.FieldByName(fnIsLine).AsInteger := SCSComponent.IsLine; mtComponents.FieldByName(fnSignType).AsInteger := SCSComponent.GetPropertyValueAsInteger(pnSignType); mtComponents.FieldByName(fnIsDismount).AsInteger := SCSComponent.IsDismount; mtComponents.FieldByName(fnIsUseDismounted).AsInteger := SCSComponent.IsUseDismounted; end else if SCSCatalog <> nil then begin mtComponents.FieldByName(fnName).AsString := SCSCatalog.GetNameForVisible; end; mtComponents.FieldByName(fnComponObjectAddress).AsInteger := Integer(ASCSObjCompon); mtComponents.FieldByName(fnNormObjectAddress).AsInteger := Integer(Norm); mtComponents.Post; end; procedure TF_InterfaceInfo.AddNormToCurrComponInMT(ANorm: TSCSNorm); var SCSObjCompon: TSCSComponCatalogClass; NormFromCompon: TSCSNorm; NormFromNode: TSCSNorm; NormNode: TFlyNode; NodeWithComponsWithoutNorms: TFlyNode; begin SCSObjCompon := nil; if mtComponents.Active and (mtComponents.RecordCount > 0) then SCSObjCompon := TSCSComponCatalogClass(mtComponents.FieldByName(fnComponObjectAddress).AsInteger); if SCSObjCompon <> nil then begin NormNode := GetNodeByNormGUIDNB(ANorm.GuidNB); NormFromNode := nil; if NormNode = nil then begin NormFromNode := TSCSNorm.Create(GForm, ntProj); NormFromNode.Assign(ANorm); NormNode := TreeView.Items.Add(nil, NormFromNode.Name); NormNode.Data := NormFromNode; NormNode.ImageIndex := -1; NormNode.SelectedIndex := -1; end else NormFromNode := TSCSNorm(NormNode.Data); if NormFromNode <> nil then begin ANorm.MasterTableKind := GetTableKindBySCSTreeElType(SCSObjCompon.TreeElementType); //13.11.2013 ctkComponent ANorm.IDMaster := SCSObjCompon.ID; SCSObjCompon.NormsResources.Norms.Add(ANorm); ANorm.SaveNormAsNew(ANorm.IDMaster); if SCSObjCompon is TSCSComponent then if GetPreyscurantFromNormByCompon(NormFromNode, TSCSComponent(SCSObjCompon)) = nil then AddPreyscurantToNorm(NormFromNode, TSCSComponent(SCSObjCompon), itConstructive); //*** Если норма добавилась повторно в ту же самую ветвь if TreeView.Selected = NormNode then AddNormSCSObjComponToMT(SCSObjCompon, ANorm); //*** Если компонент наход-ся в ветви "Без Норм", то удалить его из этой ветви NodeWithComponsWithoutNorms := GetNodeWithComponsWithoutNorms; if NodeWithComponsWithoutNorms <> nil then if TreeView.Selected = NodeWithComponsWithoutNorms then begin //TSCSComponents(NodeWithComponsWithoutNorms.Data).Remove(SCSObjCompon); TSCSObjectList(NodeWithComponsWithoutNorms.Data).Remove(SCSObjCompon); mtComponents.Delete; end; end; SetControls; end; end; procedure TF_InterfaceInfo.ApplyFilter(AOldFilterBlock: TFilterBlock); begin try if Not IsEqualFilterBlocks(AOldFilterBlock, FFilterBlock) then ReloadNodes; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.ApplyFilter', E.Message); end; end; procedure TF_InterfaceInfo.ApplyFilterToCAD(AFormMode: TInterfaceInfoMode); var CurrFilterValue: string; CurrFilterUseInCAD: Boolean; FilterInfo: TFilterInfo; CanApply: Boolean; begin if pnUseFilterInCAD.Visible then begin CurrFilterValue := ''; CurrFilterUseInCAD := false; FilterInfo := TF_Main(GForm).GSCSBase.CurrProject.GetFilterInfoByType(FFilteType); if FilterInfo <> nil then begin CurrFilterValue := FilterInfo.FilterValue; CurrFilterUseInCAD := FilterInfo.UseInCAD; end; // проверяем было ли изменение для КАДа CanApply := false; // если менялось значение фильтра и (включено для када или исменлялся этот флаг) if (CurrFilterUseInCAD or (CurrFilterUseInCAD <> FOldFilterUseInCAD)) and (CurrFilterValue <> FOldFilterValue) then CanApply := true else // или просто менялся этот флаг if CurrFilterUseInCAD <> FOldFilterUseInCAD then CanApply := true; if CanApply then begin if FObject <> nil then if FObject is TSCSCatalog then begin BeginProgress; try if AFormMode = iimConnectedConObjects then DefineChildObjectsFullness(TSCSCatalog(FObject), itSCSConnector) else if AFormMode = iimConnectedLineCompons then DefineChildObjectsFullness(TSCSCatalog(FObject), itSCSLine) finally EndProgress; end; end; SetStatusFilteredConnectedObjToCAD(0); end; end; end; procedure TF_InterfaceInfo.ClearTree; var i: Integer; begin TreeView.OnChange := nil; try {case GFormMode of iimConnectedConObjects, iimDisconnectedConObjects, iimConnectedLineCompons, iimDisconnectedLineCompons: begin for i := 0 to TreeView.Items.Count - 1 do FreeMem(TreeView.Items[i].Data); end; iimNormComponents: ; end;} TreeView.Items.Clear; finally TreeView.OnChange := TreeViewChange; end; end; function TF_InterfaceInfo.GetFilterTypeByFormMode(AForFile: Boolean): Integer; begin Result := ftNone; if AForFile then begin case GFormMode of {iimConnectedLineCompons: Result := ftConnectedLineCompons; iimDisconnectedLineCompons: Result := ftDisconnectedLineCompons; iimConnectedConObjects: Result := ftConnectedConObjects; iimDisconnectedConObjects: Result := ftDisconnectedConObjects;} iimConnectedLineCompons, iimDisconnectedLineCompons, iimConnectedConObjects, iimDisconnectedConObjects: Result := ftConnDisconnCompons; iimCablesNoInCanals: Result := ftCablesNoInCanals; //added by Tolik iimCableSwerves: Result := ftCableSwerves; iimNoConnectedRoutes: Result := ftNoConnectedRoutes; end; end else begin case GFormMode of iimConnectedLineCompons: Result := ftConnectedLineCompons; iimDisconnectedLineCompons: Result := ftDisconnectedLineCompons; iimConnectedConObjects: Result := ftConnectedConObjects; iimDisconnectedConObjects: Result := ftDisconnectedConObjects; iimCablesNoInCanals: Result := ftCablesNoInCanals; //added by Tolik iimCableSwerves: Result := ftCableSwerves; end; end; end; procedure TF_InterfaceInfo.UpdateComponentsParamsInMT; var // StrBookMark: string; StrBookMark: TBookMArk; SCSObjCompon: TSCSComponCatalogClass; SCSComponent: TSCSComponent; begin //StrBookMark := mtComponents.Bookmark; StrBookMark := mtComponents.getBookmark; mtComponents.DisableControls; try mtComponents.First; while Not mtComponents.Eof do begin SCSObjCompon := TSCSComponCatalogClass(mtComponents.FieldByName(fnComponObjectAddress).AsInteger); if SCSObjCompon <> nil then if SCSObjCompon is TSCSComponent then begin SCSComponent := TSCSComponent(SCSObjCompon); mtComponents.Edit; mtComponents.FieldByName(fnSignType).AsInteger := SCSComponent.GetPropertyValueAsInteger(pnSignType); mtComponents.FieldByName(fnIsDismount).AsInteger := SCSComponent.IsDismount; mtComponents.FieldByName(fnIsUseDismounted).AsInteger := SCSComponent.IsUseDismounted; mtComponents.Post; end; mtComponents.Next; end; finally if StrBookMark <> nil then begin mtComponents.gotoBookmark(StrBookMark); mtComponents.FreeBookmark(StrBookMark); end; //mtComponents.Bookmark := StrBookMark; mtComponents.EnableControls; end; end; procedure TF_InterfaceInfo.SaveSelectedNormResource; var SCSNorm: TSCSNorm; SCSComponent: TSCSComponent; ptrProperty: PProperty; begin case FEditedBandIndex of biNormData: begin SCSNorm := TSCSNorm(mtComponents.FieldByName(fnNormObjectAddress).AsInteger); if SCSNorm <> nil then begin {if FEditedFieldName = fnIsOn then SCSNorm.IsOn := mtComponents.FieldByName(fnIsOn).AsInteger else if FEditedFieldName = fnKolvo then SCSNorm.Kolvo := RoundX(mtComponents.FieldByName(fnKolvo).AsFloat, PrecisionNormKolvo) else if FEditedFieldName = fnExpenseForLength then SCSNorm.ExpenseForLength := RoundCP(mtComponents.FieldByName(fnExpenseForLength).AsFloat) else if FEditedFieldName = fnCountForPoint then SCSNorm.CountForPoint := RoundCP(mtComponents.FieldByName(fnCountForPoint).AsFloat) else if FEditedFieldName = fnStepOfPoint then SCSNorm.StepOfPoint := RoundCP(mtComponents.FieldByName(fnStepOfPoint).AsFloat);} SCSNorm.IsOn := mtComponents.FieldByName(fnIsOn).AsInteger; SCSNorm.LaborTime := mtComponents.FieldByName(fnLaborTime).AsInteger; //15.11.2013 SCSNorm.PricePerTime := RoundX(mtComponents.FieldByName(fnPricePerTime).AsFloat, PrecisionNormKolvo); //15.11.2013 SCSNorm.Price := RoundX(mtComponents.FieldByName(fnCost).AsFloat, PrecisionNormKolvo); //15.11.2013 SCSNorm.Kolvo := RoundX(mtComponents.FieldByName(fnKolvo).AsFloat, PrecisionNormKolvo); SCSNorm.ExpenseForLength := RoundCP(mtComponents.FieldByName(fnExpenseForLength).AsFloat); SCSNorm.CountForPoint := RoundCP(mtComponents.FieldByName(fnCountForPoint).AsFloat); SCSNorm.StepOfPoint := RoundCP(mtComponents.FieldByName(fnStepOfPoint).AsFloat); SCSNorm.NotifyChange; end; end; biComponData: begin SCSComponent := TSCSComponent(mtComponents.FieldByName(fnComponObjectAddress).AsInteger); if SCSComponent <> nil then begin if FEditedFieldName = fnSignType then begin ptrProperty := SCSComponent.GetPropertyBySysName(pnSignType); if ptrProperty <> nil then begin ptrProperty.Value := IntToStr(mtComponents.FieldByName(fnSignType).AsInteger); TF_Main(GForm).OnChangeComponPropertyVal(ptrProperty, SCSComponent); //*** Значение свойства по всей длине MakeEditPropertyForWholeComponent(meEdit, SCSComponent, ptrProperty); end; end else begin //if FEditedFieldName = fnSignType then // SCSComponent.SetPropertyValueAsString(pnSignType, IntToStr(mtComponents.FieldByName(fnSignType).AsInteger), true) //else if FEditedFieldName = fnIsDismount then SCSComponent.IsDismount := mtComponents.FieldByName(fnIsDismount).AsInteger else if FEditedFieldName = fnIsUseDismounted then SCSComponent.IsUseDismounted := mtComponents.FieldByName(fnIsUseDismounted).AsInteger; TF_Main(GForm).OnUpdateComponent(meEdit, nil, SCSComponent, false, false); end; SCSComponent.NotifyChange; UpdateComponentsParamsInMT; end; end; end; FChanged := true; end; procedure TF_InterfaceInfo.SetControls; begin if GFormMode = iimNormComponents then begin Act_AddNorm.Enabled := (TreeView.Selected <> nil) {and (TObject(TreeView.Selected.Data) is TSCSNorm)}; Act_DelNorm.Enabled := (TreeView.Selected <> nil) and (TObject(TreeView.Selected.Data) is TSCSNorm) and mtComponents.Active and (mtComponents.RecordCount > 0); end; end; procedure TF_InterfaceInfo.SetFilterControls; begin Act_Filter.Checked := FFilterBlock.IsOn; spTreeWithFilter.UpperLeft.Visible := tbTreeView.Visible and Act_Filter.Checked; lbFilter.Caption := FFilterBlock.GetFilterAsString(true); pnUseFilterInCAD.Visible := ((GFormMode = iimConnectedConObjects) or (GFormMode = iimConnectedLineCompons)); // // Act_SaveToExcel.Enabled := TreeView.GetVisiblecount > 0; // changed by Tolik // Tolik 20/03/2019 { if not RzPageControl1.Visible then Act_SaveToExcel.Enabled := TreeView.GetVisiblecount > 0 else begin if RzPageControl1.ActivePage = TabSheet1 then Act_SaveToExcel.Enabled := TreeView2.GetVisiblecount > 0 else Act_SaveToExcel.Enabled := TreeView1.GetVisiblecount > 0 end; } if not RzPageControl1.Visible then Act_SaveToExcel.Enabled := TreeView.Columns.GetVisiblecount > 0 else begin if RzPageControl1.ActivePage = TabSheet1 then Act_SaveToExcel.Enabled := TreeView2.Columns.GetVisiblecount > 0 else Act_SaveToExcel.Enabled := TreeView1.Columns.GetVisiblecount > 0 end; // end; procedure TF_InterfaceInfo.ShowPCTreeData(AShow: Boolean; AActivePage: TRzTabSheet); begin if AShow then begin gbTreeView.Visible := true; gbTreeView.Align := alLeft; gbTreeView.Width := Round(Self.Width / 2); Splitter.Visible := true; Splitter.Align := alRight; Splitter.Align := alLeft; //GroupBox_Interfaces.Visible := true; //GroupBox_Interfaces.Align := alClient; pcTreeData.Visible := true; pcTreeData.ActivePage := AActivePage; //tsInterfaces; end else begin gbTreeView.Visible := true; gbTreeView.Align := alClient; Splitter.Visible := false; pcTreeData.Visible := false; end; end; function TF_InterfaceInfo.GetNodeByNormGUIDNB(AGUID: String): TFlyNode; var i: Integer; Node: TFlyNode; begin Result := nil; if TreeView.Items.Count > 0 then begin Node := TreeView.Items[0]; while Node <> nil do begin if TObject(Node.Data) is TSCSNorm then if TSCSNorm(Node.Data).GuidNB = AGUID then begin Result := Node; Break; //// BREAK //// end; Node := Node.GetNext; end; end; end; function TF_InterfaceInfo.GetNodeWithComponsWithoutNorms: TFlyNode; var i: Integer; Node: TFlyNode; begin Result := nil; if TreeView.Items.Count > 0 then begin Node := TreeView.Items[0]; while Node <> nil do begin if TObject(Node.Data) is TSCSObjectList then //14.11.2013 if TObject(Node.Data) is TSCSComponents then begin Result := Node; Break; //// BREAK //// end; Node := Node.GetNext; end; end; end; function TF_InterfaceInfo.IsVisibleComponByFilter(AComponent: TSCSComponent): Boolean; var SCSInterface: TSCSInterface; ChildFilterBlock: TFilterBlock; i, j: Integer; begin Result := false; if Not FFilterBlock.IsOn then Result := true else begin // Пропускаем каждый функциональный интерфейс через фильтр for i := 0 to AComponent.Interfaces.Count - 1 do begin SCSInterface := AComponent.Interfaces[i]; if SCSInterface.TypeI = itFunctional then begin {for j := 0 to FFilterBlock.AllChildBlocks.Count - 1 do begin ChildFilterBlock := FFilterBlock.AllChildBlocks[j]; if (ChildFilterBlock.Condition <> nil) and (ChildFilterBlock.CheckIsOnUp) then begin case ChildFilterBlock.Condition.FieldIndex of ffFunctionalInterface: begin if SCSInterface.IsPort = biFalse then ChildFilterBlock.Condition.FieldValue := SCSInterface.GUIDInterface else ChildFilterBlock.Condition.FieldValue := ''; end; ffPort: begin if SCSInterface.IsPort = biTrue then ChildFilterBlock.Condition.FieldValue := SCSInterface.GUIDInterface else ChildFilterBlock.Condition.FieldValue := ''; end; ffConnected: begin if SCSInterface.KolvoBusy > 0 then ChildFilterBlock.Condition.FieldValue := bsTrue else ChildFilterBlock.Condition.FieldValue := bsFalse; end; ffNoConnected: begin if SCSInterface.KolvoBusy > 0 then ChildFilterBlock.Condition.FieldValue := bsFalse else ChildFilterBlock.Condition.FieldValue := bsTrue; end; else ChildFilterBlock.Condition.FieldValue := ''; end; end; end; if FFilterBlock.Execute then Result := true; } if IsVisibleInterfaceByFilter(SCSInterface, FFilterBlock) then Result := true; if Result then Break; //// BREAK //// end; if Result then Break; //// BREAK //// end; end; end; function TF_InterfaceInfo.IsVisibleNodeByFilter(ANode: TFlyNode; ARecursive: Boolean): Boolean; var ObjectNode: TObject; NextNode: TFlyNode; begin Result := false; try if Not FFilterBlock.IsOn then Result := true else begin ObjectNode := ANode.Data; if ObjectNode <> nil then if ObjectNode is TSCSComponent then begin if IsVisibleComponByFilter(TSCSComponent(ObjectNode)) then Result := true; end; if Not Result and ARecursive then begin NextNode := ANode.getFirstChild; while NextNode <> nil do begin if IsVisibleNodeByFilter(NextNode, true) then begin Result := true; Break; //// BREAK //// end; NextNode := NextNode.GetNextSibling; end; end; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.IsVisibleNodeByFilter', E.Message); end; end; procedure TF_InterfaceInfo.LoadFilterBlockFromProject; var FilterInfo: TFilterInfo; UseFilterInCAD: Boolean; SavedOnClick: TNotifyEvent; begin FFilterBlock.Clear; FFilterBlock.IsOn := false; LoadFilterFieldValues; UseFilterInCAD := false; FOldFilterValue := ''; FOldFilterUseInCAD := false; FilterInfo := TF_Main(GForm).GSCSBase.CurrProject.GetFilterInfoByType(FFilteType); if FilterInfo <> nil then begin UseFilterInCAD := FilterInfo.UseInCAD; FOldFilterValue := FilterInfo.FilterValue; FOldFilterUseInCAD := FilterInfo.UseInCAD; FFilterBlock.LoadFromStr(FilterInfo.FilterValue, FFilterFieldValues); ApplyFilter(nil); end; SavedOnClick := cbUseFilterInCAD.OnClick; cbUseFilterInCAD.OnClick := nil; try cbUseFilterInCAD.Checked := UseFilterInCAD; finally cbUseFilterInCAD.OnClick := SavedOnClick; end; SetFilterControls; end; procedure TF_InterfaceInfo.LoadFilterFieldValues; var ProjInterfaces: TSCSInterfaces; SCSInterface: TSCSInterface; LookedInterfGUIDs: TStringList; FilterField: TFilterField; FilterFieldInterf: TFilterField; FilterFieldPort: TFilterField; i: Integer; begin FFilterFieldValues.Clear; if GUseVisibleInterfaces then begin // поле интерфейс FilterFieldInterf := TFilterField.Create; FilterFieldInterf.FieldName := fnGuidInterface; FilterFieldInterf.FieldIndex := ffFunctionalInterface; FilterFieldInterf.FieldCaption := cInterfaceInfo_Msg9_1; FFilterFieldValues.Add(FilterFieldInterf); ProjInterfaces := TF_Main(GForm).GSCSBase.CurrProject.GetAllInterfaces; LookedInterfGUIDs := TStringList.Create; for i := 0 to ProjInterfaces.Count - 1 do begin SCSInterface := ProjInterfaces[i]; if LookedInterfGUIDs.IndexOf(SCSInterface.GUIDInterface) = -1 then begin SCSInterface.LoadName; FilterFieldInterf.Values.Add(SCSInterface.GUIDInterface); FilterFieldInterf.ValueCaptions.Add(SCSInterface.Name); LookedInterfGUIDs.Add(SCSInterface.GUIDInterface); end; end; SortComplexStringList(FilterFieldInterf.ValueCaptions, FilterFieldInterf.Values); FreeAndNil(LookedInterfGUIDs); FreeAndNil(ProjInterfaces); // поле порт FilterFieldPort := nil; if GFormMode <> iimCablesNoInCanals then begin FilterFieldPort := TFilterField.Create; FilterFieldPort.FieldName := fnGuidPort; FilterFieldPort.FieldIndex := ffPort; FilterFieldPort.FieldCaption := cDM_Msg13; FFilterFieldValues.Add(FilterFieldPort); FilterFieldPort.Values.AddStrings(FilterFieldInterf.Values); FilterFieldPort.ValueCaptions.AddStrings(FilterFieldInterf.ValueCaptions); end; end; // Поле "Подключенный" FilterField := TFilterField.Create; FilterField.FieldName := fnConnected; FilterField.FieldIndex := ffConnected; FilterField.FieldCaption := cInterfaceInfo_Msg9_3; FilterField.Values.Add(bsTrue); FilterField.Values.Add(bsFalse); FilterField.ValueCaptions.Add(cBaseCommon11); FilterField.ValueCaptions.Add(cBaseCommon12); FFilterFieldValues.Add(FilterField); // Поле "Не подключенный" FilterField := TFilterField.Create; FilterField.FieldName := fnNoConnected; FilterField.FieldIndex := ffNoConnected; FilterField.FieldCaption := cInterfaceInfo_Msg9_4; FilterField.Values.Add(bsTrue); FilterField.Values.Add(bsFalse); FilterField.ValueCaptions.Add(cBaseCommon11); FilterField.ValueCaptions.Add(cBaseCommon12); FFilterFieldValues.Add(FilterField); end; procedure TF_InterfaceInfo.ReloadNodes; var TopNode: TFlyNode; CurrVisibleNode: TFlyNode; PrevLevelNode: TFlyNode; LevelNode: TFlyNode; LookedNodes: TList; begin try TopNode := nil; if TreeView.Items.Count > 0 then TopNode := TreeView.Items[0]; if TopNode <> nil then begin LookedNodes := TList.Create; // Перебераем видимые ветви. Для каждой видимой ветви перебераем все ее соседние ветви CurrVisibleNode := TopNode; //TreeView.GetFirstVisibleNode; while CurrVisibleNode <> nil do begin // Ищем первую ветвь по уровню LevelNode := CurrVisibleNode; PrevLevelNode := LevelNode; while PrevLevelNode <> nil do begin LevelNode := PrevLevelNode; PrevLevelNode := PrevLevelNode.getPrevSibling; end; // Перебераем все ветки по уровню while LevelNode <> nil do begin if LookedNodes.IndexOf(LevelNode) = -1 then begin LevelNode.Hidden := Not IsVisibleNodeByFilter(LevelNode, true); LookedNodes.Add(LevelNode); end; LevelNode := LevelNode.GetNextSibling; end; CurrVisibleNode := CurrVisibleNode.GetNextVisible; end; FreeAndNil(LookedNodes); end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.ReloadNodes', E.Message); end; end; procedure TF_InterfaceInfo.SaveFilterToProject; var FilterInfo: TFilterInfo; begin try // сохраняем фильтр в проект FilterInfo := TF_Main(GForm).GSCSBase.CurrProject.GetFilterInfoByType(FFilteType); if FilterInfo = nil then begin FilterInfo := TFilterInfo.Create; FilterInfo.ID := TF_Main(GForm).GSCSBase.CurrProject.GenIDByGeneratorIndex(giFilterinfoID); FilterInfo.FilterType := FFilteType; TF_Main(GForm).GSCSBase.CurrProject.Filters.Add(FilterInfo); end; if FilterInfo <> nil then begin FilterInfo.FilterValue := FFilterBlock.GetFilterAsString(false); if pnUseFilterInCAD.Visible then FilterInfo.UseInCAD := cbUseFilterInCAD.Checked; end; TF_Main(GForm).GSCSBase.CurrProject.NotifyChange; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.SaveFilterToProject', E.Message); end; end; constructor TF_InterfaceInfo.Create(AOwner: TComponent; AForm: TForm); begin GForm := AForm; inherited Create(AOwner); end; destructor TF_InterfaceInfo.Destroy; begin inherited; end; procedure TF_InterfaceInfo.FormCreate(Sender: TObject); var i: Integer; begin {TreeView.Free; TreeView := TFlyTreeViewPro.Create(Self); TreeView.Parent := spTreeWithFilter.LowerRight.Pane; TreeView.Align := alClient; TreeView.DefaultRowHeight := 24; TreeView.FitColumnToClientWidth := true; TreeView.Showlines := false; TreeView.ShowButtons := true; TreeView.ShowRoot := true; TreeView.ShowImages := true;} TreeView.Options := []; ActionCaptionsToHints(ActionList); gbTreeView.Caption := ''; TcxCurrencyEditProperties(GT_InterfacesValueI.Properties).DisplayFormat := GetDisplayFormatForFloat; TcxCurrencyEditProperties(GT_InterfacesValueI.Properties).DecimalPlaces := FloatPrecision; with TF_Main(GForm).DM.MemTable_InterfaceRel do for i := 0 to FieldDefs.Count - 1 do MemTable_Interfaces.FieldDefs.Add(FieldDefs[i].Name, FieldDefs[i].DataType, FieldDefs[i].Size); with TF_Main(GForm).DM.MemTable_Comp_State_Type do for i := 0 to FieldDefs.Count - 1 do mtSignTypes.FieldDefs.Add(FieldDefs[i].Name, FieldDefs[i].DataType, FieldDefs[i].Size); mtSignTypes.LoadFromDataSet(TF_Main(GForm).DM.MemTable_Comp_State_Type, []); mtComponents.FieldDefs.Add(fnID, ftInteger); mtComponents.FieldDefs.Add(fnIsOn, ftInteger); mtComponents.FieldDefs.Add(fnLaborTime, ftInteger); //15.11.2013 mtComponents.FieldDefs.Add(fnPricePerTime, ftFloat); //15.11.2013 mtComponents.FieldDefs.Add(fnKolvo, ftFloat); mtComponents.FieldDefs.Add(fnCost, ftFloat); //15.11.2013 mtComponents.FieldDefs.Add(fnExpenseForLength, ftFloat); mtComponents.FieldDefs.Add(fnCountForPoint, ftFloat); mtComponents.FieldDefs.Add(fnStepOfPoint, ftFloat); mtComponents.FieldDefs.Add(fnIsFromInterface, ftInteger); mtComponents.FieldDefs.Add(fnName, ftString, 255); mtComponents.FieldDefs.Add(fnIsLine, ftInteger); mtComponents.FieldDefs.Add(fnSignType, ftInteger); mtComponents.FieldDefs.Add(fnIsDismount, ftInteger); mtComponents.FieldDefs.Add(fnIsUseDismounted, ftInteger); mtComponents.FieldDefs.Add(fnComponObjectAddress, ftInteger); mtComponents.FieldDefs.Add(fnNormObjectAddress, ftInteger); TreeView.Items.Clear; TreeView.Images.Clear; TreeView.Images.AddImages(TF_Main(GForm).DM.ImageList_Dir); TreeView.Images.AddImages(ilState); TreeView.ButtonCollapsedIndex := (TF_Main(GForm).DM.ImageList_Dir.Count-1) + 1; TreeView.ButtonExpandedIndex := (TF_Main(GForm).DM.ImageList_Dir.Count-1) + 2; TreeView.FixedRows := 0; TreeView.FitColumnToClientWidth := true; TreeView.Options := TreeView.Options + [goColSizing] - [goDrawFocusSelected, goHorzLine, goVertLine, goRangeSelect]; TreeView.StatesDrawed := false; // added by Tolik TreeView1.Items.Clear; TreeView1.Images.Clear; TreeView1.Images.AddImages(TF_Main(GForm).DM.ImageList_Dir); TreeView1.Images.AddImages(ilState); TreeView1.ButtonCollapsedIndex := (TF_Main(GForm).DM.ImageList_Dir.Count-1) + 1; TreeView1.ButtonExpandedIndex := (TF_Main(GForm).DM.ImageList_Dir.Count-1) + 2; TreeView1.FixedRows := 0; TreeView1.FitColumnToClientWidth := true; TreeView1.Options := TreeView.Options + [goColSizing] - [goDrawFocusSelected, goHorzLine, goVertLine, goRangeSelect]; TreeView1.StatesDrawed := false; TreeView2.Items.Clear; TreeView2.Images.Clear; TreeView2.Images.AddImages(TF_Main(GForm).DM.ImageList_Dir); TreeView2.Images.AddImages(ilState); TreeView2.ButtonCollapsedIndex := (TF_Main(GForm).DM.ImageList_Dir.Count-1) + 1; TreeView2.ButtonExpandedIndex := (TF_Main(GForm).DM.ImageList_Dir.Count-1) + 2; TreeView2.FixedRows := 0; TreeView2.FitColumnToClientWidth := true; TreeView2.Options := TreeView.Options + [goColSizing] - [goDrawFocusSelected, goHorzLine, goVertLine, goRangeSelect]; TreeView2.StatesDrawed := false; RzPageControl1.visible := false; // TcxCurrencyEditProperties(GT_ComponentsKolvo.Properties).DisplayFormat := GetDisplayFormatForFloatByPrecision(PrecisionNormKolvo); TcxCurrencyEditProperties(GT_ComponentsKolvo.Properties).DecimalPlaces := PrecisionNormKolvo; TcxCurrencyEditProperties(GT_ComponentsExpenseForLength.Properties).DisplayFormat := GetDisplayFormatForFloat; TcxCurrencyEditProperties(GT_ComponentsExpenseForLength.Properties).DecimalPlaces := FloatPrecision; GT_ComponentsCountForPoint.Caption := cNameCountForPoint; GT_ComponentsCountForPoint.DataBinding.FieldName := fnCountForPoint; TcxCurrencyEditProperties(GT_ComponentsCountForPoint.Properties).DisplayFormat := GetDisplayFormatForFloat; TcxCurrencyEditProperties(GT_ComponentsCountForPoint.Properties).DecimalPlaces := FloatPrecision; GT_ComponentsStepOfPoint.DataBinding.FieldName := fnStepOfPoint; TcxCurrencyEditProperties(GT_ComponentsStepOfPoint.Properties).DisplayFormat := GetDisplayFormatForFloat; TcxCurrencyEditProperties(GT_ComponentsStepOfPoint.Properties).DecimalPlaces := FloatPrecision; ActionList.Images := TF_Main(GForm).DM.ImageList_ToolEdit; pmNormCompons.Images := TF_Main(GForm).DM.ImageList_ToolEdit; tbNormCompons.Images := TF_Main(GForm).DM.ImageList_ToolEdit; ////*** Action List Hints //for i := 0 to ActionList.ActionCount - 1 do // TAction(ActionList.Actions[i]).Hint := TAction(ActionList.Actions[i]).Caption; FFilterBlock := TFilterBlock.Create(nil, btBlock); //FFilterInfo := nil; FFilterFieldValues := TObjectList.Create(true); end; procedure TF_InterfaceInfo.TreeView_GetSelectedIndex(Sender: TObject; Node: TTreeNode); begin Node.SelectedIndex := Node.ImageIndex; end; procedure TF_InterfaceInfo.FormHide(Sender: TObject); begin ClearTree; GFormMode := iimNone; end; procedure TF_InterfaceInfo.TreeView_Change(Sender: TObject; Node: TTreeNode); var NodeDat: PObjectData; MainTreeViewNode: TTreeNode; Catalog: TCatalog; SCSID: Integer; SCSCatalog: TSCSCatalog; SCSComponent: TSCSComponent; WholeLineCompon: TWholeLineCompon; LineComponTrace: TIntList; ptrID: ^Integer; begin {LineComponTrace := nil; WholeLineCompon.WholeCompon := nil; try try NodeDat := Node.Data; if NodeDat = nil then Exit; //// EXIT //// if NodeDat.ItemType = itSCSConnector then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(NodeDat.ObjectID, false) else MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(NodeDat.ObjectID, true); if MainTreeViewNode <> nil then TF_Main(GForm).Tree_Catalog.Selected := MainTreeViewNode; case NodeDat.ItemType of itSCSConnector: begin //SCSID := TF_Main(GForm).DM.GetScsIDByIDCatalog(NodeDat.ObjectID); //SelectConnectedConnector(ScsID); SCSCatalog := TF_Main(GForm).GSCSBase.CurrProject.GetCatalogFromReferences(NodeDat.ObjectID); if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end; itComponCon: begin //Catalog := TF_Main(GForm).DM.GetCatalogByCompon(NodeDat.ObjectID); //SelectConnectedConnector(Catalog.Scs_ID); SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(NodeDat.ObjectID); SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end; itComponLine: begin if Node.Parent = nil then begin WholeLineCompon := GetLineComponsInTrace(NodeDat.ObjectID); if WholeLineCompon.WholeCompon <> nil then LineComponTrace := GetTraceByListCompon(WholeLineCompon.WholeCompon); end else begin WholeLineCompon.WholeCompon := TIntList.Create; WholeLineCompon.WholeCompon.Add(NodeDat.ObjectID); LineComponTrace := TIntList.Create; SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(NodeDat.ObjectID); SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then begin //New(ptrID); //ptrID^ := SCSCatalog.ScsID; LineComponTrace.Add(SCSCatalog.ScsID); end; end; if LineComponTrace <> nil then if LineComponTrace.Count > 0 then begin LoadInterfaces(WholeLineCompon.WholeCompon); SelectConnectedCables(TF_Main(GForm).GSCSBase.CurrProject.CurrList.CurrID, LineComponTrace); end; end; end; except on E: Exception do AddExceptionToLog('TF_InterfaceInfo.TreeViewChange: '+E.Message); end; finally LineComponTrace.Free; //FreeList(LineComponTrace); WholeLineCompon.WholeCompon.Free; //FreeList(WholeLineCompon.WholeCompon); end;} end; // ##### Изменение позиции интерфейса ##### procedure TF_InterfaceInfo.GT_InterfacesFocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); var MainTreeViewDat: PObjectData; MainTreeViewNode: TTreeNode; IDComponent: Integer; begin try try IDComponent := MemTable_Interfaces.FieldByName(fnIDcomponent).AsInteger; if (GFormMode = iimConnectedLineCompons) or (GFormMode = iimDisconnectedLineCompons) then with TF_Main(GForm) do begin MainTreeViewDat := Tree_Catalog.Selected.Data; if MainTreeViewDat.ObjectID <> IDComponent then begin MainTreeViewNode := FindComponOrDirInTree(IDComponent, True); if MainTreeViewNode <> nil then Tree_Catalog.Selected := MainTreeViewNode; end; //DM.MemTable_InterfaceRel.DisableControls; if Grid_Interfaces.ActiveLevel.Index <> cdliInterface then //*** Индекс вкладки интерфейсов begin Grid_CompData.ActiveLevel := Grid_CompData.Levels.Items[cdliInterface]; Grid_CompData.OnActiveTabChanged(Grid_CompData, Grid_CompData.ActiveLevel); end; DM.MemTable_InterfaceRel.Locate(fnID, MemTable_Interfaces.FieldByName(fnID).AsInteger, []); //SearchRecordMT(DM.MemTable_InterfaceRel, 'id', MemTable_Interfaces.FieldByName('id').AsInteger); end; except on E: Exception do AddExceptionToLog('TF_InterfaceInfo.GT_InterfacesFocusedRecordChanged: '+E.Message); end; finally //TF_Main(GForm).DM.MemTable_InterfaceRel.EnableControls; end; end; procedure TF_InterfaceInfo.GT_InterfacesTypeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin if AText = '0' then AText := cInterfaceInfo_Msg3_1; if AText = '1' then AText := cInterfaceInfo_Msg3_2; end; procedure TF_InterfaceInfo.GT_InterfacesGenderGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin if AText = '0' then AText := cInterfaceInfo_Msg4_1; if AText = '1' then AText := cInterfaceInfo_Msg4_2; end; procedure TF_InterfaceInfo.GT_InterfacesCoordZGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin if AText = '0' then AText := cInterfaceInfo_Msg5; end; procedure TF_InterfaceInfo.GT_InterfacesNumPairGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin if AText = '0' then AText := cInterfaceInfo_Msg5; end; procedure TF_InterfaceInfo.GT_InterfacesSideGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin if AText = '0' then AText := cInterfaceInfo_Msg5; end; procedure TF_InterfaceInfo.Execute(AFormMode: TInterfaceInfoMode; AObject: TObject); var DisplayFormatM: String; NormResources: TSCSNormsResources; ComponsWithOutNorms: TSCSObjectList; //14.11.2013 TSCSComponents; ComponWithOutNorm: TSCSComponent; TreeNode: TFlyNode; i: Integer; SavedIsDefineInterfaceNormsOnChangeNode: Boolean; begin GFormMode := AFormMode; FObject := AObject; //FFilterInfo := nil; //Caption := ''; //15.11.2013 DisplayFormatM := GetDisplayFormat(TF_Main(GForm).GCurrencyM.NameBrief); GT_ComponentsLaborTime.Caption := TF_Main(GForm).GT_NormsResourcesLaborTime.Caption; GT_ComponentsPricePerTime.Caption := TF_Main(GForm).GT_NormsResourcesPricePerTime.Caption; TcxCurrencyEditProperties(GT_ComponentsPricePerTime.Properties).DisplayFormat := DisplayFormatM; //GetDisplayFormatForFloat; TcxCurrencyEditProperties(GT_ComponentsPricePerTime.Properties).DecimalPlaces := FloatPrecision; //15.11.2013 GT_ComponentsCost.Caption := TF_Main(GForm).GT_NormsResourcesCost.Caption; TcxCurrencyEditProperties(GT_ComponentsCost.Properties).DisplayFormat := DisplayFormatM; //GetDisplayFormatForFloat; TcxCurrencyEditProperties(GT_ComponentsCost.Properties).DecimalPlaces := FloatPrecision; GT_ComponentsExpenseForLength.Caption := TF_Main(GForm).GT_NormsResourcesExpenseForLength.Caption; GT_ComponentsExpenseForLength.DataBinding.FieldName := fnExpenseForLength; GT_ComponentsStepOfPoint.Caption := TF_Main(GForm).GT_NormsResourcesStepOfPoint.Caption; FChanged := false; FFilteType := ftNone; FFilteTypeFile := ftNone; if AFormMode in [iimCablesNoInCanals] then begin RzPageControl1.Visible := True; TreeView.Visible := False; end else begin RzPageControl1.Visible := False; TreeView.Visible := True; end; if AFormMode in [iimConnectedConObjects, iimDisconnectedConObjects, iimConnectedLineCompons, iimDisconnectedLineCompons, iimCablesNoInCanals, iimNoConnectedRoutes] then begin MemTable_Interfaces.Active := false; MemTable_Interfaces.Active := true; //GroupBox_ConnDisconnConObjects.Visible := false; //GroupBox_Interfaces.Visible := false; TreeView.Options := TreeView.Options - [goHorzLine]; TreeView.Showlines := true; TreeView.ShowRoot := true; pcTreeData.Visible := false; tbTreeView.Visible := false; tbTreeView.Visible := true; case GFormMode of iimConnectedConObjects, iimDisconnectedConObjects, iimCablesNoInCanals, iimNoConnectedRoutes: begin ShowPCTreeData(false, nil); case GFormMode of iimConnectedConObjects: Caption := cInterfaceInfo_Msg1_1; iimDisconnectedConObjects: Caption := cInterfaceInfo_Msg1_2; // Tolik 13/02/2018 iimNoConnectedRoutes: Caption := cInterfaceInfo_Msg11; // end; if TreeView.Visible then begin if TreeView.Selected <> nil then TreeViewChange(TreeView, TreeView.Selected); end else begin if RzPageControl1.ActivePage = TabSheet1 then TreeViewChange(TreeView2, TreeView2.Selected) else TreeViewChange(TreeView1, TreeView1.Selected) end; end; iimConnectedLineCompons, iimDisconnectedLineCompons: begin ShowPCTreeData(GUseVisibleInterfaces, tsInterfaces); //14.05.2009 ShowPCTreeData(true, tsInterfaces); case GFormMode of iimConnectedLineCompons: begin Caption := cInterfaceInfo_Msg1_3; GroupBox_Interfaces.Caption := cInterfaceInfo_Msg2_1; end; iimDisconnectedLineCompons: begin Caption := cInterfaceInfo_Msg1_4; GroupBox_Interfaces.Caption := cInterfaceInfo_Msg2_2; end; end; end; end; // Tolik 10/05/17 -- { Act_DelCompons.Visible := ((AFormmode in [iimDisconnectedConObjects, iimDisconnectedLineCompons]) and (TreeView.Selected <> nil) and (TObject(TreeView.Selected.Data) is TSCSComponent));// and //(mtComponents.Active = True) and (mtComponents.RecordCount > 0)); Act_DeleteAllCompons.Visible := Act_DelCompons.Visible;} // FFilteType := GetFilterTypeByFormMode(false); FFilteTypeFile := GetFilterTypeByFormMode(true); LoadFilterBlockFromProject; FSimpleCaption := Caption; if AObject <> nil then Caption := Caption+' '+cInterfaceInfo_Msg8+' '+TSCSCatalog(AObject).GetNameForVisible; if TreeView.Selected <> nil then TreeViewChange(TreeView, TreeView.Selected); end else if AFormMode = iimNormComponents then begin Caption := cInterfaceInfo_Msg1_5_1; FSimpleCaption := Caption; ClearTree; TreeView.Options := TreeView.Options + [goHorzLine]; TreeView.Showlines := false; TreeView.ShowRoot := false; tbTreeView.Visible := true; tbTreeView.Visible := false; //pcTreeData.Visible := true; //pcTreeData.ActivePage := tsComponents; ShowPCTreeData(true, tsComponents); FEditedBandIndex := -1; FEditedFieldName := ''; if (AObject <> nil) and (AObject is TSCSCatalogExtended) then begin if AObject is TSCSProject then Caption := Caption + cInterfaceInfo_Msg1_5_2 +' '+ TSCSProject(AObject).GetNameForVisible else if AObject is TSCSList then Caption := Caption + cInterfaceInfo_Msg1_5_3 +' '+ TSCSList(AObject).GetNameForVisible; NormResources := nil; BeginProgress; try NormResources := TSCSCatalogExtended(AObject).GetAllNormsResources([nrNorms], false, true, false, true, true, false); for i := 0 to NormResources.Norms.Count - 1 do begin TreeNode := TreeView.Items.Add(nil, TSCSNorm(NormResources.Norms[i]).Name); TreeNode.Data := NormResources.Norms[i]; TreeNode.ImageIndex := -1; TreeNode.SelectedIndex := -1; end; TreeView.SortType := stText; TreeView.SortType := stNone; //*** Определить компоненты без норм ComponsWithOutNorms := nil; for i := 0 to TSCSCatalogExtended(AObject).ComponentReferences.Count - 1 do begin ComponWithOutNorm := TSCSCatalogExtended(AObject).ComponentReferences[i]; if ComponWithOutNorm.NormsResources.Norms.Count = 0 then begin if ComponsWithOutNorms = nil then ComponsWithOutNorms := TSCSObjectList.Create(false); //14.11.2013 TSCSComponents.Create(false); ComponsWithOutNorms.Add(ComponWithOutNorm); end; end; if ComponsWithOutNorms <> nil then begin TreeNode := TreeView.Items.Insert(nil, cInterfaceInfo_Msg6); TreeNode.Data := ComponsWithOutNorms; TreeNode.ImageIndex := -1; TreeNode.SelectedIndex := -1; //TreeNode. //TreeView. end; if TreeView.Visible then begin if TreeView.Selected <> nil then TreeViewChange(TreeView, TreeView.Selected); end else begin if RzPageControl1.ActivePage = TabSheet1 then TreeViewChange(TreeView2, TreeView2.Selected) else TreeViewChange(TreeView1, TreeView1.Selected) end; NormResources.Norms.OwnsObjects := false; NormResources.Free; finally EndProgress; end; end; SetControls; end ; { else if AFormMode = iimNoConnectedRoutes then begin MemTable_Interfaces.Active := false; MemTable_Interfaces.Active := true; //GroupBox_ConnDisconnConObjects.Visible := false; //GroupBox_Interfaces.Visible := false; TreeView.Options := TreeView.Options - [goHorzLine]; TreeView.Showlines := true; TreeView.ShowRoot := true; pcTreeData.Visible := false; tbTreeView.Visible := false; tbTreeView.Visible := true; //ShowPCTreeData(GUseVisibleInterfaces, tsInterfaces); ShowPCTreeData(true, tsInterfaces); {FFilteType := GetFilterTypeByFormMode(false); FFilteTypeFile := GetFilterTypeByFormMode(true); LoadFilterBlockFromProject;} //end; SavedIsDefineInterfaceNormsOnChangeNode := TF_Main(GForm).FIsDefineInterfaceNormsOnChangeNode; TF_Main(GForm).FIsDefineInterfaceNormsOnChangeNode := false; SetFilterControls; // Tolik -- 13/05/2017 -- if TreeView.Visible then EnableDisableTreeViewPopup; // ShowModal; ApplyFilterToCAD(AFormMode); if FChanged then TF_Main(GForm).RefreshNode(true); TF_Main(GForm).FIsDefineInterfaceNormsOnChangeNode := SavedIsDefineInterfaceNormsOnChangeNode; end; procedure TF_InterfaceInfo.LoadNormObjects(AGroupNorm: TSCSNorm; AObjsCompons: TSCSObjectList); var i, j: Integer; //NormIsOn: Integer; //NormKolvo: Double; //NormExpenseForLength: Double; //NormIsFromInterface: Integer; SCSObj: TSCSComponCatalogClass; Norm: TSCSNorm; ComponNorms: TSCSNorms; begin mtComponents.DisableControls; try try for i := 0 to AObjsCompons.Count - 1 do begin SCSObj := TSCSComponCatalogClass(AObjsCompons[i]); ComponNorms := TSCSNorms.Create(false); //*** отобрать нормы компоненты в список if AGroupNorm <> nil then begin for j := 0 to SCSObj.NormsResources.Norms.Count - 1 do begin Norm := SCSObj.NormsResources.Norms[j]; if Norm.GuidNB = AGroupNorm.GuidNB then ComponNorms.Add(Norm); end; end else ComponNorms.Add(nil); for j := 0 to ComponNorms.Count - 1 do begin AddNormSCSObjComponToMT(SCSObj, ComponNorms[j]); {Norm := ComponNorms[j]; NormIsOn := biFalse; NormKolvo := 0; NormExpenseForLength := 0; NormIsFromInterface := biFalse; if Norm <> nil then begin NormIsOn := Norm.IsOn; NormKolvo := Norm.Kolvo; NormExpenseForLength := Norm.ExpenseForLength; NormIsFromInterface := Norm.IsFromInterface end; mtComponents.Append; mtComponents.FieldByName(fnID).AsInteger := SCSComponent.ID; mtComponents.FieldByName(fnIsOn).AsInteger := NormIsOn; mtComponents.FieldByName(fnKolvo).AsFloat := RoundX(NormKolvo, PrecisionNormKolvo); mtComponents.FieldByName(fnExpenseForLength).AsFloat := RoundCP(NormExpenseForLength); mtComponents.FieldByName(fnIsFromInterface).AsInteger := NormIsFromInterface; mtComponents.FieldByName(fnName).AsString := SCSComponent.GetNameForVisible; mtComponents.FieldByName(fnIsLine).AsInteger := SCSComponent.IsLine; mtComponents.FieldByName(fnSignType).AsInteger := SCSComponent.GetPropertyValueAsInteger(pnSignType); mtComponents.FieldByName(fnIsDismount).AsInteger := SCSComponent.IsDismount; mtComponents.FieldByName(fnIsUseDismounted).AsInteger := SCSComponent.IsUseDismounted; mtComponents.FieldByName(fnComponObjectAddress).AsInteger := Integer(SCSComponent); mtComponents.FieldByName(fnNormObjectAddress).AsInteger := Integer(Norm); mtComponents.Post;} end; FreeAndNil(ComponNorms); end; except on E: Exception do AddExceptionToLogEx('LoadNormObjects', E.Message); end; {for i := 0 to AComponents.Count - 1 do begin SCSComponent := AComponents[i]; //*** Включена ли норма Norm := nil; NormIsOn := biFalse; NormKolvo := 0; NormExpenseForLength := 0; NormIsFromInterface := biFalse; if AGroupNorm <> nil then begin Norm := SCSComponent.NormsResources.Norms.GetNormByGuidNB(AGroupNorm.GuidNB, true); if Norm <> nil then begin NormIsOn := Norm.IsOn; NormKolvo := Norm.Kolvo; NormExpenseForLength := Norm.ExpenseForLength; NormIsFromInterface := Norm.IsFromInterface end; end; mtComponents.Append; mtComponents.FieldByName(fnID).AsInteger := SCSComponent.ID; mtComponents.FieldByName(fnIsOn).AsInteger := NormIsOn; mtComponents.FieldByName(fnKolvo).AsFloat := RoundX(NormKolvo, PrecisionNormKolvo); mtComponents.FieldByName(fnExpenseForLength).AsFloat := RoundCP(NormExpenseForLength); mtComponents.FieldByName(fnIsFromInterface).AsInteger := NormIsFromInterface; mtComponents.FieldByName(fnName).AsString := SCSComponent.GetNameForVisible; mtComponents.FieldByName(fnIsLine).AsInteger := SCSComponent.IsLine; mtComponents.FieldByName(fnSignType).AsInteger := SCSComponent.GetPropertyValueAsInteger(pnSignType); mtComponents.FieldByName(fnIsDismount).AsInteger := SCSComponent.IsDismount; mtComponents.FieldByName(fnIsUseDismounted).AsInteger := SCSComponent.IsUseDismounted; mtComponents.FieldByName(fnComponObjectAddress).AsInteger := Integer(SCSComponent); mtComponents.FieldByName(fnNormObjectAddress).AsInteger := Integer(Norm); mtComponents.Post; end; } finally mtComponents.EnableControls; end; end; // ##### Вывод интерфейсов ##### procedure TF_InterfaceInfo.LoadInterfaces(ALineComponent: TIntList); var i, j: Integer; SCSComponent: TSCSComponent; Interfac: TSCSInterface; ChildSumValueI: Double; begin GT_Interfaces.OnFocusedRecordChanged := nil; try try SCSComponent := nil; //SCSComponent := TSCSComponent.Create(GForm); MemTable_Interfaces.DisableControls; MemTable_Interfaces.Active := false; MemTable_Interfaces.Active := true; for i := 0 to ALineComponent.Count - 1 do begin //SCSComponent.LoadComponentByID(Integer(ALineComponent.Items[i]^), false); //SCSComponent.LoadInterfaces(-1, false); SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(ALineComponent.Items[i]); if Assigned(SCSComponent) then for j := 0 to SCSComponent.Interfaces.Count - 1 do begin Interfac := SCSComponent.Interfaces.Items[j]; if Not((Interfac.TypeI = itConstructive) {and (Interfac.Gender = gtMale)}) then if ((GFormMode = iimConnectedLineCompons) and (Interfac.IsBusy = biTrue)) or ((GFormMode = iimDisconnectedLineCompons) and (Interfac.IsBusy = biFalse)) then begin if Interfac.Name = '' then Interfac.LoadName; MemTable_Interfaces.Append; MemTable_Interfaces.Edit; MemTable_Interfaces.FieldByName(fnID).AsInteger := Interfac.ID; MemTable_Interfaces.FieldByName(fnNpp).AsInteger := Interfac.Npp; MemTable_Interfaces.FieldByName(fnIDCOMPONENT).AsInteger := Interfac.ID_Component; MemTable_Interfaces.FieldByName(fnIDINTERFACE).AsInteger := Interfac.ID_Interface; MemTable_Interfaces.FieldByName(fnName).AsString := Interfac.Name; MemTable_Interfaces.FieldByName(fnKolvo).AsInteger := Interfac.Kolvo; MemTable_Interfaces.FieldByName(fnKolvoBusy).AsInteger := Interfac.KolvoBusy; MemTable_Interfaces.FieldByName(fnTYPEI).AsInteger := Interfac.TypeI; MemTable_Interfaces.FieldByName(fnGENDER).AsInteger := Interfac.Gender; MemTable_Interfaces.FieldByName(fnMultiple).AsInteger := Interfac.Multiple; MemTable_Interfaces.FieldByName(fnISBUSY).AsInteger := Interfac.IsBusy; MemTable_Interfaces.FieldByName(fnValueI).AsFloat := Interfac.ValueI; MemTable_Interfaces.FieldByName(fnNumPair).AsInteger := Interfac.NumPair; MemTable_Interfaces.FieldByName(fnSignType).AsInteger := Interfac.SignType; MemTable_Interfaces.FieldByName(fnSideSection).AsString := Interfac.SideSection; //*** Подгрузить Объем с вычитанием объемов комплектующих if Interfac.TypeI = itConstructive then begin ChildSumValueI := TF_Main(GForm).DM.GetConnectedInterfacesValues(TF_Main(GForm).DM.scsQSelect, Interfac.ID); MemTable_Interfaces.FieldByName(fnValueI).AsFloat := Interfac.ValueI - ChildSumValueI; end; MemTable_Interfaces.FieldByName(fnColor).AsInteger := Interfac.Color; MemTable_Interfaces.FieldByName(fnIDadverse).AsInteger := Interfac.IDAdverse; MemTable_Interfaces.FieldByName(fnSide).AsInteger := Interfac.Side; if TF_Main(GForm).GDBMode = bkProjectManager then MemTable_Interfaces.FieldByName(fnCoordZ).AsFloat := Interfac.CoordZ; MemTable_Interfaces.Post; end; end; end; //*** Загрузить наименования интерфейсов {with F_NormBase.DM do begin ChangeSQLQuery(scsQSelect, ' select name from interface where id = :id '); MemTable_Interfaces.First; while Not MemTable_Interfaces.Eof do begin scsQSelect.Close; scsQSelect.SetParamAsInteger('id', MemTable_Interfaces.FieldByName('id_interface').AsInteger); scsQSelect.ExecQuery; MemTable_Interfaces.Edit; MemTable_Interfaces.FieldByName(fnName).AsString := scsQSelect.GetFNAsString('Name'); MemTable_Interfaces.Post; MemTable_Interfaces.Next; end; if MemTable_Interfaces.RecordCount > 0 then MemTable_Interfaces.RecNo := 1; end;} except on E: Exception do AddExceptionToLog('TF_InterfaceInfo.LoadInterfaces: '+E.Message); end; finally MemTable_Interfaces.EnableControls; GT_Interfaces.OnFocusedRecordChanged := GT_InterfacesFocusedRecordChanged; end; end; procedure TF_InterfaceInfo.Panel_BottomResize(Sender: TObject); begin //SetMiddleControlPos(Button_Close); SetMiddleControlChilds(TControl(Sender), TControl(Self)); end; procedure TF_InterfaceInfo.FormDestroy(Sender: TObject); begin DeactiveDataSets(Self); FreeAndNil(FFilterBlock); FreeAndNil(FFilterFieldValues); end; procedure TF_InterfaceInfo.Timer_TreeViewChangeTimer(Sender: TObject); var Node: TFlyNode; ObjectNode: TObject; //NodeDat: PObjectData; MainTreeViewNode: TTreeNode; Catalog: TCatalog; SCSID: Integer; SCSCatalog: TSCSCatalog; currSCSComponent,SCSComponent: TSCSComponent; WholeLineCompon: TWholeLineCompon; LineComponTrace: TIntList; ptrID: ^Integer; Norm, NormItem: TSCSNorm; NormObjects: TSCSObjectList; CreatedNormObjects: Boolean; //added by Tolik ListCad : TF_Cad; Figure : TFigure; ExistsLineComponents: Boolean; i,j: Integer; FoundedNode: TTreeNode; SavedScaleMode: Boolean; begin if IsOtherTimerToHandleInOrder(TTimer(Sender)) then Exit; ///// EXIT ///// EnableTimerWithOrder(TTimer(Sender), false); // changed by Tolik // Node := TreeView.Selected; // получаем выбранный объект дерева //if TreeView.Visible then //Tolik --10/05/2017 -- //TreeView.FlushSelection; // if not RzPageControl1.Visible then begin Node := TreeView.Selected; end else begin if RZPageControl1.ActivePage = tabSheet1 then Node := TreeView2.Selected else begin TreeView1.Visible := true; Node := TreeView1.Selected; end; end; // обработчик LineComponTrace := nil; ZeroMemory(@WholeLineCompon, SizeOf(TWholeLineCompon)); WholeLineCompon.WholeCompon := nil; try // InitCommonControl; // так было { if GFormMode in [iimConnectedConObjects, iimDisconnectedConObjects, iimConnectedLineCompons, iimDisconnectedLineCompons, iimCablesNoInCanals] then begin ObjectNode := nil; if Node <> nil then ObjectNode := Node.Data; if ObjectNode = nil then Exit; //// EXIT //// if ObjectNode is TSCSCatalog then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(TSCSCatalog(ObjectNode).ID, false) else if ObjectNode is TSCSComponent then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(TSCSComponent(ObjectNode).ID, true); if MainTreeViewNode <> nil then TF_Main(GForm).SelectNodeDirect(MainTreeViewNode); //TF_Main(GForm).Tree_Catalog.Selected := MainTreeViewNode; if ObjectNode is TSCSCatalog then begin SCSCatalog := TSCSCatalog(ObjectNode); //TF_Main(GForm).GSCSBase.CurrProject.GetCatalogFromReferences(NodeDat.ObjectID); if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end else if ObjectNode is TSCSComponent then begin SCSComponent := TSCSComponent(ObjectNode); case SCSComponent.IsLine of biFalse: begin //SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(NodeDat.ObjectID); SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end; biTrue: begin if (iimCablesNoInCanals = GFormMode) or (Node.Parent <> nil) then begin WholeLineCompon.WholeCompon := TIntList.Create; WholeLineCompon.WholeCompon.Add(SCSComponent.ID); LineComponTrace := TIntList.Create; //SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(NodeDat.ObjectID); SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then begin //New(ptrID); //ptrID^ := SCSCatalog.ScsID; LineComponTrace.Add(SCSCatalog.ScsID); end; end else if Node.Parent = nil then begin WholeLineCompon := GetLineComponsInTrace(SCSComponent.ID, SCSComponent); if WholeLineCompon.WholeCompon <> nil then LineComponTrace := GetTraceByListCompon(WholeLineCompon.WholeCompon); end; if LineComponTrace <> nil then if LineComponTrace.Count > 0 then begin if Not(iimCablesNoInCanals = GFormMode) then LoadInterfaces(WholeLineCompon.WholeCompon); SelectConnectedCables(TF_Main(GForm).GSCSBase.CurrProject.CurrList.CurrID, LineComponTrace); end; end; end; end; LineComponTrace.Free; //FreeList(LineComponTrace); if WholeLineCompon.WholeCompon <> nil then WholeLineCompon.WholeCompon.Free; //FreeList(WholeLineCompon.WholeCompon); if WholeLineCompon.WholeComponObj <> nil then WholeLineCompon.WholeComponObj.Free; end else if GFormMode = iimNormComponents then begin mtComponents.Active := false; mtComponents.Active := true; if Node.Data <> nil then begin CreatedNormObjects := false; Norm := nil; if TObject(Node.Data) is TSCSNorm then begin //GT_ComponentsIsOn.Visible := true; GT_Components.Bands[biNormData].Visible := true; Norm := TSCSNorm(Node.Data); NormObjects := GetComponentsFromCatalogByNorm(TSCSCatalog(FObject), Norm, false); //GetComonentsFromPrescurants(Norm.Preyscurants, false); CreatedNormObjects := true; //12.11.2013 - нормы объектов //for i := 0 to TSCSCatalog(FObject).NormsResources.Norms.Count - 1 do //begin // NormItem := TSCSCatalog(FObject).NormsResources.Norms[i]; // if NormItem.GuidNB = Norm.GuidNB then // NormObjects.Add(FObject); //end; end else if TObject(Node.Data) is TSCSObjectList then //14.11.2013 if TObject(Node.Data) is TSCSComponents then begin //GT_ComponentsIsOn.Visible := false; GT_Components.Bands[biNormData].Visible := false; NormObjects := TSCSObjectList(Node.Data); //14.11.2013 TSCSComponents(Node.Data); end; ExistsLineComponents := false; if NormObjects <> nil then begin LoadNormObjects(Norm, NormObjects); //*** проверить, есть ли линейные компоненты for i := 0 to NormObjects.Count - 1 do if NormObjects[i] is TSCSComponent then if TSCSComponent(NormObjects[i]).IsLine = biTrue then begin ExistsLineComponents := true; Break; //// BREAK //// end; end; GT_ComponentsExpenseForLength.Visible := ExistsLineComponents; GT_ComponentsCountForPoint.Visible := ExistsLineComponents; GT_ComponentsStepOfPoint.Visible := ExistsLineComponents; if CreatedNormObjects then FreeAndNil(NormObjects); end; end; } // changed by Tolik Case GFormMode of iimConnectedConObjects, iimDisconnectedConObjects, iimConnectedLineCompons, iimDisconnectedLineCompons, iimNoConnectedRoutes : begin for i := 0 to TreeView.Items.Count - 1 do begin if TFlyNode(TreeView.Items[i]).Selected then TFlyNode(TreeView.Items[i]).Selected := True else TFlyNode(TreeView.Items[i]).Selected := False; end; ObjectNode := nil; if Node <> nil then ObjectNode := Node.Data; if ObjectNode = nil then Exit; //// EXIT //// // Tolik 13/02/2018 if ObjectNode is TSCSList then begin if TSCSList(ObjectNode).TreeViewNode <> nil then TF_Main(F_ProjMan).SwitchInCAD(TSCSList(ObjectNode).TreeViewNode, ccOne) else begin FoundedNode := TF_Main(F_ProjMan).FindComponOrDirInTree(TSCSList(ObjectNode).Id, false); if FoundedNode <> nil then TF_Main(F_ProjMan).SwitchInCAD(FoundedNode, ccOne); end; end; // if ObjectNode is TSCSCatalog then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(TSCSCatalog(ObjectNode).ID, false) else if ObjectNode is TSCSComponent then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(TSCSComponent(ObjectNode).ID, true); if MainTreeViewNode <> nil then TF_Main(GForm).SelectNodeDirect(MainTreeViewNode); //TF_Main(GForm).Tree_Catalog.Selected := MainTreeViewNode; if ObjectNode is TSCSCatalog then begin SCSCatalog := TSCSCatalog(ObjectNode); //TF_Main(GForm).GSCSBase.CurrProject.GetCatalogFromReferences(NodeDat.ObjectID); if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end else if ObjectNode is TSCSComponent then begin SCSComponent := TSCSComponent(ObjectNode); case SCSComponent.IsLine of biFalse: begin SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end; biTrue: begin if (iimCablesNoInCanals = GFormMode) or (Node.Parent <> nil) then begin WholeLineCompon.WholeCompon := TIntList.Create; WholeLineCompon.WholeCompon.Add(SCSComponent.ID); LineComponTrace := TIntList.Create; SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then begin LineComponTrace.Add(SCSCatalog.ScsID); end; end else if Node.Parent = nil then begin WholeLineCompon := GetLineComponsInTrace(SCSComponent.ID, SCSComponent); if WholeLineCompon.WholeCompon <> nil then LineComponTrace := GetTraceByListCompon(WholeLineCompon.WholeCompon); end; if LineComponTrace <> nil then if LineComponTrace.Count > 0 then begin if Not(iimCablesNoInCanals = GFormMode) then LoadInterfaces(WholeLineCompon.WholeCompon); SelectConnectedCables(TF_Main(GForm).GSCSBase.CurrProject.CurrList.CurrID, LineComponTrace); end; end; end; end; // Tolik 13/02/2018 -- если не лист, то показать на Каде выбранный объект if not (ObjectNode is TSCSList) then begin if GCadForm <> nil then begin SavedScaleMode := GCadForm.FListSettings.ScaleByCursor; try if GCadForm.FListSettings.ScaleByCursor then GCadForm.FListSettings.ScaleByCursor := False; GCadForm.SetZoomScale(StrToInt(FSCS_Main.cbScaleNoob.Text) - 1); GCadForm.SetZoomScale(StrToInt(FSCS_Main.cbScaleNoob.Text)); RefreshCAD(GCadForm.PCad); GCadForm.FListSettings.ScaleByCursor := SavedScaleMode; except on E: exception do GCadForm.FListSettings.ScaleByCursor := SavedScaleMode; end; end; end; // LineComponTrace.Free; //FreeList(LineComponTrace); if WholeLineCompon.WholeCompon <> nil then WholeLineCompon.WholeCompon.Free; //FreeList(WholeLineCompon.WholeCompon); if WholeLineCompon.WholeComponObj <> nil then WholeLineCompon.WholeComponObj.Free; end; iimCablesNoInCanals : begin if RzPageControl1.Visible then begin if RzPageControl1.ActivePage = TabSheet1 then begin ObjectNode := nil; if Node <> nil then ObjectNode := Node.Data; if ObjectNode = nil then Exit; //// EXIT //// if ObjectNode is TSCSCatalog then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(TSCSCatalog(ObjectNode).ID, false) else if ObjectNode is TSCSComponent then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(TSCSComponent(ObjectNode).ID, true); if MainTreeViewNode <> nil then TF_Main(GForm).SelectNodeDirect(MainTreeViewNode); //TF_Main(GForm).Tree_Catalog.Selected := MainTreeViewNode; if ObjectNode is TSCSCatalog then begin SCSCatalog := TSCSCatalog(ObjectNode); //TF_Main(GForm).GSCSBase.CurrProject.GetCatalogFromReferences(NodeDat.ObjectID); if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end else if ObjectNode is TSCSComponent then begin SCSComponent := TSCSComponent(ObjectNode); case SCSComponent.IsLine of biFalse: begin //SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(NodeDat.ObjectID); SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.ListID, SCSCatalog.SCSID); // На КАД end; biTrue: begin if (iimCablesNoInCanals = GFormMode) or (Node.Parent <> nil) then begin WholeLineCompon.WholeCompon := TIntList.Create; WholeLineCompon.WholeCompon.Add(SCSComponent.ID); LineComponTrace := TIntList.Create; SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then begin LineComponTrace.Add(SCSCatalog.ScsID); end; end else if Node.Parent = nil then begin WholeLineCompon := GetLineComponsInTrace(SCSComponent.ID, SCSComponent); if WholeLineCompon.WholeCompon <> nil then LineComponTrace := GetTraceByListCompon(WholeLineCompon.WholeCompon); end; if LineComponTrace <> nil then if LineComponTrace.Count > 0 then begin if Not(iimCablesNoInCanals = GFormMode) then LoadInterfaces(WholeLineCompon.WholeCompon); SelectConnectedCables(TF_Main(GForm).GSCSBase.CurrProject.CurrList.CurrID, LineComponTrace); end; end; end; end; LineComponTrace.Free; //FreeList(LineComponTrace); if WholeLineCompon.WholeCompon <> nil then WholeLineCompon.WholeCompon.Free; //FreeList(WholeLineCompon.WholeCompon); if WholeLineCompon.WholeComponObj <> nil then WholeLineCompon.WholeComponObj.Free; end else begin // deselect all figures on current project for i := 0 to TF_Main(GForm).GSCSBase.CurrProject.ChildCatalogReferences.Count-1 do begin SCSCatalog := TF_Main(GForm).GSCSBase.CurrProject.ChildCatalogReferences[i]; if SCSCatalog.ItemType = itList then begin // Кад листа ListCad := GetListByID(SCSCatalog.SCSID); for j := 0 to ListCad.PCad.FigureCount-1 do begin Figure := TFigure(ListCad.PCad.Figures[j]); Figure.Selected := false; end; end; end; // deselect end // select current Cable ObjectNode := nil; if Node <> nil then begin ObjectNode := Node.Data; if ObjectNode is TSCSComponent then begin SCSComponent := TSCSComponent(ObjectNode); SCSComponent.LoadWholeComponent(true); for i := 0 to SCSComponent.WholeComponent.Count - 1 do begin currSCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(SCSComponent.WholeComponent[i]); SCSCatalog := currSCSComponent.GetFirstParentCatalog; ListCad := GetListByID(SCSCatalog.GetListOwner.SCSID); Figure := GetFigureByID(ListCad,SCSCatalog.SCSID); Figure.selected := true; ListCad.PCad.Refresh; end; end; end; end; end; end; iimNormComponents : begin mtComponents.Active := false; mtComponents.Active := true; if Node.Data <> nil then begin CreatedNormObjects := false; Norm := nil; if TObject(Node.Data) is TSCSNorm then begin GT_Components.Bands[biNormData].Visible := true; Norm := TSCSNorm(Node.Data); NormObjects := GetComponentsFromCatalogByNorm(TSCSCatalog(FObject), Norm, false); //GetComonentsFromPrescurants(Norm.Preyscurants, false); CreatedNormObjects := true; end else if TObject(Node.Data) is TSCSObjectList then //14.11.2013 if TObject(Node.Data) is TSCSComponents then begin GT_Components.Bands[biNormData].Visible := false; NormObjects := TSCSObjectList(Node.Data); //14.11.2013 TSCSComponents(Node.Data); end; ExistsLineComponents := false; if NormObjects <> nil then begin LoadNormObjects(Norm, NormObjects); //*** проверить, есть ли линейные компоненты for i := 0 to NormObjects.Count - 1 do if NormObjects[i] is TSCSComponent then if TSCSComponent(NormObjects[i]).IsLine = biTrue then begin ExistsLineComponents := true; Break; //// BREAK //// end; end; GT_ComponentsExpenseForLength.Visible := ExistsLineComponents; GT_ComponentsCountForPoint.Visible := ExistsLineComponents; GT_ComponentsStepOfPoint.Visible := ExistsLineComponents; if CreatedNormObjects then FreeAndNil(NormObjects); end; end; end; // end Case SetControls; except on E: Exception do AddExceptionToLog('TF_InterfaceInfo.Timer_TreeViewChangeTimer: '+E.Message); end; end; // Tolik -- 13/05/2017 -- procedure TF_InterfaceInfo.EnableDisableTreeViewPopup; begin if TreeView.Items.Count = 0 then begin TreeView.PopupMenu := nil; Act_DelCompons.Enabled := False; Act_DeleteAllCompons.Enabled := False; end else begin TreeView.PopupMenu := PopupMenu1; Act_DelCompons.Enabled := True; Act_DeleteAllCompons.Enabled := True; end; end; // procedure TF_InterfaceInfo.TreeViewChange(Sender: TObject; Node: TFlyNode); {var NodeDat: PObjectData; MainTreeViewNode: TTreeNode; Catalog: TCatalog; SCSID: Integer; SCSCatalog: TSCSCatalog; SCSComponent: TSCSComponent; WholeLineCompon: TWholeLineCompon; LineComponTrace: TIntList; ptrID: ^Integer; Norm: TSCSNorm; NormComponents: TSCSComponents; CreatedNormComponents: Boolean; ExistsLineComponents: Boolean; i: Integer;} begin // Tolik 10/04/2017 -- { if GFormMode in [iimConnectedConObjects, iimDisconnectedConObjects, iimConnectedLineCompons, iimDisconnectedLineCompons] then F_ProjMan.Tree_Catalog.ClearSelection(True); } // EnableTimerWithOrder(Timer_TreeViewChange, true); { LineComponTrace := nil; WholeLineCompon.WholeCompon := nil; try if GFormMode in [iimConnectedConObjects, iimDisconnectedConObjects, iimConnectedLineCompons, iimDisconnectedLineCompons] then begin NodeDat := Node.Data; if NodeDat = nil then Exit; //// EXIT //// if NodeDat.ItemType = itSCSConnector then MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(NodeDat.ObjectID, false) else MainTreeViewNode := TF_Main(GForm).FindComponOrDirInTree(NodeDat.ObjectID, true); if MainTreeViewNode <> nil then TF_Main(GForm).Tree_Catalog.Selected := MainTreeViewNode; case NodeDat.ItemType of itSCSConnector: begin SCSCatalog := TF_Main(GForm).GSCSBase.CurrProject.GetCatalogFromReferences(NodeDat.ObjectID); if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.SCSID); // На КАД end; itComponCon: begin SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(NodeDat.ObjectID); SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then SelectConnectedConnector(SCSCatalog.SCSID); // На КАД end; itComponLine: begin if Node.Parent = nil then begin WholeLineCompon := GetLineComponsInTrace(NodeDat.ObjectID); if WholeLineCompon.WholeCompon <> nil then LineComponTrace := GetTraceByListCompon(WholeLineCompon.WholeCompon); end else begin WholeLineCompon.WholeCompon := TIntList.Create; WholeLineCompon.WholeCompon.Add(NodeDat.ObjectID); LineComponTrace := TIntList.Create; SCSComponent := TF_Main(GForm).GSCSBase.CurrProject.GetComponentFromReferences(NodeDat.ObjectID); SCSCatalog := nil; if Assigned(SCSComponent) then SCSCatalog := SCSComponent.GetFirstParentCatalog; if Assigned(SCSCatalog) then begin //New(ptrID); //ptrID^ := SCSCatalog.ScsID; LineComponTrace.Add(SCSCatalog.ScsID); end; end; if LineComponTrace <> nil then if LineComponTrace.Count > 0 then begin LoadInterfaces(WholeLineCompon.WholeCompon); SelectConnectedCables(LineComponTrace); end; end; end; LineComponTrace.Free; //FreeList(LineComponTrace); WholeLineCompon.WholeCompon.Free; //FreeList(WholeLineCompon.WholeCompon); end else if GFormMode = iimNormComponents then begin mtComponents.Active := false; mtComponents.Active := true; if Node.Data <> nil then begin CreatedNormComponents := false; Norm := nil; if TObject(Node.Data) is TSCSNorm then begin //GT_ComponentsIsOn.Visible := true; GT_Components.Bands[biNormData].Visible := true; Norm := TSCSNorm(Node.Data); NormComponents := GetComonentsFromPrescurants(Norm.Preyscurants); CreatedNormComponents := true; end else if TObject(Node.Data) is TSCSComponents then begin //GT_ComponentsIsOn.Visible := false; GT_Components.Bands[biNormData].Visible := false; NormComponents := TSCSComponents(Node.Data); end; ExistsLineComponents := false; if NormComponents <> nil then begin LoadNormComponents(Norm, NormComponents); //*** проверить, есть ли линейные компоненты for i := 0 to NormComponents.Count - 1 do if NormComponents[i].IsLine = biTrue then begin ExistsLineComponents := true; Break; //// BREAK //// end; end; GT_ComponentsExpenseForLength.Visible := ExistsLineComponents; if CreatedNormComponents then FreeAndNil(NormComponents); end; end; except on E: Exception do AddExceptionToLog('TF_InterfaceInfo.TreeViewChange: '+E.Message); end;} // Tolik -- 13/05/2017 -- если дерево пустое -- откючить меню удаления объектов EnableDisableTreeViewPopup; end; procedure TF_InterfaceInfo.TreeViewGetNodeAttributes(Node: TFlyNode; Column: Integer; aFont: TFont; var BackColor: TColor; var Alignment: TAlignment); begin //*** Позиция Без норм if GFormMode = iimNormComponents then if (Node <> nil) and (Node.Index = 0) then begin if Node.Data <> nil then if TObject(Node.Data) is TSCSObjectList then //14.11.2013 if TObject(Node.Data) is TSCSComponents then aFont.Style := aFont.Style + [fsBold]; end; end; procedure TF_InterfaceInfo.GT_Components_SignTypeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin if AText = IntToStr(oitProjectible) then AText := cInterfaceInfo_Msg7_1 else if AText = IntToStr(oitActive) then AText := cInterfaceInfo_Msg7_2; end; procedure TF_InterfaceInfo.GT_Components_FocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); var SCSComponent: TSCSComponent; SCSObject: TSCSCatalog; begin if mtComponents.Active then if mtComponents.RecordCount > 0 then begin SCSComponent := nil; SCSObject := nil; if cbSelectComponInCAD.Checked then begin SCSComponent := TSCSComponent(mtComponents.FieldByName(fnObjectAddress).AsInteger); if SCSComponent <> nil then begin SCSObject := SCSComponent.GetFirstParentCatalog; TF_Main(GForm).SelectComponByIDInTree(SCSComponent.ID); end; if SCSObject <> nil then SelectObjectInCAD(SCSObject.ListID, SCSObject.SCSID, ''); end; end; end; procedure TF_InterfaceInfo.GT_ComponentsSignTypeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin {if AText = IntToStr(oitProjectible) then AText := cInterfaceInfo_Msg7_1 else if AText = IntToStr(oitActive) then AText := cInterfaceInfo_Msg7_2; } end; procedure TF_InterfaceInfo.Timer_PostNormComponentsTimer(Sender: TObject); var SCSNorm: TSCSNorm; SCSComponent: TSCSComponent; ptrProperty: PProperty; begin if IsOtherTimerToHandleInOrder(TTimer(Sender)) then Exit; ///// EXIT ///// EnableTimerWithOrder(TTimer(Sender), false); //TTimer(Sender).Enabled := false; try if GT_Components.DataController.IsEditing and (mtComponents.State <> dsBrowse) then begin GT_Components.DataController.Post; SaveSelectedNormResource; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.Timer_PostNormComponentsTimer', E.Message); end; end; procedure TF_InterfaceInfo.GT_ComponentsEditValueChanged( Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem); begin //FEditedBandIndex := TcxGridDBBandedColumn(AItem).Position.BandIndex; //FEditedFieldName := TcxGridDBBandedColumn(AItem).DataBinding.FieldName; if Sender.DataController.IsEditing and (mtComponents.State <> dsBrowse) then begin EnableTimerWithOrder(Timer_PostNormComponents, true, true); //Timer_PostNormComponents.Enabled := true; end; end; procedure TF_InterfaceInfo.GT_ComponentsFocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); var SCSObjCompon: TSCSComponCatalogClass; SCSObject: TSCSCatalog; i: Integer; NormIsFromInterface: Integer; begin if mtComponents.Active then if mtComponents.RecordCount > 0 then begin SCSObjCompon := nil; SCSObject := nil; //*** Не редактировать поля нормы из интерфейсов NormIsFromInterface := mtComponents.FieldByName(fnIsFromInterface).AsInteger; //for i := 0 to TcxGridDBBandedTableView(Sender).Bands[biNormData].ColumnCount - 1 do // TcxGridDBBandedTableView(Sender).Bands[biNormData].Columns[i].Options.Editing := (NormIsFromInterface = biFalse); GT_ComponentsKolvo.Options.Editing := (NormIsFromInterface = biFalse); GT_ComponentsExpenseForLength.Options.Editing := (NormIsFromInterface = biFalse) and (mtComponents.FieldByName(fnIsLine).AsInteger = biTrue); GT_ComponentsCountForPoint.Options.Editing := GT_ComponentsExpenseForLength.Options.Editing; GT_ComponentsStepOfPoint.Options.Editing := GT_ComponentsExpenseForLength.Options.Editing; if cbSelectComponInCAD.Checked then begin SCSObjCompon := TSCSComponCatalogClass(mtComponents.FieldByName(fnComponObjectAddress).AsInteger); if SCSObjCompon is TSCSComponent then begin if SCSObjCompon <> nil then begin SCSObject := TSCSComponent(SCSObjCompon).GetFirstParentCatalog; TF_Main(GForm).SelectComponByIDInTree(SCSObjCompon.ID); end; //if SCSObject <> nil then // SelectObjectInCAD(SCSObject.ListID, SCSObject.SCSID, ''); end else if SCSObjCompon is TSCSCatalog then begin SCSObject := TSCSCatalog(SCSObjCompon); TF_Main(GForm).SelectObjByIDInTree(SCSObjCompon.ID); end; end; end; end; procedure TF_InterfaceInfo.Act_AddNormExecute(Sender: TObject); var SCSObjCompon: TSCSComponCatalogClass; ComponCurrencyProperGlobalMainInNB: TCurrency; NormFromSprav: TSCSNorm; NormFromCompon: TSCSNorm; NormFromNode: TSCSNorm; NormNode: TFlyNode; NodeWithComponsWithoutNorms: TFlyNode; begin try if GFormMode = iimNormComponents then begin SCSObjCompon := TSCSComponCatalogClass(mtComponents.FieldByName(fnComponObjectAddress).AsInteger); if SCSObjCompon is TSCSComponent then ComponCurrencyProperGlobalMainInNB := TF_Main(GForm).DM.GetCatalogOrComponCurrencyProperGlobalMainInNB(0, SCSObjCompon.ID) else ComponCurrencyProperGlobalMainInNB := TF_Main(GForm).GLocalCurrencyM.Data; NormFromSprav := TF_Main(GForm).DM.GetNormFromSpravochnik(fmMake, '', SCSObjCompon.ID, ComponCurrencyProperGlobalMainInNB, TF_Main(GForm).GLocalCurrencyM.Data); if NormFromSprav <> nil then begin NormFromCompon := SCSObjCompon.NormsResources.Norms.GetNormByGuidNB(NormFromSprav.GuidNB, true); //if NormFromCompon <> nil then //begin // MessageModal(cNameNormB+' '+NormFromSprav.Name+' '+cNowExists+'.', ApplicationName, MB_ICONINFORMATION or MB_OK); // FreeAndNil(NormFromSprav); //end //else begin NormFromSprav.Kolvo := 1; AddNormToCurrComponInMT(NormFromSprav); {NormNode := GetNodeByNormGUIDNB(NormFromSprav.GuidNB); NormFromNode := nil; if NormNode = nil then begin NormFromNode := TSCSNorm.Create(GForm, ntProj); NormFromNode.Assign(NormFromSprav); NormNode := TreeView.Items.Add(nil, NormFromNode.Name); NormNode.Data := NormFromNode; NormNode.ImageIndex := -1; NormNode.SelectedIndex := -1; end else NormFromNode := TSCSNorm(NormNode.Data); if NormFromNode <> nil then begin NormFromSprav.MasterTableKind := ctkComponent; SCSComponent.NormsResources.Norms.Add(NormFromSprav); NormFromSprav.SaveNormAsNew(NormFromSprav.IDMaster); if GetPreyscurantFromNormByCompon(NormFromNode, SCSComponent) = nil then AddPreyscurantToNorm(NormFromNode, SCSComponent, itConstructive); //*** Если норма добавилась повторно в ту же самую ветвь if TreeView.Selected = NormNode then AddNormSCSObjComponToMT(SCSComponent, NormFromSprav); //*** Если компонент наход-ся в ветви "Без Норм", то удалить его из этой ветви NodeWithComponsWithoutNorms := GetNodeWithComponsWithoutNorms; if NodeWithComponsWithoutNorms <> nil then if TreeView.Selected = NodeWithComponsWithoutNorms then begin TSCSComponents(NodeWithComponsWithoutNorms.Data).Remove(SCSComponent); mtComponents.Delete; end; end;} end; end; SetControls; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.Act_AddNormExecute', E.Message); end; end; procedure TF_InterfaceInfo.Act_DelNormExecute(Sender: TObject); var SCSComponent: TSCSComponent; NormFromMT: TSCSNorm; NormGUID: string; NormFromNode: TSCSNorm; NormNode: TFlyNode; NodeWithComponsWithoutNorms: TFlyNode; begin try if GFormMode = iimNormComponents then begin SCSComponent := TSCSComponent(mtComponents.FieldByName(fnComponObjectAddress).AsInteger); NormFromMT := TSCSNorm(mtComponents.FieldByName(fnNormObjectAddress).AsInteger); if NormFromMT <> nil then begin if GUseVisibleInterfaces and (NormFromMT.IsFromInterface = biTrue) then MessageModal(cImpossibleDelNorm+' "'+ NormFromMT.Name +'" '+cbMessage5, cDeletingNorm, MB_ICONINFORMATION or MB_OK) else if MessageModal(cQuastDelNorm+' "'+ NormFromMT.Name +'"?', cDeletingNorm, MB_ICONQUESTION or MB_YESNO) = IDYES then begin mtComponents.Delete; NormNode := GetNodeByNormGUIDNB(NormFromMT.GuidNB); NormGUID := NormFromMT.GuidNB; SCSComponent.NormsResources.Norms.Remove(NormFromMT); FreeAndNil(NormFromMT); if NormNode <> nil then begin NormFromNode := TSCSNorm(NormNode.Data); if NormFromNode <> nil then begin //*** Если в компоненте не осталось норм if SCSComponent.NormsResources.Norms.GetNormByGuidNB(NormGUID, true) = nil then RemovePreyscurantFromNorm(NormFromNode, SCSComponent); //*** Если в ветви с нормой не осталось больще компонент, то удалить эту ветвь if NormFromNode.Preyscurants.Count = 0 then begin FreeAndNil(NormFromNode); NormNode.Delete; end; end; end; //*** Если в компоненты не осталось норм, вкинуть его в ветвь компонентов без норм if SCSComponent.NormsResources.Norms.Count = 0 then begin NodeWithComponsWithoutNorms := GetNodeWithComponsWithoutNorms; if NodeWithComponsWithoutNorms <> nil then TSCSObjectList(NodeWithComponsWithoutNorms.Data).Add(SCSComponent); //14.11.2013 TSCSComponents(NodeWithComponsWithoutNorms.Data).Add(SCSComponent); end; end; end; SetControls; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.Act_DelNormExecute', E.Message); end; end; procedure TF_InterfaceInfo.TreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); var TargetNode: TFlyNode; begin Accept := false; try TargetNode := TreeView.GetNodeAt(X, Y); if TargetNode <> nil then if Source is TcxDragControlObject then begin if TObject(TargetNode.Data) is TSCSNorm then Accept := true; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.TreeViewDragOver', E.Message); end; end; procedure TF_InterfaceInfo.TreeViewDragDrop(Sender, Source: TObject; X, Y: Integer); var TargetNode: TFlyNode; NewNorm: TSCSNorm; begin try TargetNode := TreeView.GetNodeAt(X, Y); if TargetNode <> nil then if Source is TcxDragControlObject then begin if TObject(TargetNode.Data) is TSCSNorm then begin NewNorm := TSCSNorm.Create(GForm, ntProj); NewNorm.AssignOnlyNorm(TSCSNorm(TargetNode.Data)); NewNorm.Kolvo := 1; NewNorm.IsFromInterface := biFalse; AddNormToCurrComponInMT(NewNorm); end; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.TreeViewDragDrop', E.Message); end; end; procedure TF_InterfaceInfo.GT_ComponentsLaborTimePropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var ValueFloat: Double; IsCalcNormTotal: Boolean; begin try if DisplayValue = '' then begin DisplayValue := FloatToStr(mtComponents.FieldByName(fnLaborTime).AsInteger); Exit; ///// EXIT ///// end; ValueFloat := StrToFloat_My(DisplayValue); mtComponents.Edit; mtComponents.FieldByName(fnLaborTime).AsFloat := ValueFloat; mtComponents.Post; TF_Main(GForm).DM.CalcNormCostTime(mtComponents, fnLaborTime, IsCalcNormTotal); //15.11.2013 SaveSelectedNormResource; except end; end; procedure TF_InterfaceInfo.GT_ComponentsPricePerTimePropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var ValueFloat: Double; IsCalcNormTotal: Boolean; begin try if DisplayValue = '' then begin DisplayValue := FloatToStr(mtComponents.FieldByName(fnPricePerTime).AsFloat); Exit; ///// EXIT ///// end; ValueFloat := StrToFloat_My(DisplayValue); mtComponents.Edit; mtComponents.FieldByName(fnPricePerTime).AsFloat := ValueFloat; mtComponents.Post; TF_Main(GForm).DM.CalcNormCostTime(mtComponents, fnPricePerTime, IsCalcNormTotal); //15.11.2013 SaveSelectedNormResource; except end; end; procedure TF_InterfaceInfo.GT_ComponentsCostPropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var ValueFloat: Double; IsCalcNormTotal: Boolean; begin try if DisplayValue = '' then begin DisplayValue := FloatToStr(mtComponents.FieldByName(fnCost).AsFloat); Exit; ///// EXIT ///// end; ValueFloat := StrToFloat_My(DisplayValue); mtComponents.Edit; mtComponents.FieldByName(fnCost).AsFloat := ValueFloat; mtComponents.Post; TF_Main(GForm).DM.CalcNormCostTime(mtComponents, fnCost, IsCalcNormTotal); //15.11.2013 SaveSelectedNormResource; except end; end; procedure TF_InterfaceInfo.GT_ComponentsKolvoPropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var ValueFloat: Double; begin try if DisplayValue = '' then begin DisplayValue := FloatToStr(mtComponents.FieldByName(fnKolvo).AsFloat); Exit; ///// EXIT ///// end; ValueFloat := StrToFloat_My(DisplayValue); mtComponents.Edit; mtComponents.FieldByName(fnKolvo).AsFloat := ValueFloat; mtComponents.FieldByName(fnExpenseForLength).AsFloat := 0; mtComponents.FieldByName(fnCountForPoint).AsFloat := 0; mtComponents.FieldByName(fnStepOfPoint).AsFloat := 0; mtComponents.Post; SaveSelectedNormResource; except end; end; procedure TF_InterfaceInfo.GT_ComponentsLaborTimeGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin AText := GetDisplayTextToNORMLaborTime(AText); end; procedure TF_InterfaceInfo.GT_ComponentsExpenseForLengthGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin AText := GetDisplayTextToNORMExpenseForLength(AText, TF_Main(GForm).FUOM); end; procedure TF_InterfaceInfo.GT_ComponentsExpenseForLengthPropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var ValueFloat: Double; begin try // Преобразуем расход из TF_Main(GForm).FUOM на метр if DisplayValue = '' then begin DisplayValue := FloatToStr(mtComponents.FieldByName(fnExpenseForLength).AsFloat); Exit; ///// EXIT ///// end; ValueFloat := StrToFloat_My(DisplayValue); ValueFloat := FloatInUOM(ValueFloat, umMetr, TF_Main(GForm).FUOM); mtComponents.Edit; mtComponents.FieldByName(fnExpenseForLength).AsFloat := RoundCP(ValueFloat); mtComponents.FieldByName(fnKolvo).AsFloat := 0; mtComponents.FieldByName(fnCountForPoint).AsFloat := 0; mtComponents.FieldByName(fnStepOfPoint).AsFloat := 0; mtComponents.Post; SaveSelectedNormResource; except end; end; procedure TF_InterfaceInfo.GT_ComponentsCountForPointPropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var ValueFloat: Double; begin try if DisplayValue = '' then begin DisplayValue := FloatToStr(mtComponents.FieldByName(fnCountForPoint).AsFloat); Exit; ///// EXIT ///// end; ValueFloat := StrToFloat_My(DisplayValue); //mtComponents.Edit; //mtComponents.FieldByName(fnCountForPoint).AsFloat := RoundCP(ValueFloat); //mtComponents.Post; InputFloatToRelatedZeroFieldInMT(mtComponents, ValueFloat, fnCountForPoint, fnStepOfPoint, fnKolvo+';'+fnExpenseForLength, cAddComponent_Msg20_1, true, TF_Main(GForm).FUOM); SaveSelectedNormResource; except end; end; procedure TF_InterfaceInfo.GT_ComponentsStepOfPointGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: String); begin AText := GetDisplayTextInFLoatUOM(AText, TF_Main(GForm).FUOM); end; procedure TF_InterfaceInfo.GT_ComponentsStepOfPointPropertiesValidate( Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var ValueFloat: Double; begin try if DisplayValue = '' then begin DisplayValue := FloatToStr(mtComponents.FieldByName(fnStepOfPoint).AsFloat); Exit; ///// EXIT ///// end; ValueFloat := StrToFloat_My(DisplayValue); ValueFloat := FloatInUOM(ValueFloat, TF_Main(GForm).FUOM, umMetr); //mtComponents.Edit; //mtComponents.FieldByName(fnStepOfPoint).AsFloat := RoundCP(ValueFloat); //mtComponents.Post; InputFloatToRelatedZeroFieldInMT(mtComponents, ValueFloat, fnStepOfPoint, fnCountForPoint, fnKolvo+';'+fnExpenseForLength, cAddComponent_Msg20_2, false, TF_Main(GForm).FUOM); SaveSelectedNormResource; except end; end; procedure TF_InterfaceInfo.GT_ComponentsInitEdit( Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit); begin FEditedBandIndex := TcxGridDBBandedColumn(AItem).Position.BandIndex; FEditedFieldName := TcxGridDBBandedColumn(AItem).DataBinding.FieldName; if AItem = GT_ComponentsExpenseForLength then AEdit.EditValue := GetDisplayTextToNORMExpenseForLength(AEdit.EditValue, TF_Main(GForm).FUOM) else if AItem = GT_ComponentsStepOfPoint then AEdit.EditValue := GetDisplayTextInFLoatUOM(AEdit.EditValue, TF_Main(GForm).FUOM); end; procedure TF_InterfaceInfo.Act_FilterExecute(Sender: TObject); begin if FFilterBlock.GetActiveConditionCount = 0 then begin FFilterBlock.IsOn := false; Act_FilterProperties.Execute; SetFilterControls; end else begin FFilterBlock.IsOn := Not FFilterBlock.IsOn; ApplyFilter(nil); SaveFilterToProject; SetFilterControls; end; end; procedure TF_InterfaceInfo.Act_FilterPropertiesExecute(Sender: TObject); var i: Integer; F_FilterConfigurator: TF_FilterConfigurator; OldFilterBlock: TFilterBlock; begin try F_FilterConfigurator := TF_FilterConfigurator.Create(Self, Self); F_FilterConfigurator.Caption := cFilterConfigurator1; F_FilterConfigurator.ColumnCaptionConditionType := cFilterConfigurator2_1; F_FilterConfigurator.ColumnCaptionFieldName := cFilterConfigurator2_2; F_FilterConfigurator.ColumnCaptionCompareType := cFilterConfigurator2_3; F_FilterConfigurator.ColumnCaptionValue := cFilterConfigurator2_4; F_FilterConfigurator.OpenSaveDialogFilter := GetDialogFilter(exdComponFilter, enCfr); F_FilterConfigurator.OpenDialog.InitialDir := ExtractDirByCategoryType(dctFilters); //14.04.2009 ExtractSaveDirForCategory(sdFilters); //07.04.2009 ExtractFileDir(ParamStr(0)); F_FilterConfigurator.OpenDialog.Title := exdComponFilter; F_FilterConfigurator.OpenDialog.DefaultExt := '*.'+enCfr; F_FilterConfigurator.SaveDialog.InitialDir := ExtractDirByCategoryType(dctFilters); //14.04.2009 ExtractSaveDirForCategory(sdFilters); //07.04.2009 ExtractFileDir(ParamStr(0)); F_FilterConfigurator.SaveDialog.Title := exdComponFilter; F_FilterConfigurator.SaveDialog.DefaultExt := '*.'+enCfr; if F_FilterConfigurator.Execute(FFilterFieldValues, FFilterBlock, FFilteTypeFile) then begin OldFilterBlock := FFilterBlock; FFilterBlock := F_FilterConfigurator.GetMainFilterBlock; ApplyFilter(OldFilterBlock); if OldFilterBlock <> nil then FreeAndNil(OldFilterBlock); SaveFilterToProject; SetFilterControls; {FFilterParams.DefineIsUseFilterField; DM.DefineIsOnFilterBlocks(FFilterParams, false); ApplyComponentFilter(OldFilterParams, FFilterParams, false); SaveComponFilter; if OldFilterParams <> nil then FreeAndNil(OldFilterParams); if cbFindComponsAfterFilterConfigurator.Checked then Act_FindComponsByFilter.Execute;} end; FreeAndNil(F_FilterConfigurator); except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.Act_FilterPropertiesExecute', E.Message); end; end; procedure TF_InterfaceInfo.ToolButton5Click(Sender: TObject); begin TreeView.Items.BeginUpdate; TreeView.Selected.Hidden := true; TreeView.Items.EndUpdate; end; procedure TF_InterfaceInfo.ToolButton6Click(Sender: TObject); begin TreeView.Items.BeginUpdate; TreeView.Selected.Show(True); TreeView.Items.EndUpdate; end; procedure TF_InterfaceInfo.TreeViewExpanding(Sender: TObject; Node: TFlyNode; var AllowExpansion: Boolean); var ChildNode: TFlyNode; begin try // Все подветви пропустить через фильтр ChildNode := Node.getFirstChild; while ChildNode <> nil do begin ChildNode.Hidden := Not IsVisibleNodeByFilter(ChildNode, true); ChildNode := ChildNode.GetNextSibling; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.TreeViewExpanding', E.Message); end; end; procedure TF_InterfaceInfo.Act_SaveToExcelExecute(Sender: TObject); var SaveDialog: {TSavePictureDialog; //}TSaveDialog; xf: TXLSFile; Range: TRange; Node: TFlyNode; StartColumn: Integer; WriteCount: Integer; TitleRow: Integer; WriteColumn: Integer; MaxColumn: Integer; SCSProjCatalog: TSCSProject; IsOpenFileAfterSave: Boolean; begin try SaveDialog := {TSavePictureDialog.Create(Self); //}TSaveDialog.Create(Self); try SaveDialog.Title := ''; SaveDialog.InitialDir := ExtractSaveDir; SaveDialog.DefaultExt := '*.'+enXls; SaveDialog.FileName := GetNoExistsFileNameForCopy(FileNameCorrect(Caption)); SaveDialog.Filter := GetDialogFilter(exdXls, enXls); //ExtName+' ('+FullExtName+')|'+FullExtName; SaveDialog.Options := SaveDialog.Options - [ofNoChangeDir] + [ofOverwritePrompt]; //SaveDialog.OnShow //SaveDialog.OnClose; IsOpenFileAfterSave := true; if TF_Main(GForm).ExecuteDialogWithCheckBox(SaveDialog, cInterfaceInfo_Msg10, @IsOpenFileAfterSave) then begin BeginProgress; try Application.ProcessMessages; xf := TXLSFile.Create; try Node := nil; WriteCount := 0; StartColumn := 1; MaxColumn := StartColumn; SCSProjCatalog := TSCSCatalog(FObject).GetProject; // пишем дату, наименование проекта с номером версии WriteCount := WriteCount + 1; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].Value := DateToStr(Date)+' '+cResourceReport_Msg24 +ApplicationName+' '+VersionEXE; WriteCount := WriteCount + 2; // Наименование проекта xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].Value := cRepMsg03+': '+SCSProjCatalog.GetNameForVisible; WriteCount := WriteCount + 1; // Наименование листа if FObject is TSCSList then begin xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].Value := cRepMsg10+': '+TSCSList(FObject).GetNameForVisible; WriteCount := WriteCount + 1; end; WriteCount := WriteCount + 2; // Заголовок // Changed by Tolik if not RzPageControl1.Visible then begin xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].Value := FSimpleCaption; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].FontHeight := 16; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].FontItalic := true; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].FontName := 'Times New Roman'; TitleRow := WriteCount; WriteCount := WriteCount + 1; end else begin xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].Value := RzPageControl1.ActivePage.Caption; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].FontHeight := 16; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].FontItalic := true; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].FontName := 'Times New Roman'; TitleRow := WriteCount; WriteCount := WriteCount + 1; end; // Записываем содержимое фильтра if Act_Filter.Checked then begin xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn].Value := gbFilter.Caption; WriteCount := WriteCount + 1; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn+1].Value := lbFilter.Caption; xf.Workbook.Sheets[0].Cells[WriteCount, StartColumn+1].FontColorRGB := lbFilter.Font.Color; WriteCount := WriteCount + 2; MaxColumn := StartColumn + 1; end; { // Записываем ветви if TreeView.Items.Count > 0 then Node := TreeView.Items[0]; while Node <> nil do begin if IsVisibleNodeByFilter(Node, true) then begin WriteColumn := Node.Level + StartColumn; if WriteColumn > MaxColumn then MaxColumn := WriteColumn; xf.Workbook.Sheets[0].Cells[WriteCount, WriteColumn].Value := Node.Text; WriteCount := WriteCount + 1; end; Node := Node.GetNext; end; } // Записываем ветви // changed by Tolik if not RzPageControl1.Visible then begin if TreeView.Items.Count > 0 then Node := TreeView.Items[0]; while Node <> nil do begin if IsVisibleNodeByFilter(Node, true) then begin WriteColumn := Node.Level + StartColumn; if WriteColumn > MaxColumn then MaxColumn := WriteColumn; xf.Workbook.Sheets[0].Cells[WriteCount, WriteColumn].Value := Node.Text; WriteCount := WriteCount + 1; end; Node := Node.GetNext; end; end else begin if RzPageControl1.ActivePage = TabSheet1 then begin if TreeView2.Items.Count > 0 then Node := TreeView2.Items[0]; while Node <> nil do begin if IsVisibleNodeByFilter(Node, true) then begin WriteColumn := Node.Level + StartColumn; if WriteColumn > MaxColumn then MaxColumn := WriteColumn; xf.Workbook.Sheets[0].Cells[WriteCount, WriteColumn].Value := Node.Text; WriteCount := WriteCount + 1; end; Node := Node.GetNext; end; end else begin if TreeView1.Items.Count > 0 then Node := TreeView1.Items[0]; while Node <> nil do begin if IsVisibleNodeByFilter(Node, true) then begin WriteColumn := Node.Level + StartColumn; if WriteColumn > MaxColumn then MaxColumn := WriteColumn; xf.Workbook.Sheets[0].Cells[WriteCount, WriteColumn].Value := Node.Text; WriteCount := WriteCount + 1; end; Node := Node.GetNext; end; end; end; // Объединить ячейки с заголовком {Range := xf.Workbook.Sheets[0].Ranges.Add; Range.AddRect(TitleRow, TitleRow, StartColumn, MaxColumn); Range.MergeCells;} try xf.SaveAs(SaveDialog.FileName); except on E: Exception do begin IsOpenFileAfterSave := false; PauseProgress(true); MessageModal(cProgressExp_Msg4, ApplicationName, MB_OK or MB_ICONINFORMATION); PauseProgress(false); end; end; finally xf.Free; end; if IsOpenFileAfterSave then ShellExecute(0, nil, PChar(SaveDialog.FileName), nil, nil, SW_MAXIMIZE); finally EndProgress; end; end; finally SaveDialog.Free; end; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.Act_SaveToExcelExecute', E.Message); end; end; procedure TF_InterfaceInfo.cbUseFilterInCADClick(Sender: TObject); begin SaveFilterToProject; end; procedure TF_InterfaceInfo.FormShow(Sender: TObject); begin if RzPageControl1.Visible then RzPageControl1.Pages[0].SetFocus; end; procedure TF_InterfaceInfo.TabSheet1Enter(Sender: TObject); begin //Act_SaveToExcel.Enabled := TreeView2.GetVisiblecount > 0 Act_SaveToExcel.Enabled := TreeView2.Columns.GetVisiblecount > 0; end; procedure TF_InterfaceInfo.TabSheet2Enter(Sender: TObject); begin //Act_SaveToExcel.Enabled := TreeView1.GetVisiblecount > 0 Act_SaveToExcel.Enabled := TreeView1.Columns.GetVisiblecount > 0; end; procedure TF_InterfaceInfo.RzPageControl1Change(Sender: TObject); var Node : TFlyNode; i : integer; begin if RZPageControl1.ActivePage = TabSheet1 then begin TreeView2.visible := true; Node := TreeView2.Selected; //Act_SaveToExcel.Enabled := TreeView2.GetVisiblecount > 0; Act_SaveToExcel.Enabled := TreeView2.Columns.GetVisiblecount > 0; TreeViewChange(TreeView2, TreeView2.Selected); end else begin TreeView1.visible := true; Node := TreeView1.Selected; //Act_SaveToExcel.Enabled := TreeView1.GetVisiblecount > 0; Act_SaveToExcel.Enabled := TreeView1.Columns.GetVisiblecount > 0; TreeViewChange(TreeView1, TreeView1.Selected); end; end; //Tolik -- function GetListForUndo(aComponList: TSCSComponents): TList; var i: Integer; ComponCatalog: TSCSCatalog; Compon: TSCSComponent; ListIdList: TIntList; begin //Result := TList.Create; ListIdList := TIntList.Create; for i := 0 to aComponList.Count - 1 do begin Compon := TSCSComponent(aComponList[i]); ComponCatalog := Compon.GetFirstParentCatalog; if ComponCatalog <> nil then begin if ListIdList.IndexOf(ComponCatalog.ListID) = -1 then ListIdList.Add(ComponCatalog.ListID); end; end; Result := IntCadsToCads(ListIdList); ListIdList.Free; end; procedure TF_InterfaceInfo.Act_DelComponsExecute(Sender: TObject); var Node, ChildNode: TFlyNode; NodeDat: TObject; ComponToDel: TSCSComponent; ComponToDeleteList: TSCSComponents; CanDelChildNode: Boolean; vList: TList; begin Node := TreeView.Selected; TreeView.Items.BeginUpdate; if Node <> nil then begin try NodeDat := Node.Data; ComponToDeleteList := TSCSComponents.Create(False); if (NodeDat <> nil) and (NodeDat is TSCSComponent) then begin ComponToDel := TSCSComponent(NodeDat); if (ComponToDel <> nil) and (not ComponToDel.ServToDelete) then begin if ComponToDeleteList.IndexOf(ComponToDel) = -1 then ComponToDeleteList.Add(ComponToDel); end; end; CanDelChildNode := True; while CanDelChildNode do begin CanDelChildNode := False; ChildNode := Node.getFirstChild; if ChildNode <> nil then begin CanDelChildNode := True; NodeDat := ChildNode.Data; if (NodeDat <> nil) and (NodeDat is TSCSComponent) then begin ComponToDel := TSCSComponent(NodeDat); if (ComponToDel <> nil) and (not ComponToDel.ServToDelete) then begin if ComponToDeleteList.IndexOf(ComponToDel) = -1 then ComponToDeleteList.Add(ComponToDel); end; end; childNode.Delete; end; end; Node.Delete; if ComponToDeleteList.Count > 0 then begin // *UNDO* -- тут на всякий - ундо проекта, чтобы при удалении компонента не с текущего листа // сработал CTRL+Z vList := GetListForUndo(ComponToDeleteList); SaveForProjectUndo(vList, True, False); vList.free; // F_ProjMan.DelComponentsFromList(F_ProjMan.GSCSBase.CurrProject.CurrList, ComponToDeleteList, False, biNone, false, nil); end; ComponToDeleteList.Free; TreeView.Selected := nil; TreeView.Items.EndUpdate; TreeView.Refresh; except on E: Exception do begin AddExceptionToLogEx('TF_InterfaceInfo.DeleteComponFromTree', E.Message); end; end; end; EnableDisableTreeViewPopup; end; procedure TF_InterfaceInfo.Act_DeleteAllComponsExecute(Sender: TObject); var Node, childNode: TFlyNode; NodeDat: TObject; ComponToDel: TSCSComponent; ComponToDeleteList: TSCSComponents; CanDelChildNode: Boolean; vList: TList; begin TreeView.Items.BeginUpdate; try ComponToDeleteList := TSCSComponents.Create(False); while TreeView.Items.Count > 0 do begin Node := TreeView.Items[0]; if Node <> nil then begin NodeDat := Node.Data; if (NodeDat <> nil) and (NodeDat is TSCSComponent) then begin ComponToDel := TSCSComponent(NodeDat); if (ComponToDel <> nil) and (not ComponToDel.ServToDelete) then begin if ComponToDeleteList.IndexOf(ComponToDel) = -1 then ComponToDeleteList.Add(ComponToDel); end; end; CanDelChildNode := True; while CanDelChildNode do begin CanDelChildNode := False; ChildNode := Node.getFirstChild; if ChildNode <> nil then begin CanDelChildNode := True; NodeDat := ChildNode.Data; if (NodeDat <> nil) and (NodeDat is TSCSComponent) then begin ComponToDel := TSCSComponent(NodeDat); if (ComponToDel <> nil) and (not ComponToDel.ServToDelete) then begin if ComponToDeleteList.IndexOf(ComponToDel) = -1 then ComponToDeleteList.Add(ComponToDel); end; end; childNode.Delete; end; end; Node.Delete; end; end; if ComponToDeleteList.Count > 0 then begin //if MessageBoxA(FSCS_Main.Handle, PAnsiChar(cMain_Mes48_1),cMain_Mes48_2, MB_YESNO) = IDYes then if MessageBox(FSCS_Main.Handle, PChar(cMain_Mes48_1), PChar(cMain_Mes48_2), MB_YESNO) = IDYes then begin // *UNDO* vList := GetListForUndo(ComponToDeleteList); if vList.Count = 1 then begin if GCadForm.FCanSaveForUndo then begin GCadForm.SaveForUndo(uat_None, True, True); GCadForm.FCanSaveForUndo := False; end; end else if vList.Count > 1 then begin SaveForProjectUndo(vList, True, False); end; vList.Free; F_ProjMan.DelComponentsFromList(F_ProjMan.GSCSBase.CurrProject.CurrList, ComponToDeleteList, False, biNone, false, nil); end; end; ComponToDeleteList.Free; except on E: Exception do AddExceptionToLogEx('TF_InterfaceInfo.DeleteAllComponents', E.Message); end; TreeView.Selected := nil; TreeView.Items.EndUpdate; TreeView.Refresh; EnableDisableTreeViewPopup; end; end.