StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TPoints3D.cxx
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@mail.cern.ch) 24/04/99
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "Riostream.h"
13 
14 #include "TROOT.h"
15 #include "TClass.h"
16 #include "TPoints3D.h"
17 #include "TPointsArray3D.h"
18 
19 //______________________________________________________________________________
20 //
21 // TPoints3D is an abstract class of the array of 3-dimensional points.
22 // It has 4 different constructors.
23 //
24 // This class has no implemenatation for Paint, Draw, and SavePrimitive methods
25 //
26 // First one, without any parameters TPoints3D(), we call 'default
27 // constructor' and it's used in a case that just an initialisation is
28 // needed (i.e. pointer declaration).
29 //
30 // Example:
31 // TPoints3D *pl1 = new TPoints3D;
32 //
33 //
34 // Second one is 'normal constructor' with, usually, one parameter
35 // n (number of points), and it just allocates a space for the points.
36 //
37 // Example:
38 // TPoints3D pl1(150);
39 //
40 //
41 // Third one allocates a space for the points, and also makes
42 // initialisation from the given array.
43 //
44 // Example:
45 // TPoints3D pl1(150, pointerToAnArray);
46 //
47 //
48 // Fourth one is, almost, similar to the constructor above, except
49 // initialisation is provided with three independent arrays (array of
50 // x coordinates, y coordinates and z coordinates).
51 //
52 // Example:
53 // TPoints3D pl1(150, xArray, yArray, zArray);
54 //
55 
56 ClassImp(TPoints3D);
57 
60 
61 TPoints3D::TPoints3D(TPoints3DABC *points) : fPoints(points)
62 {
63  DoOwner(kFALSE);
64  fPoints = points;
65  if (!fPoints) {
66  fPoints = new TPointsArray3D;
67  DoOwner();
68  }
69 }
70 
74 
75 TPoints3D::TPoints3D(Int_t n, Option_t *option) : fPoints( new TPointsArray3D(n,option))
76 {
77  DoOwner();
78 }
79 
83 
84 TPoints3D::TPoints3D(Int_t n, Float_t *p, Option_t *option) : fPoints(new TPointsArray3D(n,p,option))
85 {
86  DoOwner();
87 }
88 
89 
93 
94 TPoints3D::TPoints3D(Int_t n, Float_t *x, Float_t *y, Float_t *z, Option_t *option)
95  : fPoints(new TPointsArray3D(n,x,y,z,option))
96 {
97  DoOwner();
98 }
99 
100 
103 
105 {
106  Delete();
107 }
110 
111 TPoints3D::TPoints3D(const TPoints3D &point) : TPoints3DABC(point)
112 {
113  ((TPoints3D&)point).Copy(*this);
114 }
117 
118 void TPoints3D::Copy(TObject &obj) const
119 {
120  TPoints3DABC::Copy(obj);
121  TPoints3D &thatObject = (TPoints3D&)obj;
122  thatObject.Delete();
123  if (thatObject.IsOwner()) {
124  thatObject.fPoints = new TPoints3D(GetN(),GetP(),GetOption());
125  (thatObject.fPoints)->SetLastPosition(GetLastPosition());
126  }
127  else
128  thatObject.fPoints = fPoints;
129 }
130 
133 
135 {
136  if (fPoints && IsOwner()) delete fPoints;
137  fPoints = 0;
138 }
139 
142 
143 Bool_t TPoints3D::DoOwner(Bool_t done)
144 {
145  if (done) SetBit(kIsOwner);
146  else ResetBit(kIsOwner);
147  return IsOwner();
148 }
149 
152 
153 void TPoints3D::ExecuteEvent(Int_t event, Int_t px, Int_t py)
154 {
155  if (fPoints)
156  fPoints->ExecuteEvent(event,px,py);
157 }
158 
161 
162 void TPoints3D::ls(Option_t *option) const
163 {
164  TROOT::IndentLevel();
165  std::cout << IsA()->GetName() << " N=" <<GetN()<<" Option="<<option<<std::endl;
166 // IsOwner()?"Owner":"Not owner" << std::endl;
167 }
168 
171 
172 void TPoints3D::Print(Option_t *option) const
173 {
174  std::cout <<" " << IsA()->GetName() <<" Printing N=" <<GetN()<<" Option="<<option<<std::endl;
175 // IsOwner()?"Owner":"Not owner" << std::endl;
176 }
177 
virtual void Delete()
Delete only own object.
Definition: TPoints3D.cxx:134
virtual void Print(Option_t *option="") const
Dump this 3-D polyline with its attributes.
Definition: TPoints3D.cxx:172
virtual void Copy(TObject &points) const
Copy this TPoints3D to another.
Definition: TPoints3D.cxx:118
Bool_t DoOwner(Bool_t done=kTRUE)
to be documented
Definition: TPoints3D.cxx:143
TPoints3D(TPoints3DABC *points=0)
3-D PolyLine default constructor.
Definition: TPoints3D.cxx:61
virtual void ls(Option_t *option="") const
List this 3-D polyline with its attributes.
Definition: TPoints3D.cxx:162
virtual ~TPoints3D()
3-D PolyLine default destructor.
Definition: TPoints3D.cxx:104
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TPoints3D.cxx:153