unit U_BlockParams; interface uses Windows, U_LNG, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, PCPanel, PCDrawBox, PCDrawing, PowerCad, PCTypesUtils, DrawObjects, PCgui, GuiStrings, DrawEngine, ExtCtrls, RzPanel, cxLookAndFeelPainters, StdCtrls, cxButtons, cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxSpinEdit, cxCheckBox, siComp, siLngLnk, RzButton, RzRadChk, ComCtrls, ActnList, Buttons, Spin{Tolik 17/07/2017 -- }, Math, RzLabel, cxGraphics, cxLookAndFeels, Menus; type TF_BlockParams = class(TForm) pnMain: TRzPanel; lng_Forms: TsiLangLinked; pnAddition: TPanel; lbAddition: TLabel; edAddition: TcxSpinEdit; lbAdditionUOM: TLabel; edAdditionProcent: TcxSpinEdit; lbAdditionProcent: TLabel; pnConfirm: TPanel; bOK: TcxButton; bCancel: TcxButton; pnDimensions: TPanel; Label5: TLabel; lbHeight: TLabel; lbHeightProcent: TLabel; lbWidthProcent: TLabel; Label3: TLabel; Label4: TLabel; edWidth: TcxSpinEdit; edHeight: TcxSpinEdit; edWidthProcent: TcxSpinEdit; edHeightProcent: TcxSpinEdit; pnProportion: TPanel; lbRotateTo: TLabel; lbRotateToGrad: TLabel; cbProportions: TRzCheckBox; edRotateTo: TcxSpinEdit; Transparency_Bar: TTrackBar; Label1: TLabel; BitBtn1: TBitBtn; PnPieProp: TPanel; Label2: TLabel; Label6: TLabel; Label7: TLabel; SpinEdit1: TSpinEdit; SpinEdit2: TSpinEdit; Label8: TLabel; Label9: TLabel; Label10: TLabel; ActionList1: TActionList; aDefFigureFillColor: TAction; cbAutoApply: TRzCheckBox; ApplyLabel: TRzLabel; cbSizeToAngle: TRzCheckBox; edPieRadius: TcxSpinEdit; //Tolik -- 30/09/2017 -*- procedure ScaleRichText(px,py: Double; aFigure: TFigure{rPoint: TDoublepoint}); Procedure ScaleBlockToNormalSize; Procedure ScaleBlockToValues; // procedure edWidthPropertiesChange(Sender: TObject); procedure edHeightPropertiesChange(Sender: TObject); procedure edWidthProcentPropertiesChange(Sender: TObject); procedure edHeightProcentPropertiesChange(Sender: TObject); procedure edWidthKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure edHeightKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormCreate(Sender: TObject); procedure edAdditionProcentPropertiesChange(Sender: TObject); procedure aDefFigureFillColorExecute(Sender: TObject); procedure Transparency_BarChange(Sender: TObject); procedure SpinEdit1Change(Sender: TObject); procedure SpinEdit2Change(Sender: TObject); procedure bCancelClick(Sender: TObject); procedure edRotateToPropertiesChange(Sender: TObject); procedure ApplyLabelClick(Sender: TObject); procedure bOKClick(Sender: TObject); procedure cbAutoApplyClick(Sender: TObject); Procedure RecalcSizeToAngle; Procedure SetValuesToBounds(aWithPercentage: Boolean = False); procedure cbSizeToAngleClick(Sender: TObject); procedure edPieRadiusPropertiesChange(Sender: TObject); procedure CalcPercentValues(CalcWidth, CalcHeight: Boolean); // procedure SpinEdit3Change(Sender: TObject); private { Private declarations } BaseW: Double; BaseH: Double; // Tolik -- 09/10/2017 -- ZeroAngleW, ZeroAngleH: Double; // в оригинальном размере, не переводя в ед измерения // BaseWProcent: Integer; BaseHProcent: Integer; FLockChangeEvent: Boolean; BeForeFigureAngle: integer; OldFigureAngle: Double; FAllowProportion: Boolean; public FSrcCaption: String; { Public declarations } function Execute(aBlock: TFigure; aAllowPersent: Boolean=true; aAllowProportion: Boolean=true; const aCaption: String=''): Boolean; end; var F_BlockParams: TF_BlockParams; // 26/05/2017 -- FigureBrushColor, FigureBrushStyle, FigureColor : Integer; OldFigureBrushColor, OldFigureBrushStyle, OldFigureColor: Integer; OldFigureTransparency: Integer; BlockFigure: TFigure = nil; BlockCenterPoint: TDoublePoint; implementation uses USCS_Main, U_CAD, U_Common, U_BaseCommon, U_Constants, U_LoadColor; {$R *.dfm} { TF_BlockParams } function TF_BlockParams.Execute(aBlock: TFigure; aAllowPersent: Boolean=true; aAllowProportion: Boolean=true; const aCaption: String=''): Boolean; var Bnd: TDoubleRect; w, h: double; NewW, NewH: Double; ScaleKoefW, ScaleKoefH: double; OldPieFAngle, OldPieSangle, OldPieRadius: double; OldFigureBrs: Integer; xAction: TUndoAction; RefreshFlag: Boolean; TempFigureAngle: Double; begin Result := False; //Tolik -- 30/09/2017 -- FLockChangeEvent := False; BeForeFigureAngle := 0; BlockFigure := aBlock; GCadForm.PCad.RecordModifyUndo(TFigure(aBlock)); //Tolik 08/10/2021 - - //Self.Height := 309; Self.Height := 320; // FAllowProportion := True; // Tolik 19/10/2017 -- проинициализировать все значения и компоненты формы // видимость панелек Self.pnMain.Height := 144; Self.pnDimensions.Height := 65; Self.pnAddition.Height := 27; Self.pnProportion.Height := 44; Self.PnPieProp.Height := 144; Self.pnConfirm.Height := 139; Self.pnAddition.Visible := False; Self.pnConfirm.Visible := True; Self.pnDimensions.Visible := True; Self.pnMain.Visible := True; Self.PnPieProp.Visible := True; Self.pnProportion.Visible := True; //значения свойств edAddition.Visible := True; FLockChangeEvent := True; // запретить пересчет значений edAddition.Value := 0; edAdditionProcent.Visible := True; edAdditionProcent.Value := 0; edHeight.Visible := True; edHeight.Value := 0; edHeightProcent.Visible := True; edHeightProcent.Value := 100; edPieRadius.Visible := True; edPieRadius.Top := 80; edPieRadius.Value := 0; SpinEdit1.Visible := True; SpinEdit1.Top := 12; SpinEdit2.Visible := True; SpinEdit2.Top := 48; edRotateTo.Visible := True; edRotateTo.Value := 0; edWidth.Visible := True; edWidth.Value := 0; edWidthProcent.Visible := True; edWidthProcent.Value := 100; FLockChangeEvent := False; // разрешить пересчет значений //лейблы ApplyLabel.Visible := True; ApplyLabel.Top := 60; ApplyLabel.Enabled := false; lbAddition.Visible := True; lbAdditionProcent.Visible := True; lbAdditionUOM.Visible := True; lbHeight.Visible := True; lbHeightProcent.Visible := True; lbRotateTo.Visible := True; lbRotateToGrad.Visible := True; lbWidthProcent.Visible := True; Label1.Visible := True; Label1.Top := 0; Label2.Visible := True; Label2.Top := 16; Label3.Visible := True; Label4.Visible := True; Label5.Visible := True; Label6.Visible := True; Label6.Top := 48; Label7.Visible := True; Label7.Top := 80; Label8.Visible := True; Label8.Top := 9; Label9.Visible := True; Label9.Top := 45; Label10.Visible := True; Label10.Top := 86; // кнопки bOk.Top := 114; bCancel.Top := 114; bitBtn1.Visible := True; bitBtn1.Top := 20; Transparency_Bar.Visible := True; Transparency_Bar.Top := 20; cbAutoApply.Visible := True; cbAutoApply.Top := 60; cbSizeToAngle.Visible := True; cbSizeToAngle.Top := 84; // центр фигуры (изначально) BlockCenterPoint.x := 0; BlockCenterPoint.y := 0; if ABlock <> nil then if not aBlock.deleted then Bnd := aBlock.GetBoundRect; BlockCenterPoint.x := (bnd.Left + bnd.Right)/2; BlockCenterPoint.y := (bnd.Top + bnd.Bottom)/2; // *UNDO* // xAction:= TundoAction.Create(uaModify); // GCadForm.PCad.AddFigureToModifyUndo(xAction,TFigure(aBlock)); //xAction := TUndoAction.Create(uaRemove); //xAction.List.Add(aBlock); //TFigure(aBlock).Urc := TFigure(aBlock).Urc + 1; //GCadForm.PCad.InsertUndoAction(xAction); // {if GCadForm.FCanSaveForUndo then begin GCadForm.SaveForUndo(uat_None, True, False); GCadForm.FCanSaveForUndo := False; end; } // // Tolik -- 18/07/2017 -- OldFigureBrs := -1; // try Label8.Caption := CHR(176); Label9.Caption := CHR(176); ApplyLabel.Enabled := False; // Tolik -- 26/05/2017 -- //Self.Width := 285;//265; Self.Width := 300;//265; // FigureBrushColor := aBlock.Brc; FigureColor := aBlock.color; FigureBrushStyle := aBlock.Brs; OldFigureTransparency := aBlock.Transparency; Transparency_Bar.Hint := IntToStr(aBlock.Transparency); OldFigureBrushColor := aBlock.Brc; OldFigureColor := aBlock.color; OldFigureBrushStyle := aBlock.Brs; Transparency_Bar.Position := aBlock.Transparency; // // система измерений if GCurrProjUnitOfMeasure = umSM then begin Label3.Caption := cMetric_sm; Label4.Caption := cMetric_sm; lbAdditionUOM.Caption := cMetric_sm; Label10.Caption := cMetric_sm; end; if GCurrProjUnitOfMeasure = umM then begin Label3.Caption := cMetric_m; Label4.Caption := cMetric_m; lbAdditionUOM.Caption := cMetric_m; Label10.Caption := cMetric_m; end; if GCurrProjUnitOfMeasure = umIn then begin Label3.Caption := cWhitworth_in; Label4.Caption := cWhitworth_in; lbAdditionUOM.Caption := cWhitworth_in; Label10.Caption := cWhitworth_in; end; if GCurrProjUnitOfMeasure = umFt then begin Label3.Caption := cWhitworth_ft; Label4.Caption := cWhitworth_ft; lbAdditionUOM.Caption := cWhitworth_ft; Label10.Caption := cWhitworth_ft; end; //Tolik -- 14/07/2017 -- if aBlock.ClassName = 'TPie' then begin OldPieSangle := TPie(aBlock).SAngle; OldPieFangle := TPie(aBlock).FAngle; OldPieRadius := TPie(aBlock).Radius; Self.pnProportion.Visible := False; Self.pnAddition.Visible := False; Self.pnDimensions.Visible := False; //Self.pnConfirm.Visible := False; Self.pnPieProp.Visible := True; Self.pnMain.Height := 115;//Self.pnMain.Height - 30; //Self.Height := 260;//240;//240;//Self.Height - 20; Self.Height := 280;//240;//240;//Self.Height - 20; SpinEdit1.Value := Round((TPie(BlockFigure).SAngle * 180)/PI); SpinEdit2.Value := Round((TPie(BlockFigure).FAngle * 180)/PI); //Edit1.Text := FloatToStr(RoundX(TPie(BlockFigure).Radius, 2)); FLockChangeEvent := True; edPieRadius.Value := RoundX(MetreToUom((TPie(BlockFigure).Radius * GCadForm.PCad.MapScale) / 1000), 2); FLockChangeEvent := False; if aCaption <> '' then Caption := aCaption; cbSizeToAngle.Visible := False; bOk.Top := bOk.Top - 25; bCancel.Top := bCancel.Top - 25; //Self.Height := 255; Self.Height := 265; end else if aBlock.ClassNAme = 'TCircle' then begin FLockChangeEvent := true; Self.pnProportion.Visible := False; Self.pnAddition.Visible := False; Self.pnDimensions.Visible := False; Self.pnPieProp.Visible := True; Self.pnMain.Height := 44; Self.pnPieProp.Height := 44; Self.pnConfirm.Top := 45; Label2.Visible := False; Label6.Visible := False; Label8.Visible := False; Label9.Visible := False; Label7.Top := 12; Label10.Top := 12; edPieRadius.Top := 12; SpinEdit1.Visible := False; SpinEdit2.Visible := False; PnPieProp.AutoSize := True; PnPieProp.AutoSize := False; Self.Height := 220; edPieRadius.Value := RoundX(MetreToUom((TCircle(BlockFigure).Radius * GCadForm.PCad.MapScale) / 1000), 2); if aCaption <> '' then Caption := aCaption; cbSizeToAngle.Visible := False; bOk.Top := bOk.Top - 25; bCancel.Top := bCancel.Top - 25; Self.Height := Self.Height - 25; FLockChangeEvent := False; end else if (aBlock.ClassName = 'TFigureGrp') or (aBlock.ClassName = 'TEllipse') or (aBlock.ClassName = 'TText') or (aBlock.ClassName = 'TRichText') or (aBlock.ClassName = 'TRectangle') or (aBlock.ClassName = 'TArc') or (aBlock.ClassName = 'TElpArc') or (aBlock.ClassName = TPolyLine.ClassNAme) then begin OldFigureAngle := 0; Self.Height := 309; pnAddition.visible := False; PnPieProp.Visible := False; Self.pnMain.Height := 144; //Self.pnConfirm.Visible := True; Self.pnConfirm.Top := 144; Bnd := aBlock.GetBoundRect; // границы блока w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); ZeroAngleW := w; ZeroAngleH := h; // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); // начальные границы блока как есть BaseW := w; // BaseH := h; // FLockChangeEvent := True; // Tolik -- 30/09/2017 edWidth.Value := BaseW; // выставить ширину edHeight.Value := BaseH; // выставить высоту // в процентах к изначальному размеру BaseWProcent := 100; BaseHProcent := 100; edWidthProcent.Value := 100; edHeightProcent.Value := 100; edRotateTo.Value := 0; // угол поворота (изначально = 0) //FAllowProportion := aAllowProportion; FLockChangeEvent := False; // Tolik -- 30/09/2017 // если не эллипс или не прямоугольник, то убираем настройки заливки фигуры if (aBlock.ClassName <> 'TEllipse') then if (aBlock.ClassName <>'TRectangle') then begin Label1.Visible := False; Transparency_Bar.Visible := False; BitBtn1.Visible := False; cbAutoApply.Top := cbAutoApply.Top - 45; ApplyLabel.Top := ApplyLabel.Top - 45; cbSizeToAngle.Top := cbSizeToAngle.Top - 45; bOk.Top := bOk.Top - 45; bCancel.Top := bCancel.Top - 45; Self.Height := Self.Height - 45; end; if aBlock.ClassName <> 'TFigureGrp' then begin cbSizeToAngle.Visible := False; bOk.Top := bOk.Top - 25; bCancel.Top := bCancel.Top - 25; Self.Height := Self.Height - 15; end; end else if (aBlock.ClassName = TLine.ClassName) then // линия begin OldFigureAngle := 0; Self.Height := 309; pnAddition.visible := False; PnPieProp.Visible := False; Self.pnMain.Height := 144; //Self.pnConfirm.Visible := True; Self.pnConfirm.Top := 144; Bnd := aBlock.GetBoundRect; // границы блока w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); ZeroAngleW := w; ZeroAngleH := h; // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); // начальные границы блока как есть BaseW := w; // BaseH := h; // FLockChangeEvent := True; // Tolik -- 30/09/2017 edWidth.Value := BaseW; // выставить ширину edHeight.Value := BaseH; // выставить высоту // в процентах к изначальному размеру BaseWProcent := 100; BaseHProcent := 100; edWidthProcent.Value := 100; edHeightProcent.Value := 100; edRotateTo.Value := 0; // угол поворота (изначально = 0) //FAllowProportion := aAllowProportion; FLockChangeEvent := False; // Tolik -- 30/09/2017 Label1.Visible := False; Transparency_Bar.Visible := False; BitBtn1.Visible := False; cbAutoApply.Top := cbAutoApply.Top - 45; ApplyLabel.Top := ApplyLabel.Top - 45; cbSizeToAngle.Top := cbSizeToAngle.Top - 45; bOk.Top := bOk.Top - 45; bCancel.Top := bCancel.Top - 45; Self.Height := Self.Height - 45; cbSizeToAngle.Visible := False; bOk.Top := bOk.Top - 25; bCancel.Top := bCancel.Top - 25; Self.Height := Self.Height - 25; end else begin // Tolik 14/07/2017 -- Self.pnProportion.Visible := True; //Self.pnAddition.Visible := True; Self.pnDimensions.Visible := True; //Self.pnConfirm.Visible := True; Self.pnMain.Visible := True; Self.pnPieProp.Visible := False; OldFigureAngle := 0;// TFigure(aBlock).AngletoPoint*180/PI; Bnd := aBlock.GetBoundRect; //если не посчитать заранее центральную точку и не выставить Modified = False // то хер что мы получим адекватный угол поворота фигуры //Tfigure(aBlock).RotPoint.x := (Bnd.Right + Bnd.Left)/2; //Tfigure(aBlock).RotPoint.y := (Bnd.Bottom + Bnd.Top)/2; // // w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); ZeroAngleW := w; ZeroAngleH := h; // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); // начальные границы блока как есть BaseW := w; // BaseH := h; // FLockChangeEvent := True; // Tolik -- 30/09/2017 // Tolik -- 09/10/2017 -- // изначальные размеры блока (при нулевом повороте) //ZeroAngleW := BaseW; //ZeroAngleH := BaseH; // {if cbSizeToAngle.Checked then begin} edWidth.Value := BaseW; edHeight.Value := BaseH; {end else begin edWidth.Value := ZeroAngleW; edHeight.Value := ZeroAngleH; end;} BaseWProcent := 100; BaseHProcent := 100; edWidthProcent.Value := 100; edHeightProcent.Value := 100; // Tolik --09/10/2017 -- // показать изначальный угол поворота фигуры edRotateTo.Value := 0; //Round(OldFigureAngle); BeForeFigureAngle := 0; //Round(OldFigureAngle); // //FAllowProportion := aAllowProportion; edWidthProcent.Visible := aAllowPersent; edHeightProcent.Visible := aAllowPersent; edAdditionProcent.Visible := aAllowPersent; edRotateTo.Visible := aAllowPersent; lbWidthProcent.Visible := aAllowPersent; lbHeightProcent.Visible := aAllowPersent; lbAdditionProcent.Visible := aAllowPersent; cbProportions.Visible := aAllowProportion; FLockChangeEvent := False; // Tolik -- 30/09/2017 if aAllowPersent then begin //Height := 182; Width := 269; bOK.Left := 56; bCancel.Left := 152; end else begin // Tolik -- 18/07/2017 -- if (aBlock.ClassName <> 'TRectangle') then if (aBlock.ClassName <> 'TPie') then begin // Width := 269 - 86; bOK.Left := 56 - (86 div 2); bCancel.Left := 152 - (86 div 2); Label1.Visible := False; Transparency_Bar.Visible := False; BitBtn1.Visible := False; {Self.AutoSize := True; Self.AutoSize := False;} end; end; if aAllowProportion then begin //pnMain.Height := 145; //09.01.2013 113; //Height := 211; //09.01.2013 182; end else begin //pnMain.Height := 145 - 52; //09.01.2013 113 - 20; //Height := 211 - 52; //09.01.2013 182 - 20; end; pnProportion.Visible := aAllowProportion; pnMain.AutoSize := True; pnMain.AutoSize := False; pnMain.Height := pnMain.Height + 10; {Self.AutoSize := True; Self.AutoSize := False;} if aCaption <> '' then Caption := aCaption; end; // Tolik 18/07/2017 -- (* if ((aBlock.ClassName = 'TRectangle') or (aBlock.ClassName = 'TPie') or (aBlock.ClassName = 'TEllipse') or (aBlock.ClassName = 'TCircle')) then begin {Self.AutoSize := True; Self.AutoSize := False;} if aBlock.ClassName <> 'TPie' then begin { if aAllowProportion then Self.Height := 280//260//240 else Self.Height := 200;} end else if aBlock.ClassName = 'TPie' then Self.Height := 260;//240; //Tolik 06/10/2017 -- bOK.Left := 47;//50 - (86 div 2); bCancel.Left := 143;//146 - (86 div 2); // BitBtn1.Visible := True; TransParency_bar.Visible := True; Label1.visible := True; bOk.Top := 105;//85;//67; bCancel.Top := 105;//85;//67; // Tolik 10/10/2017 - - {Self.AutoSize := True; Self.AutoSize := False;} Self.Width := 285; if (aBlock.ClassName = 'TPie') then begin //cbAutoApply.Visible := False; //ApplyLabel.Visible := False; cbSizeToAngle.visible := False; bOk.Top := 90; bCancel.Top := 90; Self.Height := 260; end; end else begin {Self.AutoSize := True; Self.AutoSize := False;} {Self.Height := 200;} {BitBtn1.Visible := False; TransParency_bar.Visible := False; Label1.visible := False; bOk.Top := 11; bCancel.Top := 11; } end; *) if ShowModal = mrOK then // если ок -- ок begin Result := True; GCadForm.BeginSaveForUndo(uat_None, False, False); try if BlockFigure.ClassName = 'TPie' then begin if ApplyLabel.Enabled then TPie(BlockFigure).Radius := (edPieRaDius.Value / GCadForm.PCad.MapScale) * 1000; end else begin { NewW := edWidth.Value; NewH := edHeight.Value; ScaleKoefW := NewW / BaseW; ScaleKoefH := NewH / BaseH; aBlock.Scale(ScaleKoefW, ScaleKoefH, aBlock.ap1); // Tolik -- 26/05/2017 -- //aBlock.Brc := FigureBrushColor; //aBlock.Transparency := Transparency_Bar.Position; // if edRotateTo.Value <> 0 then RotateFigure(aBlock, edRotateTo.Value);} end; finally GCadForm.EndSaveForUndo; end; end else // есди не ОК -- возврат значений обратно (како было до....) begin aBlock.Brc := oldFigureBrushColor; aBlock.Transparency := OldFigureTransparency; if aBlock.ClassName = 'TPie' then TPie(aBlock).Radius := OldPieRadius; if OldFigureBrs <> -1 then aBlock.Brs := OldFigureBrs; aBlock.Brs := OldFigureBrushStyle; end; if aCaption <> '' then Caption := FSrcCaption; GCadForm.PCad.Refresh; except on E: Exception do AddExceptionToLogEx('TF_BlockParams.Execute', E.Message); end; end; // Tolik 30/09/2017 -- Procedure TF_BlockParams.RecalcSizeToAngle; begin if ApplyLabel.Enabled then ApplyLabel.OnClick(Self) else begin end; end; procedure TF_BlockParams.ScaleRichText(px,py: Double; aFigure: TFigure{rPoint: TDoublepoint}); var a: integer; oldcp, newcp: TDoublePoint; rt: TRichText; deltax, deltay: double; begin // если TRichText - подогнать шрифт под область for a:= 1 to TRichText(aFigure).pointcount do begin TRichText(aFigure).actualpoints[a] := ScalePoint(TRichText(aFigure).AP1,TRichText(aFigure).actualpoints[a],px,py); TRichText(aFigure).originalpoints[a] := ScalePoint(TRichText(aFigure).ap1,TRichText(aFigure).originalpoints[a],px,py); end; TRichText(aFigure).radius := TRichText(aFigure).radius * px; if TRichText(aFigure).DimLines.Count > 0 then TRichText(aFigure).CreateDimLines; TRichText(aFigure).ResetRegion; end; Procedure TF_BlockParams.ScaleblockToNormalSize; var ScaleKoefW, ScaleKoefH: Double; Bnd: TDoubleRect; w, h: double; TempAngle: double; var i: integer; begin if Blockfigure <> nil then if not BlockFigure.Deleted then //if BlockFigure.ClassName = 'TFigureGRP' then begin Bnd := BlockFigure.GetBoundRect; w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); // перевести в метры {w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); ScaleKoefW := BaseW/w; ScaleKoefH := BaseH/h; } ScaleKoefW := ZeroAngleW/w; ScaleKoefH := ZeroAngleH/h; if ((ScaleKoefW <> 1) or (ScaleKoefH <> 1)) then begin if BlockFigure.ClassName = TRichText.ClassName then ScaleRichText(ScaleKoefW, ScaleKoefH, BlockFigure) else begin if BlockFigure.ClassName = TFigureGRP.ClassName then TFigureGrp(BlockFigure).Scale(ScaleKoefW, ScaleKoefH) else BlockFigure.Scale(ScaleKoefW, ScaleKoefH, BlockFigure.ap1); { if BlockFigure.ClassName = TFigureGRP.ClassName then begin for i := 0 to TFigureGrp(BlockFigure).InFigures.Count - 1 do begin if TFigure(TFigureGrp(BlockFigure).InFigures[i]).ClassName = TRichText.ClassName then ScaleRichText(ScaleKoefW,ScaleKoefH, TRichText(TFigureGrp(BlockFigure).InFigures[i])); end; end; } end; end; end; end; Procedure TF_BlockParams.ScaleBlockToValues; var NewW, ScaleKoefW, NewH, ScaleKoefH: Double; Bnd: TDoubleRect; w, h: double; TempAngle: Double; Refreshflag: Boolean; BlockCP: TDoublePoint; begin if BlockFigure <> nil then if not BlockFigure.deleted then begin // Tolik 30/09/2017 -- NewW := edWidth.Value; if NewW <> 0 then begin refreshflag := GCanRefreshCad; GCanRefreshCad := False; FLockChangeEvent := True; try NewH := edHeight.Value; if NewH <> 0 then begin ScaleKoefW := NewW / BaseW; ScaleKoefH := NewH / BaseH; if BlockFigure.ClassName = TFigureGRP.ClassName then if cbSizeToAngle.Checked then begin bnd := BlockFigure.GetBoundRect; w := bnd.Right - bnd.Left; h := bnd.Bottom - bnd.Top; // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); ScaleKoefW := NewW/w; ScaleKoefH := NewH/h; end; TempAngle := 0; //если угол поворота поменялся -- довернуть фигуру if CompareValue(BeForeFigureAngle, edRotateTo.Value) <> 0 then begin //поворот RotateFigure(BlockFigure, edRotateTo.Value - BeforeFigureAngle); BeforeFigureAngle := edRotateTo.Value; end; if BlockFigure.ClassName <> TFigureGRP.ClassName then begin if BeForeFigureAngle <> 0 then // повернуть в 0, чтобы отмасштабировать в нормальный размер begin RotateFigure(BlockFigure, 0 - BeforeFigureAngle); end; end; begin if BlockFigure.ClassName = TRichText.ClassName then begin ScaleBlockToNormalSize; if (ScaleKoefW <> 1) or (ScaleKoefH <> 1) then // если размер поменялся - скейлим, если нет - нех ScaleRichText(ScaleKoefW, ScaleKoefH, BlockFigure); // end else if BlockFigure.ClassName = TFigureGrp.ClassName then begin if (edHeight.Value <> 0) and (edWidth.Value <> 0) and // если нет нулевых значений (потому как хер что потом вернешься с нуля к) (edHeightProcent.Value <> 0) and (edWidthProcent.Value <> 0) then // изначальным значениям begin NewH := edHeight.Value; NewW := edWidth.Value; // Если размеры относительно угла поворота if cbSizeToAngle.Checked then begin bnd := BlockFigure.GetBoundRect; h := Bnd.Bottom - Bnd.Top; w := Bnd.Right - Bnd.Left; // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); ScaleKoefW := NewW/w; ScaleKoefH := NewH/h; if ((ScaleKoefW <> 1) and (ScaleKoefH <> 1)) then BlockFigure.Scale(ScaleKoefW, ScaleKoefH); end // Если не относительно угла поворота else begin if BeforeFigureAngle <> 0 then RotateFigure(BlockFigure, 0 - BeforeFigureAngle); ScaleBlockToNormalSize; ScaleKoefW := NewW/BaseW; ScaleKoefH := NewH/BaseH; if ((ScaleKoefW <> 1) and (ScaleKoefH <> 1)) then BlockFigure.Scale(ScaleKoefW, ScaleKoefH); if BeforeFigureAngle <> 0 then RotateFigure(BlockFigure, BeforeFigureAngle); end; end; end else begin ScaleBlockToNormalSize; if (ScaleKoefW <> 1) or (ScaleKoefH <> 1) then // если размер поменялся - скейлим, если нет - нех BlockFigure.Scale(ScaleKoefW, ScaleKoefH, BlockFigure.ap1); // end; end; if BlockFigure.ClassName <> TFigureGrp.ClassName then begin if BeforeFigureAngle <> 0 then RotateFigure(BlockFigure, BeforeFigureAngle); end; bnd := BlockFigure.GetBoundRect; BlockCP.x := (bnd.Left + bnd.Right)/2; BlockCp.y := (bnd.Top + bnd.Bottom)/2; BlockFigure.Move(BlockCenterPoint.x - BlockCP.x, BlockCenterPoint.y - BlockCP.y); end; Except On E: Exception do; end; GCanRefreshCad := refreshflag; if GCadForm <> nil then GCadForm.PCad.Refresh; FLockChangeEvent := False; end; // end; end; // procedure TF_BlockParams.CalcPercentValues(CalcWidth, CalcHeight: Boolean); var w,h: Double; Bnd: TDoubleRect; TempAngle: Integer; RefreshFlag: Boolean; Valint: Integer; begin If BlockFigure.ClassName = TFigureGrp.ClassName then begin RefreshFlag := GCanRefreshCad; GCanRefreshCad := False; FLockChangeEvent := True; try TempAngle := edRotateTo.Value; if TempAngle <> 0 then RotateFigure(BlockFigure, 0 - TempAngle); Bnd := BlockFigure.GetBoundRect; w := bnd.Right - bnd.Left; h := bnd.Bottom - bnd.Top; w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); //FLockChangeEvent := True; // пересчитать ширину в процентах if CalcWidth then begin ValInt := Round(100 * (w/BaseW)); edWidthProcent.Value := ValInt; end; //пересчитать высоту в процентах if CalcHeight then begin ValInt := Round(100 * (h/BaseH)); edHeightProcent.Value := ValInt; end; FLockChangeEvent := False; if TempAngle <> 0 then RotateFigure(BlockFigure, TempAngle); Except on E: Exception do; end; GCanRefreshCad := RefreshFlag; FLockChangeEvent := False; // на всякий end; end; procedure TF_BlockParams.edWidthPropertiesChange(Sender: TObject); var CurrVal: Double; ValDbl: Double; ValInt: Integer; Koef: Double; tFile: TextFile; TempAngle: Integer; Bnd: TDoubleRect; w, h: Double; begin try if not FLockChangeEvent then begin if edWidth.Value <> 0 then begin FLockChangeEvent := True; if BlockFigure.ClassName = TFigureGrp.ClassName then begin // групповая фигура if cbSizeToAngle.Checked then begin Bnd := BlockFigure.GetBoundRect; w := Bnd.Right - Bnd.Left; h := Bnd.Bottom - bnd.Top; w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); Koef := edWidth.Value/w; if cbProportions.Checked then begin ValDbl := h * Koef; edHeight.Value := BriefFormat(ValDbl); CalcPercentValues(True, True); // высота в процентах // ValInt := Round(100 * Koef); // edHeightProcent.Value := ValInt; end else CalcPercentValues(True, False); // ширина в процентах //ValInt := Round(100 * Koef); //edWidthProcent.Value := ValInt; end else begin // соблюдать пропорции if FAllowProportion and cbProportions.Checked then begin Koef := edWidth.Value / BaseW; // высота ValDbl := BaseH * Koef; edHeight.Value := BriefFormat(ValDbl); // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; // end else // не соблюдать begin // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; end; end; end else begin // не групповая фигура // соблюдать пропорции if FAllowProportion and cbProportions.Checked then begin Koef := edWidth.Value / BaseW; // высота ValDbl := BaseH * Koef; edHeight.Value := BriefFormat(ValDbl); // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; // end else // не соблюдать begin // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; end; end; FLockChangeEvent := False; if cbAutoApply.Checked then ScaleBlockToValues else ApplyLabel.Enabled := True; {assignfile(TFile, 'd:\NODebug.txt'); if FileExists('d:\NODebug.txt') then Append(TFile) else rewrite(TFile); Writeln(TFile, 'AP1.x = ' + Floattostr(BlockFigure.ap1.x) + 'AP1.y = ' + Floattostr(BlockFigure.ap1.y)); CloseFile(TFile);} end; end; except on E: Exception do AddExceptionToLogEx('TF_BlockParams.edWidthPropertiesChange', E.Message); end; end; procedure TF_BlockParams.edHeightPropertiesChange(Sender: TObject); var CurrVal: Double; ValDbl: Double; ValInt: Integer; Koef: Double; bnd: TDoubleRect; h, w: Double; begin try if not FLockChangeEvent then begin if edHeight.Value <> 0 then begin FLockChangeEvent := True; if BlockFigure.ClassName = TFigureGrp.ClassName then begin // групповая фигура if cbSizeToAngle.Checked then begin Bnd := BlockFigure.GetBoundRect; h := Bnd.Bottom - Bnd.Top; w := Bnd.Right - Bnd.Left; h := h * GCadForm.PCad.MapScale / 1000; w := w * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ h := MetreToUOM(h); w := MetreToUOM(w); Koef := edHeight.Value/h; if cbProportions.Checked then begin ValDbl := w * Koef; edwidth.Value := BriefFormat(ValDbl); // ширина в процентах {ValInt := Round(100 * Koef); edWidthProcent.Value := ValInt;} CalcPercentValues(True, True); end else CalcPercentValues(False, True); // высота в процентах { ValInt := Round(100 * Koef); edHeightProcent.Value := ValInt;} end else begin // соблюдать пропорции if FAllowProportion and cbProportions.Checked then begin Koef := edHeight.Value / BaseH; // высота ValDbl := Basew * Koef; edWidth.Value := BriefFormat(ValDbl); // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; // end else // не соблюдать begin // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; end; end; end else begin // соблюдать пропорции if FAllowProportion and cbProportions.Checked then begin Koef := edHeight.Value / BaseH; // ширина ValDbl := BaseW * Koef; edWidth.Value := BriefFormat(ValDbl); // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; end else // не соблюдать begin // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; end; end; FLockChangeEvent := False; if cbAutoApply.Checked then ScaleBlockToValues else ApplyLabel.Enabled := True; end; end; except on E: Exception do AddExceptionToLogEx('TF_BlockParams.edHeightPropertiesChange', E.Message); end; end; procedure TF_BlockParams.edWidthProcentPropertiesChange(Sender: TObject); var CurrVal: Double; ValDbl: Double; ValInt: Integer; Koef: Double; begin try if not FLockChangeEvent then begin // Tolik 30/09/2017 - - if edWidthProcent.Value <> 0 then begin // соблюдать пропорции FLockChangeEvent := True; if FAllowProportion and cbProportions.Checked then begin // ширина ValDbl := (edWidthProcent.Value * BaseW / BaseWProcent); edWidth.Value := BriefFormat(ValDbl); // высота Koef := edWidth.Value / BaseW; ValDbl := BaseH * Koef; edHeight.Value := BriefFormat(ValDbl); // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; end else // не соблюдать begin // ширина ValDbl := (edWidthProcent.Value * BaseW / BaseWProcent); edWidth.Value := BriefFormat(ValDbl); end; // Tolik 30/09/2017 -- if cbAutoApply.Checked then ScaleBlockToValues else ApplyLabel.Enabled := True; // end; FLockChangeEvent := False; end; except on E: Exception do AddExceptionToLogEx('TF_BlockParams.edWidthProcentPropertiesChange', E.Message); end; end; procedure TF_BlockParams.edHeightProcentPropertiesChange(Sender: TObject); var CurrVal: Double; ValDbl: Double; ValInt: Integer; Koef: Double; begin try if not FLockChangeEvent then begin // Tolik 30/09/2017 -- if edHeightProcent.Value <> 0 then begin FLockChangeEvent := True; // соблюдать пропорции if FAllowProportion and cbProportions.Checked then begin // высота ValDbl := (edHeightProcent.Value * BaseH / BaseHProcent); edHeight.Value := BriefFormat(ValDbl); // ширина Koef := edHeight.Value / BaseH; ValDbl := BaseW * Koef; edWidth.Value := BriefFormat(ValDbl); // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; end else // не соблюдать begin // высота ValDbl := (edHeightProcent.Value * BaseH / BaseHProcent); edHeight.Value := BriefFormat(ValDbl); end; // Tolik 30/09/2017 -- if cbAutoApply.Checked then ScaleBlockToValues else ApplyLabel.Enabled := True; end; FLockChangeEvent := False; end; except on E: Exception do AddExceptionToLogEx('TF_BlockParams.edHeightProcentPropertiesChange', E.Message); end; end; procedure TF_BlockParams.edWidthKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin if edWidth.Value > 10000 then edWidth.Value := 10000; end; procedure TF_BlockParams.edHeightKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin if edHeight.Value > 10000 then edHeight.Value := 10000; end; procedure TF_BlockParams.FormCreate(Sender: TObject); begin FSrcCaption := Caption; // Tolik Label8.Caption := CHR(176); Label9.Caption := CHR(176); BlockFigure := nil; // end; procedure TF_BlockParams.edAdditionProcentPropertiesChange( Sender: TObject); var CurrVal: Double; ValDbl: Double; ValInt: Integer; Koef: Double; begin end; // Tolik -- заливка и прозрачность procedure TF_BlockParams.aDefFigureFillColorExecute(Sender: TObject); begin try F_LoadColor.ColorPicker.DefaultColor := clBlack; F_LoadColor.ColorPicker.SelectedColor := FigureBrushColor; // Tolik --06/10/2017 -- F_LoadColor.ShowModal; if F_LoadColor.ColorPicker.SelColorIndex <> -1 then begin FigureBrushColor := F_LoadColor.ColorPicker.SelectedColor; if BlockFigure <> nil then begin BlockFigure.Brc := FigureBrushColor; if BlockFigure.Brs = 1 then begin BlockFigure.Brs := 0; end; BlockFigure.DrawFill(GCadForm.PCad.DEngine, False); end; end else begin if BlockFigure <> nil then begin BlockFigure.Brs := 1; BlockFigure.DrawFill(GCadForm.PCad.DEngine, False); end; end; GCadForm.PCad.Refresh; except on E: Exception do addExceptionToLogEx('TF_BlockParams.aBrushColorExecute', E.Message); end; end; procedure TF_BlockParams.Transparency_BarChange(Sender: TObject); begin if not FLockChangeEvent then begin if BlockFigure <> nil then begin Transparency_Bar.Hint := IntToStr(F_BlockParams.Transparency_Bar.Position); BlockFigure.Transparency := F_BlockParams.Transparency_Bar.Position; end; GCadForm.PCad.Refresh; end; end; // procedure TF_BlockParams.SpinEdit1Change(Sender: TObject); begin if not FLockChangeEvent then begin if BlockFigure.ClassName = 'TPie' then begin if cbAutoApply.Checked then begin TPie(BlockFigure).Sangle := (SpinEdit1.Value/180)*PI; GCadForm.PCad.refresh; end else ApplyLabel.Enabled := True; end; end; end; procedure TF_BlockParams.SpinEdit2Change(Sender: TObject); begin if BlockFigure.ClassName = 'TPie' then begin if not FLockChangeEvent then begin if cbAutoApply.Checked then begin TPie(BlockFigure).Fangle := (SpinEdit2.Value/180)*PI; GCadForm.PCad.refresh; end else ApplyLabel.Enabled := True; end; end; end; {procedure TF_BlockParams.cxSpinEdit1Change(Sender: TObject); begin if BlockFigure.ClassName = 'TPie' then begin if CompareValue(Roundx(TPie(BlockFigure).Radius), Double(cxSpinEdit1.value)) <> 0 then begin TPie(BlockFigure).Radius := SpinEdit3.Value; GCadForm.PCad.refresh; end; end; end; } Procedure TF_BlockParams.SetValuesToBounds(aWithPercentage: boolean); // вывести реальные значения после поворота (если размеры не относительно угла поворота) var Bnd: TDoubleRect; w, h: double; NewW, NewH: Double; ValInt: Double; begin Bnd := BlockFigure.GetBoundRect; w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); FLockChangeEvent := True; edWidth.Value := w; edHeight.Value := h; if aWithPercentage then begin if cbSizeToAngle.Checked then begin // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; end else begin // ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; end; end; FLockChangeEvent := False; end; // Tolik 30/09/2017 -- procedure TF_BlockParams.bCancelClick(Sender: TObject); var RefreshFlag: Boolean; begin RefreshFlag := GCanrefreshCad; GCanRefreshCad := False; try //GCadForm.SCSUndoNormalList; GCadForm.PCad.UnDo; if not GProjectChanged then // Tolik 28/08/2019 -- SetProjectChanged(True); Except on E: Exception do; end; GCanRefreshCad := RefreshFlag; GCadForm.PCad.Refresh; BlockFigure := nil; end; procedure TF_BlockParams.edRotateToPropertiesChange(Sender: TObject); var Bnd: TDoubleRect; w,h: double; ValInt: Integer; BlockCP: TDoublePoint; refreshFlag: Boolean; begin RefreshFlag := GCanRefreshCad; GCanRefreshCad := False; try //if edRotateTo.Value <> 0 then if not FLockChangeEvent then // Tolik 13/10/2017 -- begin if cbAutoApply.Checked then begin if CompareValue(edRotateTo.Value, BeForeFigureAngle) <> 0 then begin RotateFigure(BlockFigure, edRotateTo.Value - BeForeFigureAngle); BeForeFigureAngle := edRotateTo.Value; end; if BlockFigure.ClassName = TFigureGRP.ClassName then begin if cbSizeToAngle.Checked then begin Bnd := BlockFigure.GetBoundRect; w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); // начальные границы блока как есть //BaseW := w; //BaseH := h; FLockChangeEvent := True; // Tolik -- 30/09/2017 edWidth.Value := W; // выставить ширину edHeight.Value := H; // выставить высоту //ширина в процентах ValInt := Round(edWidth.Value * BaseWProcent / BaseW); edWidthProcent.Value := ValInt; // высота в процентах ValInt := Round(edHeight.Value * BaseHProcent / BaseH); edHeightProcent.Value := ValInt; FLockChangeEvent := False; end end; // если снова выкрутили на 0 - выставляем центр //if BeforeFigureAngle = 0 then {begin Bnd := BlockFigure.GetBoundRect; BlockCenterPoint.x := (bnd.Left + bnd.Right)/2; BlockCenterPoint.y := (bnd.Top + bnd.Bottom)/2; end;} {bnd := BlockFigure.GetBoundRect; BlockCP.x := (bnd.Left + bnd.Right)/2; BlockCp.y := (bnd.Top + bnd.Bottom)/2; BlockFigure.Move(BlockCenterPoint.x - BlockCP.x, BlockCenterPoint.y - BlockCP.y);} end else begin if not FLockChangeEvent then ApplyLabel.Enabled := True; end; Bnd := BlockFigure.GetBoundRect; BlockCP.x := (Bnd.Right + Bnd.Left)/2; BlockCP.y := (Bnd.Top + Bnd.Bottom)/2; BlockFigure.Move(BlockCenterPoint.x - BlockCP.x, BlockCenterPoint.y - BlockCP.y); end; Except on E: Exception do; end; FLockChangeEvent := False; // на всякий GCanRefreshCad := RefreshFlag; GCadForm.PCad.Refresh; end; // procedure TF_BlockParams.ApplyLabelClick(Sender: TObject); var Bnd: TDoubleRect; RefreshFlag: Boolean; w,h, NewH, NewW: double; ScaleKoefW,ScaleKoefH: double; TempAngle: Integer; BlockCP: TDoublePoint; begin RefreshFlag := GCanRefreshCad; GCanRefreshCad := False; try begin if BlockFigure.ClassName = 'TPie' then begin TPie(BlockFigure).Fangle := (SpinEdit2.Value/180)*PI; TPie(BlockFigure).Sangle := (SpinEdit1.Value/180)*PI; TPie(BlockFigure).Radius := (edPieRadius.Value / GCadForm.PCad.MapScale) * 1000; //GCadForm.PCad.refresh; end else if BlockFigure.ClassName = 'TCircle' then begin if edPieRadius.Value <> 0 then begin TCircle(BlockFigure).Radius := (edPieRadius.Value / GCadForm.PCad.MapScale) * 1000; end; end else if BlockFigure.ClassName = TFigureGrp.ClassName then begin if (edHeight.Value <> 0) and (edWidth.Value <> 0) and // если нет нулевых значений (потому как хер что потом вернешься с нуля к) (edHeightProcent.Value <> 0) and (edWidthProcent.Value <> 0) then // изначальным значениям begin NewH := edHeight.Value; NewW := edWidth.Value; //если угол поворота поменялся if CompareValue(BeForeFigureAngle, edRotateTo.Value) <> 0 then begin //поворот RotateFigure(BlockFigure, edRotateTo.Value - BeforeFigureAngle); BeforeFigureAngle := edRotateTo.Value; end; // Если размеры относительно угла поворота if cbSizeToAngle.Checked then begin bnd := BlockFigure.GetBoundRect; h := Bnd.Bottom - Bnd.Top; w := Bnd.Right - Bnd.Left; // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); ScaleKoefW := NewW/w; ScaleKoefH := NewH/h; if ((ScaleKoefW <> 1) and (ScaleKoefH <> 1)) then BlockFigure.Scale(ScaleKoefW, ScaleKoefH); end // Если не относительно угла поворота else begin if BeforeFigureAngle <> 0 then RotateFigure(BlockFigure, 0 - BeforeFigureAngle); ScaleBlockToNormalSize; ScaleKoefW := NewW/BaseW; ScaleKoefH := NewH/BaseH; if ((ScaleKoefW <> 1) and (ScaleKoefH <> 1)) then BlockFigure.Scale(ScaleKoefW, ScaleKoefH); if BeforeFigureAngle <> 0 then RotateFigure(BlockFigure, BeforeFigureAngle); end; bnd := BlockFigure.GetBoundRect; BlockCP.x := (bnd.Left + bnd.Right)/2; BlockCp.y := (bnd.Top + bnd.Bottom)/2; BlockFigure.Move(BlockCenterPoint.x - BlockCP.x, BlockCenterPoint.y - BlockCP.y); end; end else begin if (edHeight.Value <> 0) and (edWidth.Value <> 0) and // если нет нулевых значений (потому как хер что потом вернешься с нуля к) (edHeightProcent.Value <> 0) and (edWidthProcent.Value <> 0) then // изначальным значениям begin ScaleBlockToValues; { if CompareValue(BeForeFigureAngle, edRotateTo.Value) <> 0 then // поворот begin RotateFigure(BlockFigure, edRotateTo.Value - BeForeFigureAngle); BeForeFigureAngle := edRotateTo.Value; if BeforeFigureAngle = 0 then begin // 23/10/2017 //BlockCenterPoint.x := (bnd.Left + bnd.Right)/2; //BlockCenterPoint.y := (bnd.Top + bnd.Bottom)/2; end; end; bnd := BlockFigure.GetBoundRect; BlockCP.x := (bnd.Left + bnd.Right)/2; BlockCp.y := (bnd.Top + bnd.Bottom)/2; BlockFigure.Move(BlockCenterPoint.x - BlockCP.x, BlockCenterPoint.y - BlockCP.y); {if cbSizeToAngle.Checked then // SetValuesToBounds; SetValuesToBounds(True);} end; end; end; F_BlockParams.ApplyLabel.Enabled := False; Except on E: exception do; end; GCanRefreshCad := RefreshFlag; GCadForm.PCad.Refresh; end; procedure TF_BlockParams.bOKClick(Sender: TObject); begin if ApplyLabel.Enabled then begin ApplyLabelClick(self); {ScaleBlockToValues; RotateFigure(BlockFigure, edRotateTo.Value - BeForeFigureAngle);} //BeForeFigureAngle := edRotateTo.Value; ApplyLabel.Enabled := False; end; end; procedure TF_BlockParams.cbAutoApplyClick(Sender: TObject); begin if F_BlockParams.cbAutoApply.Checked then if F_BlockParams.ApplyLabel.Enabled then F_BlockParams.ApplyLabelClick(Self); end; procedure TF_BlockParams.cbSizeToAngleClick(Sender: TObject); var Bnd: TDoubleRect; w, h: Double; TempAngle: double; RefreshFlag: Boolean; BlockCP: TDoublePoint; begin // если показать размеры относительно угла поворота - пересчитываем // границы относительно поворота // ТОЛЬКО ДЛЯ ГРУППОВЫХ ФИГУР !!! if cbAutoApply.Checked then begin if BlockFigure.ClassName = TFigureGrp.ClassName then begin if F_BlockParams.cbSizeToAngle.Checked then begin Bnd := BlockFigure.GetBoundRect; w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); FLockChangeEvent := True; edWidth.Value := w; edHeight.Value := h; w := w/BaseW*100; h := h/BaseH*100; w := BriefFormat(w); h := BriefFormat(h); edWidthProcent.Value := w; edHeightProcent.Value := h; FLockChangeEvent := False; end else begin Tempangle := edRotateTo.Value;//*PI/180; RefreshFlag := GCanRefreshCad; GCanRefreshCad := False; // чтобы не передернуло вигуру на Каде try if edRotateTo.Value <> 0 then RotateFigure(BlockFigure, 0 - TempAngle); // поворот в исходное положение Bnd := BlockFigure.GetBoundRect; w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); FLockChangeEvent := True; edWidth.Value := w; edHeight.Value := h; w := w/BaseW*100; h := h/BaseH*100; w := BriefFormat(w); h := BriefFormat(h); edWidthProcent.Value := w; edHeightProcent.Value := h; FLockChangeEvent := False; if edRotateTo.Value <> 0 then begin RotateFigure(BlockFigure, TempAngle); // повернуть обратно как было //ApplyLabel.Enabled := True; end; Bnd := BlockFigure.GetBoundRect; BlockCP.x := (Bnd.Right + Bnd.Left)/2; BlockCP.y := (Bnd.Top + Bnd.Bottom)/2; BlockFigure.Move(BlockCenterPoint.x - BlockCP.x, BlockCenterPoint.y - BlockCP.y); Except on E: Exception do; end; FLockChangeEvent := False; // на всякий GCanRefreshCad := RefreshFlag; GCadForm.PCad.refresh; end; end; end else // если галочка снята - пересчитываем реальный размер блока begin if BlockFigure.ClassName = TFigureGrp.ClassName then begin Tempangle := edRotateTo.Value;//*PI/180; RefreshFlag := GCanRefreshCad; GCanRefreshCad := False; // чтобы не передернуло вигуру на Каде try if edRotateTo.Value <> 0 then RotateFigure(BlockFigure, 0 - TempAngle); // поворот в исходное положение Bnd := BlockFigure.GetBoundRect; w := abs(Bnd.Right - Bnd.Left); h := abs(Bnd.Bottom - Bnd.Top); // перевести в метры w := w * GCadForm.PCad.MapScale / 1000; h := h * GCadForm.PCad.MapScale / 1000; // перевести в нужную СИ w := MetreToUOM(w); h := MetreToUOM(h); w := BriefFormat(w); h := BriefFormat(h); FLockChangeEvent := True; edWidth.Value := w; edHeight.Value := h; w := w/BaseW*100; h := h/BaseH*100; { w := BriefFormat(w); h := BriefFormat(h); edWidthProcent.Value := w; edHeightProcent.Value := h;} FLockChangeEvent := False; if edRotateTo.Value <> 0 then begin RotateFigure(BlockFigure, TempAngle); // повернуть обратно как было ApplyLabel.Enabled := True; end; Bnd := BlockFigure.GetBoundRect; BlockCP.x := (Bnd.Right + Bnd.Left)/2; BlockCP.y := (Bnd.Top + Bnd.Bottom)/2; BlockFigure.Move(BlockCenterPoint.x - BlockCP.x, BlockCenterPoint.y - BlockCP.y); except on E: Exception do; end; FLockChangeEvent := False; GCanRefreshCad := RefreshFlag; // вернуть флаг разрешения обновления Када - как было GCadForm.PCad.refresh; end; end; end; procedure TF_BlockParams.edPieRadiusPropertiesChange(Sender: TObject); begin if not FLockChangeEvent then // Tolik 13/10/2017 -- begin if cbAutoApply.Checked then begin if edPieRadius.Value <> 0 then begin //Tolik 08/10/2021 -- //TPie(BlockFigure).Radius := (EdPieRadius.Value / GCadForm.PCad.MapScale) * 1000; TPie(BlockFigure).Radius := UomToMetre(EdPieRadius.Value / GCadForm.PCad.MapScale) * 1000; GCadForm.PCad.Refresh; end; end else ApplyLabel.Enabled := True; end; end; end.