I developed a QtROOT based program with an embedded histogram browser with funcionalities similar to a TBrowser but highly specialized to the application’s need.
When I pop-up a widget with an embedded TCanvas divided into subpads, I would later like to unzoom all histograms displayed in the pads by the push of a button. Unfortunately only the last pad in the canvas gets unzoomed and I run out of options on how to fix this.
Here’s a snapshot of the relevant code:
[code] selectedObjectsDef selectedObjects = this->getSelectedItems() ;
for (selectedObjectsDef::iterator it=selectedObjects.begin(); it!=selectedObjects.end(); ++it)
{
for(tFileVDef::iterator jt=it->second.begin(); jt!=it->second.end(); ++jt)
{
if( (*jt)->IsA() == TDirectory::Class() ) continue ;
if( (*jt)->IsA() == TFolder::Class() ) continue ;
if( (*jt)->IsA() == TDirectoryFile::Class() ) continue ;
if( (*jt)->IsA() == TCanvas::Class() ) continue ;
((TH1*)(*jt))->GetXaxis()->UnZoom() ;
((TH1*)(*jt))->GetYaxis()->UnZoom() ;
}
}
serviceCanvas_[currentCanvas_]->flush() ; // Update the Canvas and force rapaint
[/code]
and here’s the flush method snippet
void canvasWidget::flush( void )
{
int tot = 0 ;
TObject * obj = NULL ;
TIter next(ui->theCanvas->GetCanvas()->GetListOfPrimitives()) ;
while((obj = next()))
{
if( obj->InheritsFrom(TVirtualPad::Class()))
{
ui->theCanvas->GetCanvas()->SetClickSelectedPad((TPad*)(obj)) ;
ui->theCanvas->GetCanvas()->SetClickSelected((obj)) ;
tot++ ;
ui->theCanvas->GetCanvas()->cd(tot) ;
gPad->Update();
ui->theCanvas->GetCanvas()->Modified() ;
ui->theCanvas->GetCanvas()->Update();
}
}
}
I tried every conceivable combination of Update calls and SetClick… methods. I always get the last plot unzoomed and the others are left unchanged. But if I click on them interactively afterwards, they immediately get unzoomed as well (which led me to think that I need to “select” them in order to Update).
I would appreciate hints on what am I missing here.
Thanks