Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions graf2d/postscript/inc/TPostScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ class TPostScript : public TVirtualPS {
Float_t fRed; ///< Per cent of red
Float_t fGreen; ///< Per cent of green
Float_t fBlue; ///< Per cent of blue
Float_t fWidth; ///< Current line width
Int_t fStyle; ///< Current line style
Float_t fLineScale; ///< Line width scale factor
Int_t fSave; ///< Number of gsave for restore
Int_t fNXzone; ///< Number of zones along X
Int_t fNYzone; ///< Number of zones along Y
Int_t fIXzone; ///< Current zone along X
Int_t fIYzone; ///< Current zone along Y
Float_t fMarkerSizeCur; ///< current transformed value of marker size
Int_t fCurrentColor; ///< current Postscript color index
Int_t fNpages; ///< number of pages
Int_t fType; ///< PostScript workstation type
Int_t fMode; ///< PostScript mode
Expand Down Expand Up @@ -92,12 +93,12 @@ class TPostScript : public TVirtualPS {
void Close(Option_t *opt="") override;
Int_t CMtoPS(Double_t u) {return Int_t(0.5 + 72*u/2.54);}
void DefineMarkers();
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
void DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t yt, Int_t mode, Int_t border, Int_t dark,
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
void DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t yt, Int_t mode, Int_t border, Int_t dark,
Int_t light) override;
void DrawHatch(Float_t dy, Float_t angle, Int_t n, Float_t *x, Float_t *y);
void DrawHatch(Float_t dy, Float_t angle, Int_t n, Double_t *x, Double_t *y);
void DrawPolyLine(Int_t n, TPoints *xy);
void DrawHatch(Float_t dy, Float_t angle, Int_t n, Float_t *x, Float_t *y);
void DrawHatch(Float_t dy, Float_t angle, Int_t n, Double_t *x, Double_t *y);
void DrawPolyLine(Int_t n, TPoints *xy);
void DrawPolyLineNDC(Int_t n, TPoints *uv);
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override;
void DrawPolyMarker(Int_t n, Double_t *x, Double_t *y) override;
Expand All @@ -124,6 +125,8 @@ class TPostScript : public TVirtualPS {
void SetLineScale(Float_t scale=3) {fLineScale = scale;}
void SetMarkerColor(Color_t cindex=1) override;
void SetTextColor(Color_t cindex=1) override;
void SetWidth(Width_t linewidth = 1);
void SetStyle(Style_t linestyle = 1);
void MovePS(Int_t x, Int_t y);
void Range(Float_t xrange, Float_t yrange);
void SetColor(Int_t color = 1);
Expand All @@ -139,7 +142,7 @@ class TPostScript : public TVirtualPS {
Int_t YtoPS(Double_t y);
void Zone();

ClassDefOverride(TPostScript,0) //PostScript driver
ClassDefOverride(TPostScript,1) //PostScript driver
};

#endif
112 changes: 64 additions & 48 deletions graf2d/postscript/src/TPostScript.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ TPostScript::TPostScript() : TVirtualPS()
fClear = kFALSE;
fClip = 0;
fClipStatus = kFALSE;
fCurrentColor = 0;
fDXC = 0.;
fDYC = 0.;
fFX = 0.;
Expand All @@ -301,6 +300,8 @@ TPostScript::TPostScript() : TVirtualPS()
fRange = kFALSE;
fRed = 0.;
fSave = 0;
fWidth = 0.;
fStyle = 1;
fX1v = 0.;
fX1w = 0.;
fX2v = 0.;
Expand Down Expand Up @@ -361,7 +362,6 @@ void TPostScript::Open(const char *fname, Int_t wtype)
}

fMarkerSizeCur = 0;
fCurrentColor = 0;
fRed = -1;
fGreen = -1;
fBlue = -1;
Expand Down Expand Up @@ -944,13 +944,13 @@ void TPostScript::DrawPolyLine(Int_t nn, TPoints *xy)
if (nn > 0) {
if (fLineWidth<=0) return;
n = nn;
SetLineStyle(fLineStyle);
SetLineWidth(fLineWidth);
SetStyle(fLineStyle);
SetWidth(fLineWidth);
SetColor(Int_t(fLineColor));
} else {
n = -nn;
SetLineStyle(1);
SetLineWidth(1);
SetStyle(1);
SetWidth(1);
SetColor(Int_t(fLineColor));
}

Expand Down Expand Up @@ -1005,8 +1005,8 @@ void TPostScript::DrawPolyLine(Int_t nn, TPoints *xy)
}
END:
if (nn < 0) {
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
}
}

