Re: [fpc-pascal] Looking for a suitable graphics library/component

2011-03-22 Thread Anthony Walter
Oh, you want a retained mode graphics system. That should be pretty easy to
write yourself.

Just write a class like TDrawable with a Paint(), HitTest(Point), and
Intersects(Rect) methods and derive from that to have your different drawn
types.

Keep a list of those items in your drawing surface.

Call HitTest(MousePoint) when the mouse moves over the drawing area and
track the hot/pressed/captured item.

When you surface needs to be painted, loop through the list and if
DrawableItem.Intersects(DirectRect) then DrawableItem.Paint().

I don't think you'll find a ready made system to accommodate all your
drawing needs.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Looking for a suitable graphics library/component

2011-03-22 Thread Adrian Maier
On Tue, Mar 22, 2011 at 18:13, Horacio Jamilis  wrote:
> You could take a look to AggPas.

I'll look , thanks .

--
Adrian
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Looking for a suitable graphics library/component

2011-03-22 Thread Adrian Maier
On Tue, Mar 22, 2011 at 17:18, Anthony Walter  wrote:
> For drawing lines, shapes, fills, on Linux I'd recommend using cairo. On
> Windows I'd say you should use GDI or GDI+. You can find pascal files
> importing the functions for those libraries using google. Some of them may
> come with FPC.
>
> For widgets, if you are using Lazarus, it comes with a widget toolkit. Then
> there is also the free pascal gui tookit located here:
> http://fpgui.sourceforge.net/
>
> Finally, for handling scrolling, what you need to do is determine the max
> bounds of your area, compare that to screen area and your drawing scale
> (your zoom factor). Use that to recalculate both the horizontal  and
> vertical scroll bar information (page size, scroll size) when the draw area
> is resized and update the scroll bars accordingly.
>
> When you receive a scroll position change notification (the user drags the
> scroll bar) you call some api to scroll the drawing (such as
> ScrollWindowEx), which will invalidate a dirty rectangle in your window.
>
> When you receive a paint notification (either when the user scrolls or a
> window is dragged over your window), you should also retrieve the dirty
> rectangle. Then you need to find the rectangles of your drawn objects that
> intersect the dirty rectangle. Redraw objects that intersect the dirty
> rectangle.
>
> If the user zooms in or out, invalidate the entire area.
>
> It's all pretty standard stuff ...
> http://imagebot.org/snapshops/phun-gears-builder.jpg


Thanks Anthony for your answers.

I will keep in mind these suggestions if I fail to find a higher-level
component.
(for example,  the TAChart is a "higher-level" component for drawing charts
that is much more convenient to use compared to drawing the chart from
scratch).

Ideally, I am hoping that already exists some kind of  "svg canvas" that can be
used in fpgui or Lazarus applications.  For example: if I draw a
rectangle in the
canvas I want to be able to later :
- change color
- modify size/position
- associate it with a "mouse click" event

I didn't mention that I will need to handle in parallel multiple
coordinates systems:
- number of meters
- position withing each track segment  (each segment has a starting km and an
ending km).   And it's possible that a segment ends at km=35.4  and
the next one
begins at km=38.2 . It is even possible that the next segment has
coordinates in
reverse order.
- position relative to balises
So the problem itself is relatively mind-twisting .

It would be really nice to find a component that allows me to add and
manipulate
the graphical objects in a "scalar-graphics" way ,   that takes care of drawing
on-screen without forcing me to go into the details .


--
Adrian
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Looking for a suitable graphics library/component

2011-03-22 Thread Horacio Jamilis

You could take a look to AggPas.

Good luck!

Horacio

El 22/03/2011 11:37, Adrian Maier escribió:

Hello,

I am seeking for some advice regarding what graphics library to use
for a new project.

I am aware that the application can be done by drawing lines, points
and text within a canvas. But I am hoping to find out about the existence
of some already existing libraries that would ease the development ...

The application will be a railway route viewer (it's a tool that will
be useful for me at work). I'll try to explain next what does it involve.
- the description of a train station tracknet is read from an xml file
(the tracknet is like a spider web)
- a route is a concrete path of a train ; it's a set of connected
track segments
- within the application i intend to represent the route as a long
horizontal line
- on the route i need to represent elements (signals, points,
balises). At a given location there can be more than one element.
- i need zooming and horizontal scrolling
- i need to be able to click on an element (and display information about it)
- there are many kinds of "areas" that also need to be marked visually
(for example the max speed areas)
- in future I might also want to add a moving train
- i'll need a configurable annotation system (enable/disable areas,
enable/disable labels)
- did i already mention zooming and scrolling ?  ;)

