]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpPCBPainter.cxx
New splines and first eta maps for the 2013 pPb runs (Benjamin)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPCBPainter.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17 // $MpId: AliMpPCBPainter.cxx,v 1.8 2006/05/24 13:58:32 ivana Exp $
18
19
20 //-----------------------------------------------------------------------------
21 /// \class AliMpPCBPainter
22 /// 
23 /// Class for drawing a PCB into canvas
24 /// 
25 /// \author L. Aphecetche
26 //-----------------------------------------------------------------------------
27
28 #include "AliMpPCBPainter.h"
29
30 #include "AliMpGraphContext.h"
31 #include "AliMpMotifPosition.h"
32 #include "AliMpPCB.h"
33
34 #include "AliLog.h"
35
36 #include "TVirtualX.h"
37 #include "TPad.h"
38
39 #include <iostream>
40
41 /// \cond CLASSIMP
42 ClassImp(AliMpPCBPainter)
43 /// \endcond
44
45 //_____________________________________________________________________________
46 AliMpPCBPainter::AliMpPCBPainter(AliMpPCB* pcb)
47   : AliMpVPainter(), fPCB(pcb)
48 {
49     ///
50     /// Default ctor.
51     ///
52 }
53
54 //_____________________________________________________________________________
55 AliMpPCBPainter::~AliMpPCBPainter()
56 {
57   ///
58   /// Dtor.
59   ///
60 }
61
62 //_____________________________________________________________________________
63 TVector2
64 AliMpPCBPainter::GetDimensions() const
65 {
66   ///
67   /// Returns the half-sizes of the PCB.
68   ///
69   return TVector2(fPCB->DX(),fPCB->DY());
70 }
71
72 //_____________________________________________________________________________
73 TVector2
74 AliMpPCBPainter::GetPosition() const
75 {
76   ///
77   /// Returns the (x,y) position of the PCB.
78   ///
79   return TVector2(fPCB->X(),fPCB->Y());
80 }
81
82 //_____________________________________________________________________________
83 void
84 AliMpPCBPainter::Draw(Option_t* option)
85 {
86   ///
87   /// Draws the PCB.
88   ///
89   AliMpGraphContext *gr = AliMpGraphContext::Instance();
90   if (!fPCB) return;
91
92   gr->Push();
93   InitGraphContext();
94
95   switch (option[0])
96   {
97     case 'M':
98       for ( Int_t i = 0; i < fPCB->GetSize(); ++i )
99       {
100         AliMpMotifPosition* pos = fPCB->GetMotifPosition(i);
101         
102         gr->Push();
103         gr->SetPadPosForReal(TVector2(pos->GetPositionX(),pos->GetPositionY()),
104                              TVector2(pos->GetDimensionX(),pos->GetDimensionY()));
105         gr->SetColor(gr->GetColor()+i);
106         
107         DrawObject(pos,option+1);
108         
109         gr->Pop();
110       }
111       break;
112     default:
113       AppendPad(option);
114   }
115   
116   gr->Pop();
117 }
118
119 //_____________________________________________________________________________
120 void
121 AliMpPCBPainter::Paint(Option_t* /*option*/)
122 {
123   ///
124   /// Paint the object.
125   ///
126   AliMpGraphContext* gr = AliMpGraphContext::Instance();
127   if (!fPCB) return;
128   Int_t col=gVirtualX->GetFillColor();
129   gr->Push();
130   gPad->Range(0.,0.,1.,1.);
131   InitGraphContext();
132
133   PaintWholeBox(kTRUE);
134   
135   gr->Pop();
136   gVirtualX->SetFillColor(col);
137 }