/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/EventDisplay/BesVisLib/BesVisLib-00-04-04/src/BesMarker2D.cxx

Go to the documentation of this file.
00001 
00002 #include <iostream>
00003 #include <TString.h>
00004 #include <TPad.h>
00005 
00006 #include "BesVisLib/BesMarker2D.h"
00007 #include "BesVisLib/BesView.h"
00008 
00009 using namespace std;
00010 
00011 #ifndef __CINT__
00012 ClassImp(BesMarker2D)
00013 #endif
00014 
00015 //_____________________________________________________
00016 // BesMarker2D
00017 // 2-dimensional marker
00018 //
00019 //
00020 BesMarker2D::BesMarker2D() {
00021     //
00022     // BesMarker2D default constructor
00023     if ( gDebug ) cout << "BesMarker2D ctor called" << endl;
00024 }
00025 
00026 //_____________________________________________________
00027 
00028 BesMarker2D::BesMarker2D(const char* name, const char* title, Float_t x, Float_t y, Float_t z) : TMarker(0,0,3) {
00029     //
00030     // BesMarker2D normal constructor
00031     if ( gDebug ) cout << "BesMarker2D normal ctor called" << endl;
00032     fName = name;
00033     fTitle = title;
00034     fWCX = x;
00035     fWCY = y;
00036     fWCZ = z;
00037     this->SetMarkerColor(kGreen);
00038     this->SetMarkerSize(1);
00039     this->SetMarkerSizeMultiple(4);
00040     TAttMarker::Modify();
00041 
00042 }
00043 
00044 //_____________________________________________________
00045 
00046 BesMarker2D::BesMarker2D(const char* name, const char* title, Double_t x, Double_t y, Double_t z) : TMarker(0,0,3) {
00047     //
00048     // BesMarker2D normal constructor
00049     if ( gDebug ) cout << "BesMarker2D normal ctor called" << endl;
00050     fName = name;
00051     fTitle = title;
00052     fWCX = (Float_t)x;
00053     fWCY = (Float_t)y;
00054     fWCZ = (Float_t)z;
00055     this->SetMarkerColor(kGreen);
00056     this->SetMarkerSize(1);
00057     this->SetMarkerSizeMultiple(4); // default
00058     TAttMarker::Modify();
00059 
00060 }
00061 /*
00062 //______________________________________________________________________________
00063 
00064 Int_t BesMarker2D::DistancetoPrimitive(Int_t px, Int_t py) {
00065 
00066   Int_t pxm, pym;
00067   if (TestBit(kMarkerNDC)) {
00068     pxm = gPad->UtoPixel(fX);
00069     pym = gPad->VtoPixel(fY);
00070   } else {
00071     pxm  = gPad->XtoAbsPixel(gPad->XtoPad(fX));
00072     pym  = gPad->YtoAbsPixel(gPad->YtoPad(fY));
00073   }
00074   Int_t dist = sqrt( Double_t((px-pxm)*(px-pxm) + (py-pym)*(py-pym)) );
00075   if (dist < 20) dist = 2;
00076 
00077   return dist;
00078 }
00079 */
00080 
00081 void BesMarker2D::GetCenterPixel(Int_t &px, Int_t &py) {
00082 
00083     if (TestBit(kMarkerNDC)) {
00084         px = gPad->UtoPixel(fX);
00085         py = gPad->VtoPixel(fY);
00086     } else {
00087         px  = gPad->XtoAbsPixel(gPad->XtoPad(fX));
00088         py  = gPad->YtoAbsPixel(gPad->YtoPad(fY));
00089     }
00090 }
00091 
00092 //________________________________________________________
00093 
00094 void BesMarker2D::Draw(Option_t *option) {
00095     //
00096     // ZMarker3D draw function
00097     AppendPad(option);
00098 }
00099 
00100 //_____________________________________________________
00101 
00102 void BesMarker2D::Paint(Option_t *option) {
00103     //
00104     // BesMarker2D paint function
00105 
00106     // get View
00107     BesView *view = (BesView*)gPad->GetView();
00108 
00109     // get Marker Size from ZView
00110     this->SetMarkerSize(view->GetMarkerSize() * this->GetMarkerSizeMultiple());
00111     //TAttMarker::Modify();
00112 
00113     // transform to NDC
00114     Float_t WC[3],NDC[3];
00115     WC[0]=fWCX;
00116     WC[1]=fWCY;
00117     WC[2]=fWCZ;
00118     view->WCtoNDC(WC,NDC);
00119     this->SetX(NDC[0]);
00120     this->SetY(NDC[1]);
00121 
00122     // call TMarker::Paint
00123 
00124     TMarker::Paint(option);
00125 
00126 }
00127 
00128 //_____________________________________________________
00129 
00130 BesMarker2D::~BesMarker2D() {
00131     //
00132     // BesMarker2D default destructor
00133     if ( gDebug ) cout << "BesMarker2D default dtor called" << endl;
00134 }
00135 
00136 //_____________________________________________________
00137 
00138 char *BesMarker2D::GetObjectInfo(Int_t px, Int_t py) const {
00139 
00140     BesView *view = (BesView*)gPad->GetView();
00141     if (view) return view->GetObjectInfo(px, py);
00142     else return TObject::GetObjectInfo(px, py);
00143 
00144     /*  //
00145     // Returns string containing info about the object at position (px,py).
00146     TString info("Info: x=");
00147     info += px;
00148     info += (", y=");
00149     info += py;
00150     return (char*)(info.Data());
00151     */
00152 }
00153 
00154 //_____________________________________________________
00155 
00156 void BesMarker2D::SetParameter(const char* name, const char* title, Float_t x, Float_t y, Float_t z) {
00157     //
00158     // set parameters
00159     fName = name;
00160     fTitle = title;
00161     fWCX = x;
00162     fWCY = y;
00163     fWCZ = z;
00164 }
00165 

Generated on Tue Nov 29 23:12:04 2016 for BOSS_7.0.2 by  doxygen 1.4.7