RE: [ROOT] gVirtualX->PutImage and TCanvas

From: Valeri Fine (fine@bnl.gov)
Date: Tue May 04 2004 - 17:52:44 MEST


Hello Thomas. 

  It is hard to advice without your code and running example.
 ( I did not see your source so I am still guessing :-)

 Anyway in your Paint method you may try to do something like this
    
void MImage::Paint( . . . ) {

    Window_t fid = gVitualX->GetWindow(gPad->GetPixmaID());
    gVirtualX->PutImage(fid, <  . . . other PutImage parameters  . . . >
) 

}
If you still need speed you may regard to disable the double buffering
to paint the TCanvas screen directly replacing 

 gPad->GetPixmapID() 

http://root.cern.ch/root/htmldoc/TPad.html#TPad:GetPixmapID 

with gpad->GetCanvasID();

http://root.cern.ch/root/htmldoc/TPad.html#TPad:GetCanvasID 
http://root.cern.ch/root/htmldoc/TCanvas.html#TCanvas:GetCanvasID 
abd applying  
http://root.cern.ch/root/htmldoc/TGX11.html#TGX11:SetDoubleBuffer 
method.


Hope this helps.
                        Valeri

> -----Original Message-----
> From: Thomas Bretz [mailto:Thomas_Bretz@ph.tum.de]
> Sent: Monday, May 03, 2004 10:04 PM
> To: Valeri Fine
> Cc: roottalk@pcroot.cern.ch
> Subject: RE: [ROOT] gVirtualX->PutImage and TCanvas
> 
> Hi Valeri,
> 
> > Did I understand correctly that you tried to use
> > http://root.cern.ch/root/htmldoc/TVirtualX.html#TVirtualX:PutImage
> > method to paint TCanvas ?
> 
> Yes, you are right.
> 
> > I am afraid this method can not be used to paint TCanvas / TPad
> > To do that you have to provide the "Drawable_t id" for TPad.
> > As soon as I know there is no method to do that.
> > One can get the "Drawable_t" for the parent widget of TCanvas.
> > However it is not the TCanvas itself.
> >
> > With TCanvas the best thing you can do, you can draw the parent
widget
> > using PutImage method, but then ROOT will paint the real and empty
> > TCanvas/TPad over.
> 
> That exactly seems to be my problem.
> 
> > To do what you want you should regard using the TGFrame object
rather
> > TCanvas/TPad. Then you can apply PutImage method to paint it.
> > (see:
> >
http://root.cern.ch/root/htmldoc/src/TGColorPick.cxx.html#TGColorPick:Do
> > Redraw
> > for example)
> 
> I know. This is exactly where my problem comes from. I have a
> sky-coordinate system grid which is painted using TLine - which
becuase of
> the nice features of TPad is necessary. In a different application I
> readout a CCD camera of a sky image and I want to underlay this CCD
image
> (768x576x8bit, 25fps) This must be done with less than 1% CPU on a
1.5GHz
> linux machine. I know that the algorithm (with PutImage) is working
very
> fast and well in my TGFrame application, but now I want to have both.
The
> nice and fast PutImage and the powerfull class drawing the grid.
> 
> > Another way to manage thing is to provide your own implementation of
> > TImage abstract ROOT class using the existent TASImage
implementation as
> > a pattern
> >

> > With the mixed Qt/ROOT env you can just apply the class
> > http://doc.trolltech.com/3.3/qmovie.html to paint the TCanvas /TPad
as
> > well.
> 
> I have two classes already available which servs for different
> necessarities. I think developing a new class would not make sense.
I'm
> just triing to write a simple interface to merge the display of both.
> 
> Best regards
> Thomas.
> 
> > > -----Original Message-----
> > > From: owner-roottalk@pcroot.cern.ch
> > [mailto:owner-roottalk@pcroot.cern.ch] On
> > > Behalf Of Thomas Bretz
> > > Sent: Monday, May 03, 2004 4:36 PM
> > > To: Valeriy Onuchin
> > > Cc: roottalk@pcroot.cern.ch
> > > Subject: Re: [ROOT] gVirtualX->PutImage and TCanvas
> > >
> > > Hi,
> > > sorry, I don't know what happened. I hope this time they are
complete.
> > > Thomas.
> > > On
> > > Mon, 3 May 2004, Valeriy Onuchin wrote:
> > > > Hi Thomas,
> > > > two files in attachment are empty.
> > > >
> > > > Regards. Valeriy
> > > >
> > > > ----- Original Message -----
> > > > From: "Thomas Bretz" <Thomas_Bretz@ph.tum.de>
> > > > To: <roottalk@pcroot.cern.ch>
> > > > Sent: Monday, May 03, 2004 6:45 PM
> > > > Subject: [ROOT] gVirtualX->PutImage and TCanvas
> > > >
> > > >
> > > > > Hi,
> > > > >
> > > > > with the (very simple) attached class I try to display a gray
> > scaled
> > > > > bitmap in a canvas. It doesn't work. Can somebody explain me,
what
> > I'm
> > > > > doing wrong?
> > > > >
> > > > > (I'm developing this class, because I need a really fast
access to
> > the
> > > > > screen - 25fps - which I think I won't get with the big
overgead
> > of
> > > > > TASImage)
> > > > >
> > > > > Thanks in advance,
> > > > > Thomas.
> > > > >
> > > > >
> > > >
> > > >
> > > >
> >
------------------------------------------------------------------------
> > ------
> > > --
> > > >
> > > >
> > > > > void test()
> > > > > {
> > > > >     TCanvas *c=new TCanvas;
> > > > >
> > > > >     MImage2 *i = new MImage2(100, 100);
> > > > >
> > > > >     byte buf[100*100];
> > > > >
> > > > >     for (int j=0; j<100*100; j++)
> > > > >         buf[j]=j;
> > > > >
> > > > >     i->DrawImg(buf);
> > > > >     i->Draw();
> > > > > }
> > > > >
> > > >
> > > -----
> > > Würden Sie Windows 95 die Kontrolle eines AKWs überlassen?
> > > Hiroshima '45...! Tschernobyl '86...!! Windows 95...!!!
> > > Unix ist benutzerfreundlich - es ist nur etwas wählerisch..."
(Walter
> > Misar)
> > > Was sagt ein arbeitsloser Physiker zu einem Physiker mit Arbeit?
> > >  - "Eine Currywurst mit Pommes bitte!"
> >
> >
> >
> >
> 
> -----
> Würden Sie Windows 95 die Kontrolle eines AKWs überlassen?
> Hiroshima '45...! Tschernobyl '86...!! Windows 95...!!!
> Unix ist benutzerfreundlich - es ist nur etwas wählerisch..." (Walter
Misar)
> Was sagt ein arbeitsloser Physiker zu einem Physiker mit Arbeit?
>  - "Eine Currywurst mit Pommes bitte!"



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET