TPad::SaveAs working differently for PDF and PNG

Hi,

Trying to print a canvas, I get different results with vector and bitmap outputs : basically bitmap works, vector don’t (see the attached images).

The objects have custom Paint methods, which uses the following method :

[code]void
AliMUONContourPainter::Paint(const AliMUONContour& contour,
Int_t lineColor, Int_t lineWidth,
Int_t fillColor, Int_t fillStyle)
{
/// Paint the given contour.
/// If lineColor > 0 the outline is drawn
/// If fillColor > 0 the contour is filled.

Bool_t outline(lineColor>0);
Bool_t fill(fillColor>0);

Int_t fc = gVirtualX->GetFillColor();
Int_t fs = gVirtualX->GetFillStyle();
Int_t lc = gVirtualX->GetLineColor();
Int_t lw = gVirtualX->GetLineWidth();

if ( lineColor > 0 ) gVirtualX->SetLineColor(lineColor);
if ( lineWidth > 0 ) gVirtualX->SetLineWidth(lineWidth);
if ( fillColor > 0 ) gVirtualX->SetFillColor(fillColor);
if ( fillStyle > 0 ) gVirtualX->SetFillStyle(fillStyle);

TIter next(contour.Polygons());
AliMUONPolygon* pol;
while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
{
Int_t n = pol->NumberOfVertices();
Double_t* x = new Double_t[n];
Double_t* y = new Double_t[n];
for ( Int_t i = 0; i < n; ++i )
{
x[i] = gPad->GetLogx() ? gPad->XtoPad(pol->X(i)) : pol->X(i);
y[i] = gPad->GetLogy() ? gPad->YtoPad(pol->Y(i)) : pol->Y(i);
}
if ( fill )
{
gPad->PaintFillArea(n,x,y);
}
if (outline)
{
gPad->PaintPolyLine(n,x,y);
}

delete[] x;
delete[] y;

}

gVirtualX->SetFillColor(fc);
gVirtualX->SetFillStyle(fs);
gVirtualX->SetLineColor(lc);
gVirtualX->SetLineWidth(lw);

}[/code]

Is there something special to know about the PaintFillArea ?

Thanks,
test.pdf (174 KB)


gVirtualX will change only the attributes on screen and in the bitmap output formats which are directly related to the screen. To change the PS and PDF attributes you should also invoke gVirtualPS:

if (gVirtualPS) {
      gVirtualPS->SetLineStyle(linecolor);
      gVirtualPS->SetLineWidth(linewidth));
      .....
}

Hi,

Works great.

Thanks.