Re: [fpc-pascal] FP Vector graphics library

2009-05-27 Thread Michael Van Canneyt



On Tue, 26 May 2009, Felipe Monteiro de Carvalho wrote:


Hello,

I and another worker have developed a vector graphics library for Free
Pascal and I am thinking about making it modifyed-LGPL and adding to
the lazarus-ccr repository, like fpspreadsheet. So I was wondering,
anyone interrested in it?

At the moment it supports only reading PDF and only writing GCode for
a CNC machine I am developing and also only lines and polylines (I
will be adding curves in the next months), but the main structure is
done and it is extensible for more formats and more geometrical
figures and it's properties.

Here is the kind of code that you can write with it:

 Vec := TvVectorialDocument.Create;
 try
   Vec.ReadFromFile(dialogoAbrir.FileName, vfPDF);
   Vec.WriteToStrings(memoCodigo.Lines, vfGCodeAvisoCNCPrototipoV5);
 finally
   Vec.Free;
 end;

Just 1 command to read a PDF, then the information is in the class and
just another command to save the output to a file, or a TStrings or a
TStream.

Formats are added by adding units to the uses clause, so only
necessary code is linked. Upon initialization they add themselves to a
list of formats in the fpvectorial unit.


Shouldn't it be part of FPC's canvas/image support ?

Or does it depend on the LCL ? I imagine only actual drawing routines
depend on the LCL, in which case it can be split in a GUI-independent
part (reading/writing files) and a GUI dependent part, such as drawing 
code.


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


Re: [fpc-pascal] exceptions

2009-05-27 Thread Rainer Stratmann
Am Dienstag, 26. Mai 2009 22:27 schrieb Jonas Maebe:
 Well, as I said: it does not raise any exceptions.

Would it be possible to catch that exception?
With the try except block?
Are other functions existing to catch linux exceptions?

 The socket unit calls through to unix routines (either via libc or via
 syscalls), and these set errno based on the result. However, that
 result should not propagate into inoutres/ioresult (which is what
 could make the program exit with that error at some point if you later
 on call e.g. writeln).

I am sure that the exception comes from the send call.
Because the next debug calls are not executed (print something on the screen).
Also the errorcode 13 makes sense.
The result is not directly shown by freepascal.
But a calling program which does not fail shows the result.

Rainer

 Jonas
 ___
 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] exceptions

2009-05-27 Thread Vincent Snijders

Rainer Stratmann schreef:

Am Dienstag, 26. Mai 2009 22:27 schrieb Jonas Maebe:

Well, as I said: it does not raise any exceptions.


Would it be possible to catch that exception?
With the try except block?
Are other functions existing to catch linux exceptions?



No, you cannot catch exception that are not raised.

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


Re: [fpc-pascal] FP Vector graphics library

2009-05-27 Thread Felipe Monteiro de Carvalho
On Wed, May 27, 2009 at 6:07 AM, Michael Van Canneyt
mich...@freepascal.org wrote:
 Shouldn't it be part of FPC's canvas/image support ?

But FCL canvas/image is for raster images. I don't see how they would
correctly describe vector images.

PDF can hold text, raster images and vector images. For this library I
am ignoring the text and the raster image and using only the vectors
part.

 Or does it depend on the LCL ?

No, I am talking about non-visual support for the formats.

There could be routines to draw the images into a canvas, but I
haven't developed any yet.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FP Vector graphics library

2009-05-27 Thread Michael Van Canneyt



On Wed, 27 May 2009, Felipe Monteiro de Carvalho wrote:


On Wed, May 27, 2009 at 6:07 AM, Michael Van Canneyt
mich...@freepascal.org wrote:

Shouldn't it be part of FPC's canvas/image support ?


But FCL canvas/image is for raster images. I don't see how they would
correctly describe vector images.

PDF can hold text, raster images and vector images. For this library I
am ignoring the text and the raster image and using only the vectors
part.


All correct, and currently we have support in FPC for raster images.
My proposal is to add your code to FPC so we also support vector
graphics: FCL-image seems like the appropriate place for this.


Or does it depend on the LCL ?


