Changeset 6938


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r6937 r6938  
    2121
    2222                                                 -*-*- END OF LINE -*-*-
     23
     24 2005/04/13 Thomas Bretz
     25
     26   * mbase/MStatusDisplay.[h,cc]:
     27     - implemented new Image types which can be written
     28
     29   * mhbase/MBinning.[h,cc]:
     30     - added some more constructors which can set the binning directly
     31
     32   * mhflux/MHEnergyEst.h:
     33     - added getter for fHEnergy
     34
     35   * mhflux/FluxLinkDef.h, mhflux/Makefile:
     36     - added MHCollectionArea
     37
     38   * mhflux/MHCollectionArea.[h,cc]:
     39     - added
     40
     41
    2342
    2443 2005/04/13 Daniela Dorner
  • 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="");
  • trunk/MagicSoft/Mars/mhbase/MBinning.cc

    r6932 r6938  
    9191// --------------------------------------------------------------------------
    9292//
     93// Initialize Binning from an axis of a TH1. If no title given,
     94// a title combined from the axis titles and the TH1 title is
     95// used.
     96//
     97MBinning::MBinning(const TH1 &h, const Char_t axis, const char *name, const char *title)
     98{
     99    fName  = name  ? name : gsDefName.Data();
     100    fTitle = title ? Form("%s;%s;%s;%s", h.GetTitle(),
     101                          h.GetXaxis()->GetTitle(),
     102                          h.GetYaxis()->GetTitle(),
     103                          h.GetZaxis()->GetTitle()) : gsDefTitle.Data();
     104
     105    SetEdges(h, axis);
     106}
     107
     108// --------------------------------------------------------------------------
     109//
     110// Initialize Binning from TAxis.
     111//
     112MBinning::MBinning(const TAxis &axis, const char *name, const char *title)
     113{
     114    fName  = name  ? name : gsDefName.Data();
     115    fTitle = title ? title : gsDefTitle.Data();
     116
     117    SetEdges(axis);
     118}
     119
     120// --------------------------------------------------------------------------
     121//
    93122// Search in the parameter list for the binning with name "name". If found,
    94123// set the edges and title accordingly. Default is name of object.
     
    412441    *fLog << all;
    413442    *fLog << GetDescriptor() << ": nbins=" << GetNumBins() << " [";
    414     *fLog << GetEdgeLo() << ", " << GetEdgeHi() << "] ";
     443    *fLog << GetEdgeLo() << ", " << GetEdgeHi() << "] <";
    415444    switch (fType)
    416445    {
    417     case kIsDefault:     *fLog << "deafult"; break;
     446    case kIsDefault:     *fLog << "default"; break;
    418447    case kIsLinear:      *fLog << "linear"; break;
    419448    case kIsLogarithmic: *fLog << "logarithmic"; break;
  • trunk/MagicSoft/Mars/mhbase/MBinning.h

    r5971 r6938  
    4141    MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name=0, const char *opt="", const char *title=NULL);
    4242    MBinning(const MBinning &bins) { SetEdges(bins); }
     43    MBinning(const TH1 &h, const Char_t axis='x', const char *name=0, const char *title=0);
     44    MBinning(const TAxis &a, const char *name=0, const char *title=0);
    4345
    4446    void Copy(TObject &named) const
  • trunk/MagicSoft/Mars/mhflux/FluxLinkDef.h

    r6892 r6938  
    1111#pragma link C++ class MHFalseSource+;
    1212#pragma link C++ class MHEffectiveOnTime+;
     13#pragma link C++ class MHCollectionArea+;
    1314
    1415#endif
  • trunk/MagicSoft/Mars/mhflux/MHEnergyEst.h

    r6932 r6938  
    4848    MHEnergyEst(const char *name=NULL, const char *title=NULL);
    4949
     50    const TH3D &GetHEnergy() const { return fHEnergy; }
     51
    5052    void InitMapping(MHMatrix *mat);
    5153    void StopMapping();
  • trunk/MagicSoft/Mars/mhflux/Makefile

    r6891 r6938  
    2929           MHEnergyEst.cc \
    3030           MHEffectiveOnTime.cc \
     31           MHCollectionArea.cc \
    3132           MHFalseSource.cc
    3233
Note: See TracChangeset for help on using the changeset viewer.