Restore a zoom
Moderators: SDS, support, admin
Restore a zoom
Hi,
For my software i need to re-created a new TSgImage some times (when i add or remove entityes, then a re-load all entities (just some insert)).
So i have a procedure New_Drawing who free my sgimage and the create another (who loadfile a empty dwg file to be initialized). After i redraw all my datas. (your compoment is so quick than it's not a problem for my soft [;)]).
But i would like restore the zoom that i have on the last sgimage to the new sgimage.
I try (we have bought the source), to save a TsgScale and then on the new sgimage i add fonction who add my TsgScale to FPrevScal and then call PrevScale.
But this doesn't working !
Do you have a idea ?
Thanks
Best Regards
E.Jourde
For my software i need to re-created a new TSgImage some times (when i add or remove entityes, then a re-load all entities (just some insert)).
So i have a procedure New_Drawing who free my sgimage and the create another (who loadfile a empty dwg file to be initialized). After i redraw all my datas. (your compoment is so quick than it's not a problem for my soft [;)]).
But i would like restore the zoom that i have on the last sgimage to the new sgimage.
I try (we have bought the source), to save a TsgScale and then on the new sgimage i add fonction who add my TsgScale to FPrevScal and then call PrevScale.
But this doesn't working !
Do you have a idea ?
Thanks
Best Regards
E.Jourde
Hello Jourde,
Thank you for the question.
We will answer you soon.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Thank you for the question.
We will answer you soon.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Hello Jourde,
We recommend to use the following way:
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
We recommend to use the following way:
Code: Select all
<b>uses</b>
... DXFConv, DXFImage, sgConsts, SGImage;
<b>type</b>
TForm1 = <b>class</b>(TForm)
...
sgImage1: TsgImage;
btnPreviousView: TButton;
btnGetScale: TButton;
...
<b>procedure</b> btnOpenClick(Sender: TObject);
<b>procedure</b> btnPreviousViewClick(Sender: TObject);
<b>procedure</b> btnGetScaleClick(Sender: TObject);
<b>private</b>
<font color="blue"><i>{ Private declarations }</i></font id="blue">
PrevScale: Single;
CenterPoint: TFPoint;
FImg: TsgDXFImage;
...
<b>procedure</b> TForm1.btnOpenClick(Sender: TObject);
<b>begin</b>
sgImage1.Align := alClient;
sgImage1.LoadFromFile(<font color="blue">'c:\Test.dxf'</font id="blue">);
<b>if</b> sgImage1.Picture.Graphic <b>is</b> TsgDXFImage <b>then</b>
FImg := TsgDXFImage(sgImage1.Picture.Graphic)
<b>else
begin</b>
FImg := <b>nil</b>;
Exit;
<b>end</b>;
<b>end</b>;
<b>procedure</b> TForm1.btnGetScaleClick(Sender: TObject);
<b>begin</b>
PrevScale := sgImage1.Scale;
CenterPoint := FImg.GetCADCoords(((sgImage1.Parent.ClientRect.Right - sgImage1.Parent.ClientRect.Left) /<font color="blue">2</font id="blue"> -sgImage1.Left) /sgImage1.Width,
<font color="blue">1</font id="blue"> - ((sgImage1.Parent.ClientRect.Bottom - sgImage1.Parent.ClientRect.Top)/<font color="blue">2</font id="blue"> - sgImage1.Top) /sgImage1.Height);
<b>end</b>;
<b>procedure</b> TForm1.btnPreviousViewClick(Sender: TObject);
<b>var</b>
FPoint: TFPoint;
FRect: TFRect;
<b>procedure</b> CalcParamsForShowPoint(<b>var</b> Location: TFPoint;
AsgImage: TsgImage; <b>var</b> APoint: TFPoint; <b>var</b> ARect: TFRect);
<b>var</b>
vPoint: TPoint;
vRect: TRect;
R: Double;
<b>begin</b>
vPoint := FImg.GetPoint(Location);
APoint := MakeFPoint(vPoint.X, vPoint.Y, <font color="blue">0</font id="blue">);
vRect := AsgImage.PictureRect;
<b>if</b> AsgImage.UsePictureRect <b>then
begin</b>
vRect.Left := vRect.Left - AsgImage.Left;
vRect.Right := vRect.Right - AsgImage.Left;
vRect.Top := vRect.Top - AsgImage.Top;
vRect.Bottom := vRect.Bottom - AsgImage.Top;
<b>end</b>;
ARect := MakeFRect(vRect.Left, vRect.Top, <font color="blue">0</font id="blue">, vRect.Right, vRect.Bottom, <font color="blue">0</font id="blue">);
<b>if not</b> AsgImage.UsePictureRect <b>then
begin</b>
APoint.X := APoint.X + ARect.Left;
APoint.Y := APoint.Y + ARect.Top;
<b>end</b>;
<font color="blue"><i>//The TFRect top must be greater than bottom</i></font id="blue">
R := ARect.Top;
ARect.Top := ARect.Bottom;
ARect.Bottom := R;
<b>end</b>;
<b>begin
if</b> FImg = <b>nil then</b>
Exit;
FRect := FImg.Extents;
CalcParamsForShowPoint(CenterPoint, sgImage1, FPoint, FRect);
sgImage1.ShowPoint(FPoint, PrevScale * <font color="blue">100</font id="blue">, FRect);
<b>end</b>;
Please post questions to the forum or write to support@cadsofttools.com