Re: [lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: Marc Weustink wrote: AFAIK there is no restriction on where a toolbar is placed On win32 if I put a Toolbar on the bottom of the app it will appear twice. Once on the bottom without any of it's buttons and another on the top of the form with the buttons. It will even cover components that apear on the top of the form, or at least covered part of my TNotebook. The problem does not exist on gtk. Report it as bug. Marc _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Marc Weustink wrote: AFAIK there is no restriction on where a toolbar is placed On win32 if I put a Toolbar on the bottom of the app it will appear twice. Once on the bottom without any of it's buttons and another on the top of the form with the buttons. It will even cover components that apear on the top of the form, or at least covered part of my TNotebook. The problem does not exist on gtk. But this isn't very important... It's a question of using something else to hold components to the bottom of the form. Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: Felipe Monteiro de Carvalho wrote: Apparently Windows requires that ToolBars must be on the botton of the application. of course I meant "must be on the top of the application" AFAIK there is no restriction on where a toolbar is placed Marc _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: Apparently Windows requires that ToolBars must be on the botton of the application. of course I meant "must be on the top of the application" Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: Also, when I first opened my project the TToolBar was all messed up (the components I had put inside of the toolbar were outside it! and the Tnotebook was not working). I had to remove the toolbar to make the form look normal ... sure a strange problem. Apparently Windows requires that ToolBars must be on the botton of the application. Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
On Sun, 2005-10-02 at 11:10 -0300, Felipe Monteiro de Carvalho wrote: > On 10/2/05, Matthijs Willemstein <[EMAIL PROTECTED]> wrote: > On Sun, 2005-10-02 at 09:52 -0300, Felipe Monteiro de Carvalho wrote: > > I added a lot of information you guys said here at: > > http://wiki.lazarus.freepascal.org/index.php/Developing_with_Graphics > Tela means Screen in portuguese. I can´t use TScreen, because it´s > reserved and I am not sure what else to put... If you have an idea I´ll > be happy to change the component name. As this is only an example to create a control with some drawing features, you could name your component something like TMyDrawingControl. Matthijs. -- Matthijs Willemstein <[EMAIL PROTECTED]> _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: Creating a custom control and drawing to a bitmap first fixed the flickering, at 10Hz. I'll add this knowledge to the "Developing with Graphics" section of the wiki. I loaded my project on Windows and the flickering is back =/ On linux it works perfectly. I´m using the exact same code I put in the wiki. It´s a TCustomControl descendent that paints itself. There is a timer calling Invalidate at 10Hz. Also, when I first opened my project the TToolBar was all messed up (the components I had put inside of the toolbar were outside it! and the Tnotebook was not working). I had to remove the toolbar to make the form look normal ... sure a strange problem. I hope I am not not asking too many questions ^^ thanks a lot, Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
On 10/2/05, Matthijs Willemstein <[EMAIL PROTECTED]> wrote: On Sun, 2005-10-02 at 09:52 -0300, Felipe Monteiro de Carvalho wrote: > I added a lot of information you guys said here at: > http://wiki.lazarus.freepascal.org/index.php/Developing_with_Graphics thanks for that. In the code you create a class TTela. I wonder what a Tela would be in English. Using local languages in sources on the Wiki is (in my opinion) a bat thing, because the term " using meaningful names" is not followed here. I guess your speaking either Spanish or Portugese and both languages are not languages meaningful to me (and others)! But again, thanks for your contribution! Matthijs - I reposted the message because I keep forgetting not to post from gmail :^) sorry Tela means Screen in portuguese. I can´t use TScreen, because it´s reserved and I am not sure what else to put... If you have an idea I´ll be happy to change the component name. Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
Hi, I added a lot of information you guys said here at: http://wiki.lazarus.freepascal.org/index.php/Developing_with_Graphics I hope it is ok for everyone, Felipe
[lazarus] Re: Graphics basics on gtk
Andrew Haines wrote: Tela.Parent := Self; Regards, thank you very much. Creating a custom control and drawing to a bitmap first fixed the flickering, at 10Hz. I'll add this knowledge to the "Developing with Graphics" section of the wiki. Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
On Sunday 02 October 2005 04:01, Felipe Monteiro de Carvalho wrote: > A.J. Venter wrote: > > Felipe, you may also want to look at gamepack, which provides a > > double-buffered drawing component as well as sprite support. Mail me > > off-list if you want the details. > > Sounds very interesting. TDoubleBuffer seams very similar to what I am > trying to do. I must be doing a simple error ... > > I really am going to write a good example program about this once I have > time and get this right. > > But why don't you give the details on the list? This way they might > benifit someone reading the mail archives... > Because I have given it on-list before and don't wish to be accused of spamming. Since you ask though, you can check it out from SVN with svn co svn://silentcoder.co.za/lazarus/gamepack Or you can browse the code at http://www.silentcoder.co.za/viewsvn It's under the lazarus license. A.J. -- "80% Of a hardware engineer's job is application of the uncertainty principle. 80% of a software engineer's job is pretending this isn't so." A.J. Venter Chief Software Architect OpenLab International http://www.getopenlab.com http://www.silentcoder.co.za _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
On 10/2/05, Andrew Haines <[EMAIL PROTECTED]> wrote: > Felipe Monteiro de Carvalho wrote: > > > > > I tryed to create a TCustomControl descendent, but I can't seam to see > > it on the screen no matter what I do ... My tests were done in Win32, some time ago i had to display frames from a Camera wich i first had to process, drawing on a graphic control was slow, on a form was little faster, but the best performance i achieved was using a Panel in wich i trapped all possible paint messages or even faster making my own control and adding a canvas like other window based controls, all the processing and drawing was done off-screen on a buffer bitmap, i haven't performed any speed tests with non accelerated Video Cards & OpenGL so GL may be faster only in newer cards, dunno if using dedicated software GL libs like SGI's and Mesa helps. Hope it helps. Razvan _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: I tryed to create a TCustomControl descendent, but I can't seam to see it on the screen no matter what I do ... Can anyone help me (again)? Here is how I create it: procedure TfrmPrincipal.FormCreate(Sender: TObject); begin Tela := TTela.Create(Self); Tela.Height := 400; Tela.Width := 500; Tela.Left := 0; Tela.Top := 0; Tela.OnPaint := @DesenharRetas; // DesenharRetas is a painting TNotifyEvent. It doesn't matter if it is here. Tela.Visible := True; Tela.Parent := Self; Regards, Andrew _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
A.J. Venter wrote: Felipe, you may also want to look at gamepack, which provides a double-buffered drawing component as well as sprite support. Mail me off-list if you want the details. Sounds very interesting. TDoubleBuffer seams very similar to what I am trying to do. I must be doing a simple error ... I really am going to write a good example program about this once I have time and get this right. But why don't you give the details on the list? This way they might benifit someone reading the mail archives... Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Mattias Gaertner wrote: To avoid flickering: Create a descendent of TCustomControl, call Invalidate and Application.ProcessMessages, in Paint draw to a bitmap and draw the bitmap to the canvas. I tryed to create a TCustomControl descendent, but I can't seam to see it on the screen no matter what I do ... Can anyone help me (again)? Here is how I create it: procedure TfrmPrincipal.FormCreate(Sender: TObject); begin Tela := TTela.Create(Self); Tela.Height := 400; Tela.Width := 500; Tela.Left := 0; Tela.Top := 0; Tela.OnPaint := @DesenharRetas; // DesenharRetas is a painting TNotifyEvent. It doesn't matter if it is here. Tela.Visible := True; // Tela.Invalidate; or Tela.RePaint; neither work end; And here is how it is defined: TTela = class(TCustomControl) public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Paint; override; end; implementation procedure TTela.Paint; var x, y: Integer; begin // Limpa a tela Canvas.Pen.Color := clWhite; Canvas.Rectangle(0, 0, Width, Height); // Desenha os quadrados Canvas.Pen.Color := clBlack; for x := 1 to 8 do for y := 1 to 8 do Canvas.Rectangle(Round((x - 1) * Width / 8), Round((y - 1) * Height / 8), Round(x * Width / 8), Round(y * Height / 8)); inherited Paint; end; I also tryed inheriting from TGraphicalComponent or something like that. thanks, Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: Andrew Haines wrote: I used fmod a while back and it has the ability to output VU levels. I just put the paint methods in a timer event and used a TPanel to draw on. I'm not sure if this would work for you. What is VU? Volume Units. In fmod's case it's an array 0..512 of float representing the volume levels for the different frequencies. I am using a Analigic-to-Digital conversor witch can handle up to 200 khz, so I need a timer that is able to execute at 500 khz or so to keep asking the ISA card to send data faster then it can to avoid loss of data. TTimer can only executa at a maximum of 1khz, so it is discarted. My needs were very basic, so I only needed the timer to run every 50 millseconds or so. Regards, Andrew _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
> The timer problem is non-graphics related. I would like to receive data > from the ISA card at 500khz (or I will lose data). But thank you all for > your help so far. I will research if there is a way to create a very > efficient timer. If not, I'll just use another thread. > Felipe, you may also want to look at gamepack, which provides a double-buffered drawing component as well as sprite support. Mail me off-list if you want the details. Ciao A.J. -- "80% Of a hardware engineer's job is application of the uncertainty principle. 80% of a software engineer's job is pretending this isn't so." A.J. Venter Chief Software Architect OpenLab International http://www.getopenlab.com http://www.silentcoder.co.za _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Mattias Gaertner wrote: To avoid flickering: Create a descendent of TCustomControl, call Invalidate and Application.ProcessMessages, in Paint draw to a bitmap and draw the bitmap to the canvas. Thanks, I'll try that. Because a paint will take longer than a 500kHz intervall, you either call Invalidate only once a second and loose some data, or you use threads. Acctually I don't need to paint at 500khz. A good movie is 24Hz or so anyway, and the monitor won't do any better then 60Hz anyway. I was thinking of painting at ~10Hz. The timer problem is non-graphics related. I would like to receive data from the ISA card at 500khz (or I will lose data). But thank you all for your help so far. I will research if there is a way to create a very efficient timer. If not, I'll just use another thread. thanks, Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
On Sat, 01 Oct 2005 08:57:33 -0300 Felipe Monteiro de Carvalho <[EMAIL PROTECTED]> wrote: > Felipe Monteiro de Carvalho wrote: > > and put a: "PaintBox.Repaint;" on a separate timer that is slower. > > This method is really terrible. There is an awful lot of flickering ... > > Does anyone know a better method to redraw the content of the canvas? To avoid flickering: Create a descendent of TCustomControl, call Invalidate and Application.ProcessMessages, in Paint draw to a bitmap and draw the bitmap to the canvas. Because a paint will take longer than a 500kHz intervall, you either call Invalidate only once a second and loose some data, or you use threads. Mattias _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: and put a: "PaintBox.Repaint;" on a separate timer that is slower. This method is really terrible. There is an awful lot of flickering ... Does anyone know a better method to redraw the content of the canvas? _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Andrew Haines wrote: I used fmod a while back and it has the ability to output VU levels. I just put the paint methods in a timer event and used a TPanel to draw on. I'm not sure if this would work for you. What is VU? I am using a Analigic-to-Digital conversor witch can handle up to 200 khz, so I need a timer that is able to execute at 500 khz or so to keep asking the ISA card to send data faster then it can to avoid loss of data. TTimer can only executa at a maximum of 1khz, so it is discarted. I remember that once I used DirectX as a interface to DirectDraw, and I used a special timer that came with DirecX to draw instead of the default one claiming the Delphi timer is unreliable at high speed. Is it the same with lazarus timer? Should I build my own timer? In the lack of a Timer I may even create a separete thread that runs on a infinite loop asking the ISA to send data, but this is really ugly. Of course Interuptions or Direct Memory Access (DMA) would be more elegant, but this can as well work. If there is time left on november I may implement interruptions for the osciloscope. My current method is: Put the data fletching routine on the Timer and the drawing function on the a PaintBox.RePaint event. So I need to put a PaintBox.RePaint on the Timer that executes from time to time (10Hz or so ?). Is this method eficient? There is significant change between the frames as if RePaint executes on 10Hz the data has already changed many times. Is there a better method then Repaint? I used the Canvas.LineTo procedure and I found that the most efficient way overall to draw the line was to only draw the differences. U ... acctually I did not understand it. Here is my current code: procedure TForm1.PaintBox1Paint(Sender: TObject); var Largura, Altura: Integer; x, y: Integer; begin Largura := 500; Altura := 400; // Limpa a tela Canvas.Pen.Color := clWhite; Canvas.Rectangle(0, 0, Largura, Altura); // Desenha os quadrados Canvas.Pen.Color := clBlack; for x := 1 to 8 do for y := 1 to 8 do begin Canvas.Rectangle(Round((x - 1) * Largura / 8), Round((y - 1) * Altura / 8), Round(x * Largura / 8), Round(y * Altura / 8)); end; // Desenha utilizando o metodo das retas Canvas.Pen.Color := clBlack; Canvas.MoveTo(0, 0); for x := 0 to 200 do Canvas.LineTo(5 * x, (Altura div 2) + -5 * Medidas[x]); end; procedure TForm1.Timer1Timer(Sender: TObject); begin // here I populate Medidas[x] with data. Currently it is dummy data, but it will be data from the Osciloscope next month =) end; and put a: "PaintBox.Repaint;" on a separate timer that is slower. _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
Felipe Monteiro de Carvalho wrote: Thanks, but the Osciloscope is being implemented on an ISA card and such BUS only exists on old computers. The GUI will be running on something like a Pentium 233 Mhz, but I may even try to get it running on older computers, so no OpenGL ;) The idea of creating a custom control seams very good. Can it really improve the drawing speed? why? About the drawing function, I won't use anything fancy. My tasks are more programming oriented than graphics oriented, like finding the Fourier Series of the wave and drawing it. It's just a plotting of many dots and lines. Curves can be made with the dots and lines. I used fmod a while back and it has the ability to output VU levels. I just put the paint methods in a timer event and used a TPanel to draw on. I'm not sure if this would work for you. I used the Canvas.LineTo procedure and I found that the most efficient way overall to draw the line was to only draw the differences. Example: Assume the max value is 100 If the old value is 40 and the new value is 65 then Panel.Canvas.Pen.Color := clRed; Panel.Canvas.MoveTo(X, 40); Panel.Canvas.LineTo(X, 65); If the old value is 70 and the new value is 32 then // Draw the line from the old value to the new value, but use the Panel color so the line is "erased" Panel.Canvas.Pen.Color := Panel.Color; Panel.Canvas.MoveTo(X, 70); Panel.Canvas.LineTo(X, 32); Anyway I found this to work the best for me. HTH Andrew Another example: var OldYValues: Array [0..10] of Integer; procedure TForm1.Timer(Sender: TObject); var X: Integer; NewValue: Integer; PaintColor := TColor; begin for X := 0 to 10 do begin NewValue := GetNewYValueFromX(X); if NewValue < OldYValues[X] then PaintColor := clRed else PaintColor := Panel.Color; Panel.Canvas.Pen.Color := PaintColor; Panel.Canvas.MoveTo(X, OldYValues[X]); Panel.Canvas.LineTo(X, NewValue); OldYValues[X] := NewValue; end; end; TForm1.Panel1Paint(Sender: TObject); // Panels OnPaint Event var X: Integer; begin for X := 0 to 10 do OldYValues[X] := 0; end; _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] Re: Graphics basics on gtk
On Fri, 30 Sep 2005 14:38:37 -0300 Felipe Monteiro de Carvalho <[EMAIL PROTECTED]> wrote: > > I would not use any graphic control to do fast drawing but instead a > > window based control such as TPanel or create my own with an internal > > canvas, however for making an Osciloscope i would certainly use > > dedicated libraries such as SDL or OpenGL, you may try the GLScene > > components, with this kind of libs you can easily get hundreds of > > frames and they are not so bad to setup, not to mention that you have > > specific drawing funcs for various shapes and all kinds of goodies and > > they are CrossPlatform you can even use a Panel to render using > > OpenGL. > > > > Razvan > > Thanks, but the Osciloscope is being implemented on an ISA card and such > BUS only exists on old computers. The GUI will be running on something > like a Pentium 233 Mhz, but I may even try to get it running on older > computers, so no OpenGL ;) > > The idea of creating a custom control seams very good. Can it really > improve the drawing speed? why? There is no speed gain between a custum control using the paint event of a form/panel/paintbox/image. Only drawing on a TImage picture is slow. You can gain speed with opengl or other direct access functions, but you can use them for any control. Creating a custom control has the advantage of structuring your code. You can reuse the control. > About the drawing function, I won't use anything fancy. My tasks are > more programming oriented than graphics oriented, like finding the > Fourier Series of the wave and drawing it. It's just a plotting of many > dots and lines. Curves can be made with the dots and lines. Mattias _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
I would not use any graphic control to do fast drawing but instead a window based control such as TPanel or create my own with an internal canvas, however for making an Osciloscope i would certainly use dedicated libraries such as SDL or OpenGL, you may try the GLScene components, with this kind of libs you can easily get hundreds of frames and they are not so bad to setup, not to mention that you have specific drawing funcs for various shapes and all kinds of goodies and they are CrossPlatform you can even use a Panel to render using OpenGL. Razvan Thanks, but the Osciloscope is being implemented on an ISA card and such BUS only exists on old computers. The GUI will be running on something like a Pentium 233 Mhz, but I may even try to get it running on older computers, so no OpenGL ;) The idea of creating a custom control seams very good. Can it really improve the drawing speed? why? About the drawing function, I won't use anything fancy. My tasks are more programming oriented than graphics oriented, like finding the Fourier Series of the wave and drawing it. It's just a plotting of many dots and lines. Curves can be made with the dots and lines. thanks, Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] Re: Graphics basics on gtk
Thank you all for your help =) Felipe _ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives