Recent

Author Topic: CanvasCoordsToFPVectorial  (Read 11186 times)

eraaijma

  • New Member
  • *
  • Posts: 26
CanvasCoordsToFPVectorial
« on: July 28, 2015, 11:02:15 pm »
Hi guys,
Since 15 years I have been using Delphi7. The last year I have tried to use Lazarus as the next platform. So far, so good. Delphi is able to display a WMF in an TImage. I am now trying to use FPvectorial to display a DXF. I am quite familiar with databases, unfortunately, not familiar with graphics

I have opened and converted the FP Vectorial converter from 'examples'
I've added a button that fires:
aVecDoc.ReadFromFile(OpenDialog1.FileName,vfDXF);
DrawFPVectorialToCanvas(aVecDoc.GetPageAsVectorial(0));
Works fine :), I recognize the drawing, but not everything is in the right place.

Now I would like to add the CanvasCoordsToFPVectorial function and CanvasTextPosToFPVectorial function to present the DXF the way it should be.

Can anyone help me and point me in the right direction, how to do this?





felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: CanvasCoordsToFPVectorial
« Reply #1 on: July 29, 2015, 04:19:35 pm »
You could open a bug report and attach the DXF file there and 2 screenshots (1 for actual result, 1 for expected result) and I could try to take a look at my spare time.

Basically its probably something wrong with interpretation of DXF, there is no easy fix, one really needs to study fpvectorial code for dxf and generic codebase and debug and fix the bug.

Without the DXF file its impossible to be more specific.

eraaijma

  • New Member
  • *
  • Posts: 26
Re: CanvasCoordsToFPVectorial
« Reply #2 on: August 13, 2015, 05:56:07 pm »
Hello Felipe,

Thank you so much for your offer to help. This inspired me to have a closer look myself.

What I found:
- DXF files, generated from different programs or even different versions of one program, are different. As I own licences for AutoCAD and Inventor 2013LT, I will have to use DXF files generated with these programs.
- DXF version 2010 are the latest version to be accepted by fpvectorial.

Preparation of drawings:
- Explode hatch
- Explode multiline text

Make small changes to the program:
function TvDXFVectorialReader.ReadENTITIES_TEXT(ATokens: TDXFTokens;
  AData: TvVectorialPage; ADoc: TvVectorialDocument; AOnlyCreate: Boolean = False): TvText;   
  This line
    Result.Y := PosY;
  Replaced by
    Result.Y := PosY+round(FontSize);


procedure TvText.Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo; ADestX: Integer;
  ADestY: Integer; AMulX: Double; AMulY: Double; ADoDraw: Boolean);
  This line
    LowerDim.Y := CoordToCanvasY(Y) + lFontSizePx * 1.2 * (Value.Count - i)
  Replace by
    LowerDim.Y := CoordToCanvasY(Y) - lFontSizePx * 1.2 * (Value.Count - i) 
  Added
    LowerDim.Y := LowerDim.Y + round(lFontSizePx*1.2);

So far the result is stunning: A perfect rendering of the DXF so far.

I will have to figure out the following:
- arrows on dimensions
- angular dimensions don't work 'division by zero' problem.

As fpvectorial is written by a far better programmer then me, everything will take some time, but I am sure I'll get the program to run as I want.

I will keep you informed as soon as I make some more progress.

Thanks again
Eugene Raaijmakers

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: CanvasCoordsToFPVectorial
« Reply #3 on: August 15, 2015, 06:45:28 pm »
Hello please send changes in the standard patch format from latest SVN code, as described here: http://wiki.freepascal.org/Creating_A_Patch

You can send diff files attached to an issue in our bug tracker, thanks =)

zamtmn

  • Hero Member
  • *****
  • Posts: 593
Re: CanvasCoordsToFPVectorial
« Reply #4 on: August 18, 2015, 09:19:44 am »
eraaijma
if I understood you correctly
Quote
Now I would like to add the CanvasCoordsToFPVectorial function and CanvasTextPosToFPVectorial function to present the DXF the way it should be.
Can anyone help me and point me in the right direction, how to do this?
Everywhere in the render code there is such fragments:
Code: [Select]
...
  function CoordToCanvasX(ACoord: Double): Integer;
  begin
    Result := Round(ADestX + AmulX * ACoord);
  end;

  function CoordToCanvasY(ACoord: Double): Integer;
  begin
    Result := Round(ADestY + AmulY * ACoord);
  end;
...
Knowing these values, the inverse transform is easy to do

felipemdc
In my opinion more correct to use a matrix, not just the proportional and additive coefficients. Math will become easier and more universal, there are additional types of transformations and the ability to display nested blocks

eraaijma

  • New Member
  • *
  • Posts: 26
Re: CanvasCoordsToFPVectorial
« Reply #5 on: August 22, 2015, 10:36:11 am »
@administrator
The issues are solved and maybe this thread can be closed now.
- All the text is in the right scale, on the right place now with little tweaking of the code for my purpose.  :D
@zamtmn
- That is the way I was able to change the code in my favour. FPvectorial looked like a scary beast at first, but I am starting to find my way around in it now.
@felipemdc
- You made a lovely program. It will eventualy help me a lot distributing drawings in production and purchase orders.
- I am still working on 'dimensions' in a DXF, so it is too early to post a patch.
- Maybe it is a good idea to start a new thread about dimensions in DXF drawings.

Thank you all for your support

zamtmn

  • Hero Member
  • *****
  • Posts: 593
Re: CanvasCoordsToFPVectorial
« Reply #6 on: August 22, 2015, 12:32:31 pm »
I develop another DXF realisation with lazarus http://forum.lazarus.freepascal.org/index.php/topic,16665.0.html some things out there more compatible with the DXF standard. Maybe that something will be useful

 

TinyPortal © 2005-2018