RE: drawing TNode in TPad

From: Valery Fine (Faine) (fine@bnl.gov)
Date: Wed May 26 1999 - 19:42:59 MEST


  Here is a very primitive macro one may find useful.
               Valery

void PadControlPanel(){
//
// This macro generates a Controlbar menu:
// To execute an item, click with the left mouse button.
//   gROOT->Reset();
   TControlBar *bar = new TControlBar("vertical", "Pad Control Panel");
   bar->AddButton("Black background", "SetBackround(kBlack);", "Change the backgroung color to black");
   bar->AddButton("White background", "SetBackround(kWhite);", "Change the backgroung color to white");
   bar->AddButton("Centered","Centered3DImages();","Place (0,0,0) into the center of the view port");
   bar->AddButton("Scale +","Inscrease3DScale();","Change the scale of the image");
   bar->AddButton("Scale -","Decrease3DScale();","Change the scale of the image");
   bar->AddButton("Top View","TopView();","Show the top view");
   bar->AddButton("Side View","SideView();","Show the side view");
   bar->AddButton("Front View","FrontView();","Show the fornt view");

   bar->Show();
}

//__________________________________________________
void SetBackround(Color_t color, TVirtualPad *pad=0)
{
  TVirtualPad *thisPad = pad;
  if (!thisPad) thisPad = gPad;
  if (thisPad)  {
    thisPad->SetFillColor(color);
    thisPad->Modified();
    thisPad->Update();
  }
}

//__________________________________________________
void RotateView(Float_t phi, Float_t theta, TVirtualPad *pad=0)
{
  TVirtualPad *thisPad = pad;
  if (!thisPad) thisPad = gPad;
  if (thisPad) {
    TView *view = thisPad->GetView(); 
    if (view) {
      Int_t iret;
      view->SetView(phi, theta, 0, iret);
      thisPad->Modified();
      thisPad->Update();
    }
  }
}
//__________________________________________________
void FrontView(){
  RotateView(0,-90.0);
}
//__________________________________________________
void TopView(){
  RotateView(90.0,-90.0);
}
//__________________________________________________
void SideView(){
  RotateView(90.0,0.0);
}
//__________________________________________________
void Centered3DImages()
{
  // This macro prints out the sizes of the sekected 3d pad
  TView *view = gPad->GetView(); 
  Float_t min[3],max[3];
  view->GetRange(min,max);
  int i;
  for (i=0;i<3; i++) min[i]=-max[i];
  view->SetRange(min,max);
  gPad->Modified();
  gPad->Update();
}

//__________________________________________________
void Decrease3DScale()
{
  // This macro prints out the sizes of the sekected 3d pad
  TView *view = gPad->GetView(); 
  Float_t min[3],max[3];
  view->GetRange(min,max);
  int i;
  for (i=0;i<2; i++) {max[i] /= 0.8; min[i]=max[i]*0.1;}
  view->SetRange(min,max);
  printf("\n ---- \n");
  gPad->Modified();
  gPad->Update();
}

//__________________________________________________
void Inscrease3DScale()
{
  // This macro prints out the sizes of the sekected 3d pad
  TView *view = gPad->GetView(); 
  Float_t min[3],max[3];
  view->GetRange(min,max);
  int i;
  for (i=0;i<2; i++) {max[i] *= 0.8; min[i]=max[i]*0.1;}
  view->SetRange(min,max);
  gPad->Modified();
  gPad->Update();
}

> 
> Rutger van der Eijk wrote:
> > 
> > Hi rooters,
> > 
> > When a TNode is drawn in a TPad the z-axis is always orientated 'up' (i.e.
> > to the top of my screen). However I would like the z-axis to be horizontal
> > (i.e. along a beam-axis). Is there an option to change this 'default'
> > orientation?
> > 
> > (I could define a mother volume around the TNode and have the child TNode
> > orientated such that Z becomes horizontal. However I don't want this
> > because I want to use the same event display to draw sub-parts of the
> > detector (i.e. child TNodes, child/child TNodes etc...), which would mean
> > defining these extra TNodes for every sub node...)
> > 
> > Thanks,
> > 
> > Rutger van der Eijk
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:33 MET