Hi Valeri,
To use the 3-d objects in a pad/canvas, you must create first a TView
object and set its range. In the macro below, you will find an example.
In an interactive viewer, you can call TView::SetRange using parameters
computed from an area selected with the mouse.
I can send you an example (ALICE event display class) illustrating
how this is done.
Federico Carminati will probably post to this mailing list the URL
for the ALICE classes.
Rene Brun
{
gROOT->Reset();
TH3F *h3 = new TH3F("h3","test fitz",5,-4,4,8,-4,4,5,0,20);
for (Int_t i=0;i<100000;i++) {
Float_t x = gRandom->Gaus(0,1);
Float_t y = gRandom->Gaus(0,1);
Float_t z = gRandom->Gaus(10,4);
h3->Fill(x,y,z);
}
Int_t bin,ix,iy,iz;
Float_t xmin,xmax,ymin,ymax,zmin,zmax,wmin,wmax,w;
Int_t nbinsx = h3->GetXaxis()->GetNbins();
Int_t nbinsy = h3->GetYaxis()->GetNbins();
Int_t nbinsz = h3->GetZaxis()->GetNbins();
//compute min and max of all cells
wmin = wmax = 0;
for (ix=1;ix<=nbinsx;ix++) {
for (iy=1;iy<=nbinsy;iy++) {
for (iz=1;iz<=nbinsz;iz++) {
bin = h3->GetBin(ix,iy,iz);
w = h3->GetBinContent(bin);
if (w > wmax) wmax = w;
if (w < wmin) wmin = w;
}
}
}
TCanvas *c1 = new TCanvas("c1");
TView *view = new TView(1);
view->SetRange(h3->GetXaxis()->GetXmin(),
h3->GetYaxis()->GetXmin(),
h3->GetZaxis()->GetXmin(),
h3->GetXaxis()->GetXmax(),
h3->GetYaxis()->GetXmax(),
h3->GetZaxis()->GetXmax());
//Draw TMarker3DBox with size proportional to cell content
TMarker3DBox *m3;
Float_t scale;
for (ix=1;ix<=nbinsx;ix++) {
xmin = h3->GetXaxis()->GetBinLowEdge(ix);
xmax = xmin + h3->GetXaxis()->GetBinWidth(ix);
for (iy=1;iy<=nbinsy;iy++) {
ymin = h3->GetYaxis()->GetBinLowEdge(iy);
ymax = ymin + h3->GetYaxis()->GetBinWidth(iy);
for (iz=1;iz<=nbinsz;iz++) {
zmin = h3->GetZaxis()->GetBinLowEdge(iz);
zmax = zmin + h3->GetZaxis()->GetBinWidth(iz);
bin = h3->GetBin(ix,iy,iz);
w = h3->GetBinContent(bin);
scale = (w-wmin)/(wmax-wmin);
m3 = new
TMarker3DBox(0.5*(xmin+xmax),0.5*(ymin+ymax),0.5*(zmin+zmax),
scale*(xmax-xmin),scale*(ymax-ymin),scale*(zmax-zmin),0,0);
m3->SetLineColor(h3->GetMarkerColor());
m3->Draw();
}
}
}
}