61 TShape::TShape(
const char *name,
const char *title,
const char *materialname)
62 : TNamed (name, title), TAttLine(), TAttFill()
65 if (!gGeometry) gGeometry =
new TGeometry(
"Geometry",
"Default Geometry");
66 fMaterial = gGeometry->GetMaterial(materialname);
67 fNumber = gGeometry->GetListOfShapes()->GetSize();
68 gGeometry->GetListOfShapes()->Add(
this);
79 TShape::TShape(
const TShape& ts) :
85 fVisibility(ts.fVisibility),
86 fMaterial(ts.fMaterial)
93 TShape& TShape::operator=(
const TShape& ts)
96 TNamed::operator=(ts);
97 TAttLine::operator=(ts);
98 TAttFill::operator=(ts);
99 TAtt3D::operator=(ts);
101 fVisibility=ts.fVisibility;
102 fMaterial=ts.fMaterial;
112 if (gGeometry) gGeometry->GetListOfShapes()->Remove(
this);
118 Int_t TShape::ShapeDistancetoPrimitive(Int_t numPoints, Int_t px, Int_t py)
122 TView *view = gPad->GetView();
123 if (!(numPoints && view))
return dist;
125 Double_t *points =
new Double_t[3*numPoints];
127 Double_t dpoint2, x1, y1, xndc[3];
128 for (Int_t i = 0; i < numPoints; i++) {
129 if (gGeometry) gGeometry->Local2Master(&points[3*i],&points[3*i]);
130 view->WCtoNDC(&points[3*i], xndc);
131 x1 = gPad->XtoAbsPixel(xndc[0]);
132 y1 = gPad->YtoAbsPixel(xndc[1]);
133 dpoint2= (px-x1)*(px-x1) + (py-y1)*(py-y1);
134 if (dpoint2 < dist) dist = (Int_t)dpoint2;
137 return Int_t(TMath::Sqrt(Float_t(dist)));
143 void TShape::Paint(Option_t *)
145 TVirtualViewer3D * viewer3D = gPad->GetViewer3D();
147 const TBuffer3D & buffer = GetBuffer3D(TBuffer3D::kAll);
148 viewer3D->AddObject(buffer);
155 void TShape::SetPoints(Double_t *)
const
157 AbstractMethod(
"SetPoints(Double_t *buffer) const");
163 void TShape::Streamer(TBuffer &R__b)
165 if (R__b.IsReading()) {
167 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
169 R__b.ReadClassBuffer(TShape::Class(),
this, R__v, R__s, R__c);
173 TNamed::Streamer(R__b);
174 TAttLine::Streamer(R__b);
175 TAttFill::Streamer(R__b);
176 TAtt3D::Streamer(R__b);
180 R__b.CheckByteCount(R__s, R__c, TShape::IsA());
184 R__b.WriteClassBuffer(TShape::Class(),
this);
191 void TShape::TransformPoints(Double_t *points, UInt_t NbPnts)
const
193 if (gGeometry && points) {
196 for (UInt_t j=0; j<NbPnts; j++) {
197 dlocal[0] = points[3*j];
198 dlocal[1] = points[3*j+1];
199 dlocal[2] = points[3*j+2];
200 gGeometry->Local2Master(&dlocal[0],&dmaster[0]);
201 points[3*j] = dmaster[0];
202 points[3*j+1] = dmaster[1];
203 points[3*j+2] = dmaster[2];
212 void TShape::FillBuffer3D(TBuffer3D & buffer, Int_t reqSections)
const
214 if (reqSections & TBuffer3D::kRaw)
216 if (!(reqSections & TBuffer3D::kRawSizes) && !buffer.SectionsValid(TBuffer3D::kRawSizes))
222 if (reqSections & TBuffer3D::kCore) {
223 buffer.ClearSectionsValid();
229 buffer.fColor = GetLineColor();
230 buffer.fTransparency = 0;
231 buffer.fLocalFrame = kFALSE;
232 buffer.fReflection = kFALSE;
234 buffer.SetLocalMasterIdentity();
235 buffer.SetSectionsValid(TBuffer3D::kCore);
242 Int_t TShape::GetBasicColor()
const
244 Int_t basicColor = ((GetLineColor() %8) -1) * 4;
245 if (basicColor < 0) basicColor = 0;
253 const TBuffer3D &TShape::GetBuffer3D(Int_t )
const
255 static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
256 Warning(
"GetBuffer3D",
"this must be implemented for shapes in a TNode::Paint hierarchy. This will become a pure virtual fn eventually.");