]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpPCBPainter.cxx
b5dbbb0052ea841ccbea1cb1da4eef637340311b
[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.4 2005/09/19 18:56:46 ivana Exp $
18
19 ///
20 /// \class AliMpSlatPainter
21 /// 
22 /// Class for drawing a PCB into canvas
23 /// 
24 /// \author L. Aphecetche
25
26 #include "AliMpPCBPainter.h"
27
28 #include "AliMpGraphContext.h"
29 #include "AliMpMotifPosition.h"
30 #include "AliMpPCB.h"
31
32 #include "AliLog.h"
33
34 #include "TVirtualX.h"
35 #include "TPad.h"
36
37 #include <iostream>
38
39 ClassImp(AliMpPCBPainter)
40
41 //_____________________________________________________________________________
42 AliMpPCBPainter::AliMpPCBPainter(AliMpPCB* pcb)
43   : AliMpVPainter(), fPCB(pcb)
44 {
45     //
46     // Default ctor.
47     //
48 }
49
50 //______________________________________________________________________________
51 AliMpPCBPainter::AliMpPCBPainter(const AliMpPCBPainter& right) 
52   : AliMpVPainter(right) 
53 {  
54 /// Protected copy constructor (not implemented)
55
56   AliFatal("Copy constructor not provided.");
57 }
58
59 //_____________________________________________________________________________
60 AliMpPCBPainter::~AliMpPCBPainter()
61 {
62   //
63   // Dtor.
64   //
65 }
66
67 //______________________________________________________________________________
68 AliMpPCBPainter& 
69 AliMpPCBPainter::operator=(const AliMpPCBPainter& right)
70 {
71 /// Protected assignement operator (not implemented)
72
73   // check assignement to self
74   if (this == &right) return *this;
75
76   AliFatal("Assignement operator not provided.");
77     
78   return *this;  
79 }    
80
81 //_____________________________________________________________________________
82 TVector2
83 AliMpPCBPainter::GetDimensions() const
84 {
85   //
86   // Returns the half-sizes of the PCB.
87   //
88   return TVector2(fPCB->DX(),fPCB->DY());
89 }
90
91 //_____________________________________________________________________________
92 TVector2
93 AliMpPCBPainter::GetPosition() const
94 {
95   //
96   // Returns the (x,y) position of the PCB.
97   //
98   return TVector2(fPCB->X(),fPCB->Y());
99 }
100
101 //_____________________________________________________________________________
102 void
103 AliMpPCBPainter::Draw(Option_t* option)
104 {
105   //
106   // Draws the PCB.
107   //
108   AliMpGraphContext *gr = AliMpGraphContext::Instance();
109   if (!fPCB) return;
110
111   gr->Push();
112   InitGraphContext();
113
114   switch (option[0])
115   {
116     case 'M':
117       for ( AliMpPCB::Size_t i = 0; i < fPCB->GetSize(); ++i )
118       {
119         AliMpMotifPosition* pos = fPCB->GetMotifPosition(i);
120         
121         gr->Push();
122         gr->SetPadPosForReal(pos->Position(),
123                              pos->Dimensions());
124         gr->SetColor(gr->GetColor()+i);
125         
126         DrawObject(pos,option+1);
127         
128         gr->Pop();
129       }
130       break;
131     default:
132       AppendPad(option);
133   }
134   
135   gr->Pop();
136 }
137
138 //_____________________________________________________________________________
139 void
140 AliMpPCBPainter::Paint(Option_t* /*option*/)
141 {
142   //
143   // Paint the object.
144   //
145   AliMpGraphContext* gr = AliMpGraphContext::Instance();
146   if (!fPCB) return;
147   Int_t col=gVirtualX->GetFillColor();
148   gr->Push();
149   gPad->Range(0.,0.,1.,1.);
150   InitGraphContext();
151
152   PaintWholeBox(kTRUE);
153   
154   gr->Pop();
155   gVirtualX->SetFillColor(col);
156 }