]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONContourPainter.cxx
- Replace the TClonesArray of AliMUONTrackParam by a TObjArray in
[u/mrichter/AliRoot.git] / MUON / AliMUONContourPainter.cxx
CommitLineData
0b936dc0 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
18/// \class AliMUONContourPainter
19///
20/// Class to draw AliMUONContour objects (2D)
21///
22/// \author Laurent Aphecetche, Subatech
23
24#include "AliMUONContourPainter.h"
25
26#include "TVirtualX.h"
27#include "AliMUONPolygon.h"
28#include "AliMUONContour.h"
29#include "TObjArray.h"
30#include "TVirtualPad.h"
b1b918fd 31#include "TVirtualPS.h"
0b936dc0 32
33///\cond CLASSIMP
34ClassImp(AliMUONContourPainter)
35///\endcond
36
37//_____________________________________________________________________________
38AliMUONContourPainter::AliMUONContourPainter()
39{
40 /// Ctor
41}
42
43//_____________________________________________________________________________
44AliMUONContourPainter::~AliMUONContourPainter()
45{
46 /// dtor
47}
48
49//_____________________________________________________________________________
50void
51AliMUONContourPainter::Paint(const AliMUONContour& contour,
52 Int_t lineColor, Int_t lineWidth,
53 Int_t fillColor, Int_t fillStyle)
54{
55 /// Paint the given contour.
56 /// If lineColor > 0 the outline is drawn
57 /// If fillColor > 0 the contour is filled.
58
59 Bool_t outline(lineColor>0);
60 Bool_t fill(fillColor>0);
61
62 Int_t fc = gVirtualX->GetFillColor();
63 Int_t fs = gVirtualX->GetFillStyle();
64 Int_t lc = gVirtualX->GetLineColor();
65 Int_t lw = gVirtualX->GetLineWidth();
66
67 if ( lineColor > 0 ) gVirtualX->SetLineColor(lineColor);
68 if ( lineWidth > 0 ) gVirtualX->SetLineWidth(lineWidth);
69 if ( fillColor > 0 ) gVirtualX->SetFillColor(fillColor);
70 if ( fillStyle > 0 ) gVirtualX->SetFillStyle(fillStyle);
71
b1b918fd 72 if (gVirtualPS) {
73 if ( lineColor > 0 ) gVirtualPS->SetLineColor(lineColor);
74 if ( lineWidth > 0 ) gVirtualPS->SetLineWidth(lineWidth);
75 if ( fillColor > 0 ) gVirtualPS->SetFillColor(fillColor);
76 if ( fillStyle > 0 ) gVirtualPS->SetFillStyle(fillStyle);
77 }
78
0b936dc0 79 TIter next(contour.Polygons());
80 AliMUONPolygon* pol;
81 while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
82 {
83 Int_t n = pol->NumberOfVertices();
84 Double_t* x = new Double_t[n];
85 Double_t* y = new Double_t[n];
86 for ( Int_t i = 0; i < n; ++i )
87 {
88 x[i] = gPad->GetLogx() ? gPad->XtoPad(pol->X(i)) : pol->X(i);
89 y[i] = gPad->GetLogy() ? gPad->YtoPad(pol->Y(i)) : pol->Y(i);
90 }
91 if ( fill )
92 {
93 gPad->PaintFillArea(n,x,y);
94 }
95 if (outline)
96 {
97 gPad->PaintPolyLine(n,x,y);
98 }
99
100 delete[] x;
101 delete[] y;
102 }
103
104 gVirtualX->SetFillColor(fc);
105 gVirtualX->SetFillStyle(fs);
106 gVirtualX->SetLineColor(lc);
107 gVirtualX->SetLineWidth(lw);
108
109}