BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMarker2D.cxx
Go to the documentation of this file.
1
2#include <iostream>
3#include <TString.h>
4#include <TPad.h>
5
6#include "BesVisLib/BesMarker2D.h"
7#include "BesVisLib/BesView.h"
8
9using namespace std;
10
11#ifndef __CINT__
13#endif
14
15//_____________________________________________________
16// BesMarker2D
17// 2-dimensional marker
18//
19//
21 //
22 // BesMarker2D default constructor
23 if ( gDebug ) cout << "BesMarker2D ctor called" << endl;
24}
25
26//_____________________________________________________
27
28BesMarker2D::BesMarker2D(const char* name, const char* title, Float_t x, Float_t y, Float_t z) : TMarker(0,0,3) {
29 //
30 // BesMarker2D normal constructor
31 if ( gDebug ) cout << "BesMarker2D normal ctor called" << endl;
32 fName = name;
33 fTitle = title;
34 fWCX = x;
35 fWCY = y;
36 fWCZ = z;
37 this->SetMarkerColor(kGreen);
38 this->SetMarkerSize(1);
39 this->SetMarkerSizeMultiple(4);
40 TAttMarker::Modify();
41
42}
43
44//_____________________________________________________
45
46BesMarker2D::BesMarker2D(const char* name, const char* title, Double_t x, Double_t y, Double_t z) : TMarker(0,0,3) {
47 //
48 // BesMarker2D normal constructor
49 if ( gDebug ) cout << "BesMarker2D normal ctor called" << endl;
50 fName = name;
51 fTitle = title;
52 fWCX = (Float_t)x;
53 fWCY = (Float_t)y;
54 fWCZ = (Float_t)z;
55 this->SetMarkerColor(kGreen);
56 this->SetMarkerSize(1);
57 this->SetMarkerSizeMultiple(4); // default
58 TAttMarker::Modify();
59
60}
61/*
62//______________________________________________________________________________
63
64Int_t BesMarker2D::DistancetoPrimitive(Int_t px, Int_t py) {
65
66 Int_t pxm, pym;
67 if (TestBit(kMarkerNDC)) {
68 pxm = gPad->UtoPixel(fX);
69 pym = gPad->VtoPixel(fY);
70 } else {
71 pxm = gPad->XtoAbsPixel(gPad->XtoPad(fX));
72 pym = gPad->YtoAbsPixel(gPad->YtoPad(fY));
73 }
74 Int_t dist = sqrt( Double_t((px-pxm)*(px-pxm) + (py-pym)*(py-pym)) );
75 if (dist < 20) dist = 2;
76
77 return dist;
78}
79*/
80
81void BesMarker2D::GetCenterPixel(Int_t &px, Int_t &py) {
82
83 if (TestBit(kMarkerNDC)) {
84 px = gPad->UtoPixel(fX);
85 py = gPad->VtoPixel(fY);
86 } else {
87 px = gPad->XtoAbsPixel(gPad->XtoPad(fX));
88 py = gPad->YtoAbsPixel(gPad->YtoPad(fY));
89 }
90}
91
92//________________________________________________________
93
94void BesMarker2D::Draw(Option_t *option) {
95 //
96 // ZMarker3D draw function
97 AppendPad(option);
98}
99
100//_____________________________________________________
101
102void BesMarker2D::Paint(Option_t *option) {
103 //
104 // BesMarker2D paint function
105
106 // get View
107 BesView *view = (BesView*)gPad->GetView();
108
109 // get Marker Size from ZView
110 this->SetMarkerSize(view->GetMarkerSize() * this->GetMarkerSizeMultiple());
111 //TAttMarker::Modify();
112
113 // transform to NDC
114 Float_t WC[3],NDC[3];
115 WC[0]=fWCX;
116 WC[1]=fWCY;
117 WC[2]=fWCZ;
118 view->WCtoNDC(WC,NDC);
119 this->SetX(NDC[0]);
120 this->SetY(NDC[1]);
121
122 // call TMarker::Paint
123
124 TMarker::Paint(option);
125
126}
127
128//_____________________________________________________
129
131 //
132 // BesMarker2D default destructor
133 if ( gDebug ) cout << "BesMarker2D default dtor called" << endl;
134}
135
136//_____________________________________________________
137
138char *BesMarker2D::GetObjectInfo(Int_t px, Int_t py) const {
139
140 BesView *view = (BesView*)gPad->GetView();
141 if (view) return view->GetObjectInfo(px, py);
142 else return TObject::GetObjectInfo(px, py);
143
144 /* //
145 // Returns string containing info about the object at position (px,py).
146 TString info("Info: x=");
147 info += px;
148 info += (", y=");
149 info += py;
150 return (char*)(info.Data());
151 */
152}
153
154//_____________________________________________________
155
156void BesMarker2D::SetParameter(const char* name, const char* title, Float_t x, Float_t y, Float_t z) {
157 //
158 // set parameters
159 fName = name;
160 fTitle = title;
161 fWCX = x;
162 fWCY = y;
163 fWCZ = z;
164}
165
ClassImp(BesMarker2D) BesMarker2D
Definition: BesMarker2D.cxx:12
Double_t x[10]
gr SetMarkerColor(4)
virtual void GetCenterPixel(Int_t &px, Int_t &py)
Definition: BesMarker2D.cxx:81
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual void Paint(Option_t *option="")
virtual void SetParameter(const char *name, const char *title, Float_t x, Float_t y, Float_t z)
virtual ~BesMarker2D()
virtual void Draw(Option_t *option="")
Definition: BesMarker2D.cxx:94
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Definition: BesView.cxx:659
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Definition: BesView.cxx:800