Rene Brun
//method1
{
new TCanvas("can","test",700,500);
TPad *m_Pad = (TPad*)gPad;
TGeometry *ams = new TGeometry("ams","ams.C");
mat = new TMaterial("mat16","VACUUM",0,0,0);
AMSG = new TBRIK("AMSG","AMSG","mat16",190,190,190);
node1 = new TNode("AMSG1","AMSG1","AMSG");
Float_t theta=90; Float_t phi=0;
gPad->SetFillColor(10);
gPad->Clear();
ams->Draw();
TView *view = gPad->GetView();
view->SetRange(-800.0, -800.0, -520.0, 800.0, 800.0, 520.0);
Int_t iret;
if ( theta != 9999 && phi != 9999 ) view->SetView(phi, theta, 0,
iret);
gPad->Modified();
gPad->Update();
}
//method2
{
new TCanvas("can","test",700,500);
TPad *m_Pad = (TPad*)gPad;
TGeometry *ams = new TGeometry("ams","ams.C");
mat = new TMaterial("mat16","VACUUM",0,0,0);
AMSG = new TBRIK("AMSG","AMSG","mat16",190,190,190);
node1 = new TNode("AMSG1","AMSG1","AMSG");
Float_t theta=90; Float_t phi=0;
gPad->SetFillColor(10);
gPad->Clear();
TView *view = new TView(1);
view->SetRange(-800.0, -800.0, -520.0, 800.0, 800.0, 520.0);
ams->Draw("same");
Int_t iret;
if ( theta != 9999 && phi != 9999 ) view->SetView(phi, theta, 0,
iret);
gPad->Modified();
gPad->Update();
}
Ye Shuwei wrote:
>
> Hi, ROOT team,
>
> When I use TView::SetView to change the view angle, it always cause
> " *** Break *** segmentation violation " in case TGeometry is drawn.
>
> Here is the macro I used:
>
> {
> new TCanvas("can","test",700,500);
> TPad *m_Pad = (TPad*)gPad;
>
> TGeometry *ams = new TGeometry("ams","ams.C");
> mat = new TMaterial("mat16","VACUUM",0,0,0);
> AMSG = new TBRIK("AMSG","AMSG","mat16",190,190,190);
> node1 = new TNode("AMSG1","AMSG1","AMSG");
>
> Float_t theta=90; Float_t phi=0;
>
> gPad->SetFillColor(10);
> gPad->Clear();
>
> // gPad->SetPhi(-90-phi); gPad->SetTheta(90-theta);
>
> TView *view = new TView(1);
> view->SetRange(-800.0, -800.0, -520.0, 800.0, 800.0, 520.0);
> ams->Draw();
>
> Int_t iret;
> if ( theta != 9999 && phi != 9999 ) view->SetView(phi, theta, 0, iret);
>
> gPad->Modified();
> gPad->Update();
> }
>
> If I use gPad->SetPhi/SetTheta to change instead of view->SetView, it is
> OK.
>
> Did I invoke in a wrong way to change view angle ?
>
> Thanks in advance --Shuwei