Ignore:
Timestamp:
04/13/05 17:30:51 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r6932 r6938  
    3131// (see Read and Write) or printed as a postscript file (see SaveAsPS).
    3232//
    33 // To write gif files of C-Macros use SaveAsGif() or SaveAsC().
     33// 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
    3535// PrintToLpr().
     
    193193    filemenu->AddSeparator();
    194194    filemenu->AddEntry("Save status.&ps",   kFileSaveAsPS);
     195    filemenu->AddEntry("Save status.&png",  kFileSaveAsPNG);
    195196    filemenu->AddEntry("Save status.&gif",  kFileSaveAsGIF);
     197    filemenu->AddEntry("Save status.&jpg",  kFileSaveAsJPG);
     198    filemenu->AddEntry("Save status.&xpm",  kFileSaveAsXPM);
    196199    filemenu->AddEntry("Save status.&C",    kFileSaveAsC);
    197200    filemenu->AddEntry("Save status.&root", kFileSaveAsRoot);
     
    217220    tabmenu->AddSeparator();
    218221    tabmenu->AddEntry("Save tab-i.&ps",   kTabSaveAsPS);
     222    tabmenu->AddEntry("Save tab-i.&png",  kTabSaveAsPNG);
    219223    tabmenu->AddEntry("Save tab-i.&gif",  kTabSaveAsGIF);
     224    tabmenu->AddEntry("Save tab-i.&jpg",  kTabSaveAsJPG);
     225    tabmenu->AddEntry("Save tab-i.&xpm",  kTabSaveAsXPM);
    220226    tabmenu->AddEntry("Save tab-i.&C",    kTabSaveAsC);
    221227    tabmenu->AddEntry("Save tab-i.&root", kTabSaveAsRoot);
     
    11981204        return kTRUE;
    11991205
     1206    case kFileSaveAsPNG:
     1207        SaveAsPNG();
     1208        return kTRUE;
     1209
    12001210    case kFileSaveAsGIF:
    12011211        SaveAsGIF();
    12021212        return kTRUE;
    12031213
     1214    case kFileSaveAsXPM:
     1215        SaveAsXPM();
     1216        return kTRUE;
     1217
     1218    case kFileSaveAsJPG:
     1219        SaveAsJPG();
     1220        return kTRUE;
     1221
    12041222    case kFileSaveAsC:
    12051223        SaveAsC();
     
    12221240        return kTRUE;
    12231241
     1242    case kTabSaveAsPNG:
     1243        SaveAsPNG(fTab->GetCurrent());
     1244        return kTRUE;
     1245
    12241246    case kTabSaveAsGIF:
    12251247        SaveAsGIF(fTab->GetCurrent());
     1248        return kTRUE;
     1249
     1250    case kTabSaveAsXPM:
     1251        SaveAsXPM(fTab->GetCurrent());
     1252        return kTRUE;
     1253
     1254    case kTabSaveAsJPG:
     1255        SaveAsJPG(fTab->GetCurrent());
    12261256        return kTRUE;
    12271257
     
    18691899}
    18701900
    1871 void MStatusDisplay::AddExtension(TString &name, const TString &ext, Int_t num) const
     1901// --------------------------------------------------------------------------
     1902//
     1903// If the filename name doesn't end with ext, ext is added to the end.
     1904// If name.IsNull() "status" is assumed and the a number (>0) is added
     1905// as "status-6".
     1906// The extension is returned.
     1907//
     1908const TString &MStatusDisplay::AddExtension(TString &name, const TString &ext, Int_t num) const
    18721909{
    18731910    if (name.IsNull())
     
    18821919
    18831920    if (name.EndsWith("."+ext))
    1884         return;
     1921        return ext;
    18851922
    18861923    name += ".";
    18871924    name += ext;
     1925
     1926    return ext;
    18881927}
    18891928
     
    21702209}
    21712210
    2172 Bool_t MStatusDisplay::SaveAsGIF(Int_t num, TString name)
     2211Bool_t MStatusDisplay::SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type)
    21732212{
    21742213    if (gROOT->IsBatch())
    21752214    {
    2176         *fLog << warn << "Sorry, writing gif-files is not available in batch mode." << endl;
     2215        *fLog << warn << "Sorry, writing image-files is not available in batch mode." << endl;
     2216        //*fLog << warn << "Sorry, writing gif-files is not available in batch mode." << endl;
    21772217        return 0;
    21782218    }
    2179     SetStatusLine1("Writing GIF file...");
     2219    //SetStatusLine1("Writing GIF file...");
     2220    SetStatusLine1("Writing image file... <please be patient>");
    21802221    SetStatusLine2("");
    21812222
     
    21862227    }
    21872228
    2188     AddExtension(name, "gif", num);
     2229    TString ext;
     2230    switch (type)
     2231    {
     2232    case TImage::kXpm:
     2233    case TImage::kZCompressedXpm:
     2234        ext = AddExtension(name, "xpm", num);
     2235        break;
     2236//    case TImage::kGZCompressedXpm:
     2237//        ext = AddExtension(name, "xpm.gz", num);
     2238//        break;
     2239    case TImage::kPng:
     2240        ext = AddExtension(name, "png", num);
     2241        break;
     2242    case TImage::kJpeg:
     2243        ext = AddExtension(name, "jpg", num);
     2244        break;
     2245//    case TImage::kXcf:
     2246//        ext = AddExtension(name, "xcf", num);
     2247//        break;
     2248//    case TImage::kPpm:
     2249//        ext = AddExtension(name, "ppm", num);
     2250//        break;
     2251//    case TImage::kPnm:
     2252//        ext = AddExtension(name, "pnm", num);
     2253//        break;
     2254//    case TImage::kBmp:
     2255//        ext = AddExtension(name, "bmp", num);
     2256//        break;
     2257//    case TImage::kIco:
     2258//        ext = AddExtension(name, "ico", num);
     2259//        break;
     2260//    case TImage::kCur:
     2261//        ext = AddExtension(name, "cur", num);
     2262//        break;
     2263    case TImage::kGif:
     2264        ext = AddExtension(name, "gif", num);
     2265        break;
     2266//    case TImage::kTiff:
     2267//        ext = AddExtension(name, "tif", num);
     2268//        break;
     2269//    case TImage::kXbm:
     2270//        ext = AddExtension(name, "xbm", num);
     2271//        break;
     2272//    case TImage::kFits:
     2273//        ext = AddExtension(name, "fits", num);
     2274//        break;
     2275//    case TImage::kTga:
     2276//        ext = AddExtension(name, "tga", num);
     2277//        break;
     2278//    case TImage::kXml:
     2279//        ext = AddExtension(name, "xml", num);
     2280//        break;
     2281    default:
     2282        *fLog << warn << "Sorry, unknown or unsupported file type..." << endl;
     2283        return 0;
     2284    }
    21892285
    21902286    if (num<0)
    2191         *fLog << inf << "Writing gif-Files..." << endl;
     2287        *fLog << inf << "Writing " << ext << "-Files..." << endl;
    21922288
    21932289    TPad *padsav = (TPad*)gPad;
     
    22392335
    22402336        c->Draw();
    2241         c->SaveAs(writename);
    2242         /*
    2243          n->Draw();
    2244          n->SaveAs(writename);
    2245          delete n;
    2246          */
     2337        if (type==TImage::kGif)
     2338            c->SaveAs(writename); // FIXME: Seems not to work well in TImage! (root 3.10/02)
     2339        else
     2340        {
     2341            TImage *img = TImage::Create();
     2342            img->FromPad(c);
     2343            img->WriteImage(writename, type);
     2344            delete img;
     2345        }
    22472346
    22482347        if (num<0)
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.h

    r6932 r6938  
    1212#ifndef ROOT_TTimer
    1313#include <TTimer.h>
     14#endif
     15
     16#ifndef ROOT_TImage
     17#include <TImage.h>
    1418#endif
    1519
     
    3842        // kFile
    3943        kFileBrowser, kFileCanvas, kFileOpen, kFileSave, kFileSaveAs, kFileSaveAsPS,
    40         kFileSaveAsRoot, kFileSaveAsGIF, kFileSaveAsC, kFilePrint,
    41         kFilePrinterName, kFileClose, kFileExit, kFileReset,
     44        kFileSaveAsRoot, kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG,
     45        kFileSaveAsXPM, kFileSaveAsC, kFilePrint, kFilePrinterName,
     46        kFileClose, kFileExit, kFileReset,
    4247        // kLoop
    4348        kLoopNone, kLoopStop,
    4449        // kTab
    45         kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsGIF,
    46         kTabSaveAsC, kTabPrint, kTabNext, kTabPrevious, kTabRemove,
     50        kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsPNG,
     51        kTabSaveAsGIF, kTabSaveAsJPG, kTabSaveAsXPM, kTabSaveAsC,
     52        kTabPrint, kTabNext, kTabPrevious, kTabRemove,
    4753        // kSize
    4854        kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
     
    124130    Bool_t Display(const TObjArray &list, const char *tab=0);
    125131
    126     void AddExtension(TString &name, const TString &ext, Int_t num) const;
     132    const TString &AddExtension(TString &name, const TString &ext, Int_t num) const;
    127133
    128134    void UpdatePSHeader(const TString &name) const;
     
    132138
    133139    TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
     140
     141    Bool_t SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type);
    134142
    135143public:
     
    187195
    188196     Int_t  SaveAsPS(TString name="", const TString addon="") { return SaveAsPS(-1, name, addon); }
     197     Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); }
    189198     Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
     199     Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); }
     200     Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); }
    190201     Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
    191202     Int_t  SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
     
    193204
    194205     Int_t  SaveAsPS(Int_t num, TString name="", const TString addon="");
    195      Bool_t SaveAsGIF(Int_t num, TString name="");
     206     Bool_t SaveAsPNG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kPng); }
     207     Bool_t SaveAsGIF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kGif); }
     208     Bool_t SaveAsXPM(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXpm); }
     209     Bool_t SaveAsJPG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kJpeg); }
    196210     Bool_t SaveAsC(Int_t num, TString name="");
    197211     Int_t  SaveAsRoot(Int_t num, TString name="");
Note: See TracChangeset for help on using the changeset viewer.