RE: drawing TNode in TPad

Valery Fine (fine@bnl.gov)
Wed, 26 May 1999 13:42:59 -0400


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
>