Introduction of the Copyright and cvs Log
[u/mrichter/AliRoot.git] / TGeant3 / TPaveTree.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 */
19
20 ///////////////////////////////////////////////////////////////////////////////
21 //                                                                           //
22 //  Interface Class to the Geant3.21 MonteCarlo                              //
23 //  Author :    Rene Brun   08/12/98                                         //
24 //                                                                           //
25 //  A TPaveTree is a TPaveLabel  specialized to draw Geant GDtree            //
26 //                                                                           //
27 //  When a TPaveTree object is drawn in a canvas, one can:                   //
28 //    - double click to draw the spec                                        //
29 //    - select pop-up item DrawTree to draw its tree                         //
30 //    - select pop-up item DrawTreeParent to draw its parent tree            //
31 //                                                                           //
32 //Begin_Html
33 /*
34 <img src="picts/TPaveTreeClass.gif">
35 */
36 //End_Html
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39 #include <fstream.h>
40 #include <iostream.h>
41
42 #include <TROOT.h>
43 #include <TVirtualPad.h>
44 #include <Buttons.h>
45 #include "TPaveTree.h"
46 #include "TGeant3.h"
47
48
49 ClassImp(TPaveTree)
50
51 //_____________________________________________________________________________
52 TPaveTree::TPaveTree(): TPaveLabel()
53 {
54   //
55   // Default Constructor
56   //
57 }
58
59 //_____________________________________________________________________________
60 TPaveTree::TPaveTree(Coord_t x1, Coord_t y1,Coord_t x2, Coord_t  y2, 
61                      const Text_t *label)
62   :TPaveLabel(x1,y1,x2,y2,label,"br")
63 {
64   //
65   // TPaveTree normal constructor
66   //
67   SetName(label);
68 }
69
70 //_____________________________________________________________________________
71 TPaveTree::~TPaveTree()
72 {
73   //
74   // Standard Destructor
75   //
76 }
77
78 //_____________________________________________________________________________
79 TPaveTree::TPaveTree(const TPaveTree &PaveTree)
80 {
81   //
82   // Copy Constructor
83   //
84   ((TPaveTree&)PaveTree).Copy(*this);
85 }
86
87 //_____________________________________________________________________________
88 void TPaveTree::Copy(TObject &obj)
89 {
90   //
91   //  Copy this PaveTree to PaveTree
92   //
93   TPaveLabel::Copy(obj);
94 }
95
96 //_____________________________________________________________________________
97 void TPaveTree::DrawSpec()
98 {
99   //
100   //  Draw specs of the volume in this TPaveTree
101   //
102   gMC->DrawOneSpec(GetLabel());
103 }
104
105 //_____________________________________________________________________________
106 void TPaveTree::DrawTree(Int_t levmax, Int_t isel)
107 {
108   //
109   //  Draw tree of the volume in this TPaveTree
110   //
111   ((TGeant3*)gMC)->Gdtree(GetLabel(),levmax,isel);
112 }
113
114 //_____________________________________________________________________________
115 void TPaveTree::DrawTreeParent(Int_t levmax, Int_t isel)
116 {
117   //
118   //  Draw parent tree of the volume in this TPaveTree
119   //
120   ((TGeant3*)gMC)->GdtreeParent(GetLabel(),levmax,isel);
121 }
122
123 //_____________________________________________________________________________
124 void TPaveTree::ExecuteEvent(Int_t event, Int_t px, Int_t py)
125 {
126   //
127   // Process mouse events.
128   // Invokes TPabeLabel::ExecuteEvent. In case of a double click
129   // draw specs of volume corresponding to this TPaveTree
130   //
131   
132   TPaveLabel::ExecuteEvent(event,px,py);
133   
134   if (event == kButton1Double) {
135     //printf("TPaveTree::ExecuteEvent\n");
136     gPad->SetCursor(kWatch);
137     gMC->DrawOneSpec(GetLabel());
138   }
139 }
140
141 //_____________________________________________________________________________
142 void TPaveTree::SavePrimitive(ofstream &out, Option_t *)
143 {
144   //
145   // Save primitive as a C++ statement(s) on output stream out
146   //
147   char quote = '"';
148   out<<"   "<<endl;
149   if (gROOT->ClassSaved(TPaveTree::Class())) {
150     out<<"   ";
151   } else {
152     out<<"   TPaveTree *";
153   }
154   out<<"pvar = new TPaveTree("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
155      <<","<<quote<<fLabel<<quote<<","<<quote<<fOption<<quote<<");"<<endl;
156   
157   SaveFillAttributes(out,"pvar",0,1001);
158   SaveLineAttributes(out,"pvar",1,1,1);
159   SaveTextAttributes(out,"pvar",22,0,1,62,0);
160   
161   out<<"   pvar->Draw();"<<endl;
162 }