]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONmpgraphics/AliMpSlatPainter.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / MUON / MUONmpgraphics / AliMpSlatPainter.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: AliMpSlatPainter.cxx,v 1.10 2006/05/24 13:58:32 ivana Exp $
18
19
20 //-----------------------------------------------------------------------------
21 /// \class AliMpSlatPainter
22 /// 
23 /// Class for drawing a slat into canvas
24 ///
25 /// \author Laurent Aphecetche
26 //-----------------------------------------------------------------------------
27
28 #include "AliMpSlatPainter.h"
29
30 #include "AliLog.h"
31 #include "AliMpGraphContext.h"
32 #include "AliMpPCB.h"
33 #include "AliMpSlat.h"
34
35 #include "TVirtualX.h"
36 #include "TPad.h"
37 #include <iostream>
38
39 /// \cond CLASSIMP
40 ClassImp(AliMpSlatPainter)
41 /// \endcond
42
43 //_____________________________________________________________________________
44 AliMpSlatPainter::AliMpSlatPainter()
45  : AliMpVPainter(),
46    fkSlat(0)
47 {
48   ///
49   /// Empty ctor.
50   ///
51 }
52
53 //_____________________________________________________________________________
54 AliMpSlatPainter::AliMpSlatPainter(const AliMpSlat* slat)
55  : AliMpVPainter(),
56    fkSlat(slat)
57 {
58     ///
59     /// Normal ctor.
60     ///
61 }
62
63 //_____________________________________________________________________________
64 AliMpSlatPainter::~AliMpSlatPainter()
65 {
66   ///
67   /// Dtor.
68   ///
69 }
70
71 //_____________________________________________________________________________
72 TVector2
73 AliMpSlatPainter::GetDimensions() const
74 {
75   ///
76   /// Returns the half-sizes of the slat.
77   ///
78   return TVector2(fkSlat->DX(),fkSlat->DY());
79 }
80
81 //_____________________________________________________________________________
82 TVector2
83 AliMpSlatPainter::GetPosition() const
84 {
85   ///
86   /// Returns the (x,y) position of the slat.
87   ///
88   return TVector2(fkSlat->DX(),fkSlat->DY());
89 }
90
91 //_____________________________________________________________________________
92 void
93 AliMpSlatPainter::Draw(Option_t* option)
94 {
95   ///
96   /// Draws the slat.
97   ///
98   /// If option[0] is 'P' then PCB are drawn too.
99   ///
100   AliMpGraphContext *gr = AliMpGraphContext::Instance();
101
102   gr->Push();
103   InitGraphContext();
104
105 //   GetPosition().Print();
106 //   GetDimensions().Print();
107
108   switch (option[0])
109     {
110     case 'P':
111       for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
112         {
113           AliMpPCB* pcb = fkSlat->GetPCB(i);
114           
115           gr->Push();
116
117           gr->SetPadPosForReal(TVector2(pcb->X(),pcb->Y()),
118                                TVector2(pcb->DX(),pcb->DY()));
119           gr->SetColor(i+2);
120           
121           DrawObject(pcb,option+1);
122           
123           gr->Pop();
124         }
125       break;
126     default:
127       AppendPad(option);
128     }
129
130   gr->Pop();
131 }
132
133 //_____________________________________________________________________________
134 void
135 AliMpSlatPainter::Paint(Option_t* /*option*/)
136 {
137   ///
138   /// Paint the object.
139   ///
140   AliMpGraphContext* gr = AliMpGraphContext::Instance();
141
142   Int_t col=gVirtualX->GetFillColor();
143   gr->Push();
144   gPad->Range(0.,0.,1.,1.);
145   InitGraphContext();
146
147   PaintWholeBox(kTRUE);
148   
149   gr->Pop();
150   gVirtualX->SetFillColor(col);
151 }
152
153