panning and scaling by function (ShowRect)
Moderators: SDS, support, admin
panning and scaling by function (ShowRect)
Hi Sergey,
I was checking newly introduced method - TsgDrawingNavigator.ShowRect to pan/scale the loaded DXF image. What I observed is the result of calling the method, for different direction of view (and rotation angle also), is not consistent. I feel it is dependent on the order of L-T-R-B of TFRect that is passed to the method as argument. I tried swapping LT with RB for a given TFRect and specifying other diagonal point for the same TFRect, to verify this.
Is there any relation between the TFRect elements and direction of view.
It is nearly correct for Top, SE and NW isometric view. For NW view I was required to interchange the LT with RB, to get the desired result. For SW and NE view I could not get the desired view no matter what I did. Is it a know issue and is there any workaround to make it work.
Please guide me.
Thanks & regards,
Avinash
I was checking newly introduced method - TsgDrawingNavigator.ShowRect to pan/scale the loaded DXF image. What I observed is the result of calling the method, for different direction of view (and rotation angle also), is not consistent. I feel it is dependent on the order of L-T-R-B of TFRect that is passed to the method as argument. I tried swapping LT with RB for a given TFRect and specifying other diagonal point for the same TFRect, to verify this.
Is there any relation between the TFRect elements and direction of view.
It is nearly correct for Top, SE and NW isometric view. For NW view I was required to interchange the LT with RB, to get the desired result. For SW and NE view I could not get the desired view no matter what I did. Is it a know issue and is there any workaround to make it work.
Please guide me.
Thanks & regards,
Avinash
Hello Avinash,
Here goes text of a simple demo, which demonstrates whether TsgDrawingNavigator.ShowRect works correctly for all views.
BTW: we have sent you this demo.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Here goes text of a simple demo, which demonstrates whether TsgDrawingNavigator.ShowRect works correctly for all views.
Code: Select all
<b>uses</b>
... SGDrawingNavigator, DXFImage;
<b>type</b>
TForm1 = <b>class</b>(TForm)
pnlmage: TPanel;
btnOpen: TButton;
OpenDialog1: TOpenDialog;
btnShowRect: TButton;
btnRotToView: TButton;
<b>procedure</b> FormCreate(Sender: TObject);
<b>procedure</b> btnOpenClick(Sender: TObject);
<b>procedure</b> btnShowRectClick(Sender: TObject);
<b>procedure</b> btnRotToViewClick(Sender: TObject);
<b>private</b>
<font color="blue"><i>{ Private declarations }</i></font id="blue">
FsgPaintBox: TSGDrawingNavigator;
vRotToView: Integer;
<b>public</b>
<font color="blue"><i>{ Public declarations }</i></font id="blue">
<b>property</b> sgPaintBox: TSGDrawingNavigator read FsgPaintBox;
<b>end</b>;
...
<b>procedure</b> TForm1.FormCreate(Sender: TObject);
<b>begin</b>
FsgPaintBox := TSGDrawingNavigator.Create(pnlmage);
FsgPaintBox.Parent := pnlmage;
sgPaintBox.Align := alClient;
sgPaintBox.AutoFocus := True;
sgPaintBox.Anchors := [akLeft,akTop,akRight,akBottom];
vRotToView := <font color="blue">0</font id="blue">;
<b>end</b>;
<b>procedure</b> TForm1.btnOpenClick(Sender: TObject);
<b>begin
if not</b> OpenDialog1.Execute <b>then</b>
Exit;
sgPaintBox.LoadFromFile(OpenDialog1.FileName);
<b>end</b>;
<b>procedure</b> TForm1.btnShowRectClick(Sender: TObject);
<b>var</b>
vImg: TsgDXFImage;
vFRect: TFRect;
<b>begin
if</b> sgPaintBox.Picture.Graphic <b>is</b> TsgDXFImage <b>then</b>
vImg := TsgDXFImage(sgPaintBox.Picture.Graphic)
<b>else</b>
Exit;
vFRect.Left := vImg.Extents.Left + vImg.Width / <font color="blue">4</font id="blue">;
vFRect.Right := vImg.Extents.Right - vImg.Width / <font color="blue">4</font id="blue">;
vFRect.Top := vImg.Extents.Top - vImg.Height / <font color="blue">4</font id="blue">;
vFRect.Bottom := vImg.Extents.Bottom + vImg.Height / <font color="blue">4</font id="blue">;
vFRect.Z1 := vImg.Extents.Z1 + (vImg.Extents.Z2 - vImg.Extents.Z1) / <font color="blue">4</font id="blue">;
vFRect.Z2 := vImg.Extents.Z2 - (vImg.Extents.Z2 - vImg.Extents.Z1) / <font color="blue">4</font id="blue">;
sgPaintBox.ShowRect(vFRect);
<b>end</b>;
<b>procedure</b> TForm1.btnRotToViewClick(Sender: TObject);
<b>var</b>
vImg: TsgDXFImage;
<b>begin
if</b> sgPaintBox.Picture.Graphic <b>is</b> TsgDXFImage <b>then</b>
vImg := TsgDXFImage(sgPaintBox.Picture.Graphic)
<b>else</b>
Exit;
sgPaintBox.FitToSize;
<b>if</b> vRotToView = <font color="blue">11</font id="blue"> <b>then</b>
vRotToView := <font color="blue">0</font id="blue">;
vImg.RotToView(TsgDXFViewDirection(vRotToView));
Inc(vRotToView);
sgPaintBox.Invalidate;
<b>end</b>;
Sergey.
Please post questions to the forum or write to support@cadsofttools.com