Re: Viewpoint in 3D

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 18 May 2009 14:11:08 +0200


Roger,

Try the script in the attachment. Use TPad::SetTheta, Phi to set the viewing angle.
Yes, we have some incoherent behavior between settings via TPad and TView.

Rene Brun

Roger Mason wrote:
> Hello Rene,
>
> Rene Brun <Rene.Brun_at_cern.ch> writes:
>
>
>> Try this...
>>
>
> I modified your example to try to rotate the viewpoint and I now have
> this:
>
> {
> TCanvas *c = new TCanvas("c","Graph2D example",0,0,600,400);
>
> TGraph2D *dt = new TGraph2D("graph.dat");
>
> gStyle->SetPalette(1);
>
> Double_t contours[] = {20,40,60,80,100,120,140,160,180,200};
>
> // Set the canvas range a bit bigger than the x,y data ranges
> c->Range(0,0,160,160); // does not work
> c->SetTheta(84);
> c->SetPhi(45);
> TH2D* h = new TH2D();
> h = dt->GetHistogram(); // Get histo interpolated between
> // control points in dt.
> h->SetContour(10,contours); // Set 10 contour levels (default is
> 20)
> h->Draw("surf2"); // Draw interpolated points as surface
> h->Draw("cont1 same"); // Contour the surface
> dt->SetMarkerStyle(8); // Marker for the control points
> dt->Draw("p same"); // Superimpose the control points
> dt->GetZaxis()->SetNdivisions(2);
> //draw text at each point
> Double_t xyz[3], uv[2];
> Int_t np = dt->GetN();
> c->Update();
>
> TView *view = c->GetView();
>
> Double_t longit = view->GetLongitude();
> Double_t lat = view->GetLatitude();
> Double_t psi = view->GetPsi();
>
> cout << "Longit: " << longit << " Lat: " << lat << " Psi: " << psi <<
> endl;
> Int_t irep;
> // view->SetView(longit,view->GetLatitude(),view->GetPsi(),0);
> view->SetView(10,0,100,irep);
> c->Modified();
> c->Update();
>
> // TText t;
> // t->SetTextSize(0.035);
> // for (Int_t i=0;i<np;i++) {
> // xyz[0] = dt->GetX()[i];
> // xyz[1] = dt->GetY()[i];
> // xyz[2] = dt->GetZ()[i];
> // view->WCtoNDC(xyz,uv);
> // t->DrawText(uv[0]+0.01,uv[1],Form("point %d",i));
> // }
> return c;
> }
>
> Using view->SetView() does not change the viewpoint. What am I doing
> wrong?
>
> Thanks for your help.
>
> Roger
>
>

Received on Mon May 18 2009 - 14:11:55 CEST

This archive was generated by hypermail 2.2.0 : Mon May 18 2009 - 17:50:01 CEST