Expand All @@ -1028,13 +1028,13 @@ void TPostScript::DrawPolyLineNDC(Int_t nn, TPoints *xy)
if (nn > 0) {
if (fLineWidth<=0) return;
n = nn;
SetLineStyle(fLineStyle);
SetLineWidth(fLineWidth);
SetStyle(fLineStyle);
SetWidth(fLineWidth);
SetColor(Int_t(fLineColor));
} else {
n = -nn;
SetLineStyle(1);
SetLineWidth(1);
SetStyle(1);
SetWidth(1);
SetColor(Int_t(fLineColor));
}

Expand Down Expand Up @@ -1089,8 +1089,8 @@ void TPostScript::DrawPolyLineNDC(Int_t nn, TPoints *xy)
}
END:
if (nn < 0) {
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
}
}

Expand All @@ -1107,8 +1107,8 @@ void TPostScript::DrawPolyMarker(Int_t n, Float_t *x, Float_t *y)
fMarkerStyle = TMath::Abs(fMarkerStyle);
Style_t linestylesav = fLineStyle;
Width_t linewidthsav = fLineWidth;
SetLineStyle(1);
SetLineWidth(TMath::Max(1, Int_t(TAttMarker::GetMarkerLineWidth(fMarkerStyle))));
SetStyle(1);
SetWidth(TMath::Max(1, Int_t(TAttMarker::GetMarkerLineWidth(fMarkerStyle))));
SetColor(Int_t(fMarkerColor));
markerstyle = TAttMarker::GetMarkerStyleBase(fMarkerStyle);
if (markerstyle <= 0) strlcpy(chtemp, " m20",10);
Expand Down Expand Up @@ -1147,8 +1147,8 @@ void TPostScript::DrawPolyMarker(Int_t n, Float_t *x, Float_t *y)
WriteInteger(YtoPS(y[0]));
if (n == 1) {
PrintStr(chtemp);
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
return;
}
np = 1;
Expand All @@ -1164,8 +1164,8 @@ void TPostScript::DrawPolyMarker(Int_t n, Float_t *x, Float_t *y)
np = 0;
}
}
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -1181,8 +1181,8 @@ void TPostScript::DrawPolyMarker(Int_t n, Double_t *x, Double_t *y)
fMarkerStyle = TMath::Abs(fMarkerStyle);
Style_t linestylesav = fLineStyle;
Width_t linewidthsav = fLineWidth;
SetLineStyle(1);
SetLineWidth(TMath::Max(1, Int_t(TAttMarker::GetMarkerLineWidth(fMarkerStyle))));
SetStyle(1);
SetWidth(TMath::Max(1, Int_t(TAttMarker::GetMarkerLineWidth(fMarkerStyle))));
SetColor(Int_t(fMarkerColor));
markerstyle = TAttMarker::GetMarkerStyleBase(fMarkerStyle);
if (markerstyle <= 0) strlcpy(chtemp, " m20",10);
Expand Down Expand Up @@ -1221,8 +1221,8 @@ void TPostScript::DrawPolyMarker(Int_t n, Double_t *x, Double_t *y)
WriteInteger(YtoPS(y[0]));
if (n == 1) {
PrintStr(chtemp);
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
return;
}
np = 1;
Expand All @@ -1238,8 +1238,8 @@ void TPostScript::DrawPolyMarker(Int_t n, Double_t *x, Double_t *y)
np = 0;
}
}
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1270,14 +1270,14 @@ void TPostScript::DrawPS(Int_t nn, Float_t *xw, Float_t *yw)
if (nn > 0) {
if (fLineWidth<=0) return;
n = nn;
SetLineStyle(fLineStyle);
SetLineWidth(fLineWidth);
SetStyle(fLineStyle);
SetWidth(fLineWidth);
SetColor(Int_t(fLineColor));
}
if (nn < 0) {
n = -nn;
SetLineStyle(1);
SetLineWidth(1);
SetStyle(1);
SetWidth(1);
SetColor(Int_t(fFillColor));
fais = fFillStyle/1000;
fasi = fFillStyle%1000;
Expand Down Expand Up @@ -1348,8 +1348,8 @@ void TPostScript::DrawPS(Int_t nn, Float_t *xw, Float_t *yw)
}
END:
if (nn < 0) {
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
}
}

