Using TView3D to show axis

Hi,

I’m display a TGeoVolume defined within a TGeoManager, it displays great but I’d like to automatically show the axis. I’m aware of right clicking the canvas and selecting the option, but I am trying to create several nice animated gifs. Thus far I’ve tried creating my own TView3D, and enabling ‘ShowAxis()’ but this has no effect, I’m not sure if declaring TView3D is doing much.

The canvas is divided into the volume display and an analysis plot,

  [...]
  TGeoVolume *top = geom->MakeBox("TOP", Vacuum, worldx,worldy,worldz);
  [...]
  static TCanvas *e3 = new TCanvas("e3", "result", 1200, 600);
  TH2F *obs_result = new TH2F("obs_result", "Solid Angle Result", 300, 0, 1, 300, 0, 1);
  TGraph *obs_graph = new TGraph();

  e3->Divide(2);
  e3->cd(1);
  TView3D *view = new TView3D();
  view->SetRange(-100,-100,-100,100,100,100);
  view->ShowAxis();
  top->Draw();
  e3->cd(2);
  gPad->SetLogz();
  gStyle->SetMarkerStyle(kFullTriangleUp);
  gStyle->SetMarkerColor(2);
  obs_result->Draw("colz");
  obs_graph->Draw("p same");
  e3->cd(1);

  [...] <-- Analysis Code omitted
  e3->GetPad(1)->Modified();
  e3->GetPad(1)->Update();
  e3->GetPad(2)->Modified();
  e3->GetPad(2)->Update();

Am I using TView3D inside the canvas subpad correctly? Changing the settings doesn’t affect the image, it seems to be using some default TView3D that is called when executing top->Draw();

Thanks for any help.

Here is a working example using ShowAxis:

{
   c1 = new TCanvas("c1","PolyLine3D & PolyMarker3D Window",200,10,500,500);

   // Creating a view
   TView3D *view = TView::CreateView(1);
   view->SetRange(5,5,5,25,25,25);
   view->ShowAxis();

   // Create a first PolyLine3D
   TPolyLine3D *pl3d1 = new TPolyLine3D(5);
   pl3d1->SetPoint(0, 10, 10, 10);
   pl3d1->SetPoint(1, 15, 15, 10);
   pl3d1->SetPoint(2, 20, 15, 15);
   pl3d1->SetPoint(3, 20, 20, 20);
   pl3d1->SetPoint(4, 10, 10, 20);

   // Create a first PolyMarker3D
   TPolyMarker3D *pm3d1 = new TPolyMarker3D(12);
   pm3d1->SetPoint(0, 10, 10, 10);
   pm3d1->SetPoint(1, 11, 15, 11);
   pm3d1->SetPoint(2, 12, 15, 9);
   pm3d1->SetPoint(3, 13, 17, 20);
   pm3d1->SetPoint(4, 14, 16, 15);
   pm3d1->SetPoint(5, 15, 20, 15);
   pm3d1->SetPoint(6, 16, 18, 10);
   pm3d1->SetPoint(7, 17, 15, 10);
   pm3d1->SetPoint(8, 18, 22, 15);
   pm3d1->SetPoint(9, 19, 28, 25);
   pm3d1->SetPoint(10, 20, 12, 15);
   pm3d1->SetPoint(11, 21, 12, 15);
   pm3d1->SetMarkerSize(2);
   pm3d1->SetMarkerColor(4);
   pm3d1->SetMarkerStyle(2);

   // Draw
   pl3d1->Draw();
   pm3d1->Draw();
}

I tried that example beforehand, I get a type conversion error,

 error: invalid conversion from ‘TView*’ to ‘TView3D*’

Adding a typecast doesnt stops the error, but nothing is different.

  static TCanvas *e3 = new TCanvas("e3", "result", 1200, 600);
  TH2F *obs_result = new TH2F("obs_result", "Solid Angle Result", 300, 0, 1, 300, 0, 1);
  TGraph *obs_graph = new TGraph();

  e3->Divide(2);
  e3->cd(1);
  TView3D *view = (TView3D*)TView::CreateView(1);
  view->SetRange(-100,-100,-100,100,100,100);
  view->ShowAxis();
  top->Draw();

There’s a typo in my last post, adding the typecast stops the error. However declaring my own TView does not have any effect.

what is "top"in your macro ?

Error: Symbol top is not defined in current scope  tv3.C:11:
Error: Failed to evaluate top->Draw()
*** Interpreter error recovered ***