No, I am talking about non-visual support for the formats.


Excellent, that means your design starts from good principles :-)

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


Re: [fpc-pascal] FP Vector graphics library

2009-05-27 Thread Felipe Monteiro de Carvalho
On Wed, May 27, 2009 at 10:53 AM, Michael Van Canneyt
mich...@freepascal.org wrote:
 All correct, and currently we have support in FPC for raster images.
 My proposal is to add your code to FPC so we also support vector
 graphics: FCL-image seems like the appropriate place for this.

I see, but are you proposing to add my units to fcl-image as they are
(which would mean separate classes for raster images and vector
images) or try to have a multi-concept class? Just trying to
understand, I would prefer to keep things separate.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FP Vector graphics library

2009-05-27 Thread Michael Van Canneyt



On Wed, 27 May 2009, Felipe Monteiro de Carvalho wrote:


On Wed, May 27, 2009 at 10:53 AM, Michael Van Canneyt
mich...@freepascal.org wrote:

All correct, and currently we have support in FPC for raster images.
My proposal is to add your code to FPC so we also support vector
graphics: FCL-image seems like the appropriate place for this.


I see, but are you proposing to add my units to fcl-image as they are
(which would mean separate classes for raster images and vector
images) or try to have a multi-concept class? Just trying to
understand, I would prefer to keep things separate.


Of course, separate classes; I don't think it is very realistic
to have a single concept for both.

What could be added later on is a class that does the drawing of 
the vector graphics on a TFPCustomCanvas, and can then be used

to create a bitmap with the TFPBitmapCanvas descendent or
on a window - since the LCL TCanvas is a descendent of 
TFPCustomCanvas anyway.


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


[fpc-pascal] How to emulate SetDIBits and GetDIBits in Linux

2009-05-27 Thread fpclist
Hi guys

In MS Windows I use the following API functions: 

1/
SetDIBits(bmap.Canvas.Handle, bmap.Handle, 0, bmap.Height, data,
PBitmapInfo(bitmapInfop)^, DIB_RGB_COLORS);

To set the pixels in a bitmap (bmap) using the colour data found in the 
specified device-independent bitmap (data)

and 

2/
GetDIBits(bmap.Canvas.Handle, bmap.Handle, 0, bmap.Height, data,
PBitmapInfo(bitmapInfop)^, DIB_RGB_COLORS);  

To retrieve the bits of the specified compatible bitmap (bmap) and write same 
into a buffer (data)

//
where
  DIB_RGB_COLORS = 0  // colour table in RGBs

and

  PRGBQuad = ^TRGBQuad;
  tagRGBQUAD = packed record
rgbBlue : Byte;
rgbGreen: Byte;
rgbRed  : Byte;
rgbReserved : Byte;
  end;
  TRGBQuad = tagRGBQUAD; 

  PBitmapInfo = ^TBitmapInfo;
  tagBITMAPINFO = packed record
bmiHeader : TBitMapInfoHeader;
bmicolors : array[0..0] of TRGBQuad;
  end;
  TBitmapInfo = tagBITMAPINFO;  
//

Does anyone know how to do the same in Linux using FPC. Code must not bound 
only to the LCL, i.e. must function in GUI and console apps. I can do 
everything else, I'm not able to create the bitmap from the RGB data.

Thanks
Nino 

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


Re: [fpc-pascal] IE 200307043

2009-05-27 Thread Jürgen Hestermann

From my point of view nil is like the infinite in mathematics, so it
is not range bounded and operations like nil+1 are impossible, or in
the worst case equal to nil again. Once you assigned nil to a pointer
the value becomes in range so it can be operated as usual.


Yes, doing arithmetics with NIL is useless. NIL is defined to mean 'not 
defined'. How can you add something to that? Even if the compiler allows 
you to do that, the result cannot be predicted.


Jürgen Hestermann.


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


Re: [fpc-pascal] IE 200307043

2009-05-27 Thread Frank Peelo

JoshyFun wrote:

Hello Frank,

Wednesday, May 27, 2009, 2:49:26 PM, you wrote:

