// @(#)root/table:$Id$ // Author: Valery Fine(fine@mail.cern.ch) 24/04/99 /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include "Riostream.h" #include "TPointsArray3D.h" #include "TVirtualPad.h" #include "TView.h" #include "TClass.h" #include "TROOT.h" #include "TMath.h" //______________________________________________________________________________ // // TPointsArray3D is an abstract class of the array of 3-dimensional points. // It has 4 different constructors. // // This class has no implementation for Paint, Draw, and SavePrimitive methods // // First one, without any parameters TPointsArray3D(), we call 'default // constructor' and it's used in a case that just an initialisation is // needed (i.e. pointer declaration). // // Example: // TPointsArray3D *pl1 = new TPointsArray3D; // // // Second one is 'normal constructor' with, usually, one parameter // n (number of points), and it just allocates a space for the points. // // Example: // TPointsArray3D pl1(150); // // // Third one allocates a space for the points, and also makes // initialisation from the given array. // // Example: // TPointsArray3D pl1(150, pointerToAnArray); // // // Fourth one is, almost, similar to the constructor above, except // initialisation is provided with three independent arrays (array of // x coordinates, y coordinates and z coordinates). // // Example: // TPointsArray3D pl1(150, xArray, yArray, zArray); // ClassImp(TPointsArray3D) //______________________________________________________________________________ TPointsArray3D::TPointsArray3D() { //*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine default constructor*-*-*-*-*-*-*-*-*-*-* //*-* ================================ fN = 0; fP = 0; fLastPoint = -1; fGLList = 0; fLastPoint = 0; } //______________________________________________________________________________ TPointsArray3D::TPointsArray3D(Int_t n, Option_t *option) { //*-*-*-*-*-*3-D PolyLine normal constructor without initialisation*-*-*-*-*-*-* //*-* ====================================================== //*-* If n < 0 the default size (2 points) is set //*-* fLastPoint = -1; if (n < 1) fN = 2; // Set the default size for this object else fN = n; fP = new Float_t[3*fN]; memset(fP,0,3*fN*sizeof(Float_t)); fOption = option; fGLList = 0; fLastPoint = 0; } //______________________________________________________________________________ TPointsArray3D::TPointsArray3D(Int_t n, Float_t *p, Option_t *option) { //*-*-*-*-*-*-*-*-*-*-*-*-*3-D Point3D normal constructor*-*-*-*-*-*-*-*-*-*-*-* //*-* =============================== //*-* If n < 0 the default size (2 points) is set //*-* if (n < 1) fN = 2; // Set the default size for this object else fN = n; fP = new Float_t[3*fN]; if (n > 0) { memcpy(fP,p,3*fN*sizeof(Float_t)); fLastPoint = fN-1; } else { memset(fP,0,3*fN*sizeof(Float_t)); fLastPoint = -1; } fOption = option; fGLList = 0; fLastPoint = 0; } //______________________________________________________________________________ TPointsArray3D::TPointsArray3D(Int_t n, Float_t *x, Float_t *y, Float_t *z, Option_t *option) { //*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine normal constructor*-*-*-*-*-*-*-*-*-*-*-* //*-* =============================== //*-* If n < 0 the default size (2 points) is set //*-* fLastPoint = -1; if (n < 1) fN = 2; // Set the default size for this object else fN = n; fP = new Float_t[3*fN]; Int_t j = 0; if (n > 0) { for (Int_t i=0; iXtoAbsPixel(gPad->GetUxmin()); Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin()); Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax()); Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax()); //*-*- return if point is not in the user area if (px < puxmin - inaxis) return Int_t (dist); if (py > puymin + inaxis) return Int_t (dist); if (px > puxmax + inaxis) return Int_t (dist); if (py < puymax - inaxis) return Int_t (dist); TView *view = gPad->GetView(); if (!view) return Int_t(dist); Int_t i; Float_t dpoint; Float_t xndc[3]; Int_t x1,y1; Int_t size = Size(); for (i=0;iWCtoNDC(&fP[3*i], xndc); x1 = gPad->XtoAbsPixel(xndc[0]); y1 = gPad->YtoAbsPixel(xndc[1]); dpoint = (px-x1)*(px-x1) + (py-y1)*(py-y1); if (dpoint < dist) dist = dpoint; } return Int_t(TMath::Sqrt(dist)); } //______________________________________________________________________________ void TPointsArray3D::ExecuteEvent(Int_t event, Int_t px, Int_t py) { //*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*-*-* //*-* ========================================= if (gPad->GetView()) gPad->GetView()->ExecuteRotateView(event, px, py); } //______________________________________________________________________________ void TPointsArray3D::ls(Option_t *option) const { //*-*-*-*-*-*-*-*-*-*List this 3-D polyline with its attributes*-*-*-*-*-*-* //*-* ========================================== TROOT::IndentLevel(); cout << IsA()->GetName() << " N=" <GetName() <<" Printing N=" <