Logo ROOT  
Reference Guide
psview.C File Reference

Detailed Description

View in nbviewer Open in SWAN An example how to display PS, EPS, PDF files in canvas.

To load a PS file in a TCanvas, the ghostscript program needs to be install.

  • On most unix systems it is installed by default.
  • On Windows it has to be installed from http://pages.cs.wisc.edu/~ghost/ also the place where gswin32c.exe sits should be added in the PATH. One way to do it is:
    1. Start the Control Panel
    2. Double click on System 3, Open the "Advanced" tab
    3. Click on the "Environment Variables" button
    4. Find "Path" in "System variable list", click on it.
    5. Click on the "Edit" button.
    6. In the "Variable value" field add the path of gswin32c (after a ";") it should be something like: "C:\Program Files\gs\gs8.13\bin"
    7. click "OK" as much as needed.
#include "TROOT.h"
#include "TCanvas.h"
#include "TImage.h"
void psview()
{
// set to batch mode -> do not display graphics
gROOT->SetBatch(1);
// create a PostScript file
TString dir = gROOT->GetTutorialDir();
dir.Append("/graphics/feynman.C");
gROOT->Macro(dir);
gPad->Print("feynman.eps");
// back to graphics mode
gROOT->SetBatch(0);
// create an image from PS file
TImage *ps = TImage::Open("feynman.eps");
if (!ps) {
printf("GhostScript (gs) program must be installed\n");
return;
}
new TCanvas("psexam", "Example how to display PS file in canvas", 600, 400);
TLatex *tex = new TLatex(0.06,0.9,"The picture below has been loaded from a PS file:");
tex->Draw();
TPad *eps = new TPad("eps", "eps", 0., 0., 1., 0.75);
eps->Draw();
eps->cd();
ps->Draw("xxx");
}
Author
Valeriy Onoutchin

Definition in file psview.C.

TPad
The most important graphics class in the ROOT system.
Definition: TPad.h:26
TGeant4Unit::ps
static constexpr double ps
Definition: TGeant4SystemOfUnits.h:165
TImage
An abstract interface to image processing library.
Definition: TImage.h:29
TLatex
To draw Mathematical Formula.
Definition: TLatex.h:18
TCanvas.h
TImage::Open
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition: TImage.cxx:118
TString
Basic string class.
Definition: TString.h:136
TImage.h
TROOT.h
TPad::cd
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition: TPad.cxx:604
TString::Append
TString & Append(const char *cs)
Definition: TString.h:564
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
TCanvas
The Canvas class.
Definition: TCanvas.h:23
gPad
#define gPad
Definition: TVirtualPad.h:287
TPad::Draw
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1300
gROOT
#define gROOT
Definition: TROOT.h:406