Expand Down Expand Up @@ -1381,14 +1381,14 @@ void TPostScript::DrawPS(Int_t nn, Double_t *xw, Double_t *yw)
if (nn > 0) {
if (fLineWidth<=0) return;
n = nn;
SetLineStyle(fLineStyle);
SetLineWidth(fLineWidth);
SetStyle(fLineStyle);
SetWidth(fLineWidth);
SetColor(Int_t(fLineColor));
}
if (nn < 0) {
n = -nn;
SetLineStyle(1);
SetLineWidth(1);
SetStyle(1);
SetWidth(1);
SetColor(Int_t(fFillColor));
fais = fFillStyle/1000;
fasi = fFillStyle%1000;
Expand Down Expand Up @@ -1459,8 +1459,8 @@ void TPostScript::DrawPS(Int_t nn, Double_t *xw, Double_t *yw)
}
END:
if (nn < 0) {
SetLineStyle(linestylesav);
SetLineWidth(linewidthsav);
SetStyle(linestylesav);
SetWidth(linewidthsav);
}
}

Expand Down Expand Up @@ -2129,7 +2129,6 @@ void TPostScript::SetFillColor( Color_t cindex )
{
fFillColor = cindex;
if (gStyle->GetFillColor() <= 0) cindex = 0;
SetColor(Int_t(cindex));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2461,7 +2460,6 @@ void TPostScript::SetFillPatterns(Int_t ipat, Int_t color)
void TPostScript::SetLineColor( Color_t cindex )
{
fLineColor = cindex;
SetColor(Int_t(cindex));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2526,7 +2524,18 @@ void TPostScript::SetLineStyle(Style_t linestyle)
{
if ( linestyle == fLineStyle) return;
fLineStyle = linestyle;
const char *st = gStyle->GetLineStyleString(linestyle);
}

////////////////////////////////////////////////////////////////////////////////
/// Change the line style in the output file

void TPostScript::SetStyle(Style_t linestyle)
{
if (linestyle == fStyle) return;

fStyle = linestyle;

const char *st = gStyle->GetLineStyleString(fStyle);
PrintFast(1,"[");
Int_t nch = strlen(st);
PrintFast(nch,st);
Expand All @@ -2538,10 +2547,21 @@ void TPostScript::SetLineStyle(Style_t linestyle)

void TPostScript::SetLineWidth(Width_t linewidth)
{
if ( linewidth == fLineWidth) return;
if (linewidth == fLineWidth) return;
fLineWidth = linewidth;
if (fLineWidth!=0) {
WriteInteger(Int_t(fLineScale*fLineWidth));
}

////////////////////////////////////////////////////////////////////////////////
/// Change the line width in the output file

void TPostScript::SetWidth(Width_t linewidth)
{
if (linewidth == fWidth) return;

fWidth = linewidth;

if (fWidth!=0) {
WriteInteger(Int_t(fLineScale*fWidth));
PrintFast(3," lw");
}
}
Expand All @@ -2552,7 +2572,6 @@ void TPostScript::SetLineWidth(Width_t linewidth)
void TPostScript::SetMarkerColor( Color_t cindex )
{
fMarkerColor = cindex;
SetColor(Int_t(cindex));
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -2561,7 +2580,6 @@ void TPostScript::SetMarkerColor( Color_t cindex )
void TPostScript::SetColor(Int_t color)
{
if (color < 0) color = 0;
fCurrentColor = color;
TColor *col = gROOT->GetColor(color);
if (col)
SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
Expand Down Expand Up @@ -2607,8 +2625,6 @@ void TPostScript::SetColor(Float_t r, Float_t g, Float_t b)
void TPostScript::SetTextColor( Color_t cindex )
{
fTextColor = cindex;

SetColor( Int_t(cindex) );
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading
Loading