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