Hi Paolo,
as far as I understood you would like to set your own procedure
when to display content of canvas. A solution would be creation
class MyCanvas derived from TCanvas with PaintModified() overloaded, e.g
void MyCanvas::PaintModified()
{
if (!gReadyToShow) return;
else TCanvas::PaintModified();
}
and put MyCanvas objects into TRootEmbeddedCanvases instead of TCanvases
Calling TCanvas::Update will not display canvas untill gReadyToShow flag is set on.
Regards. Valeriy
Hi Valeriy,
no, I meant only to prepare the TRootEmbedded canvas in memory in the final
form as I see it on screen but without displaying it.
Paolo
On Monday 23 June 2003 10:12, you wrote:
> Hi Paolo,
> not clear for me "fill completely the picture in memory ".
> Does it mean a picture of the whole of "Display Window"?
>
> Regards. Valeriy
>
> > Hi all,
> >
> > I would like to hear your opinion about the following ideas.
> >
> > In my program I built a Display Window which is essentially composed by a
> > matrix of TRootEmbeddedCanvas. In every Embedded Canvas is painted an
> > histogram. Now I would like to fill completely the picture in memory to
> > display it only when it is needed: the effect should be of a "ready to
> > see" picture appearing on the screen. I know that TRootEmbeddedCanvas
> > creates a TGCanvas in which a TCanvas is created, and that a TCanvas is
> > built using "double buffer" tecnique, but I can't figure out how I can
> > achieve the "ready to see" effect (perhaps using TPad::CopyPixmaps()?).
> >
> > Just for example I attach my present code.
> > Thanks,
> >
> > Paolo
> >
> >
> > /************************************************************************
> >*** TC_ScrollingTabFrame.cpp - description -------------------
> > begin : Thu May 8 2003
> > copyright : (C) 2003 by Paolo ADRAGNA
> > email : paolo.adragna@pi.infn.it
> >
> > *************************************************************************
> >**/
> >
> > /************************************************************************
> >*** *
> > * * This program is free software; you can redistribute it and/or
> > modify * * it under the terms of the GNU General Public License as
> > published by * * the Free Software Foundation; either version 2 of the
> > License, or * * (at your option) any later version.
> > * *
> > *
> > *************************************************************************
> >**/
> >
> > #include "TC_ScrollingTabFrame.h"
> > #include "TC_CanvasUpdateAsynch.h"
> >
> > ClassImp(TC_ScrollingTabFrame)
> >
> > TC_ScrollingTabFrame::TC_ScrollingTabFrame() :
> > TGCanvas(GetViewPort(),700,650) {}
> >
> > TC_ScrollingTabFrame::TC_ScrollingTabFrame(TGTab * tab, char *grp, char *
> > nam, Int_t id_, Int_t nhs, TH1 *hist[], char *options[], char
> > *Poptions[]) : TGCanvas(tab,550,650)
> > {
> >
> > status = 0;
> > group = new TString(grp);
> > name = new TString(nam);
> > id = id_;
> >
> > // Make a new tab explicitly building it, instead of calling Add in
> > order to add a ScrollingTabFrame
> > tab->AddFrame(new TGTabElement(tab, new TGString(nam), 50, 20,
> > tab->GetDefaultGC().GetGC(),
> > tab->GetDefaultFontStruct()),
> > 0);
> >
> > fFrame = new TGCompositeFrame(GetViewPort(), 60, 20);
> > fFrame->SetLayoutManager(new TGMatrixLayout(fFrame,0,2,10));
> > SetContainer(fFrame);
> >
> > TStyle *myStyle = (TStyle*) gROOT->FindObject("Plain1");
> > if(myStyle)
> > {
> > myStyle->cd();
> > }
> > else
> > {
> > printf("Warning. Style Plain1 not founded\n");
> > }
> >
> > int i;
> > for (i=0;i<nhs;i++)
> > {
> > char *s = new char[30];
> > sprintf(s,"%s_%i",nam,i);
> > TRootEmbeddedCanvas *fECanvas = new
> > TRootEmbeddedCanvas(s,fFrame,300,250);
> > ecanvas.push_back(fECanvas);
> > TCanvas *c = fECanvas->GetCanvas();
> > if(strcmp(Poptions[i],"Logy") == 0) c->SetLogy();
> > c->cd();
> > c->AddExec("Popuppad","TC_ScrollingTabFrame::PopUpPad()");
> > hist[i]->Draw(options[i]);
> > AddFrame(fECanvas);
> > }
> >
> > }
> >
> > TC_ScrollingTabFrame::~TC_ScrollingTabFrame()
> > {
> > for(int i=0; i<(int)ecanvas.size(); i++)
> > {
> > delete ecanvas[i];
> > }
> > delete fFrame;
> > }
> >
> > void TC_ScrollingTabFrame::PopUpPad()
> > {
> > int event = gPad->GetEvent();
> > if(event == 61)
> > {
> > TObject *select = gPad->GetSelected();
> > if (!select) return;
> > // For a TH1 the selectd object is a TFrame, not the TH1
> > // So we must select it
> > if (!select->InheritsFrom("TH1"))
> > {
> > TList *primitives = gPad->GetListOfPrimitives();
> > TListIter next(primitives);
> > TObject *to;
> > while ((to=next()))
> > {
> > if(to->InheritsFrom("TH1")) {select = to;}
> > }
> > }
> > if (select->InheritsFrom("TH1"))
> > {
> > Int_t logy = gPad->GetLogy();
> > TH1 *h = (TH1*)gROOT->FindObject(select->GetName());
> > char *name = new char[100];
> > sprintf(name,"padCanvas%s",h->GetName());
> > TCanvas *canvas = new TCanvas(name,h->GetTitle(),600,400);
> > new TC_CanvasUpdateAsynch(canvas,(Long_t)2000);
> > sprintf(name,"padPad%s",h->GetName());
> > TPad *p = new TPad(name,h->GetTitle(),0.05,0.05,0.95,0.95);
> > if(logy) p->SetLogy();
> > p->Draw();
> > p->cd();
> > file://TStyle *myStyle = new TStyle("Plain2","Generic");
> > file://myStyle->SetTitleFont(42);
> > if(select->InheritsFrom("TH2F"))
> > {
> > file://myStyle->SetOptStat(10);
> > TStyle *myStyle = (TStyle*) gROOT->FindObject("PlainPopup2");
> > if(myStyle)
> > {
> > myStyle->cd();
> > }
> > else
> > {
> > printf("Warning. Style PlainPopup2 not founded\n");
> > }
> > h->Draw("lego2");
> > }
> > else
> > {
> > file://myStyle->SetOptStat(111111);
> > TStyle *myStyle = (TStyle*) gROOT->FindObject("PlainPopup1");
> > if(myStyle)
> > {
> > myStyle->cd();
> > }
> > else
> > {
> > printf("Warning. Style PlainPopup1 not founded\n");
> > }
> > h->Draw("hist");
> > }
> >
> > }
> > }
> > }
> >
> > void TC_ScrollingTabFrame::SetVisibleFlag(bool flag)
> > {
> > status = GetSelectedFlag();
> > if (flag) { status = DW_SELECTED | DW_VISIBLE; }
> > }
> >
> > void TC_ScrollingTabFrame::SetSelectedFlag(bool flag)
> > {
> > status = 0;
> > SetVisibleFlag(flag);
> > }
> >
> > Bool_t TC_ScrollingTabFrame::ProcessMessage(Long_t msg, Long_t parm1,
> > Long_t parm2)
> > {
> > return TGCanvas::ProcessMessage(msg,parm1,parm2);
> > }
> >
> > void TC_ScrollingTabFrame::Update()
> > {
> >
> > if((!GetVisibleFlag()) || (ecanvas.size()<=0) ) {return;}
> >
> > TStyle *myStyle = (TStyle*) gROOT->FindObject("Plain1");
> > if(myStyle)
> > {
> > myStyle->cd();
> > }
> > else
> > {
> > printf("Warning. Style Plain1 not founded\n");
> > }
> > for(int i=0; i<(int)ecanvas.size(); i++)
> > {
> > TCanvas *c = ecanvas[i]->GetCanvas();
> > c->Modified();
> > c->Update();
> > }
> > }
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET