Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-06

Looking for vectors library

15 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé

Hi, I'm looking for a vector library that should be able to:

1 - Draw over TCustomCanvas descendants.
2 - Draw at least lines, circles and text.
3 - Map world coordinates to screen.
4 - Let me define a viewport on world then draw it to canvas. 5 - Zoom in/out.
6 - It must work in x86-64, i386, Win/Linux.
7 - Open Source.

Does anyone kowns if such library exists?.

P.S.:

I gave a try to AggPas, but it seems to work only on i386.

Reply by email

Mattias Gaertner
to Leonardo M. Ramé
Show quoted text 15 lines
Hi, I'm looking for a vector library that should be able to: 1 - Draw over TCustomCanvas descendants. 2 - Draw at least lines, circles and text. 3 - Map world coordinates to screen. 4 - Let me define a viewport on world then draw it to canvas. 5 - Zoom in/out. 6 - It must work in x86-64, i386, Win/Linux. 7 - Open Source. Does anyone kowns if such library exists?. P.S.: I gave a try to AggPas, but it seems to work only on i386.

Big parts of the code were already updated for 64bit. You may want to give it a try to test and update the rest.

Mattias

Reply by email

Alexander Klenin
to Mattias Gaertner
Mattias Gaertner wrote 18 lines
> Hi, I'm looking for a vector library that should be able to: > > 1 - Draw over TCustomCanvas descendants. > 2 - Draw at least lines, circles and text. > 3 - Map world coordinates to screen. > 4 - Let me define a viewport on world then draw it to canvas. > 5 - Zoom in/out. > 6 - It must work in x86-64, i386, Win/Linux. > 7 - Open Source. > > Does anyone kowns if such library exists?. > > P.S.: > > I gave a try to AggPas, but it seems to work only on i386. Big parts of the code were already updated for 64bit. You may want to give it a try to test and update the rest.

As far as I know, AggPas is a raster-based library, so maybe you want to try fpvectorial (note that it is very new, so you should use the version from CCR, not the one that comes with FPC).

Alexander S. Klenin

Reply by email

Graeme Geldenhuys
to Alexander Klenin
Alexander Klenin wrote
As far as I know, AggPas is a raster-based library,

Correct, but AggPas has support for SVG too. SVG being vector based images. See the AggPas demos for more info. I don't know if that has been ported to LCL's aggpas code though - probably is.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Felipe Monteiro de Carvalho
to Leonardo M. Ramé: Hi, I'm looking for a vector library that should be able to: 1 - Draw over TCustomCanvas…
Leonardo M. Ram? wrote 10 lines
Hi, I'm looking for a vector library that should be able to: 1 - Draw over TCustomCanvas descendants. 2 - Draw at least lines, circles and text. 3 - Map world coordinates to screen. 4 - Let me define a viewport on world then draw it to canvas. 5 - Zoom in/out. 6 - It must work in x86-64, i386, Win/Linux. 7 - Open Source.

fpvectorial does all of that:

http://wiki.lazarus.freepascal.org/fpvectorial

Felipe Monteiro de Carvalho -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110601/2114540a/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Graeme Geldenhuys: Correct, but AggPas has support for SVG too. SVG being vector based images. See the…
Graeme Geldenhuys wrote
Correct, but AggPas has support for SVG too. SVG being vector based images. See the AggPas demos for more info. I don't know if that has been ported to LCL's aggpas code though - probably is.

I don't know AggPas, but simply being able to import from SVG is not really the same as being a vector graphics library.

Felipe Monteiro de Carvalho -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110601/fcec42a9/attachment.html>

Reply by email

Marc Weustink
to Alexander Klenin: On Wed, Jun 1, 2011 at 02:29, Mattias Gaertner As far as I know, AggPas is a raster-based…
Alexander Klenin wrote 25 lines
On Wed, Jun 1, 2011 at 02:29, Mattias Gaertner wrote: >> Hi, I'm looking for a vector library that should be able to: >> >> 1 - Draw over TCustomCanvas descendants. >> 2 - Draw at least lines, circles and text. >> 3 - Map world coordinates to screen. >> 4 - Let me define a viewport on world then draw it to canvas. >> 5 - Zoom in/out. >> 6 - It must work in x86-64, i386, Win/Linux. >> 7 - Open Source. >> >> Does anyone kowns if such library exists?. >> >> P.S.: >> >> I gave a try to AggPas, but it seems to work only on i386. > > Big parts of the code were already updated for 64bit. You may want to > give it a try to test and update the rest. As far as I know, AggPas is a raster-based library, so maybe you want to try fpvectorial (note that it is very new, so you should use the version from CCR, not the one that comes with FPC).

AGG is vector based, the moment you want to draw the vectors it is rasterized :)

Marc

Reply by email

Leonardo M. Ramé
to Felipe Monteiro de Carvalho: fpvectorial does all of that: http://wiki.lazarus.freepascal.org/fpvectorial Felipe…
Felipe Monteiro de Carvalho wrote 17 lines
On Wed, Jun 1, 2011 at 3:41 AM, Leonardo M. Rame wrote: Hi, I'm looking for a vector library that should be able to: 1 - Draw over TCustomCanvas descendants. 2 - Draw at least lines, circles and text. 3 - Map world coordinates to screen. 4 - Let me define a viewport on world then draw it to canvas. 5 - Zoom in/out. 6 - It must work in x86-64, i386, Win/Linux. 7 - Open Source. fpvectorial does all of that: http://wiki.lazarus.freepascal.org/fpvectorial -- Felipe Monteiro de Carvalho

Felipe, I can't find the functions/methods to map world coordinates to screen nor to create a viewport on the drawing. Does fpVectorial includes that?.

Reply by email

Felipe Monteiro de Carvalho
to Leonardo M. Ramé
Leonardo M. Ram? wrote
Felipe, I can't find the functions/methods to map world coordinates to screen

In fpvectorial all coordinates are in milimiters.

When rendering on Screen you can use the unit fpvtocanvas and this function:

procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument;
  {$ifdef USE_LCL_CANVAS}ADest: TCanvas;{$else}ADest: TFPCustomCanvas;{$endif}
  ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0;
AMulY: Double = 1.0);

Which allows you to set a multiplier to be applied in the coordinates. 1.0 means that there is 1 pixel per milimiter. 2.0 means 2 pixels per milimiter, etc.

This function also allows you to set where the drawing will be placed, which is the viewport (ADestX, ADestY)

nor to create a viewport on the drawing. Does fpVectorial includes that?.

What do you mean by "create a viewport on the drawing"?

In fpvectorial the drawing itself has no viewport, but you can set a viewport for the whole drawing when rendering on screen, which is (ADestX, ADestY)

Felipe Monteiro de Carvalho

Reply by email

Leonardo M. Ramé
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 29 lines
On Wed, Jun 1, 2011 at 2:11 PM, Leonardo M. Ram? wrote: > Felipe, I can't find the functions/methods to map world coordinates to > screen In fpvectorial all coordinates are in milimiters. When rendering on Screen you can use the unit fpvtocanvas and this function: procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument; {$ifdef USE_LCL_CANVAS}ADest: TCanvas;{$else}ADest: TFPCustomCanvas;{$endif} ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); Which allows you to set a multiplier to be applied in the coordinates. 1.0 means that there is 1 pixel per milimiter. 2.0 means 2 pixels per milimiter, etc. This function also allows you to set where the drawing will be placed, which is the viewport (ADestX, ADestY) > nor to create a viewport on the drawing. Does fpVectorial > includes that?. What do you mean by "create a viewport on the drawing"? In fpvectorial the drawing itself has no viewport, but you can set a viewport for the whole drawing when rendering on screen, which is (ADestX, ADestY)

To me a viewport is a "window" that let you see an area of the drawing, just like any vector drawing app does.

I thing DrawFPVectorialToCanvas does what I want. Let me try to understand what it does.

For example, you have drawing of 1000 x 1000 mm, but you want to show in a canvas an area of 100 x 100 pixels, starting from the point 50, 50. To do this, you have to call DrawFPVectorialToCanvas(source, dest, 50, 50);

To zoom in/out you have to change AMultX and AMultY.

Am I right?.

Reply by email

Alexander Klenin
to Marc Weustink: AGG is vector based, the moment you want to draw the vectors it is rasterized :) Marc
Marc Weustink wrote 8 lines
> As far as I know, AggPas is a raster-based library, > so maybe you want to try fpvectorial (note that it is very > new, so you should use the version from CCR, not the one > that comes with FPC). AGG is vector based, the moment you want to draw the vectors it is rasterized :)

That's interesting. Felipe, you might then consider expanding/fixing AggPas instead of re-implementing it in fpvectorial.

Alexander S. Klenin

Reply by email

Felipe Monteiro de Carvalho
to Alexander Klenin
Alexander Klenin wrote
That's interesting. Felipe, you might then consider expanding/fixing AggPas instead of re-implementing it in fpvectorial.

I took a quick look and AggPas is very different from fpvectorial. fpvectorial is focused on modular support for readers / writers and on having the hability to modify elements.

AggPas says that it is a vectorial library, but I couldn't find any API in http://www.crossgl.com/aggpas/documentation/index.html to modify already added elements, only to remove all. It seams that in AggPas one will simply add all elements and then afterwards one can render this finished image many times. It seams to be really focused on drawing.

Of course I could have heavily modified AggPas instead of starting fpvectorial, but if that would be an option something like 4 years ago when I started fpvectorial, there is no chance of doing that now that I have many apps that use it, published articles about it and even clients.

Anyway both libraries are very different, so I don't see much duplication here. In fact, AggPas could be added to fpvectorial as a new Canvas outputter. This should make fpvectorial rendering much better.

Does anyone know if AggPas is able to render only the visible elements? (which means that in a drawing with 10.000 elements it will save time by only drawing the 100 visible elements). Or if it is fast enough to be used in the OnPaint event? That would be excelent, I already wanted since some time of a better renderer for fpvectorial and AggPas could be it.

Felipe Monteiro de Carvalho

Reply by email

Leonardo M. Ramé
to Leonardo M. Ramé: To me a viewport is a "window" that let you see an area of the drawing, just like any…
Leonardo M. Ram? wrote 45 lines
On 2011-06-01 14:38:34 +0200, Felipe Monteiro de Carvalho wrote: > On Wed, Jun 1, 2011 at 2:11 PM, Leonardo M. Ram? wrote: > > Felipe, I can't find the functions/methods to map world coordinates to > > screen > > In fpvectorial all coordinates are in milimiters. > > When rendering on Screen you can use the unit fpvtocanvas and this function: > > procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument; > {$ifdef USE_LCL_CANVAS}ADest: TCanvas;{$else}ADest: TFPCustomCanvas;{$endif} > ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; > AMulY: Double = 1.0); > > Which allows you to set a multiplier to be applied in the coordinates. > 1.0 means that there is 1 pixel per milimiter. 2.0 means 2 pixels per > milimiter, etc. > > This function also allows you to set where the drawing will be placed, > which is the viewport (ADestX, ADestY) > > > nor to create a viewport on the drawing. Does fpVectorial > > includes that?. > > What do you mean by "create a viewport on the drawing"? > > In fpvectorial the drawing itself has no viewport, but you can set a > viewport for the whole drawing when rendering on screen, which is > (ADestX, ADestY) > To me a viewport is a "window" that let you see an area of the drawing, just like any vector drawing app does. I thing DrawFPVectorialToCanvas does what I want. Let me try to understand what it does. For example, you have drawing of 1000 x 1000 mm, but you want to show in a canvas an area of 100 x 100 pixels, starting from the point 50, 50. To do this, you have to call DrawFPVectorialToCanvas(source, dest, 50, 50); To zoom in/out you have to change AMultX and AMultY. Am I right?.

Felipe, it seems to work as I thought!.

A new question. How can I check for mouse click on vectors?

Reply by email

Felipe Monteiro de Carvalho
to Leonardo M. Ramé: To me a viewport is a "window" that let you see an area of the drawing, just like any…
Leonardo M. Ram? wrote 8 lines
> procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument; > ? {$ifdef USE_LCL_CANVAS}ADest: TCanvas;{$else}ADest: TFPCustomCanvas;{$endif} > ? ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; > AMulY: Double = 1.0); > For example, you have drawing of 1000 x 1000 mm, but you want to show in a canvas an area of 100 x 100 pixels, starting from the point 50, 50. To do this, you have to call DrawFPVectorialToCanvas(source, dest, 50, 50);

The Canvas Y coordinate is inverted in relation to how fpvectorial defines it, so the most usual way to achieve what you want is:

DrawFPVectorialToCanvas(source, dest, 0, dest.height, 0.1, -0.1);
Felipe Monteiro de Carvalho

Reply by email

Felipe Monteiro de Carvalho
to Leonardo M. Ramé: Felipe, it seems to work as I thought!. A new question. How can I check for mouse click…
Leonardo M. Ram? wrote
A new question. How can I check for mouse click on vectors?

There is ready-made routine for that at the moment ... contributions are welcome =)

Basically you have to iterate through all items and check their coordinates against the mouse ones with the appropriate conversions, probably with an error margin of around 5 pixels.

This could be slow if the drawing has 10000s of elements, in that case I suppose that some kind of optimization would be necessary, like the following idea: When drawing check which elements are visible and make a list with pointers to them. On click check only that list.

Felipe Monteiro de Carvalho

Reply by email