FP But I'm more puzzled by what it would /mean/. In spite of your bracketed
FP comment here, you seem to be thinking that nil is an address: i.e.
FP adding/subtracting/multiplying a literal would mean something. I'm just
FP pointing out that, if you think it's an address, it's undefined. Because
FP it's not any address. So adding something to it doesn't mean anything.

From my point of view nil is like the infinite in mathematics, so it
is not range bounded and operations like nil+1 are impossible, or in
the worst case equal to nil again. Once you assigned nil to a pointer
the value becomes in range so it can be operated as usual.


Thanks. That's what I was trying to get across. Why try nil+1? It 
doesn't mean anything! So the Error is only that a different error 
message should appear - not that it should compile.


FP


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


Re: [fpc-pascal] exceptions

2009-05-27 Thread Rainer Stratmann
Am Mittwoch, 27. Mai 2009 11:45 schrieb Vincent Snijders:
 Rainer Stratmann schreef:
  Am Dienstag, 26. Mai 2009 22:27 schrieb Jonas Maebe:
  Well, as I said: it does not raise any exceptions.
 
  Would it be possible to catch that exception?
  With the try except block?
  Are other functions existing to catch linux exceptions?

 No, you cannot catch exception that are not raised.
What does 'raised' exactly mean?

Rainer
 Vincent
 ___
 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] IE 200307043

2009-05-27 Thread Prince Riley
Hello Frank,

If my past post was unclear as  to whether I think the constant 'nil' is  an
address, then let me be clear. I quoted the Borland Object Pascal's
statement nil 'does not reference anything' I was not equating it to a zero
address value. While a pointer with a 'zero' address value should be
invalid, it is different from a pointer with a value of 'nil.'

FP uses the special address constant, 'nil' in much the same way. If you
assign a pointer a valid address and perform valid operations on it, say you
repeatedly decrement or shift it (arithmetic) you could produce an invalid
address. But it would not be 'nil'.

Nil is, by definition, an address; albiet, a special one  like the
mathmatical set theory concept of 'empty  or null set'.  Nil is defined as a
'meta value' and as such whatever the lowest address value in the range of
addresses actually is, nil is defined not a member of that set.

The distinction between a valid address expression that has 'nil' as an
operand and an invalid one (decrementing or shifting a pointer outside a
valid address range) however raises a related by seperate issue. FP must
have operators like assignment or comparision that allow 'nil' to be used in
an expression.

The 'value' such an expression has must be defined in some way just as nil
is a defined lanuage constant; a way that consistently signals
('represents') the expression or operation produces an invalid result. So in
the example given there are two possible decisions

p := p + nil;   is INVALID (expression is valid, operands valid but result
is invalid) -- execution error, execution addressing exception

or

p := p + nil; is UNDEFINED (expression is invalid, no operation, no result)
-- compiler error


The second case is what FP does when nil is used in an expression .  The
ultimate problem lies in the first case, how to implement nil in a
consistent and reliable way as a internal binary value.

In KR, for example, the NULL address pointer is 'defined' but is
implemented in several different ways based on target CPU. If you look at C
program startup library code you'll see that. The NULL address value in 'C'
was defined for several years a binary '0' on VAX, and PDP machines. This
allowed tests for invalid or empty pointers using the compact syntatic
expression ' if (p) {...}'

Likewise, (p = NULL; and p == NULL) in C are both valid expressions neither
result in compiler warnings or errors (in strict compilers they do) But
there is a difference between how they operate on the expression (p = NULL +
p) and (p = 0 + p) which is similar to the case we are talking abotu here.

So here is our questiuon: should FP allow the expression (p := nil + p)? If
so, what should the result be? I opt that FP should treat it as an invalid
expression (compile error) and not as a valid expression with an UNDEFINED
value. I realize that this differs from what others might think or suggest.


