psview.C

Go to the documentation of this file.
00001 // An example how to display PS, EPS, PDF files in canvas
00002 // To load a PS file in a TCanvas, the ghostscript program needs to be install.
00003 // - On most unix systems it is installed by default.
00004 // - On Windows it has to be installed from http://pages.cs.wisc.edu/~ghost/
00005 //   also the place where gswin32c.exe sits should be added in the PATH. One
00006 //   way to do it is: 
00007 //     1. Start the Control Panel
00008 //     2. Double click on System
00009 //     3, Open the "Advanced" tab
00010 //     4. Click on the "Environment Variables" button
00011 //     5. Find "Path" in "System varibale list", click on it.
00012 //     6. Click on the "Edit" button.
00013 //     7. In the "Variable value" field add the path of gswin32c 
00014 //        (after a ";") it should be something like:
00015 //        "C:\Program Files\gs\gs8.13\bin"
00016 //     8. click "OK" as much as needed.
00017 //
00018 //Author: Valeriy Onoutchin
00019    
00020 #include "TROOT.h"
00021 #include "TCanvas.h"
00022 #include "TImage.h"
00023 
00024 void psview()
00025 {
00026    // set to batch mode -> do not display graphics
00027    gROOT->SetBatch(1);
00028 
00029    // create a PostScript file
00030    gROOT->Macro("feynman.C");
00031    gPad->Print("feynman.eps");
00032 
00033    // back to graphics mode
00034    gROOT->SetBatch(0);
00035 
00036    // create an image from PS file
00037    TImage *ps = TImage::Open("feynman.eps");
00038 
00039    if (!ps) {
00040       printf("GhostScript (gs) program must be installed\n");
00041       return;
00042    }
00043 
00044    new TCanvas("psexam", "Example how to display PS file in canvas", 600, 400);
00045    TLatex *tex = new TLatex(0.06,0.9,"The picture below has been loaded from a PS file:");
00046    tex->Draw();
00047 
00048    TPad *eps = new TPad("eps", "eps", 0., 0., 1., 0.75);
00049    eps->Draw();
00050    eps->cd();
00051    ps->Draw("xxx"); 
00052 }

Generated on Tue Jul 5 15:44:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1