Nearest Point
Moderators: SDS, support, admin
-
- Posts: 10
- Joined: 20 Oct 2005, 07:54
- Location: USA
Nearest Point
When the user clicks the mouse button, how can I calculate the nearest point or intersection? I basically need to figure out snapping the mouse like in AutoCad.
Hello,
Step 1.
Call <b>TsgDXFImage.GetCADCoords</b> function for obtaining real coordinates of entities.
For example:
Where:
<i>RealPoint</i> is an instance of <i>TFPoint</i>;
FImage is an instance of <i>TImage</i> or <i>TsgDXFImage</i>;
<i>X</i>, <i>Y</i> are the mouse coordinates above <i>FImage</i> obgect in pixels.
Step 2.
Call <i>TsgDXFConverter.Iterate(Proc: TsgCADEntityProc; var Params: TsgCADIterate)</i> for getting access to every entity and its data.
<b><i>procedure</b> ReadCADEntities(Entity: TsgDXFEntity);</i> - this is a user's procedure which gets entities one by one while iterating. There is an example in in SimpleImport demo in CADImportVCL\Delphi\Demos\SimpleImport folder(http://www.cadsofttools.com/download/CADImportVCL.zip).
<i>FCADParams: TsgCADIterate;</i> - returned iteration parameters
<i>Converter.Iterate(ReadCADEntities, FCADParams);</i> - call this procedure to start iteration.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Step 1.
Call <b>TsgDXFImage.GetCADCoords</b> function for obtaining real coordinates of entities.
For example:
Code: Select all
<b>var</b>
vRect: TRect;
<b>begin</b>
...
vRect := FImage.PictureRect;
RealPoint := TsgDXFImage(FImage.Picture.Graphic).GetCADCoords(X / (vRect.Right - vRect.Left), (FImage.Height - Y) / (vRect.Bottom - vRect.Top))
<i>RealPoint</i> is an instance of <i>TFPoint</i>;
FImage is an instance of <i>TImage</i> or <i>TsgDXFImage</i>;
<i>X</i>, <i>Y</i> are the mouse coordinates above <i>FImage</i> obgect in pixels.
Step 2.
Call <i>TsgDXFConverter.Iterate(Proc: TsgCADEntityProc; var Params: TsgCADIterate)</i> for getting access to every entity and its data.
<b><i>procedure</b> ReadCADEntities(Entity: TsgDXFEntity);</i> - this is a user's procedure which gets entities one by one while iterating. There is an example in in SimpleImport demo in CADImportVCL\Delphi\Demos\SimpleImport folder(http://www.cadsofttools.com/download/CADImportVCL.zip).
<i>FCADParams: TsgCADIterate;</i> - returned iteration parameters
<i>Converter.Iterate(ReadCADEntities, FCADParams);</i> - call this procedure to start iteration.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
-
- Posts: 10
- Joined: 20 Oct 2005, 07:54
- Location: USA
Hello,
It is possible to implement it yourself.
It is necessary to use DXFImage.GetPoint first for obtaining snapping point coordinates on the canvas and then draw box on the canvas.
At present CADImportVCL (http://www.cadsofttools.com/download/CADImportVCL.zip) does not support snapping. But this feature is in our tasks list.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
It is possible to implement it yourself.
It is necessary to use DXFImage.GetPoint first for obtaining snapping point coordinates on the canvas and then draw box on the canvas.
At present CADImportVCL (http://www.cadsofttools.com/download/CADImportVCL.zip) does not support snapping. But this feature is in our tasks list.
Sergey.
please post questions to the forum or write to support@cadsofttools.com