On Wed, May 27, 2009 at 7:49 AM, Frank Peelo f...@eircom.net wrote:

 Prince Riley wrote:


 Frank,

 I think the crux of the matter here is how to make the distinction between
 a pointer with 'no value' and one that is initialized or set to the 'lowest
 possible value in the range'. The quote I mentioned comes directly from
 Borland's Object Pascal  Langage Manual


 The reserved word nil is a special constant that can be
 assigned to any pointer. When nil is assigned to a pointer, the
 pointer doesn't reference anything.

 I'm only quibbling with the equation of doesn't reference anything with
 lowest possible value in the range. On many architectures, a pointer value
 of 0 might be a reasonable choice for doesn't reference anything because
 the CPU has interrupt vectors there, or uses address 0 for something else.
 But my point is that this is not guaranteed. Nil might not even point to
 valid data memory.

  You can check on this, but when I looked it up the 'nil' constant in a
 Object Pascal Language reference and what the reserved word 'nil' , a
 special constant, means in terms of pointer value (it's not an address) I
 was not able to find  and what adding/subtracting/multiplying it by  a
 literal numeric value (or another valid pointer value) to 'nil' would
 create.


 But I'm more puzzled by what it would /mean/. In spite of your bracketed
 comment here, you seem to be thinking that nil is an address: i.e.
 adding/subtracting/multiplying a literal would mean something. I'm just
 pointing out that, if you think it's an address, it's undefined. Because
 it's not any address. So adding something to it doesn't mean anything.

 ...

 If you then set another breakpoint on the next instruction,
 p := p + 1;

 you'll notice that the first thing that happens is 'p' get set to a valid
 segment address and then the offset, and not the base segment, is
 incremented by a value of '1' (again on a Intel CPU machine).


 Yup, GIGO.


 FP


 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 

Re: [fpc-pascal] IE 200307043

2009-05-27 Thread Jonas Maebe


On 27 May 2009, at 19:26, Prince Riley wrote:

p := p + nil;   is INVALID (expression is valid, operands valid but  
result

is invalid) -- execution error, execution addressing exception


This will always be invalid regardless of how nil is handled, because  
you cannot add two pointers together. You can add integers to pointers  
though, so the question is about nil + 1 and the like. Delphi indeed  
gives an error, which makes sense. I resolved the internalerror by  
accepting the expression, which is indeed not a good idea. So I'll  
change it.



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


Re: [fpc-pascal] exceptions

2009-05-27 Thread Jonas Maebe


On 27 May 2009, at 19:24, Rainer Stratmann wrote:


Am Mittwoch, 27. Mai 2009 11:45 schrieb Vincent Snijders:

Rainer Stratmann schreef:

Am Dienstag, 26. Mai 2009 22:27 schrieb Jonas Maebe:

Well, as I said: it does not raise any exceptions.


Would it be possible to catch that exception?
With the try except block?
Are other functions existing to catch linux exceptions?


No, you cannot catch exception that are not raised.

What does 'raised' exactly mean?


http://www.freepascal.org/docs-html/ref/refse73.html

Please provide a compilable sample that demonstrates the problem you  
are having. I'm guessing you can solve it by adding the sysutils  
unit to your uses clause (because currently you're probably getting a  
plain run time error, and using the sysutils unit means that it will  
be converted into an exception that you can catch), but that would  
just be a hack. You probably also would have to put the try/catch  
around the next debugging writeln, and not around the send() call to  
catch the exception (because send() does not cause any inoutres  
checks, but writeln() does)


I really have no idea how the error result of send() could end up in  
inoutres though (which is, I think, the only way that could cause the  
RTL to produce a run time error in response to a failed send() call).  
There are variants of the socket routines that work on text files and  
that do set inoutres, but send() is not one of them.


So please, provide source code (even if some hack seems to solve the  
problem) so we don't have to send 10 more mails guessing about what  
you might be doing and what might be going wrong.



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


Re: [fpc-pascal] Class procedure assigned to object's event

2009-05-27 Thread Micha Nelissen

Antonio Sanguigni wrote:

For the second one:
main.pas(261,19) Error: Incompatible types: got class method type of
procedure(TObject, Boolean,const AnsiString) of object;Register
expected procedure variable type of procedure(TObject, Boolean,const
AnsiString) of object;Register


Remove the 'class' keyword from your function. A class method is a 
different beast (with different signature) from a regular method.


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