Re: TView on the 'background'

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Mar 02 2000 - 22:10:22 MET


Hi Rutger,
If you look at the end of TNode::DistancetoPrimitive, you will see a few 
lines of code selecting the TView if no TNode is selected.
As soon as you have a TNode in the picture, the TView object will be
selected.
You will find below a modified version of tutorials/tornado.C
where I have added a few lines to draw a dummy TNode with
visibilty set to 0.
In your event display program, you can use the same logic as in 
TNode::DistancetoPrimitive to select TView if nothing else
is selected.

Rene Brun

{
    double PI = 3.141592653;
    int d = 16;
    int numberOfPoints=200;
    int numberOfCircles=40;
    float x, y, z;

    // create and open a canvas
    sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 );
    sky->SetFillColor(14);

    // creating view
    TView *view = new TView(1);
    float range = numberOfCircles*d;
    view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range );

    for( int j = d; j < numberOfCircles*d; j += d ) {
        TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints );
        for( int i = 1; i < numberOfPoints; i++ ) {
            float csin = sin(2*PI / (double)numberOfPoints  * (double)i) +
1;
            float ccos = cos(2*PI / (double)numberOfPoints  * (double)i) +
1;
            float esin = sin(2*PI / (double)(numberOfCircles*d) *
(double)j) + 1;
            x = j * ( csin + esin );
            y = j * ccos;
            z = j;
            pm3d->SetPoint( i, x, y, z );
        }
        pm3d->SetMarkerSize( 1 );
        pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) );
        pm3d->SetMarkerStyle( 3 );
        pm3d->Draw();
    }
   TBRIK *brik = new TBRIK("BRIK","BRIK","void",200,150,150);
   TNode *node1 = new TNode("NODE1","NODE1","BRIK");
   node1->SetVisibility(0);
   node1->Draw("same");
}


On Thu, 2 Mar 2000, Rutger van der Eijk wrote:

> Hi Rene,
> 
> I looked into it a bit further. Basically my question can be explained
> by looking at the examples tornado.C and shapes.C in the tutorial.
> 
> In shapes.C I create some shapes attach them to a a node. And than draw
> the top node. On the canvas (I don't mean the X3D view) I can rotate the
> view anywhere in the canvas. If I turn on 'event status', I see that this
> is because TView is always selected if not one of the shapes is 'near'.
> This is what I mean with TView beging on the 'background', and it is the
> effect I want to have.
> 
> No if I execute tornado.C I get something different. I can only rotate if
> my mouse is near the tornado. If I am away from the tornado the canvas is
> selected and NOT the TView.
> 
> My question is: Why is in the case of tornado not TView 'on the
> background'?
> 
> Cheers,
> 
> Rutger
> 
> On Sat, 26 Feb 2000, Rene Brun wrote:
> 
> > Hi Rutger,
> > The way you create TView is OK. I have to know a bit more about
> > what your Track class is (how you draw it?) to come with a diagnostic.
> > Look at $ROOTSYS/tutorials/tornado.C for a simple example.
> > Did you derive your class from TAtt3D ?
> > At least one 3-d object must be in the pad to get the view cursor.
> > 
> > Rene Brun
> > 
> > 
> > On Fri, 25 Feb 2000, Rutger van der Eijk wrote:
> > 
> > > Hi,
> > > 
> > > I want to be able to rotate a track which I draw on a canvas by using a
> > > TView.
> > > 
> > > I have some geometry description with the ROOT geometry classes. If I draw
> > > the geometry on a canvas I am able to rotate it. The rotation is provided
> > > by TView. I always get the rotation symbol if the TView is 'selected'
> > > (i.e. shortest distanceToPrimitive; turning on 'Event Status' in canvas
> > > tells me).
> > > 
> > > I want to be able to do the same thing (rotate from a TView) with a track
> > > that I paint. So as done in TNode::Draw() (which is called by
> > > TGeometry::Draw()) I create a TView:
> > > 
> > >    if (!gPad) {
> > >       if (!gROOT->GetMakeDefCanvas()) return;
> > >       (gROOT->GetMakeDefCanvas())();
> > >    }
> > >    gPad->Clear();
> > > 
> > >    TView *view = gPad->GetView();
> > >    if (!view) {
> > >       view = new TView(1);
> > >       view->SetRange(-100, -250, 300, 100, 250, 1000);
> > >      // where the range is the range where the track can be present
> > >    }
> > > 
> > > and after that draw by track
> > > 
> > > The track is correctly painted, but I am not able to rotate the track
> > > because TView is never 'selected'. Instead of TView the created canvas
> > > (c1) is selected.
> > > 
> > > Why doesn't this work? Or better why is TView selected after a geometry
> > > draw, and in my simple case not? 
> > > 
> > > (I know I can use a TMarker3DBox to get a box which helps me rotate, but I
> > > want to rotate without having to refer to the TMarker3DBox edges. Which
> > > works with TView on the 'background', i.e. always 'selected' if no other
> > > object is.)
> > > 
> > > I have the feeling I am missing something trivial. But I seem not to be
> > > able to figure out what. Can anyone show me the light?
> > > 
> > > Thanks,
> > > 
> > > Rutger
> > > 
> > > 
> > 
> > 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET