setting up current view rectangle

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
avimms
Posts: 13
Joined: 06 Dec 2005, 09:57
Location: India

setting up current view rectangle

Post by avimms » 08 Dec 2005, 08:21

Hi there,

Thanks for replying to my previous question. Our company has purchased a license copy of DXF Import VCL.

I have posted two more questions to support directly. If you have not got them, I am posting again here.

How to set some rectangular area of the DXF file as the current visible area in TsgImage component. I want it because when DXF file is loaded, it shows up with actual dimension , which happens to be too big. I need to use TScrollbar component to see the intended portion of the DXF file. Is there many method which sets up visible area. I could not find any method in your help documentation. This is like programmatically setting up the current view, without making use of the component's built-in realization of "window" zoom (using left mouse button) and moving in scroll window (using right button). Or is there any way I can call those events programmatically.

I wanted it urgently.

Thank you,
Avinash
Gnostice Information Technologies.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 08 Dec 2005, 19:11

Hello,

ZoomDemo.zip available on: http://www.soft-gold.ru/download/zoomDemo.zip solves your questions.

Sergey.

please post questions to the forum or write to support@cadsofttools.com

avimms
Posts: 13
Joined: 06 Dec 2005, 09:57
Location: India

Post by avimms » 09 Dec 2005, 10:19

Hi Sergey,

Thanks a lot for the reply to my question. The demo you suggested solved my problem.

Regards,
Avinash

e_mahesha
Posts: 3
Joined: 12 Mar 2007, 09:58
Location: India
Contact:

Post by e_mahesha » 11 Apr 2007, 12:40

Hi,

I downloaded the "ZoomDemo.Zip" and tried to adjust the view of the loaded DXF map to the desired rectangular area.
But I can not zoom the DXF image exactly to the specified rectangle.

I'm still not clear with the working of the following code:
( which is being called internally when the ZoomButton clicked, after specifying the dimensions)

01 procedure TfmZoomDemo.btZoomClick(Sender: TObject);
02 var
03 L, R, T, B: Double;
04 DrawingWidth, DrawingHeight, Scale: Double;
05 Box: TFRect;
06 Shift: TPoint;
07 NH, NW: Double;
08 begin
09 Img.Align := alNone;
10 if Img.Picture.Graphic is TsgDXFImage then
11 begin
12 L := StrToFloat(edL.Text);
13 T := StrToFloat(edT.Text);
14 R := StrToFloat(edR.Text);

// * R Not using it anywhere !?

15 B := StrToFloat(edB.Text);
16 Box := TsgDXFImage(Img.Picture.Graphic).CurrentLayout.Box;
17 DrawingHeight := Box.Top - Box.Bottom;
18 DrawingWidth := Box.RIght - Box.Left;
19 NH := DrawingHeight * Height / Abs(T - B);
20 Scale := NH / DrawingHeight;
21 NW := Scale * DrawingWidth;
22
23 Shift.X := Round((Box.Left - L) * Scale);
24 Shift.Y := Round((- Box.Top + T) * Scale);
25 Img.SetBounds(Shift.X, Shift.Y, Round(NW), Round(NH));
26 end;
27 end;

Here, we are assigning "Right" value to the variable "R" (Line No. 14), but using it nowhere.
My requirement is to zoom to the specified Rectangle (i.e, all the four L,T,R,B should match approximately after zooming.)

If possible can you explain me the the algorithm that is used in this method.

I would be grateful to you if you can clear my doubt.

Mahesha.E

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 16 Apr 2007, 10:13

Hello!
Can you please give us a link where you have downloaded this demo or just write us on support@cadsofttools.com.

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

e_mahesha
Posts: 3
Joined: 12 Mar 2007, 09:58
Location: India
Contact:

Post by e_mahesha » 16 Apr 2007, 13:43

Hi Sergey,
I downloaded the project from the link which was mentioned in one of your previous replies to this topic.
That is :
http://www.soft-gold.ru/download/zoomDemo.zip

I'm trying with CAD-ImportVCL trial.

--
Mahesha.E

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 16 Apr 2007, 17:53

Hello Mahesha,

<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">My requirement is to zoom to the specified Rectangle (i.e, all the four L,T,R,B should match approximately after zooming.)<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Do you need to view some point of the drawing or you need just to draw some exact area of the drawing on the visible part of the TsgImage component?

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

e_mahesha
Posts: 3
Joined: 12 Mar 2007, 09:58
Location: India
Contact:

Post by e_mahesha » 17 Apr 2007, 08:51

Hi Sergey,

As I specified in my first post, I want to view(/draw) the exact portion of area of the drawing on the visible part of the component. I am trying to zoom-in the full image to view the desired rectanglar area, bounded by L,T,R,B.

Thank You.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 04 May 2007, 13:59

Hello Mahesha,

You are right, this line <i>R := StrToFloat(edR.Text);</i> is unnecessary in this code.
Here goes explanation:

Code: Select all

<font color="blue"><i>Get coordinates of necessary rectangle:</font id="blue"></i>
    L := StrToFloat(edL.Text);
    T := StrToFloat(edT.Text);
    B := StrToFloat(edB.Text);
<font color="blue"><i>Get 3D box of the loaded CAD file:</font id="blue"></i>
    Box := TsgDXFImage(Img.Picture.Graphic).CurrentLayout.Box;
<font color="blue"><i>Get Width and Height of the loaded CAD file: </font id="blue"></i>
    DrawingHeight := Box.Top - Box.Bottom;//This line is equal: TsgDXFImage(Img.Picture.Graphic).AbsHeight; 
    DrawingWidth := Box.Right - Box.Left;//This line is equal: TsgDXFImage(Img.Picture.Graphic).AbsWidth;
<font color="blue"><i>Get sgImage Height respectively to the ratio of the image's visible height and sought rectangle on the drawing:</font id="blue"></i>
    NH := DrawingHeight * Height / Abs(T - B);
<font color="blue"><i>Get sgImage Height:</font id="blue"></i>
    Scale := NH  / DrawingHeight;
    NW := Scale * DrawingWidth;
<font color="blue"><i>Get offset for left top corner: </font id="blue"></i>
    Shift.X := Round((Box.Left - L) * Scale);
    Shift.Y := Round((- Box.Top + T) * Scale);
<font color="blue"><i>Set bounds for sgImage:</font id="blue"></i>
    Img.SetBounds(Shift.X, Shift.Y, Round(NW), Round(NH));
Sergey

Please post questions to the forum or write to support@cadsofttools.com

Post Reply