Previous commit had the bad side-effect of changing the behaviour of Raw QA to comput...
[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"
31
32///\cond CLASSIMP
33ClassImp(AliMUONContourPainter)
34///\endcond
35
36//_____________________________________________________________________________
37AliMUONContourPainter::AliMUONContourPainter()
38{
39 /// Ctor
40}
41
42//_____________________________________________________________________________
43AliMUONContourPainter::~AliMUONContourPainter()
44{
45 /// dtor
46}
47
48//_____________________________________________________________________________
49void
50AliMUONContourPainter::Paint(const AliMUONContour& contour,
51 Int_t lineColor, Int_t lineWidth,
52 Int_t fillColor, Int_t fillStyle)
53{
54 /// Paint the given contour.
55 /// If lineColor > 0 the outline is drawn
56 /// If fillColor > 0 the contour is filled.
57
58 Bool_t outline(lineColor>0);
59 Bool_t fill(fillColor>0);
60
61 Int_t fc = gVirtualX->GetFillColor();
62 Int_t fs = gVirtualX->GetFillStyle();
63 Int_t lc = gVirtualX->GetLineColor();
64 Int_t lw = gVirtualX->GetLineWidth();
65
66 if ( lineColor > 0 ) gVirtualX->SetLineColor(lineColor);
67 if ( lineWidth > 0 ) gVirtualX->SetLineWidth(lineWidth);
68 if ( fillColor > 0 ) gVirtualX->SetFillColor(fillColor);
69 if ( fillStyle > 0 ) gVirtualX->SetFillStyle(fillStyle);
70
71 TIter next(contour.Polygons());
72 AliMUONPolygon* pol;
73 while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
74 {
75 Int_t n = pol->NumberOfVertices();
76 Double_t* x = new Double_t[n];
77 Double_t* y = new Double_t[n];
78 for ( Int_t i = 0; i < n; ++i )
79 {
80 x[i] = gPad->GetLogx() ? gPad->XtoPad(pol->X(i)) : pol->X(i);
81 y[i] = gPad->GetLogy() ? gPad->YtoPad(pol->Y(i)) : pol->Y(i);
82 }
83 if ( fill )
84 {
85 gPad->PaintFillArea(n,x,y);
86 }
87 if (outline)
88 {
89 gPad->PaintPolyLine(n,x,y);
90 }
91
92 delete[] x;
93 delete[] y;
94 }
95
96 gVirtualX->SetFillColor(fc);
97 gVirtualX->SetFillStyle(fs);
98 gVirtualX->SetLineColor(lc);
99 gVirtualX->SetLineWidth(lw);
100
101}