1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /// \class AliMUONContourPainter
20 /// Class to draw AliMUONContour objects (2D)
22 /// \author Laurent Aphecetche, Subatech
24 #include "AliMUONContourPainter.h"
26 #include "TVirtualX.h"
27 #include "AliMUONPolygon.h"
28 #include "AliMUONContour.h"
29 #include "TObjArray.h"
30 #include "TVirtualPad.h"
33 ClassImp(AliMUONContourPainter)
36 //_____________________________________________________________________________
37 AliMUONContourPainter::AliMUONContourPainter()
42 //_____________________________________________________________________________
43 AliMUONContourPainter::~AliMUONContourPainter()
48 //_____________________________________________________________________________
50 AliMUONContourPainter::Paint(const AliMUONContour& contour,
51 Int_t lineColor, Int_t lineWidth,
52 Int_t fillColor, Int_t fillStyle)
54 /// Paint the given contour.
55 /// If lineColor > 0 the outline is drawn
56 /// If fillColor > 0 the contour is filled.
58 Bool_t outline(lineColor>0);
59 Bool_t fill(fillColor>0);
61 Int_t fc = gVirtualX->GetFillColor();
62 Int_t fs = gVirtualX->GetFillStyle();
63 Int_t lc = gVirtualX->GetLineColor();
64 Int_t lw = gVirtualX->GetLineWidth();
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);
71 TIter next(contour.Polygons());
73 while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
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 )
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);
85 gPad->PaintFillArea(n,x,y);
89 gPad->PaintPolyLine(n,x,y);
96 gVirtualX->SetFillColor(fc);
97 gVirtualX->SetFillStyle(fs);
98 gVirtualX->SetLineColor(lc);
99 gVirtualX->SetLineWidth(lw);