12 #include "TPolyLineShape.h"
14 #include "TPoints3D.h"
16 #include "TVolumePosition.h"
21 #include "TVirtualPad.h"
22 #include "TVirtualX.h"
23 #include "TTablePadView3D.h"
25 #include "TVirtualPS.h"
113 Error(
"TPolyLineShape",
"No polyline is defined");
116 fPointFlag = strchr(option,
'P')?kTRUE:kFALSE;
117 fLineFlag = strchr(option,
'L')?kTRUE:kFALSE;
129 SafeDelete(fSizeX3D);
137 if (!fConnection) SetConnection(kBrik);
145 if (!fSizeX3D) fSizeX3D =
new Size3D;
146 fSizeX3D->numPoints = 0;
147 fSizeX3D->numSegs = 0;
148 fSizeX3D->numPolys = 0;
150 Int_t size = fPoints->Size();
153 if (size > 10000) mode = 1;
154 else if (size > 3000) mode = 2;
157 fSizeX3D->numSegs = size*mode;
158 fSizeX3D->numPoints = size*mode*2;
159 fSizeX3D->numPolys = 0;
161 fSizeX3D->numSegs = size-1;
162 fSizeX3D->numPoints = size;
164 fSizeX3D->numPolys = 0;
172 Int_t TPolyLineShape::SetConnection(EShapeTypes connection)
174 Float_t size = 0.5*GetWidthFactor()*GetLineWidth();
176 if (fShapeType != connection) {
177 SafeDelete(fConnection);
178 fShapeType = connection;
179 switch (fShapeType) {
181 SetConnection(
new TSPHE(
"connection",
"sphere",
"void",0,size,0,90,0,360));
184 SetConnection(
new TBRIK(
"connection",
"brik",
"void",size,size,size));
202 Int_t ret = fPoints->DistancetoPrimitive( px, py);
219 const Int_t inaxis = 7;
220 Float_t dist = 999999;
222 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
223 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
224 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
225 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
229 if (px < puxmin - inaxis)
goto END;
230 if (py > puymin + inaxis)
goto END;
231 if (px > puxmax + inaxis)
goto END;
232 if (py < puymax - inaxis)
goto END;
234 view = gPad->GetView();
240 Int_t pointSize = fPoints->Size();
241 for (i=0;i<pointSize;i++) {
242 Float_t thisPoints[3];
243 view->WCtoNDC(fPoints->GetXYZ(thisPoints,i), xndc);
244 x1 = gPad->XtoAbsPixel(xndc[0]);
245 y1 = gPad->YtoAbsPixel(xndc[1]);
246 dpoint = (px-x1)*(px-x1) + (py-y1)*(py-y1);
247 if (dpoint < dist) dist = dpoint;
249 dist = (TMath::Sqrt(dist));
269 if (fPoints) fPoints->ExecuteEvent(event,px, py);
284 return fPoints ? fPoints->GetName() : TShape::GetName();
291 return fPoints ? fPoints->GetObjectInfo(px, py) : TShape::GetObjectInfo(px,py);
315 return fPoints ? fPoints->GetTitle() : TShape::GetTitle();
324 const Int_t kDimension = 3;
325 Double_t vector[kDimension];
326 Double_t nodeposition[kDimension];
328 for (i=0;i<kDimension;i++) {
329 vector[i]=end[i]-start[i];
330 nodeposition[i]=0.5*(start[i]+end[i]);
332 Double_t length = TMath::Normalize(vector);
336 Double_t oz[3]={0,0,1};
339 Double_t sina = TMath::Normalize(TMath::Cross(vector,oz,rotate));
340 Double_t cosa =
Product(vector,oz);
343 TShape *shape = fShape;
344 if (!shape) shape = fConnection;
346 Gyrot(rotate,cosa,sina,mrot);
348 Float_t width = GetWidthFactor()*GetLineWidth();
358 mrot[2][0] *= length;
359 mrot[2][1] *= length;
360 mrot[2][2] *= length;
362 Color_t color = GetLineColor();
364 TVolume node(
"SegmentNode",
"SegmentNode", shape);
365 node.SetLineColor(color);
367 node.SetLineColor(color);
369 TRotMatrix matrix (
"rotate",
"rotate",&mrot[0][0]);
371 ,nodeposition[2],&matrix);
373 if (!(fSmooth || fConnection)) {
380 memset(mrot,0,9*
sizeof(Double_t));
382 length = width/length;
387 TRotMatrix kneeMatrix(
"knee",
"knee",&mrot[0][0]);
388 TVolume knee(
"ConnectionNode",
"ConnectionNode", fConnection);
390 knee.SetLineColor(color);
391 node.Add(&knee,&kneePosition);
401 if (!GetPoints())
return;
403 Bool_t rangeView = opt && opt[0] && strcmp(opt,
"range")==0 ? kTRUE : kFALSE;
409 if (fLineFlag) mode =
"L";
410 if (fPointFlag) mode +=
"P";
413 view3D->PaintPoints3D(GetPoints(), mode.Data());
415 if (opt && !strstr(opt,
"x3d")) {
447 for (Int_t i=1;i<n;i++) {
449 fPoints->GetXYZ(&xyz[0],i-1,2);
450 gPad->PaintLine3D(xyz, &xyz[3]);
461 TView *view = gPad->GetView();
465 TPoint *pxy =
new TPoint[n];
466 Float_t *x =
new Float_t[n];
467 Float_t *y =
new Float_t[n];
468 Float_t xndc[3], ptr[3];
472 for (Int_t i = 0; i < n; i++) {
473 fPoints->GetXYZ(ptr,i);
474 view->WCtoNDC(ptr, xndc);
475 if (xndc[0] < gPad->GetX1() || xndc[0] > gPad->GetX2())
continue;
476 if (xndc[1] < gPad->GetY1() || xndc[1] > gPad->GetY2())
continue;
479 pxy[nin].fX = gPad->XtoPixel(x[nin]);
480 pxy[nin].fY = gPad->YtoPixel(y[nin]);
484 TAttMarker::Modify();
487 if (!gPad->IsBatch()) gVirtualX->DrawPolyMarker(nin, pxy);
491 gVirtualPS->DrawPolyMarker(nin, x, y);
504 if (!fPoints)
return;
508 struct XYZ { Float_t fValues[3]; } *points;
509 points = (XYZ *)(fPoints->GetP());
510 Int_t size = fPoints->GetN()-1;
512 for (Int_t i=0;i<size;i++)
513 PaintNode((Float_t *)(points+i+1),(Float_t *)(points+i),opt);
524 if (fPoints) size = fPoints->Size();
527 X3DBuffer *buff =
new X3DBuffer;
530 fSizeX3D->numPoints = buff->numPoints = size;
531 fSizeX3D->numSegs = buff->numSegs = size-1;
532 fSizeX3D->numPolys = buff->numPolys = 0;
536 buff->points = fPoints->GetXYZ(x3dPoints.GetP(),0,size);
543 buff->segs =
new Int_t[buff->numSegs*3];
545 for (Int_t i = 0; i < buff->numSegs; i++) {
546 buff->segs[3*i ] = c;
547 buff->segs[3*i+1] = i;
548 buff->segs[3*i+2] = i+1;
553 if (buff && buff->points && buff->segs)
556 gSize3D.numPoints -= buff->numPoints;
557 gSize3D.numSegs -= buff->numSegs;
558 gSize3D.numPolys -= buff->numPolys;
561 if (buff->segs)
delete [] buff->segs;
562 if (buff->polys)
delete [] buff->polys;
563 if (buff)
delete buff;
574 if (fPoints) size = fPoints->Size();
579 X3DBuffer *buff =
new X3DBuffer;
582 if (size > 10000) mode = 1;
583 else if (size > 3000) mode = 2;
586 fSizeX3D->numSegs = buff->numSegs = size*mode;
587 fSizeX3D->numPoints = buff->numPoints = buff->numSegs*2;
588 fSizeX3D->numPolys = buff->numPolys = 0;
594 Float_t delta = 0.002;
596 buff->points =
new Float_t[buff->numPoints*3];
598 for (i = 0; i < size; i++) {
599 for (j = 0; j < mode; j++) {
600 for (k = 0; k < 2; k++) {
602 for (n = 0; n < 3; n++) {
604 fPoints->GetXYZ(xyz,i);
605 buff->points[mode*6*i+6*j+3*k+n] =
606 xyz[n] * (1 + (j == n ? delta : 0));
617 buff->segs =
new Int_t[buff->numSegs*3];
619 for (i = 0; i < buff->numSegs; i++) {
620 buff->segs[3*i ] = c;
621 buff->segs[3*i+1] = 2*i;
622 buff->segs[3*i+2] = 2*i+1;
626 if (buff->points && buff->segs)
629 gSize3D.numPoints -= buff->numPoints;
630 gSize3D.numSegs -= buff->numSegs;
631 gSize3D.numPolys -= buff->numPolys;
634 if (buff->points)
delete [] buff->points;
635 if (buff->segs)
delete [] buff->segs;
636 if (buff->polys)
delete [] buff->polys;
637 if (buff)
delete buff;
647 if (v1 && v2 && ndim > 0)
648 for (Int_t i=0; i<ndim; i++) p+= v1[i]*v2[i];
658 if (v1 && v2 && ndim > 0)
659 for (Int_t i=0;i<ndim;i++) p+= v1[i]*v2[i];
684 memcpy(ax,dirc,3*
sizeof(Double_t));
685 TMath::Normalize(ax);
687 Double_t ca = cosang;
688 Double_t sa = sinang;
694 ca1 = (sa*sa)/(1.+ca) ;
698 for(j1 = 0; j1 < 3; j1++) {
699 for(j2 = 0; j2 < 3; j2++)
700 trans[j1][j2] = ca1*ax[j1]*ax[j2];
704 trans[0][1] = trans[0][1] - sa*ax[2];
705 trans[1][0] = trans[1][0] + sa*ax[2];
706 trans[0][2] = trans[0][2] + sa*ax[1];
707 trans[2][0] = trans[2][0] - sa*ax[1];
708 trans[1][2] = trans[1][2] - sa*ax[0];
709 trans[2][1] = trans[2][1] + sa*ax[0];
711 return (Double_t *)trans;
721 if (color != currentColor) {
723 SetMarkerColor(color);
734 if (size != currentSize) {
735 SetLineWidth(Width_t(size));
751 SetMarkerStyle(style);
769 return fPoints ? fPoints->Size():0;
783 gSize3D.numPoints += fSizeX3D->numPoints;
784 gSize3D.numSegs += fSizeX3D->numSegs;
785 gSize3D.numPolys += fSizeX3D->numPolys;
787 else Error(
"Sizeof3D()",
"buffer size has not been defined yet");
virtual void SetShape(TShape *shape)
to be documented
virtual char * GetObjectInfo(Int_t px, Int_t py) const
forward the GetObjectInfo call to the decorated object
virtual Size_t GetSizeAttribute() const
to be documented
virtual Size_t SetSizeAttribute(Size_t size)
to be documented
virtual Int_t Size() const
to be documented
virtual void PaintNode(Float_t *start, Float_t *end, Option_t *option)
virtual Size3D * CreateX3DSize(Bool_t marker=kFALSE)
to be documented
virtual Int_t PointDistancetoPrimitive(Int_t px, Int_t py)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
forward the ExecuteEvent call to the decorated object
virtual void Paint(Option_t *opt)
to be documented
virtual Color_t GetColorAttribute() const
to be documented
virtual void Create()
the X3D buffer sizes
TPolyLineShape()
to be documented
virtual const char * GetTitle() const
forward the GetObjectInfo call to the decorated object
virtual void PaintX3DLine(Option_t *opt="")
to be documented
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual Style_t SetStyleAttribute(Style_t style)
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
virtual void Paint3d(Option_t *opt)
to be documented
virtual ~TPolyLineShape()
to be documented
virtual void PaintX3DMarker(Option_t *opt="")
to be documented
virtual void Sizeof3D() const
Return total X3D size of this shape with its attributes.
virtual void PaintNodePosition(Option_t *option="", TVolumePosition *postion=0)
virtual const char * GetName() const
forward the GetName call to the decorated object
static Double_t * Gyrot(Double_t *dirc, Double_t cosang, Double_t sinang, Double_t trans[3][3])
virtual Color_t SetColorAttribute(Color_t color)
to be documented
virtual void PaintPolyMarker(Int_t n, Float_t *p=0, Marker_t m=0, Option_t *opt="")
Paint polymarker in CurrentPad World coordinates.
static Float_t Product(Float_t *v1, Float_t *v2, Int_t ndim=3)
to be documented
virtual Style_t GetStyleAttribute() const
to be documented
virtual void Draw(Option_t *opt="")
to be documented
virtual void PaintPoints(Int_t n, Float_t *p=0, Option_t *opt="")
Draw this 3-D polyline with new coordinates.