Changeset 7001


Ignore:
Timestamp:
05/09/05 10:15:41 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
6 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7000 r7001  
    2121
    2222                                                 -*-*- END OF LINE -*-*-
     23 2005/05/09 Thomas Bretz
     24
     25   * callisto.cc, ganymed.cc, mars.cc, merpp.cc, readdaq.cc,
     26     readraw.cc, showplot.cc, sinope.cc, sponde.cc, star.cc:
     27     - changed order of initialization such that a real NULL
     28       output is possible
     29     - changed TApplication name from upper to lower case
     30     - in some applications replaced manual setup of gLog with
     31       gLog.Setup
     32
     33   * showlog.cc:
     34     - improved alorithm
     35
     36   * showplot.cc:
     37     - implemented Print options
     38
     39   * mbase/MLog.[h,cc]:
     40     - fixed a bug which caused output in NULL output
     41     - added Getter IsNullOutput
     42
     43   * mbase/MStatusDisplay.[h,cc]:
     44     - implemented PDF and SVG printing
     45     - moved "Save As Something" to new submenu
     46     - fixed and improved printing
     47     - implemented PrintDialog for printing
     48     - implemented printing of log (untested)
     49     - allow saving by extension (line Print() in root): SaveAs
     50
     51   * mfileio/MWriteRootFile.h:
     52     - replaced BIT(17) by BIT(23) to improve compatibility with
     53       root 4.04/00 and upcomming versions
     54
     55   * mhflux/Makefile, mjobs/MJCut.cc:
     56     - replaced MTheta by MThetaSq to get rid of a problem
     57       with the automatic naming of the binning (BinningTheta)
     58
     59   * mhist/MHCamera.[h,cc]:
     60     - fixed a workaround (it has been fixed in root 4.04/00)
     61     - allow setting the palette through the Draw-option. This allows
     62       storage of the palette
     63     - removed fColor. The palette is now diretly set though gStyle in
     64       Paint
     65
     66   * mjobs/MJOptimize.cc:
     67     - restore null output correctly after eventloop
     68
     69   * mjobs/MJSpectrum.cc:
     70     - renamed Hist and HistOff to HistE and HistEOff
     71     - added binnings M3Long and Conc1
     72
     73
    2374
    2475 2005/05/06 Thomas Bretz
  • trunk/MagicSoft/Mars/NEWS

    r6989 r7001  
    5151     this variable (one is already existing: MHTheta, which is now the
    5252     default in ganymed). It is setup through ganymed.rc
     53
     54   - Improved support for printing in status display:
     55     + A default can now be set in .rootrc (for more details see
     56       MStatusDisplay::PrintPS)
     57     + A print dialog is opened so that printer and command line
     58       can be canged
     59
     60   - improved showplot
     61     + The new graphics formats have been implemented
     62       (pdf, svg, png, jpg and xpm)
     63     + Implemented an interface for printing. Because you can change
     64       the printing command from the command line you can use all
     65       the nice postscript tool. To print a booklet for example call:
     66       showplot -b --print --print-cmd="cat %f" filename.root | lpr
     67       showplot -b --print --print-cmd="psbook %f | psnup -2 | lpr" filename.root
     68       showplot -b --null --print --print-cmd="psbook %f" filename.root > book.ps
     69
     70   - The storage of the palette in MHCamera is now possible
    5371
    5472
  • trunk/MagicSoft/Mars/callisto.cc

    r6979 r7001  
    142142int main(int argc, char **argv)
    143143{
     144    //
     145    // Evaluate arguments
     146    //
     147    MArgs arg(argc, argv, kTRUE);
     148    gLog.Setup(arg);
     149
    144150    StartUpMessage();
    145 
    146     //
    147     // Evaluate arguments
    148     //
    149     MArgs arg(argc, argv, kTRUE);
    150151
    151152    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    157158        return 2;
    158159    }
    159 
    160     gLog.Setup(arg);
    161160
    162161    const TString kConfig     = arg.GetStringAndRemove("--config=", "callisto.rc");
     
    322321    MParContainer::Class()->IgnoreTObjectStreamer();
    323322
    324     TApplication app("Callisto", &argc, argv);
     323    TApplication app("callisto", &argc, argv);
    325324    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    326325    {
  • trunk/MagicSoft/Mars/ganymed.cc

    r6979 r7001  
    8989int main(int argc, char **argv)
    9090{
     91    //
     92    // Evaluate arguments
     93    //
     94    MArgs arg(argc, argv, kTRUE);
     95    gLog.Setup(arg);
     96
    9197    StartUpMessage();
    92 
    93     //
    94     // Evaluate arguments
    95     //
    96     MArgs arg(argc, argv, kTRUE);
    9798
    9899    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    104105        return 2;
    105106    }
    106 
    107     gLog.Setup(arg);
    108107
    109108    const TString kConfig       = arg.GetStringAndRemove("--config=", "ganymed.rc");
     
    204203    MParContainer::Class()->IgnoreTObjectStreamer();
    205204
    206     TApplication app("Ganymed", &argc, argv);
     205    TApplication app("ganymed", &argc, argv);
    207206    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    208207    {
  • trunk/MagicSoft/Mars/mars.cc

    r6888 r7001  
    6969    gLog << "Sorry the usage is:" << endl;
    7070    gLog << "   mars [-h] [-?] [-a0] [-vn]" << endl << endl;
    71     gLog << "     -a0: Do not use Ansii codes." << endl;
    72     gLog << "     -vn: Verbosity level n [default=2]" << endl;
     71    gLog.Usage();
    7372    gLog << "     -?/-h: This help" << endl << endl;
    7473}
     
    7675int main(int argc, char **argv)
    7776{
    78     StartUpMessage();
    79 
    8077    //
    8178    // Evaluate arguments
    8279    //
    83     MArgs arg(argc, argv);
     80    MArgs arg(argc, argv, kTRUE);
     81    gLog.Setup(arg);
     82
     83    StartUpMessage();
    8484
    8585    if (arg.HasOption("-?") || arg.HasOption("-h"))
     
    8888        return 2;
    8989    }
    90 
    91     //
    92     // Set verbosity to highest level.
    93     //
    94     gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
    95 
    96     if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
    97         gLog.SetNoColors();
    9890
    9991#ifdef HAVE_XPM
     
    10597    // initialise ROOT
    10698    //
    107     TApplication app("Mars", &argc, argv);
     99    TApplication app("mars", &argc, argv);
    108100    if (gROOT->IsBatch() || !gClient)
    109101    {
  • trunk/MagicSoft/Mars/mbase/MLog.cc

    r5820 r7001  
    134134#endif
    135135const char *const MLog::kBlue      = "\033[34m";
    136 const char *const MLog::kUnderline = "\033[4m";;
    137 const char *const MLog::kBlink     = "\033[5m";;
    138 const char *const MLog::kBright    = "\033[1m";;
    139 const char *const MLog::kDark      = "\033[2m";;
     136const char *const MLog::kUnderline = "\033[4m";
     137const char *const MLog::kBlink     = "\033[5m";
     138const char *const MLog::kBright    = "\033[1m";
     139const char *const MLog::kDark      = "\033[2m";
    140140
    141141//
     
    488488    if (fDevice&eStdout)
    489489    {
    490         if (!TestBit(eNoColors))
     490        if (!fIsNull && !TestBit(eNoColors))
    491491            cout << kReset;
    492492        cout.flush();
  • trunk/MagicSoft/Mars/mbase/MLog.h

    r5720 r7001  
    129129    void operator=(TGTextView *out)     { SetOutputGui(out);  }
    130130
     131    Bool_t IsNullOutput() const { return fIsNull; }
    131132    Bool_t IsOutputDeviceEnabled(int i) const { return fDevice & i; }
    132133
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r7000 r7001  
    3333// To write gif files of C-Macros use SaveAsGif()/SaveAsPNG() or SaveAsC().
    3434// Direct printing to the default printer (via lpr) can be done by
    35 // PrintToLpr().
     35// PrintPS().
    3636//
    3737// It has also to half status lines which can be used to display the status
     
    6464
    6565#include <TH1.h>                  // TH1::AddDirectory
     66#include <TPDF.h>                 // TPDF
     67#include <TSVG.h>                 // TSVG
    6668#include <TEnv.h>                 // TEnv
    6769#include <TLine.h>                // TLine
     
    7476#include <TDatime.h>              // TDatime
    7577#include <TRandom.h>              // TRandom
     78#include <TRegexp.h>              // TRegexp
    7679#include <TThread.h>              // TThread::Self()
    7780#include <TBrowser.h>             // TBrowser
     
    8083#include <TMethodCall.h>          // TMethodCall
    8184
    82 //#include <TRint.h>                // gApplication, TRint::Class()
    8385#include <TInterpreter.h>         // gInterpreter
    8486
     
    9294#include <TGFileDialog.h>         // TGFileDialog
    9395#include <TGProgressBar.h>        // TGHProgressBar
     96#include <TGTextEditDialogs.h>    // TGPrintDialog
    9497#include <TRootEmbeddedCanvas.h>  // TRootEmbeddedCanvas
    9598
     
    245248    //
    246249    MGPopupMenu *filemenu = new MGPopupMenu(gClient->GetRoot());
    247     // filemenu->AddEntry("Save &As...", kFileSaveAs);
    248     filemenu->AddEntry("New Can&vas",   kFileCanvas);
    249     filemenu->AddEntry("New &Browser",  kFileBrowser);
     250    filemenu->AddEntry("New &Canvas",       kFileCanvas);
     251    filemenu->AddEntry("New &Browser",      kFileBrowser);
    250252    filemenu->AddSeparator();
    251     filemenu->AddEntry("Save status.&ps",   kFileSaveAsPS);
    252     filemenu->AddEntry("Save status.&png",  kFileSaveAsPNG);
    253     filemenu->AddEntry("Save status.&gif",  kFileSaveAsGIF);
    254     filemenu->AddEntry("Save status.&jpg",  kFileSaveAsJPG);
    255     filemenu->AddEntry("Save status.&xpm",  kFileSaveAsXPM);
    256     filemenu->AddEntry("Save status.&C",    kFileSaveAsC);
    257     filemenu->AddEntry("Save status.&root", kFileSaveAsRoot);
     253
     254    const TString fname(MString::Form("Save %s.", gROOT->GetName()));
     255    MGPopupMenu *savemenu = new MGPopupMenu(gClient->GetRoot());
     256    savemenu->AddEntry(MString::Form("%s&ps",  fname.Data()),  kFileSaveAsPS);
     257    savemenu->AddEntry(MString::Form("%sp&df", fname.Data()),  kFileSaveAsPDF);
     258    savemenu->AddEntry(MString::Form("%s&svg", fname.Data()),  kFileSaveAsSVG);
     259    savemenu->AddSeparator();
     260    savemenu->AddEntry(MString::Form("%sp&ng", fname.Data()),  kFileSaveAsPNG);
     261    savemenu->AddEntry(MString::Form("%s&gif", fname.Data()),  kFileSaveAsGIF);
     262    savemenu->AddEntry(MString::Form("%s&jpg", fname.Data()),  kFileSaveAsJPG);
     263    savemenu->AddEntry(MString::Form("%s&xpm", fname.Data()),  kFileSaveAsXPM);
     264    //savemenu->AddEntry("Save status.x&cf",  kFileSaveAsXCF);
     265    //savemenu->AddEntry("Save status.&tiff", kFileSaveAsTIFF);
     266    //savemenu->AddEntry("Save status.&bmp",  kFileSaveAsBMP);
     267    savemenu->AddSeparator();
     268    savemenu->AddEntry(MString::Form("%s&C",    fname.Data()), kFileSaveAsC);
     269    savemenu->AddEntry(MString::Form("%s&root", fname.Data()), kFileSaveAsRoot);
     270    savemenu->Associate(this);
     271
     272    filemenu->AddEntry("&Open...",          kFileOpen);
     273    filemenu->AddPopup("&Save", savemenu);
     274    filemenu->AddEntry("Save &As...",       kFileSaveAs);
    258275    filemenu->AddSeparator();
    259     filemenu->AddEntry("&Open...",             kFileOpen);
    260     filemenu->AddEntry("Save &As...",          kFileSaveAs);
     276    filemenu->AddEntry("&Reset",            kFileReset);
    261277    filemenu->AddSeparator();
    262     filemenu->AddEntry("Re&set",               kFileReset);
     278    filemenu->AddEntry("&Print",            kFilePrint);
    263279    filemenu->AddSeparator();
    264     filemenu->AddEntry("Print with &lpr",      kFilePrint);
    265     //filemenu->AddEntry("Set printer &name",    kFilePrinterName);
    266     filemenu->AddSeparator();
    267     filemenu->AddEntry("C&lose", kFileClose);
    268     filemenu->AddEntry("E&xit", kFileExit);
     280    filemenu->AddEntry("C&lose",            kFileClose);
     281    filemenu->AddEntry("E&xit",             kFileExit);
    269282    filemenu->Associate(this);
    270283
     
    273286    //
    274287    MGPopupMenu *tabmenu = new MGPopupMenu(gClient->GetRoot());
    275     tabmenu->AddEntry("Next [&+]",           kTabNext);
    276     tabmenu->AddEntry("Previous [&-]",       kTabPrevious);
     288    tabmenu->AddEntry("Next [&+]",          kTabNext);
     289    tabmenu->AddEntry("Previous [&-]",      kTabPrevious);
    277290    tabmenu->AddSeparator();
    278     tabmenu->AddEntry("Save tab-i.&ps",   kTabSaveAsPS);
    279     tabmenu->AddEntry("Save tab-i.&png",  kTabSaveAsPNG);
    280     tabmenu->AddEntry("Save tab-i.&gif",  kTabSaveAsGIF);
    281     tabmenu->AddEntry("Save tab-i.&jpg",  kTabSaveAsJPG);
    282     tabmenu->AddEntry("Save tab-i.&xpm",  kTabSaveAsXPM);
    283     tabmenu->AddEntry("Save tab-i.&C",    kTabSaveAsC);
    284     tabmenu->AddEntry("Save tab-i.&root", kTabSaveAsRoot);
     291
     292    const TString fname2(MString::Form("Save %s-i.", gROOT->GetName()));
     293    MGPopupMenu *savemenu2 = new MGPopupMenu(gClient->GetRoot());
     294    savemenu2->AddEntry(MString::Form("%s&ps",  fname2.Data()),  kTabSaveAsPS);
     295    savemenu2->AddEntry(MString::Form("%sp&df", fname2.Data()),  kTabSaveAsPDF);
     296    savemenu2->AddEntry(MString::Form("%s&svg", fname2.Data()),  kTabSaveAsSVG);
     297    savemenu2->AddSeparator();
     298    savemenu2->AddEntry(MString::Form("%sp&ng", fname2.Data()),  kTabSaveAsPNG);
     299    savemenu2->AddEntry(MString::Form("%s&gif", fname2.Data()),  kTabSaveAsGIF);
     300    savemenu2->AddEntry(MString::Form("%s&jpg", fname2.Data()),  kTabSaveAsJPG);
     301    savemenu2->AddEntry(MString::Form("%s&xpm", fname2.Data()),  kTabSaveAsXPM);
     302    //savemenu->AddEntry("Save status.x&cf",  kFileSaveAsXCF);
     303    //savemenu->AddEntry("Save status.&tiff", kFileSaveAsTIFF);
     304    //savemenu->AddEntry("Save status.&bmp",  kFileSaveAsBMP);
     305    savemenu2->AddSeparator();
     306    savemenu2->AddEntry(MString::Form("%s&C",    fname2.Data()), kTabSaveAsC);
     307    savemenu2->AddEntry(MString::Form("%s&root", fname2.Data()), kTabSaveAsRoot);
     308    savemenu2->Associate(this);
     309
     310    tabmenu->AddPopup("&Save", savemenu2);
     311    tabmenu->AddEntry("Save tab &As...",    kTabSaveAs);
    285312    tabmenu->AddSeparator();
    286     tabmenu->AddEntry("Save tab &As...",         kTabSaveAs);
     313    tabmenu->AddEntry("&Remove",            kTabRemove);
    287314    tabmenu->AddSeparator();
    288     tabmenu->AddEntry("Re&move",             kTabRemove);
    289     tabmenu->AddSeparator();
    290     tabmenu->AddEntry("Print with &lpr",     kTabPrint);
     315    tabmenu->AddEntry("&Print",             kTabPrint);
    291316    tabmenu->Associate(this);
    292317
     
    326351    logmenu->AddEntry("&Save",          kLogSave);
    327352    logmenu->AddEntry("Save &append",   kLogAppend);
     353    logmenu->AddSeparator();
     354    logmenu->AddEntry("&Print",         kLogPrint);
    328355    logmenu->Associate(this);
    329356
     
    355382    // Add everything to autodel list
    356383    //
     384    fList->Add(savemenu);
     385    fList->Add(savemenu2);
    357386    fList->Add(filemenu);
    358387    fList->Add(loopmenu);
     
    10851114}
    10861115
     1116TString MStatusDisplay::PrintDialog(TString &p, TString &c, TString &t, const char *ext)
     1117{
     1118    // If not in batch mode open a user dialog
     1119    if (!gROOT->IsBatch())
     1120    {
     1121        char *cprinter = StrDup(p);
     1122        char *ccmd     = StrDup(c);
     1123
     1124        Int_t rc=0;
     1125        new TGPrintDialog(fClient->GetRoot(), this, 400, 150, &cprinter, &ccmd, &rc);
     1126        if (rc)
     1127        {
     1128            p = cprinter; // default has been changed
     1129            c = ccmd;
     1130        }
     1131
     1132        delete [] cprinter;
     1133        delete [] ccmd;
     1134
     1135        if (!rc)
     1136            return "";
     1137    }
     1138
     1139
     1140    if (c.Contains("%f") && ext)
     1141    {
     1142        // Get temporary file name
     1143        TString name = "mars";
     1144
     1145        FILE *f = gSystem->TempFileName(name, t);
     1146        if (!f)
     1147        {
     1148            *fLog << warn << "MStatusDisplay::PrintDialog: Couldn't create temporary file in " << t << endl;
     1149            SetStatusLine2("failed!");
     1150            return "";
     1151        }
     1152        fclose(f);
     1153
     1154        // remove temp file
     1155        gSystem->Unlink(name);
     1156        name += ".";
     1157        name += ext;
     1158
     1159        t = name;
     1160    }
     1161
     1162    // compile command
     1163    TString cmd(c);
     1164
     1165    // if sprinter.IsNull we assume that everything around %p can
     1166    // be omitted and the program uses some kind of default
     1167    if (p.IsNull())
     1168    {
     1169        TString sub;
     1170        while (1)
     1171        {
     1172            sub = TString(cmd(TRegexp(" .*%p.* "))).Strip(TString::kBoth);
     1173            if (sub.IsNull())
     1174                break;
     1175
     1176            cmd.ReplaceAll(sub, "");
     1177        }
     1178    }
     1179
     1180    cmd.ReplaceAll("%p", p);
     1181    cmd.ReplaceAll("%f", t);
     1182
     1183    return cmd;
     1184}
     1185
    10871186// --------------------------------------------------------------------------
    10881187//
    10891188// Saves the given canvas (pad) or all pads (num<0) as a temporary
    1090 // postscript file and prints it using 'lpr'. If a printer name is set
    1091 // via SetPrinter 'lpr -Pname' is used.
    1092 //
    1093 Int_t MStatusDisplay::PrintToLpr(Int_t num)
    1094 {
    1095     TString name = "mars";
    1096 
    1097     for (int i=0; i<6; i++)
    1098         name += (char)(gRandom->Uniform(25)+65);
    1099 
    1100     name += ".ps";
    1101 
    1102     const Int_t pages = SaveAsPS(num, name);
    1103 
     1189// postscript file and prints it.
     1190//
     1191// The default command line c is: lpr -P%p %f
     1192//   %p: printer name
     1193//   %f: temporary file name
     1194//
     1195// The default printer name p is: <empty>
     1196//
     1197// Both can be changed in .rootrc by:
     1198//   PrintPS.Printer
     1199//   PrintPS.Command
     1200//
     1201// Ant the location of the temporary file t can by changed by
     1202//   Print.Directory
     1203// the default is the system default directory (normally /tmp)
     1204//
     1205Int_t MStatusDisplay::PrintPS(Int_t num, const char *p, const char *c, const char *t)
     1206{
     1207    static TString sprinter = gEnv->GetValue("PrintPS.Printer", p&&*p?p:"");
     1208    static TString scmd     = gEnv->GetValue("PrintPS.Command", c&&*c?c:"lpr -P%p %f");
     1209
     1210    TString tmp = gEnv->GetValue("Print.Directory", t&&*t?t:gSystem->TempDirectory());
     1211
     1212    TString cmd = PrintDialog(sprinter, scmd, tmp, "ps");
     1213    if (cmd.IsNull())
     1214        return 0;
     1215
     1216    // set status lines
    11041217    SetStatusLine1("Printing...");
    11051218    SetStatusLine2("");
    11061219
     1220    // print to temporary file
     1221    const Int_t pages = SaveAsPS(num, tmp);
     1222
     1223    // check
    11071224    if (!pages)
    11081225    {
    1109         *fLog << warn << "MStatusDisplay::PrintToLpr: Sorry, couldn't save file as temporary postscript!" << endl;
     1226        *fLog << warn << "MStatusDisplay::Print: Sorry, couldn't save file as temporary postscript!" << endl;
    11101227        SetStatusLine2("Failed!");
    11111228        return 0;
    11121229    }
    11131230
    1114     TString cmd="lpr ";
    1115     if (!fPrinter.IsNull())
    1116     {
    1117         cmd += "-P";
    1118         cmd += fPrinter;
    1119         cmd += " ";
    1120     }
    1121     cmd += name;
    1122 
     1231    // execute command
     1232    *fLog << dbg << "Executing: " << cmd << endl;
    11231233    gSystem->Exec(cmd);
    1124     gSystem->Unlink(name);
     1234
     1235    // remove temporary file
     1236    gSystem->Unlink(tmp);
    11251237
    11261238    SetStatusLine2(MString::Form("Done (%dpage(s))", pages));
     
    12261338}
    12271339
     1340Bool_t MStatusDisplay::SaveLogAsPS(const char *n) const
     1341{
     1342    TString name(n);
     1343    AddExtension(name, "ps");
     1344
     1345    // Code taken from TGTextEdit::Print
     1346    const TString pipe = MString::Form("a2ps -o%s", name.Data());
     1347    FILE *p = gSystem->OpenPipe(pipe, "w");
     1348    if (!p)
     1349    {
     1350        *fLog << err << "ERROR - Couldn't open pipe " << pipe << endl;
     1351        return kFALSE;
     1352    }
     1353
     1354    TGText *text = fLogBox->GetText();
     1355
     1356    char   *buf1, *buf2;
     1357    Long_t  len;
     1358    ULong_t i = 0;
     1359    TGLongPosition pos;
     1360
     1361    pos.fX = pos.fY = 0;
     1362    while (pos.fY < text->RowCount())
     1363    {
     1364        len = text->GetLineLength(pos.fY);
     1365        buf1 = text->GetLine(pos, len);
     1366        buf2 = new char[len + 2];
     1367        strncpy(buf2, buf1, (UInt_t)len);
     1368        buf2[len]   = '\n';
     1369        buf2[len+1] = '\0';
     1370        while (buf2[i] != '\0') {
     1371            if (buf2[i] == '\t') {
     1372                ULong_t j = i+1;
     1373                while (buf2[j] == 16 && buf2[j] != '\0')
     1374                    j++;
     1375                strcpy(buf2+i+1, buf2+j);
     1376            }
     1377            i++;
     1378        }
     1379        fwrite(buf2, sizeof(char), strlen(buf2)+1, p);
     1380
     1381        delete [] buf1;
     1382        delete [] buf2;
     1383        pos.fY++;
     1384    }
     1385    gSystem->ClosePipe(p);
     1386    return kTRUE;
     1387}
     1388
     1389// --------------------------------------------------------------------------
     1390//
     1391// Print the log text.
     1392//
     1393// The default command line c is: a2ps -P%p
     1394//   %p: printer name
     1395//
     1396// The default printer name p is: <empty>
     1397//
     1398// Both can be changed in .rootrc by:
     1399//   PrintText.Printer
     1400//   PrintText.Command
     1401//
     1402Bool_t MStatusDisplay::PrintLog(const char *p, const char *c)
     1403{
     1404    static TString sprinter = gEnv->GetValue("PrintText.Printer", p&&*p?p:"");
     1405    static TString scmd     = gEnv->GetValue("PrintText.Command", c&&*c?c:"a2ps -P%p");
     1406
     1407    TString tmp;
     1408    TString cmd = PrintDialog(sprinter, scmd, tmp);
     1409    if (cmd.IsNull())
     1410        return kFALSE;
     1411
     1412    // set status lines
     1413    SetStatusLine1("Printing...");
     1414    SetStatusLine2("");
     1415
     1416    // print to temporary file
     1417    if (!SaveLogAsPS(cmd))
     1418    {
     1419        *fLog << warn << "MStatusDisplay::PrintLog: Sorry, couldn't create postscript!" << endl;
     1420        SetStatusLine2("Failed!");
     1421        return kFALSE;
     1422    }
     1423
     1424    // execute command
     1425    *fLog << dbg << "Executing: " << cmd << endl;
     1426    gSystem->Exec(cmd);
     1427
     1428    SetStatusLine2("Done.");
     1429
     1430    return kTRUE;
     1431}
     1432
    12281433// --------------------------------------------------------------------------
    12291434//
     
    12671472        return kTRUE;
    12681473
     1474    case kFileSaveAsPDF:
     1475        SaveAsPDF();
     1476        return kTRUE;
     1477
     1478    case kFileSaveAsSVG:
     1479        SaveAsSVG();
     1480        return kTRUE;
     1481
    12691482    case kFileSaveAsPNG:
    12701483        SaveAsPNG();
     
    12831496        return kTRUE;
    12841497
     1498    //case kFileSaveAsXCF:
     1499    //    SaveAsXCF();
     1500    //    return kTRUE;
     1501
     1502    //case kFileSaveAsTIFF:
     1503    //    SaveAsTIFF();
     1504    //    return kTRUE;
     1505
     1506    //case kFileSaveAsBMP:
     1507    //    SaveAsBMP();
     1508    //    return kTRUE;
     1509
    12851510    case kFileSaveAsC:
    12861511        SaveAsC();
     
    12921517
    12931518    case kFilePrint:
    1294         PrintToLpr();
     1519        PrintPS();
    12951520        return kTRUE;
    12961521
     
    13031528        return kTRUE;
    13041529
     1530    case kTabSaveAsPDF:
     1531        SaveAsPDF(fTab->GetCurrent());
     1532        return kTRUE;
     1533
     1534    case kTabSaveAsSVG:
     1535        SaveAsSVG(fTab->GetCurrent());
     1536        return kTRUE;
     1537
    13051538    case kTabSaveAsPNG:
    13061539        SaveAsPNG(fTab->GetCurrent());
     
    13191552        return kTRUE;
    13201553
     1554    //case kTabSaveAsXCF:
     1555    //    SaveAsXCF(fTab->GetCurrent());
     1556    //    return kTRUE;
     1557
     1558    //case kTabSaveAsBMP:
     1559    //    SaveAsBMP(fTab->GetCurrent());
     1560    //    return kTRUE;
     1561
     1562    //case kTabSaveAsTIFF:
     1563    //    SaveAsTIFF(fTab->GetCurrent());
     1564    //    return kTRUE;
     1565
    13211566    case kTabSaveAsC:
    13221567        SaveAsC(fTab->GetCurrent());
     
    13281573
    13291574    case kTabPrint:
    1330         PrintToLpr(fTab->GetCurrent());
     1575        PrintPS(fTab->GetCurrent());
    13311576        return kTRUE;
    13321577
     
    13861631        SetStatusLine2("");
    13871632        *fLog << inf << "Saving log... " << flush;
    1388         if (fLogBox->GetText()->Save("statusdisplay.log"))
     1633        if (fLogBox->GetText()->Save(MString::Form("%s.log", gROOT->GetName())))
    13891634        {
    13901635            *fLog << "done." << endl;
     
    14021647        SetStatusLine2("");
    14031648        *fLog << inf << "Appending log... " << flush;
    1404         if (fLogBox->GetText()->Append("statusdisplay.log"))
     1649        if (fLogBox->GetText()->Append(MString::Form("%s.log", gROOT->GetName())))
    14051650        {
    14061651            *fLog << "done." << endl;
     
    14121657            SetStatusLine2("Failed!");
    14131658        }
     1659        return kTRUE;
     1660
     1661    case kLogPrint:
     1662        PrintLog();
    14141663        return kTRUE;
    14151664#ifdef DEBUG
     
    19732222    if (name.IsNull())
    19742223    {
    1975         name = "status";
     2224        name = gROOT->GetName();
    19762225        if (num>0)
    19772226        {
     
    20422291    gSystem->Unlink(name);
    20432292    gSystem->Rename(name+".$$$", name);
    2044 /*
    2045     //
    2046     // Old style algorithm. Shifts blocks inside a single file --- SLOW!
    2047     //
    2048     const Int_t l = newstr.Length();
    2049 
    2050     Long_t t[4]; // { id, size, flags, modtime }
    2051     gSystem->GetPathInfo(name, t, t+1, t+2, t+3);
    2052 
    2053     char *c[2] = { new char[l], new char[l] };
    2054 
    2055     fstream f(name, ios::in|ios::out);
    2056 
    2057     TString str;
    2058     f >> str >> c[0][0];     // Read "%!PS-Adobe-2.0\n" (Mini Header)
    2059     f.read(c[0], l);
    2060     f.seekp(-l, ios::cur);
    2061     f.write(newstr, l);
    2062 
    2063     int i=0;
    2064     while (1)
    2065     {
    2066         f.read(c[(i+1)%2], l);
    2067         f.seekp(-l, ios::cur);
    2068 
    2069         if (f)
    2070         {
    2071             f.write(c[i%2],l);
    2072             i++;
    2073             i%=2;
    2074             continue;
    2075         }
    2076 
    2077         const Int_t ssz   = str.Length()+1;        // Length of Mini-Header
    2078         const Int_t block = t[1]-ssz;              // Length of block to be shifted
    2079         const Int_t size  = block%l;               // Reminder
    2080         const Int_t pos   = (block/l)*l + ssz + 1; // Position to start writing
    2081 
    2082         f.clear();
    2083         f.seekp(pos);
    2084         f.write(c[i%2], l);
    2085         f.write(c[(i+1)%2], size);
    2086         break;
    2087     }
    2088 
    2089     delete c[1];
    2090     delete c[0];
    2091 */
    2092 }
    2093 
    2094 // --------------------------------------------------------------------------
    2095 //
    2096 // In case of num<0 all tabs are written into the PS file. If num>0
     2293}
     2294
     2295void MStatusDisplay::PSToolsRange(TVirtualPS &vps, Float_t psw, Float_t psh) const
     2296{
     2297    if (vps.InheritsFrom(TPostScript::Class()))
     2298        static_cast<TPostScript&>(vps).Range(psw, psh);
     2299    // if (vps.InheritsFrom(TPDF::Class()))
     2300    //     static_cast<TPDF&>(vps).Range(psw/2, psh/2);
     2301    // if (vps.InheritsFrom(TSVG::Class()))
     2302    //     static_cast<TSVG&>(vps).Range(psw, psh);
     2303}
     2304
     2305void MStatusDisplay::PSToolsTextNDC(TVirtualPS &vps, Double_t u, Double_t v, const char *string) const
     2306{
     2307    if (vps.InheritsFrom(TPostScript::Class()))
     2308        static_cast<TPostScript&>(vps).TextNDC(u, v, string);
     2309    // if (vps.InheritsFrom(TPDF::Class()))
     2310    //    static_cast<TPDF&>(vps).TextNDC(u, v, string);
     2311    // if (vps.InheritsFrom(TSVG::Class()))
     2312    //    static_cast<TSVG&>(vps).TextNDC(u, v, string);
     2313}
     2314
     2315// --------------------------------------------------------------------------
     2316//
     2317// Write some VGF (vector graphics format). Currently PS, PDF and SVG
     2318// is available. Specified by ext.
     2319//
     2320// In case of num<0 all tabs are written into the VGF file. If num>0
    20972321// the canvas in the corresponding tab is written to the file.
    20982322// Name is the name of the file (with or without extension).
     
    21002324// Returns the number of pages written.
    21012325//
    2102 // To write all tabs you can also use SaveAsPS(name)
     2326// To write all tabs you can also use SaveAsVGF(name, ext)
    21032327//
    21042328// If the third argument is given a bottom line is drawn with the text
     
    21062330// fTitle (SetTitle) is not empty.
    21072331//
    2108 Int_t MStatusDisplay::SaveAsPS(Int_t num, TString name, const TString addon)
    2109 {
    2110     SetStatusLine1("Writing Postscript file...");
     2332Int_t MStatusDisplay::SaveAsVGF(Int_t num, TString name, const TString addon, const TString ext)
     2333{
     2334    SetStatusLine1(Form("Writing %s file...",ext.Data()));
    21112335    SetStatusLine2("");
    21122336
     
    21172341    }
    21182342
    2119     AddExtension(name, "ps", num);
     2343    AddExtension(name, ext, num);
    21202344
    21212345    if (num<0)
    2122         *fLog << inf << "Open ps-File: " << name << endl;
     2346        *fLog << inf << "Open " << ext << "-File: " << name << endl;
    21232347
    21242348    TPad       *padsav = (TPad*)gPad;
     
    21272351    TDatime d;
    21282352
    2129     TPostScript ps(name, 112);
    2130     ps.SetBit(TPad::kPrintingPS);
    2131     ps.PrintFast(13, "/nan {1} def ");
    2132 
    2133     gVirtualPS = &ps;
     2353    Int_t type = -1;
     2354
     2355    TVirtualPS *ps =0;
     2356    if (!ext.CompareTo("ps", TString::kIgnoreCase))
     2357    {
     2358        ps = new TPostScript(name, 112);
     2359        type = 1;
     2360    }
     2361    if (!ext.CompareTo("pdf", TString::kIgnoreCase))
     2362    {
     2363        ps = new TPDF(name, 112);
     2364        type = 2;
     2365    }
     2366    if (!ext.CompareTo("svg", TString::kIgnoreCase))
     2367    {
     2368        ps = new TSVG(name, 112);
     2369        type = 3;
     2370    }
     2371
     2372    if (!ps)
     2373    {
     2374        *fLog << err << "Extension " << ext << " unknown..." << endl;
     2375        SetStatusLine2("Failed!");
     2376        return 0;
     2377    }
     2378
     2379    ps->SetBit(TPad::kPrintingPS);
     2380    if (type==1)
     2381        ps->PrintFast(13, "/nan {1} def ");
     2382
     2383    gVirtualPS = ps;
    21342384
    21352385    //
     
    21702420        // has the same Aspect Ratio than on the screen.
    21712421        //
    2172         ps.NewPage();
     2422        if (i>from)
     2423            ps->NewPage();
    21732424
    21742425        //
     
    21762427        // such that the page title can be set above the canvas...
    21772428        //
    2178         Float_t psw = 28.0; // A4 - width (29.7)
     2429        Float_t psw = 28.0; // A4 - width  (29.7)
    21792430        Float_t psh = 21.0; // A4 - height (21.0)
    21802431
     
    21872438            psh = ch/cw*psw;
    21882439
    2189         ps.Range(psw, psh); // A4
     2440        PSToolsRange(*ps, psw, psh);
    21902441
    21912442        //
     
    22192470        // Print overlaying text (NDC = %)
    22202471        //
    2221         ps.SetTextColor(kBlack);
    2222         ps.SetTextSize(0.015);
    2223         ps.SetTextFont(22);
    2224         ps.SetTextAlign(11); // left top
    2225         ps.TextNDC(0, 1.015, TString("  ")+n->GetName());
    2226         ps.SetTextAlign(21); // cent top
    2227         ps.TextNDC(0.5, 1.015, TString("MARS - Magic Analysis and Reconstruction Software - ")+d.AsString());
    2228         ps.SetTextAlign(31); // right top
    2229         ps.TextNDC(1, 1.015, MString::Form("Page No.%i (%i)  ", page++, i));
     2472        ps->SetTextColor(kBlack);
     2473        ps->SetTextSize(0.015);
     2474        ps->SetTextFont(22);
     2475        ps->SetTextAlign(11); // left top
     2476        PSToolsTextNDC(*ps, 0, 1.015, TString("  ")+n->GetName());
     2477        ps->SetTextAlign(21); // cent top
     2478        PSToolsTextNDC(*ps, 0.5, 1.015, TString("MARS - Magic Analysis and Reconstruction Software - ")+d.AsString());
     2479        ps->SetTextAlign(31); // right top
     2480        PSToolsTextNDC(*ps, 1, 1.015, MString::Form("Page No.%i (%i)  ", page++, i));
    22302481        line.PaintLineNDC(0, 1.01, 1, 1.01);
    22312482
     
    22342485        {
    22352486            line.PaintLineNDC(0, -0.00, 1, -0.00);
    2236             ps.SetTextAlign(11); // left top
    2237             ps.TextNDC(0, -0.015, TString("  ")+txt);
    2238             ps.SetTextAlign(31); // right top
    2239             ps.TextNDC(1, -0.015, "(c) 2000-2004, Thomas Bretz  ");
     2487            ps->SetTextAlign(11); // left top
     2488            PSToolsTextNDC(*ps, 0, -0.015, TString("  ")+txt);
     2489            ps->SetTextAlign(31); // right top
     2490            PSToolsTextNDC(*ps, 1, -0.015, "(c) 2000-2005, Thomas Bretz  ");
    22402491        }
    22412492
     
    22502501    l.Delete();
    22512502
    2252     ps.Close();
    2253 
    2254     SetStatusLine2("Updating header of PS file...");
    2255 
    2256     if (num<0)
    2257         *fLog << " - Updating header of PS file... " << flush;
    2258     UpdatePSHeader(name);
    2259     if (num<0)
    2260         *fLog << inf << "done." << endl;
     2503    ps->Close();
     2504    delete ps;
     2505
     2506    if (type==1)
     2507    {
     2508        SetStatusLine2("Updating header of PS file...");
     2509
     2510        if (num<0)
     2511            *fLog << " - Updating header of PS file... " << flush;
     2512        UpdatePSHeader(name);
     2513        if (num<0)
     2514            *fLog << inf << "done." << endl;
     2515    }
    22612516
    22622517    gVirtualPS = psave;
     
    22742529Bool_t MStatusDisplay::SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type)
    22752530{
     2531//#if ROOT_VERSION_CODE < ROOT_VERSION(4,04,00)
    22762532    if (gROOT->IsBatch())
    22772533    {
     
    22802536        return 0;
    22812537    }
    2282     //SetStatusLine1("Writing GIF file...");
     2538//#endif
     2539
    22832540    SetStatusLine1("Writing image file... <please be patient>");
    22842541    SetStatusLine2("");
     
    23062563        ext = AddExtension(name, "jpg", num);
    23072564        break;
    2308 //    case TImage::kXcf:
    2309 //        ext = AddExtension(name, "xcf", num);
     2565    case TImage::kGif:
     2566        ext = AddExtension(name, "gif", num);
     2567        break;
     2568//    case TImage::kTiff:
     2569//        ext = AddExtension(name, "tiff", num);
    23102570//        break;
    23112571//    case TImage::kPpm:
     
    23152575//        ext = AddExtension(name, "pnm", num);
    23162576//        break;
    2317 //    case TImage::kBmp:
    2318 //        ext = AddExtension(name, "bmp", num);
    2319 //        break;
    23202577//    case TImage::kIco:
    23212578//        ext = AddExtension(name, "ico", num);
     
    23242581//        ext = AddExtension(name, "cur", num);
    23252582//        break;
    2326     case TImage::kGif:
    2327         ext = AddExtension(name, "gif", num);
    2328         break;
    2329 //    case TImage::kTiff:
    2330 //        ext = AddExtension(name, "tif", num);
     2583//    case TImage::kBmp:
     2584//        ext = AddExtension(name, "bmp", num);
     2585//        break;
     2586//    case TImage::kXcf:
     2587//        ext = AddExtension(name, "xcf", num);
    23312588//        break;
    23322589//    case TImage::kXbm:
     
    23972654        *fLog << "..." << flush;
    23982655
     2656#if ROOT_VERSION_CODE < ROOT_VERSION(4,04,00)
    23992657        c->Draw();
     2658
    24002659        if (type==TImage::kGif)
    24012660            c->SaveAs(writename); // FIXME: Seems not to work well in TImage! (root 3.10/02)
     
    24072666            delete img;
    24082667        }
    2409 
     2668#else
     2669        c->Print(writename);
     2670#endif
    24102671        if (num<0)
    24112672            *fLog << "done." << endl;
     
    25352796// --------------------------------------------------------------------------
    25362797//
     2798// Determin File type to save file as by extension. Allowed extensions are:
     2799//   root, ps, pdf, svg, gif, png, jpg, xpm, C
     2800//
     2801// returns -1 if file type is unknown. Otherwise return value of SaveAs*
     2802//
     2803Int_t MStatusDisplay::SaveAs(Int_t num, TString name)
     2804{
     2805    if (name.EndsWith(".root")) return SaveAsRoot(num, name);
     2806    if (name.EndsWith(".ps"))   return SaveAsPS(num, name);
     2807    if (name.EndsWith(".pdf"))  return SaveAsPDF(num, name);
     2808    if (name.EndsWith(".svg"))  return SaveAsSVG(num, name);
     2809    if (name.EndsWith(".gif"))  return SaveAsGIF(num, name);
     2810    if (name.EndsWith(".png"))  return SaveAsPNG(num, name);
     2811    if (name.EndsWith(".jpg"))  return SaveAsJPG(num, name);
     2812    if (name.EndsWith(".xpm"))  return SaveAsXPM(num, name);
     2813    if (name.EndsWith(".C"))    return SaveAsC(num, name);
     2814    return -1;
     2815}
     2816
     2817// --------------------------------------------------------------------------
     2818//
    25372819//  Opens a save as dialog
    25382820//
     
    25422824    {
    25432825        "PostScript",   "*.ps",
     2826        "Acrobat pdf",  "*.pdf",
     2827        "SVG vector",   "*.svg",
    25442828        "Gif files",    "*.gif",
     2829        "Png files",    "*.png",
     2830        "Gif files",    "*.gif",
     2831        "Jpeg files",   "*.jpeg",
     2832        "Xpm files",    "*.xpm",
    25452833        "Macro files",  "*.C",
    25462834        "ROOT files",   "*.root",
     
    25632851    dir = fi.fIniDir;
    25642852
    2565     const TString name(fi.fFilename);
    2566 
    2567     if (name.EndsWith(".root")) return SaveAsRoot(num, name);
    2568     if (name.EndsWith(".ps"))   return SaveAsPS(num, name);
    2569     if (name.EndsWith(".gif"))  return SaveAsGIF(num, name);
    2570     if (name.EndsWith(".C"))    return SaveAsC(num, name);
     2853    const Int_t rc = SaveAs(num, fi.fFilename);
     2854    if (rc>=0)
     2855        return rc;
    25712856
    25722857    Warning("MStatusDisplay::SaveAs", "Unknown Extension: %s", fi.fFilename);
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.h

    r6978 r7001  
    2626class TMutex;
    2727class TCanvas;
     28class TVirtualPS;
    2829
    2930class TGTab;
     
    4243    typedef enum {
    4344        // kFile
    44         kFileBrowser, kFileCanvas, kFileOpen, kFileSave, kFileSaveAs, kFileSaveAsPS,
    45         kFileSaveAsRoot, kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG,
    46         kFileSaveAsXPM, kFileSaveAsC, kFilePrint, kFilePrinterName,
     45        kFileBrowser, kFileCanvas, kFileOpen, kFileSave, kFileSaveAs,
     46        kFileSaveAsPS, kFileSaveAsPDF, kFileSaveAsSVG, kFileSaveAsRoot,
     47        kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG, kFileSaveAsXPM,
     48        /*kFileSaveAsBMP, kFileSaveAsXCF, kFileSaveAsTIFF,*/
     49        kFileSaveAsC, kFilePrint, kFilePrinterName,
    4750        kFileClose, kFileExit, kFileReset,
    4851        // kLoop
    4952        kLoopNone, kLoopStop,
    5053        // kTab
    51         kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsPNG,
    52         kTabSaveAsGIF, kTabSaveAsJPG, kTabSaveAsXPM, kTabSaveAsC,
     54        kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsPDF, kTabSaveAsSVG,
     55        kTabSaveAsRoot, kTabSaveAsPNG, kTabSaveAsGIF, kTabSaveAsJPG,
     56        kTabSaveAsXPM, /*kTabSaveAsBMP, kTabSaveAsXCF, kTabSaveAsTIFF,*/
     57        kTabSaveAsC,
    5358        kTabPrint, kTabNext, kTabPrevious, kTabRemove,
    5459        // kSize
     
    5762        // kLog
    5863        kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
     64        kLogPrint,
    5965        // kPic
    6066        kPicMagic, kPicMars,
     
    9197
    9298    Status_t fStatus;
    93 
    94     TString fPrinter;
    9599
    96100    Int_t fLogIdx;
     
    134138    Bool_t Display(const TObjArray &list, const char *tab=0);
    135139
    136     const TString &AddExtension(TString &name, const TString &ext, Int_t num) const;
     140    const TString &AddExtension(TString &name, const TString &ext, Int_t num=-1) const;
    137141
    138142    void UpdatePSHeader(const TString &name) const;
     
    144148
    145149    Bool_t SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type);
     150    Int_t  SaveAsVGF(Int_t num, TString name, const TString addon, const TString ext);
     151
     152    void PSToolsRange(TVirtualPS &vps, Float_t w, Float_t h) const;
     153    void PSToolsTextNDC(TVirtualPS &vps, Double_t u, Double_t v, const char *string) const;
     154    TString PrintDialog(TString &p, TString &c, TString &t, const char *ext=0);
     155
    146156
    147157public:
     
    161171     void SetStatusLine2(const char *txt) { SetStatusLine(txt, 1); }
    162172     void SetStatusLine2(const MParContainer &cont);
    163 
    164      void SetPrinter(const TString &lpr) { fPrinter = lpr; }
    165173
    166174     virtual void SetName(const char *name) { fName = name; }
     
    198206     void SetNoContextMenu(Bool_t flag=kTRUE);
    199207
    200      Int_t  SaveAsPS(TString name="", const TString addon="") { return SaveAsPS(-1, name, addon); }
    201      Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); }
    202      Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
    203      Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); }
    204      Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); }
    205      Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
     208     Int_t  SaveAsPS(TString name="",  const TString addon="") { return SaveAsVGF(-1, name, addon, "ps"); }
     209     Int_t  SaveAsPDF(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "pdf"); }
     210     Int_t  SaveAsSVG(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "svg"); }
     211     Bool_t SaveAsPNG(TString name="")  { return SaveAsPNG(-1, name); }
     212     Bool_t SaveAsGIF(TString name="")  { return SaveAsGIF(-1, name); }
     213     Bool_t SaveAsXPM(TString name="")  { return SaveAsXPM(-1, name); }
     214     Bool_t SaveAsJPG(TString name="")  { return SaveAsJPG(-1, name); }
     215     //Bool_t SaveAsTIFF(TString name="") { return SaveAsTIFF(-1, name); }
     216     //Bool_t SaveAsXCF(TString name="")  { return SaveAsXCF(-1, name); }
     217     //Bool_t SaveAsBMP(TString name="")  { return SaveAsBMP(-1, name); }
     218     Bool_t SaveAsC(TString name="")    { return SaveAsC(-1, name); }
    206219     Int_t  SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
    207      Int_t  PrintToLpr() { return PrintToLpr(-1); }
    208 
    209      Int_t  SaveAsPS(Int_t num, TString name="", const TString addon="");
    210      Bool_t SaveAsPNG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kPng); }
    211      Bool_t SaveAsGIF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kGif); }
    212      Bool_t SaveAsXPM(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXpm); }
    213      Bool_t SaveAsJPG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kJpeg); }
     220     Int_t  SaveAs(TString name)        { return SaveAs(-1, name); }
     221     Int_t  PrintPS() { return PrintPS(-1); }
     222
     223     Int_t  SaveAsPS(Int_t num, TString name="",  const TString addon="") { return SaveAsVGF(num, name, addon, "ps"); }
     224     Int_t  SaveAsPDF(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "pdf"); }
     225     Int_t  SaveAsSVG(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "svg"); }
     226     Bool_t SaveAsPNG(Int_t num, TString name="")  { return SaveAsImage(num, name, TImage::kPng); }
     227     Bool_t SaveAsGIF(Int_t num, TString name="")  { return SaveAsImage(num, name, TImage::kGif); }
     228     Bool_t SaveAsXPM(Int_t num, TString name="")  { return SaveAsImage(num, name, TImage::kXpm); }
     229     Bool_t SaveAsJPG(Int_t num, TString name="")  { return SaveAsImage(num, name, TImage::kJpeg); }
     230     //Bool_t SaveAsTIFF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kTiff); }
     231     //Bool_t SaveAsXCF(Int_t num, TString name="")  { return SaveAsImage(num, name, TImage::kXcf); }
     232     //Bool_t SaveAsBMP(Int_t num, TString name="")  { return SaveAsImage(num, name, TImage::kBmp); }
    214233     Bool_t SaveAsC(Int_t num, TString name="");
    215234     Int_t  SaveAsRoot(Int_t num, TString name="");
    216      Int_t  PrintToLpr(Int_t num);
     235     Int_t  SaveAs(Int_t num, TString name);
     236     Int_t  PrintPS(Int_t num, const char *p=0, const char *cmd=0, const char *tmp=0);
     237     Bool_t PrintLog(const char *p=0, const char *c=0);
     238     Bool_t SaveLogAsPS(const char *name) const;
    217239
    218240     Int_t  SaveAs(Int_t num=-1);
  • trunk/MagicSoft/Mars/merpp.cc

    r6888 r7001  
    145145int main(const int argc, char **argv)
    146146{
     147    //
     148    // Evaluate arguments
     149    //
     150    MArgs arg(argc, argv);
     151    gLog.Setup(arg);
     152
    147153    StartUpMessage();
    148 
    149     //
    150     // Evaluate arguments
    151     //
    152     MArgs arg(argc, argv);
    153154
    154155    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    160161        return 2;
    161162    }
    162 
    163     gLog.Setup(arg);
    164163
    165164    const Int_t  kComprlvl   = arg.GetIntAndRemove("-c", 2);
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h

    r7000 r7001  
    8989        // TBranchElement::kDeleteObject = BIT(16)
    9090        // TTree::kFriendLock = BIT(17)
    91         kIsNewTree  = BIT(17)
     91        kIsNewTree  = BIT(23)
    9292    };
    9393
  • trunk/MagicSoft/Mars/mhflux/FluxLinkDef.h

    r6989 r7001  
    88
    99#pragma link C++ class MHAlpha+;
    10 #pragma link C++ class MHTheta+;
     10#pragma link C++ class MHThetaSq+;
    1111#pragma link C++ class MHEnergyEst+;
    1212#pragma link C++ class MHFalseSource+;
    1313#pragma link C++ class MHEffectiveOnTime+;
    1414#pragma link C++ class MHCollectionArea+;
     15#pragma link C++ class MMatrixHist+;
     16#pragma link C++ class MMatrixUnfold+;
     17#pragma link C++ class MUnfoldBert+;
    1518
    1619#endif
  • trunk/MagicSoft/Mars/mhflux/Makefile

    r6989 r7001  
    2727           MHEnergyEst.cc \
    2828           MHAlpha.cc \
    29            MHTheta.cc \
     29           MHThetaSq.cc \
    3030           MHEnergyEst.cc \
     31           MUnfolding.cc \
    3132           MHEffectiveOnTime.cc \
    3233           MHCollectionArea.cc \
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r6926 r7001  
    107107    TVirtualPad *save = gPad;
    108108    gPad = 0;
     109    /*
    109110#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
    110111    SetPalette(1, 0);
    111 #else
     112#endif
     113    */
     114/*
     115#if ROOT_VERSION_CODE < ROOT_VERSION(4,04,00)
    112116    SetPrettyPalette();
     117#elese
    113118    // WORAROUND - FIXME: Calling it many times becomes slower and slower
    114     //SetInvDeepBlueSeaPalette();
     119    SetInvDeepBlueSeaPalette();
    115120#endif
     121*/
    116122    gPad = save;
    117123}
     
    121127//  Default Constructor. To be used by the root system ONLY.
    122128//
    123 MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend), fAbberation(0)
     129MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fAbberation(0)
    124130{
    125131    Init();
     
    133139//
    134140MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
    135 : fGeomCam(NULL), fColors(kItemsLegend), fAbberation(0)
     141: fGeomCam(NULL), fAbberation(0)
    136142{
    137143    //fGeomCam = (MGeomCam*)geom.Clone();
     
    463469//                 GeMinimum() ((val-min)/(max-min))
    464470//   'proj'        Display the y-projection of the histogram
     471//   'pal0'        Use Pretty palette
     472//   'pal1'        Use Deep Blue Sea palette
     473//   'pal2'        Use Inverse Depp Blue Sea palette
    465474//   'same'        Draw trandparent pixels on top of an existing pad. This
    466475//                 makes it possible to draw the camera image on top of an
     
    970979    {
    971980        opt.ReplaceAll("hist", "");
     981        opt.ReplaceAll("box", "");
     982        opt.ReplaceAll("pixelindex", "");
     983        opt.ReplaceAll("sectorindex", "");
     984        opt.ReplaceAll("content", "");
     985        opt.ReplaceAll("proj", "");
     986        opt.ReplaceAll("pal0", "");
     987        opt.ReplaceAll("pal1", "");
     988        opt.ReplaceAll("pal2", "");
    972989        TH1D::Paint(opt);
    973990        return;
     
    10071024    }
    10081025
     1026    const Bool_t pal1 = opt.Contains("pal1");
     1027    const Bool_t pal2 = opt.Contains("pal2");
     1028
     1029    if (!pal1 && !pal2)
     1030        SetPrettyPalette();
     1031
     1032    if (pal1)
     1033        SetDeepBlueSeaPalette();
     1034
     1035    if (pal2)
     1036        SetInvDeepBlueSeaPalette();
     1037
    10091038    // Update Contents of the pixels and paint legend
    10101039    Update(gPad->GetLogy(), hasbox, hascol, hassame);
     
    10211050}
    10221051
     1052void MHCamera::SetDrawOption(Option_t *option)
     1053{
     1054    // This is a workaround. For some reason MHCamera is
     1055    // stored in a TObjLink instead of a TObjOptLink
     1056    if (!option || !gPad)
     1057        return;
     1058
     1059    TListIter next(gPad->GetListOfPrimitives());
     1060    delete gPad->FindObject("Tframe");
     1061    TObject *obj;
     1062    while ((obj = next()))
     1063        if (obj == this && (TString)next.GetOption()!=(TString)option)
     1064        {
     1065            gPad->GetListOfPrimitives()->Remove(this);
     1066            gPad->GetListOfPrimitives()->AddFirst(this, option);
     1067            return;
     1068        }
     1069}
     1070
    10231071// ------------------------------------------------------------------------
    10241072//
     
    10531101    else
    10541102        gStyle->SetPalette(ncolors, colors);
    1055 
    1056     fColors.Set(kItemsLegend);
    1057     for (int i=0; i<kItemsLegend; i++)
    1058         fColors[i] = gStyle->GetColorPalette(i);
    10591103}
    10601104
     
    10681112void MHCamera::SetPrettyPalette()
    10691113{
    1070     if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
     1114    TString opt(GetDrawOption());
     1115
     1116    if (!opt.Contains("hist", TString::kIgnoreCase))
    10711117        SetPalette(1, 0);
     1118
     1119    opt.ReplaceAll("pal1", "");
     1120    opt.ReplaceAll("pal2", "");
     1121
     1122    SetDrawOption(opt);
    10721123}
    10731124
     
    10801131void MHCamera::SetDeepBlueSeaPalette()
    10811132{
    1082     if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
     1133    TString opt(GetDrawOption());
     1134
     1135    if (!opt.Contains("hist", TString::kIgnoreCase))
    10831136        SetPalette(51, 0);
     1137
     1138    opt.ReplaceAll("pal1", "");
     1139    opt.ReplaceAll("pal2", "");
     1140    opt += "pal1";
     1141
     1142    SetDrawOption(opt);
    10841143}
    10851144
     
    10921151void MHCamera::SetInvDeepBlueSeaPalette()
    10931152{
    1094     if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
     1153    TString opt(GetDrawOption());
     1154
     1155    if (!opt.Contains("hist", TString::kIgnoreCase))
    10951156        SetPalette(52, 0);
     1157
     1158    opt.ReplaceAll("pal1", "");
     1159    opt.ReplaceAll("pal2", "");
     1160    opt += "pal2";
     1161
     1162    SetDrawOption(opt);
    10961163}
    10971164
     
    15151582
    15161583    if (val >= max)
    1517         return fColors[maxcolidx];
     1584        return gStyle->GetColorPalette(maxcolidx);
    15181585
    15191586    if (val <= min)
    1520         return fColors[0];
     1587        return gStyle->GetColorPalette(0);
    15211588
    15221589    //
     
    15301597
    15311598    const Int_t colidx = (Int_t)(ratio*maxcolidx + .5);
    1532     return fColors[colidx];
     1599    return gStyle->GetColorPalette(colidx);
    15331600}
    15341601
     
    16121679    for (Int_t i=0; i<kItemsLegend; i++)
    16131680    {
    1614         newbox.SetFillColor(fColors[i]);
     1681        newbox.SetFillColor(gStyle->GetColorPalette(i));
    16151682        newbox.PaintBox(range, H*(i*h-1)-offset, range+w, H*((i+1)*h-1)-offset);
    16161683    }
  • trunk/MagicSoft/Mars/mhist/MHCamera.h

    r6855 r7001  
    4848    TArrayI        fBinEntries;  // number of entries per bin
    4949
    50     TArrayI        fColors;      //! Color conversion table
    5150    TList         *fNotify;      //!
    5251
     
    214213    char    *GetObjectInfo(Int_t px, Int_t py) const;
    215214    void     ExecuteEvent(Int_t event, Int_t px, Int_t py);
     215    void     SetDrawOption(Option_t *option); //*MENU*
    216216
    217217    void     SetPalette(Int_t ncolors, Int_t *colors);
     
    222222
    223223    void     SetAutoScale() { fMinimum = fMaximum = -1111; } // *MENU*
    224     void     DisplayAsHistogram() { SetDrawOption("histEP"); } // *MENU*
    225     void     DisplayAsCamera() { SetDrawOption(""); } // *MENU*
    226224
    227225    void     SetFreezed(Bool_t f=kTRUE) { f ? SetBit(kFreezed) : ResetBit(kFreezed); } // *TOGGLE* *GETTER=IsFreezed
  • trunk/MagicSoft/Mars/mjobs/MJCut.cc

    r6993 r7001  
    7878    : fStoreSummary(kFALSE), fStoreResult(kTRUE), fWriteOnly(kFALSE),
    7979    fIsWobble(kFALSE), fIsMonteCarlo(kFALSE),  fFullDisplay(kFALSE),
    80     fNameHist("MHTheta"), fCalcHadronness(0)
     80    fNameHist("MHThetaSq"), fCalcHadronness(0)
    8181{
    8282    fName  = name  ? name  : "MJCut";
     
    428428    MBinning bins7("BinningDist");
    429429    MBinning bins8("BinningMaxDist");
     430    MBinning bins9("BinningM3Long");
     431    MBinning bins0("BinningConc1");
    430432    plist.AddToList(&bins1);
    431433    plist.AddToList(&bins2);
     
    436438    plist.AddToList(&bins7);
    437439    plist.AddToList(&bins8);
     440    plist.AddToList(&bins9);
     441    plist.AddToList(&bins0);
    438442
    439443    // --------------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mjobs/MJOptimize.cc

    r6978 r7001  
    181181    eval->SetVal(0);
    182182
     183    const Bool_t isnull = gLog.IsNullOutput();
    183184    if (fDebug<3)
    184185        gLog.SetNullOutput(kTRUE);
     
    190191
    191192    if (fDebug<3)
    192         gLog.SetNullOutput(kFALSE);
     193        gLog.SetNullOutput(isnull);
    193194
    194195    const Double_t f = eval->GetVal();
  • trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc

    r6994 r7001  
    178178        return -1;
    179179
     180    TObject *hist = arr.FindObjectInCanvas("Hist", "MHAlpha", "Hist");
     181    cout << "HIST: " << hist << endl;
     182    if (hist)
     183        cout << "TYPE: " << hist->ClassName() << endl;
     184    arr.Print();
     185
    180186    vstime->Copy(h1);
    181187    size->Copy(h2);
     
    344350    taskenv1.SetDefault(fEstimateEnergy ? fEstimateEnergy : &est);
    345351
    346     MFillH fill1("HistOff [MHAlpha]", "MHillasSrc", "FillHistOff");
    347     MFillH fill2("HistOn  [MHAlpha]", "MHillasSrc", "FillHistOn");
     352    MFillH fill1("HistEOff [MHAlpha]", "MHillasSrc", "FillHistEOff");
     353    MFillH fill2("HistE    [MHAlpha]", "MHillasSrc", "FillHistE");
    348354
    349355    MFDataMember f0("DataType.fVal", '<', 0.5, "FilterOffData");
     
    382388    }
    383389
    384     const MHAlpha *halpha = (MHAlpha *)plist.FindObject("HistOn");
     390    const MHAlpha *halpha = (MHAlpha *)plist.FindObject("HistE");
    385391    if (!halpha)
    386392    {
    387         *fLog << err << GetDescriptor() << ": HistOn [MHAlpha] not found... abort." << endl;
     393        *fLog << err << GetDescriptor() << ": HistE [MHAlpha] not found... abort." << endl;
    388394        return kFALSE;
    389395    }
     
    597603    *fLog << inf << "Reading from file: " << fPathIn << endl;
    598604
    599     cout << "Opening..." << endl;
    600605    TFile file(fPathIn, "READ");
    601606    if (!file.IsOpen())
     
    605610    }
    606611
    607     cout << "Reading..." << endl;
    608612    file.cd();
    609613    MStatusArray arr;
     
    614618    }
    615619
    616     cout << "Searching..." << endl;
    617 
    618620    TH1 *excess = (TH1D*)arr.FindObjectInCanvas("Excess", "TH1D", "Hist");
    619621    if (!excess)
    620622        return kFALSE;
    621 
    622     cout << "Displaying..." << endl;
    623623
    624624    // ------------------- Plot excess versus size -------------------
     
    638638    // Don't do this on the original object!
    639639    excess->SetStats(kFALSE);
    640 
    641     cout << "ExcessSize..." << endl;
    642640
    643641    TObject *o=0;
     
    656654    }
    657655
    658     cout << "Dist..." << endl;
    659 
    660656    // -------------- Comparison of Image Parameters --------------
    661657    c.cd(2);
    662658    PlotSame(arr, plist, "Dist",   "HilSrc",  "MHHilSrcMCPost");
    663659
    664     cout << "Length..." << endl;
    665 
    666660    c.cd(3);
    667661    PlotSame(arr, plist, "Length", "PostCut", "MHHillasMCPost");
    668662
    669     cout << "M3l..." << endl;
    670 
    671663    c.cd(4);
    672664    PlotSame(arr, plist, "M3l",    "HilExt",  "MHHilExtMCPost");
    673665
    674     cout << "Conc1..." << endl;
    675 
    676666    c.cd(5);
    677667    PlotSame(arr, plist, "Conc1",  "NewPar",  "MHNewParMCPost");
    678 
    679     cout << "Width..." << endl;
    680668
    681669    c.cd(6);
     
    710698    MBinning bins7("BinningDist");
    711699    MBinning bins8("BinningMaxDist");
     700    MBinning bins9("BinningM3Long");
     701    MBinning bins0("BinningConc1");
    712702
    713703    MAlphaFitter fit;
     
    722712    plist.AddToList(&bins7);
    723713    plist.AddToList(&bins8);
     714    plist.AddToList(&bins9);
     715    plist.AddToList(&bins0);
    724716    plist.AddToList(&fit);
    725717
  • trunk/MagicSoft/Mars/readdaq.cc

    r6888 r7001  
    5151    gLog << "   readdaq [-h] [-?] [-vn] [-dec] [-a0] inputfile[.raw]" << endl << endl;
    5252    gLog << "     input file:   Magic DAQ binary file." << endl;
    53     gLog << "     -a0: Do not use Ansii codes." << endl;
    54     gLog << "     -vn: Verbosity level n [default=2]" << endl;
     53    gLog.Usage();
    5554    gLog << "     -d1: print data in decimal values" << endl;
    5655    gLog << "     -c1: print MRawCrateArray data" << endl;
     
    6059int main(int argc, char **argv)
    6160{
    62     StartUpMessage();
    63 
    6461    //
    6562    // Evaluate arguments
    6663    //
    6764    MArgs arg(argc, argv);
     65    gLog.Setup(arg);
     66
     67    StartUpMessage();
    6868
    6969    if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
     
    7676    // Set verbosity to highest level.
    7777    //
    78     gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
    79 
    80     if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
    81         gLog.SetNoColors();
    82 
    8378    const bool kDecimal    = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1;
    8479    const bool kPrintArray = arg.HasOption("-c") && arg.GetIntAndRemove("-c")==1;
  • trunk/MagicSoft/Mars/readraw.cc

    r6888 r7001  
    5454    gLog << "   readraw [-h] [-?] [-vn] [-dec] [-a0] inputfile[.root]" << endl << endl;
    5555    gLog << "     input file:   Magic DAQ binary file." << endl;
    56     gLog << "     -vn: Verbosity level n [default=2]" << endl;
     56    gLog.Usage();
    5757    gLog << "     -d, --dec: print data in decimal values" << endl;
    5858    gLog << "     -a, --no-colors: Do not use Ansii color codes" << endl;
     
    7171int main(int argc, char **argv)
    7272{
    73     StartUpMessage();
    74 
    7573    // Evaluate arguments
    7674    MArgs arg(argc, argv);
     75    gLog.Setup(arg);
     76
     77    StartUpMessage();
    7778
    7879    // check for the right usage of the program
     
    8384        return 2;
    8485    }
    85 
    86     // Set verbosity
    87     gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
    88 
    89     // Set color usage
    90     if (arg.HasOnlyAndRemove("--no-colors") || arg.HasOnlyAndRemove("-a"))
    91         gLog.SetNoColors();
    9286
    9387    // Set usage of decimal values
  • trunk/MagicSoft/Mars/showlog.cc

    r6949 r7001  
    100100            s.ReplaceAll("", "\033");
    101101
    102         // Check whether it is an empty line
    103         if (s=="\033[0m")
     102        const char *end = s.Data()+s.Length();
     103        for (const char *c=s.Data(); c<end; c++)
    104104        {
    105             gLog << endl;
    106             continue;
    107         }
     105            char *to = NULL;
     106            Int_t n  = -1;
    108107
    109         while (!s.IsNull())
    110         {
    111             Ssiz_t pos = s.First("\033[");
    112             if (pos<0)
     108            if (c+1<end-1 && *c=='\033' && *(c+1)=='[')
     109                n = strtol(c+2, &to, 10);
     110
     111            if (to==NULL || *to!='m')
    113112            {
    114                 gLog << s;
    115                 break;
     113                gLog << *c;
     114                continue;
    116115            }
    117116
    118             gLog << s(0, pos);
    119             s.Remove(0, pos+1);
    120             if (s.BeginsWith("0m") && s.Length()>3)
     117            c = to;
     118
     119            switch (n)
    121120            {
    122                 gLog << all;
    123                 s.Remove(0, 2);
     121            case 0:
     122                if (c<end-1)
     123                    gLog << flush << all;
     124                continue;
     125            case 31:
     126                gLog << flush << err;
     127                continue;
     128            case 32:
     129                gLog << flush << inf;
     130                continue;
     131            case 33:
     132                gLog << flush << warn;
     133                continue;
     134            case 34:
     135                gLog << flush << dbg;
    124136                continue;
    125137            }
    126             if (s.BeginsWith("31m"))
    127             {
    128                 gLog << err;
    129                 s.Remove(0, 3);
    130                 continue;
    131             }
    132             if (s.BeginsWith("32m"))
    133             {
    134                 gLog << inf;
    135                 s.Remove(0, 3);
    136                 continue;
    137             }
    138             if (s.BeginsWith("33m"))
    139             {
    140                 gLog << warn;
    141                 s.Remove(0, 3);
    142                 continue;
    143             }
    144             if (s.BeginsWith("34m"))
    145             {
    146                 gLog << dbg;
    147                 s.Remove(0, 3);
    148                 continue;
    149             }
    150             gLog << "\033[";
     138            gLog << flush << "\033[" << n << "m";
    151139        }
    152         gLog << endl;
     140        gLog << endl << all;
    153141    }
    154142
  • trunk/MagicSoft/Mars/showplot.cc

    r6888 r7001  
    3737    gLog << "   -q                        Quit when job is finished" << endl;
    3838    gLog << endl;
    39     gLog << " Output Options: "<< endl;
     39    gLog << " General Output Options: "<< endl;
     40    gLog << "   --print[=printer]         Print to printer" << endl;
    4041    gLog << "   --save-as-ps[=filename]   Save plots as postscript" << endl;
     42    gLog << "   --save-as-pdf[=filename]  Save plots as pdf-file" << endl;
     43    gLog << "   --save-as-svg[=filename]  Save plots as svg-file" << endl;
     44    gLog << "   --save-as-root[=filename] Save plots as root file" << endl;
     45    gLog << "   --save-as-C[=filename]    Save plots as root scripts" << endl;
     46    gLog << "   --tab=num                 Save only tab number num" << endl << endl;
     47    gLog << " Print only options:" << endl;
     48    gLog << "   --print-cmd='lpr -P%p %f' Set the printer command" << endl;
     49    gLog << "   --print-dir=/tmp          Set the printing temp directory" << endl << endl;
     50    gLog << " GUI only options:" << endl;
    4151    gLog << "   --save-as-gif[=filename]  Save plots as gif files" << endl;
    42     gLog << "   --save-as-C[=filename]    Save plots as root scripts" << endl;
    43     gLog << "   --tab=num                 Save only tab number num" << endl;
     52    gLog << "   --save-as-jpg[=filename]  Save plots as jpg files" << endl;
     53    gLog << "   --save-as-xpm[=filename]  Save plots as xpm files" << endl;
     54    gLog << "   --save-as-png[=filename]  Save plots as png files" << endl;
    4455    gLog << endl;
    4556    gLog << "   --version, -V             Show startup message with version number" << endl;
     
    4960    gLog << " Use showplot to display a MStatusArray in an MStatusDisplay." << endl;
    5061    gLog << " MStatusArrays are typically written by programs showing data" << endl;
    51     gLog << " check plots, like callisto." << endl;
     62    gLog << " check plots, like callisto." << endl << endl;
     63    gLog << "Printing:" << endl;
     64    gLog << " For more details see MStatusDisplay::PrintPS" << endl << endl;
     65    gLog << "Examples:" << endl;
     66    gLog << " showplot filename.root" << endl;
     67    gLog << " showplot -b --null --print --print-cmd='psnup -2 %f' filename.root | lpr" << endl;
     68    gLog << " showplot -b --print --print-cmd='psbook %f | psnup -2 | lpr' filename.root" << endl;
     69    gLog << " showplot -b --print --print-cmd='cat %f' filename.root > filename.ps" << endl;
     70    gLog << " showplot -b --save-as-ps filename.root" << endl;
     71    gLog << " showplot -q --save-as-gif=tab5.gif --tab=5 filename.root" << endl;
     72    gLog << " showplot -b --save-as-ps --print=lp2 filename.root" << endl;
    5273    gLog << endl;
    5374}
     
    5576int main(int argc, char **argv)
    5677{
     78    //
     79    // Evaluate arguments
     80    //
     81    MArgs arg(argc, argv, kTRUE);
     82    gLog.Setup(arg);
     83
    5784    StartUpMessage();
    58 
    59     //
    60     // Evaluate arguments
    61     //
    62     MArgs arg(argc, argv, kTRUE);
    6385
    6486    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    7193    }
    7294
    73     gLog.Setup(arg);
    74 
    75     const Bool_t kQuit      = arg.HasOnlyAndRemove("-q");
    76     const Bool_t kBatch     = arg.HasOnlyAndRemove("-b");
    77 
    78     const Int_t  kTab       = arg.GetIntAndRemove("--tab=", -1);
    79 
    80     const Bool_t kSaveAsPs  = arg.HasOnlyAndRemove("--save-as-ps")  || arg.Has("--save-as-ps=");
    81     const Bool_t kSaveAsGif = arg.HasOnlyAndRemove("--save-as-gif") || arg.Has("--save-as-gif=");
    82     const Bool_t kSaveAsC   = arg.HasOnlyAndRemove("--save-as-C")   || arg.Has("--save-as-C=");
    83 
    84     TString kNamePs  = arg.GetStringAndRemove("--save-as-ps=");
    85     TString kNameGif = arg.GetStringAndRemove("--save-as-gif=");
    86     TString kNameC   = arg.GetStringAndRemove("--save-as-C=");
     95    const Bool_t kQuit       = arg.HasOnlyAndRemove("-q");
     96    const Bool_t kBatch      = arg.HasOnlyAndRemove("-b");
     97
     98    const Int_t  kTab        = arg.GetIntAndRemove("--tab=", -1);
     99
     100    const Bool_t kPrint      = arg.HasOnlyAndRemove("--print")        || arg.Has("--print=");
     101    const Bool_t kSaveAsPs   = arg.HasOnlyAndRemove("--save-as-ps")   || arg.Has("--save-as-ps=");
     102    const Bool_t kSaveAsPdf  = arg.HasOnlyAndRemove("--save-as-pdf")  || arg.Has("--save-as-pdf=");
     103    const Bool_t kSaveAsSvg  = arg.HasOnlyAndRemove("--save-as-svg")  || arg.Has("--save-as-svg=");
     104    const Bool_t kSaveAsGif  = arg.HasOnlyAndRemove("--save-as-gif")  || arg.Has("--save-as-gif=");
     105    const Bool_t kSaveAsJpg  = arg.HasOnlyAndRemove("--save-as-jpg")  || arg.Has("--save-as-jpg=");
     106    const Bool_t kSaveAsXpm  = arg.HasOnlyAndRemove("--save-as-xpm")  || arg.Has("--save-as-xpm=");
     107    const Bool_t kSaveAsPng  = arg.HasOnlyAndRemove("--save-as-png")  || arg.Has("--save-as-png=");
     108    const Bool_t kSaveAsRoot = arg.HasOnlyAndRemove("--save-as-root") || arg.Has("--save-as-root=");
     109    const Bool_t kSaveAsC    = arg.HasOnlyAndRemove("--save-as-C")    || arg.Has("--save-as-C=");
     110
     111    TString kNamePrint = arg.GetStringAndRemove("--print=");
     112    TString kPrintCmd  = arg.GetStringAndRemove("--print-cmd=");
     113    TString kPrintDir  = arg.GetStringAndRemove("--print-dir=");
     114    TString kNamePs    = arg.GetStringAndRemove("--save-as-ps=");
     115    TString kNamePdf   = arg.GetStringAndRemove("--save-as-pdf=");
     116    TString kNameSvg   = arg.GetStringAndRemove("--save-as-svg=");
     117    TString kNameGif   = arg.GetStringAndRemove("--save-as-gif=");
     118    TString kNameJpg   = arg.GetStringAndRemove("--save-as-jpg=");
     119    TString kNameXpm   = arg.GetStringAndRemove("--save-as-xpm=");
     120    TString kNamePng   = arg.GetStringAndRemove("--save-as-png=");
     121    TString kNameRoot  = arg.GetStringAndRemove("--save-as-root=");
     122    TString kNameC     = arg.GetStringAndRemove("--save-as-C=");
    87123
    88124
     
    90126    // check for the right usage of the program
    91127    //
     128    if (arg.GetNumOptions()>0)
     129    {
     130        gLog << err << "Unknown commandline options..." << endl;
     131        arg.Print("options");
     132        gLog << endl;
     133        return 3;
     134    }
    92135    if (arg.GetNumArguments()!=1)
    93136    {
     
    96139    }
    97140
    98     TApplication app("Showplot", &argc, argv);
     141    TApplication app("showplot", &argc, argv);
    99142    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    100143    {
     
    108151    const TString kInput = arg.GetArgumentStr(0);
    109152
    110     if (kNamePs.IsNull()  && kSaveAsPs)
     153    if (kNamePs.IsNull()    && kSaveAsPs)
    111154        kNamePs = kInput;
    112     if (kNameGif.IsNull() && kSaveAsGif)
     155    if (kNamePdf.IsNull()   && kSaveAsPdf)
     156        kNamePdf = kInput;
     157    if (kNameSvg.IsNull()   && kSaveAsSvg)
     158        kNameSvg = kInput;
     159    if (kNameGif.IsNull()   && kSaveAsGif)
    113160        kNameGif = kInput;
    114     if (kNameC.IsNull()   && kSaveAsC)
     161    if (kNameJpg.IsNull()   && kSaveAsJpg)
     162        kNameJpg = kInput;
     163    if (kNameXpm.IsNull()   && kSaveAsXpm)
     164        kNameXpm = kInput;
     165    if (kNamePng.IsNull()   && kSaveAsPng)
     166        kNamePng = kInput;
     167    if (kNameRoot.IsNull()  && kSaveAsRoot)
     168        kNameRoot = kInput;
     169    if (kNameC.IsNull()     && kSaveAsC)
    115170        kNameC = kInput;
    116171
     
    124179    d->Open(kInput);
    125180
     181    if (kPrint)
     182        d->PrintPS(kTab,    kNamePrint, kPrintCmd, kPrintDir);
    126183    if (kSaveAsPs)
    127         d->SaveAsPS(kTab, kNamePs);
     184        d->SaveAsPS(kTab,   kNamePs);
     185    if (kSaveAsPdf)
     186        d->SaveAsPDF(kTab,  kNamePdf);
     187    if (kSaveAsSvg)
     188        d->SaveAsSVG(kTab,  kNameSvg);
    128189    if (kSaveAsGif)
    129         d->SaveAsGIF(kTab, kNameGif);
     190        d->SaveAsGIF(kTab,  kNameGif);
     191    if (kSaveAsJpg)
     192        d->SaveAsJPG(kTab,  kNameJpg);
     193    if (kSaveAsXpm)
     194        d->SaveAsXPM(kTab,  kNameXpm);
     195    if (kSaveAsPng)
     196        d->SaveAsPNG(kTab,  kNamePng);
     197    if (kSaveAsRoot)
     198        d->SaveAsRoot(kTab, kNameRoot);
    130199    if (kSaveAsC)
    131         d->SaveAsC(kTab, kNameC);
     200        d->SaveAsC(kTab,    kNameC);
    132201
    133202    if (kBatch || kQuit)
  • trunk/MagicSoft/Mars/sinope.cc

    r6906 r7001  
    249249int main(int argc, char **argv)
    250250{
     251    //
     252    // Evaluate arguments
     253    //
     254    MArgs arg(argc, argv, kTRUE);
     255    gLog.Setup(arg);
     256
    251257    StartUpMessage();
    252 
    253     //
    254     // Evaluate arguments
    255     //
    256     MArgs arg(argc, argv, kTRUE);
    257258
    258259    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    264265        return 2;
    265266    }
    266 
    267     gLog.Setup(arg);
    268267
    269268    //const TString kConfig     = arg.GetStringAndRemove("--config=", "callisto.rc");
     
    379378    MParContainer::Class()->IgnoreTObjectStreamer();
    380379
    381     TApplication app("Sinope", &argc, argv);
     380    TApplication app("sinope", &argc, argv);
    382381    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    383382    {
  • trunk/MagicSoft/Mars/sponde.cc

    r6977 r7001  
    8989int main(int argc, char **argv)
    9090{
     91    //
     92    // Evaluate arguments
     93    //
     94    MArgs arg(argc, argv, kTRUE);
     95    gLog.Setup(arg);
     96
    9197    StartUpMessage();
    92 
    93     //
    94     // Evaluate arguments
    95     //
    96     MArgs arg(argc, argv, kTRUE);
    9798
    9899    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    104105        return 2;
    105106    }
    106 
    107     gLog.Setup(arg);
    108107
    109108    const TString kConfig       =  arg.GetStringAndRemove("--config=", "sponde.rc");
     
    184183    MParContainer::Class()->IgnoreTObjectStreamer();
    185184
    186     TApplication app("Sponde", &argc, argv);
     185    TApplication app("sponde", &argc, argv);
    187186    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    188187    {
  • trunk/MagicSoft/Mars/star.cc

    r6993 r7001  
    9191int main(int argc, char **argv)
    9292{
     93    //
     94    // Evaluate arguments
     95    //
     96    MArgs arg(argc, argv, kTRUE);
     97    gLog.Setup(arg);
     98
    9399    StartUpMessage();
    94 
    95     //
    96     // Evaluate arguments
    97     //
    98     MArgs arg(argc, argv, kTRUE);
    99100
    100101    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    106107        return 2;
    107108    }
    108 
    109     gLog.Setup(arg);
    110109
    111110    const TString kConfig     = arg.GetStringAndRemove("--config=", "star.rc");
     
    193192    MParContainer::Class()->IgnoreTObjectStreamer();
    194193
    195     TApplication app("Star", &argc, argv);
     194    TApplication app("star", &argc, argv);
    196195    if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
    197196    {
Note: See TracChangeset for help on using the changeset viewer.