My feeling is that it would be tedious to develop such a GUI application
using only lines, points and rectangles.

So, does anyone happen to have suggestion regarding what would be the
most suitable widget set or library for building such an application ?



Thanks,
Adrian
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Looking for a suitable graphics library/component

2011-03-22 Thread Anthony Walter
For drawing lines, shapes, fills, on Linux I'd recommend using cairo. On
Windows I'd say you should use GDI or GDI+. You can find pascal files
importing the functions for those libraries using google. Some of them may
come with FPC.

For widgets, if you are using Lazarus, it comes with a widget toolkit. Then
there is also the free pascal gui tookit located here:
http://fpgui.sourceforge.net/

Finally, for handling scrolling, what you need to do is determine the max
bounds of your area, compare that to screen area and your drawing scale
(your zoom factor). Use that to recalculate both the horizontal  and
vertical scroll bar information (page size, scroll size) when the draw area
is resized and update the scroll bars accordingly.

When you receive a scroll position change notification (the user drags the
scroll bar) you call some api to scroll the drawing (such as
ScrollWindowEx), which will invalidate a dirty rectangle in your window.

When you receive a paint notification (either when the user scrolls or a
window is dragged over your window), you should also retrieve the dirty
rectangle. Then you need to find the rectangles of your drawn objects that
intersect the dirty rectangle. Redraw objects that intersect the dirty
rectangle.

If the user zooms in or out, invalidate the entire area.

It's all pretty standard stuff ...
http://imagebot.org/snapshops/phun-gears-builder.jpg
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Looking for a suitable graphics library/component

2011-03-22 Thread Adrian Maier
Hello,

I am seeking for some advice regarding what graphics library to use
for a new project.

I am aware that the application can be done by drawing lines, points
and text within a canvas. But I am hoping to find out about the existence
of some already existing libraries that would ease the development ...

The application will be a railway route viewer (it's a tool that will
be useful for me at work). I'll try to explain next what does it involve.
- the description of a train station tracknet is read from an xml file
(the tracknet is like a spider web)
- a route is a concrete path of a train ; it's a set of connected
track segments
- within the application i intend to represent the route as a long
horizontal line
- on the route i need to represent elements (signals, points,
balises). At a given location there can be more than one element.
- i need zooming and horizontal scrolling
- i need to be able to click on an element (and display information about it)
- there are many kinds of "areas" that also need to be marked visually
(for example the max speed areas)
- in future I might also want to add a moving train
- i'll need a configurable annotation system (enable/disable areas,
enable/disable labels)
- did i already mention zooming and scrolling ?  ;)

My feeling is that it would be tedious to develop such a GUI application
using only lines, points and rectangles.

So, does anyone happen to have suggestion regarding what would be the
most suitable widget set or library for building such an application ?



Thanks,
Adrian
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using properties in interfaces

2011-03-22 Thread Sven Barth

Am 22.03.2011 10:59, schrieb Michael Fuchs:

Hello,


if I understand the documentation correct, this is the only way using a
property in an interface:

IMyInterface = interface
function GetTag: Integer;
procedure SetTag(AValue: Integer);
property Tag: Integer read GetTag write SetTag;
end;

Or exists a possibilty to define the interface like that:

IMyInterface = interface
property Tag: Integer;
end;

And the programmer who implement this interface could decides how to
implement the property?


Not as I'm aware of, because without that the compiler wouldn't be able 
to call "code" behind the property (even if it's only a field). While 
this could be worked around in the compiler if the implementation is in 
the same binary, it's impossible if you use interfaces across DLL 
boundaries where you don't have (by definition) access to the source (it 
could even be done in a different language...).


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Using properties in interfaces

2011-03-22 Thread Michael Fuchs

Hello,


if I understand the documentation correct, this is the only way using a 
property in an interface:


  IMyInterface = interface
function GetTag: Integer;
procedure SetTag(AValue: Integer);
property Tag: Integer read GetTag write SetTag;
  end;

Or exists a possibilty to define the interface like that:

  IMyInterface = interface
property Tag: Integer;
  end;

And the programmer who implement this interface could decides how to 
implement the property?


regards
Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal