Changeset 1965


Ignore:
Timestamp:
04/19/03 18:39:05 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
1 added
56 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1964 r1965  
    11                                                 -*-*- END OF LINE -*-*-
     2
     3   * Makefile:
     4     - exchanged mbase and mmain
     5   
     6   * Makefile.conf.general:
     7     - added MARSVER
     8   
     9   * mars.cc:
     10     - use MARSVER
     11   
     12   * macros/readMagic.C:
     13     - updated to work with the new MH-stuff
     14     
     15   * macros/status.C:
     16     - added
     17     
     18   * manalysis/MBlindPixelCalc.cc, manalysis/MCerPhotCalc.cc,
     19     manalysis/MMcPedestalCopy.ccm, manalysis/MMcPedestalNSBAdd.cc,
     20     mfileio/MReadMarsFile.cc, mimage/MHillasCalc.cc,
     21     mimage/MImgCleanStd.cc:
     22     - changed def. title
     23   
     24   * manalysis/MCT1PointingCorrCalc.h:
     25     - minor change
     26     
     27   * manalysis/MCerPhotEvt.[h,cc]:
     28     - don't use unused pixels for calculation of min/max
     29     - added Scale member function
     30   
     31   * manalysis/MCerPhotPix.h:
     32     - added Scale inline function
     33     
     34   * mbase/MEvtLoop.[h,cc], mbase/MParContainer.[h,cc],
     35     mbase/MParList.[h,cc], mbase/MTaskList.[h,cc],
     36     mfileio/MReadMarsFile.cc, mhist/MFillH.[h,cc]:
     37     - implemented use of fDisplay
     38   
     39   * mbase/MParContainer.h:
     40     - Don't display name and class name if it is the same (GetDescriptor)
     41
     42   * meventdisp/MGCamDisplay.[h,cc]:
     43     - made working with new MH-stuff
     44   
     45   * mfileio/Makefile:
     46     - added -I../mmain
     47   
     48   * mgeom/MGeomCam.[h,cc]:
     49     - added Clone function
     50
     51   * mgeom/MGeomCamCT1.cc, mgeom/MGeomCamMagic.cc:
     52     - commented out informal output at constructor
     53   
     54   * mgui/MCamDisplay.[h,cc], mhist/MHStarMap.[h,cc],
     55     mimage/MHH*.[h,cc]:
     56     - changed to be more root oriented
     57   
     58   * mgui/MHexagon.cc:
     59     - small changes
     60     
     61   * mgui/Makefile:
     62     - added mhist
     63     
     64   * mhist/MH.[h,cc]:
     65     - changed to be more root oriented
     66     - removed border
     67     - added DrawClone
     68     - GetNewPad
     69
     70   * mhist/MH3.cc:
     71     - removed some strange debug output
     72     
     73   * mhist/MHCerPhotEvt.[h,cc]:
     74     - fixed some bug
     75     - made working with fDisplay
     76   
     77   * mhist/Makefile:
     78     - added mmain
     79     
     80   * mmain/MProgressBar.cc:
     81     - fixed a typo
     82     
     83   * mmain/MStatusDisplay.[h,cc]:
     84     - new implementation
     85     
     86   * mmain/MainLinkDef.h, mmain/Makefile:
     87     - added MStatusDisplay
     88     - added MGMenu
     89
     90   * mmain/MGMenu.[h,cc]:
     91     - added
     92
     93
    294
    395 2003/04/19: Abelardo Moralejo
     
    8100
    9101   * mmontecarlo/MMcEnergyMigration.[h,cc]
    10      -Added. Task to fill the energy migration matrix histograms
    11       contained in class MHMcEnergyMigration.
     102     - Added. Task to fill the energy migration matrix histograms
     103       contained in class MHMcEnergyMigration.
     104
     105
    12106
    13107 2003/04/17: Wolfgang Wittek
     
    37131     - add plot of Id of blind pixel
    38132
    39    MHMcCT1CollectionArea.c
    40133
    41134
     
    46139    - MNewImagePar and MNewImageParCalc removed
    47140   
     141
    48142
    49143
  • trunk/MagicSoft/Mars/Makefile

    r1940 r1965  
    3535#  ----->>>   mars libraries
    3636#
    37 SUBDIRS = mmain       \
    38           mbase       \
     37SUBDIRS = mbase       \
     38          mmain       \
    3939          mfileio     \
    4040          mfilter     \
  • trunk/MagicSoft/Mars/Makefile.conf.general

    r1438 r1965  
    1212#
    1313
    14 DEFINES   = -D__MARS__ -DROOTVER=\"$(ROOTVER)\" $(ARCHDEF)
     14DEFINES   = -D__MARS__ -DMARSVER=\"\<cvs\>\" -DROOTVER=\"$(ROOTVER)\" $(ARCHDEF)
    1515
    1616CXXFLAGS  = $(ROOTCFLAGS) $(INCLUDES) $(OPTIM) $(DEBUG) $(DEFINES)
  • trunk/MagicSoft/Mars/macros/readMagic.C

    r1947 r1965  
    100100        cout << "Event #" << read.GetNumEntry() ":" << endl;
    101101
    102         display.DrawPhotNum((MCerPhotEvt*)clone.GetClone());
     102        display.FillPhotNum(*(MCerPhotEvt*)clone.GetClone());
     103        gPad->Modified();
     104        gPad->Update();
    103105
    104106        if (!HandleInput())
     
    108110        hillas.Draw();
    109111
    110         display.DrawPhotNum((MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
     112        display.FillPhotNum(*(MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
     113        gPad->Modified();
     114        gPad->Update();
    111115
    112116        if (!HandleInput())
  • trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc

    r1574 r1965  
    7171
    7272static const TString gsDefName  = "MBlindPixelCalc";
    73 static const TString gsDefTitle = "Task to deal with hot spots (star, broken pixels, etc)";
     73static const TString gsDefTitle = "Find hot spots (star, broken pixels, etc)";
    7474
    7575// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/manalysis/MCT1PointingCorrCalc.h

    r1952 r1965  
    2727    MParameterD  *fHourAngle;
    2828
    29     Float_t      fMm2Deg;
     29    Float_t       fMm2Deg;
    3030
    3131public:
  • trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc

    r1715 r1965  
    6464{
    6565    fName  = name  ? name  : "MCerPhotCalc";
    66     fTitle = title ? title : "Task to calculate pixel signal from raw data";
     66    fTitle = title ? title : "Calculate pixel signal from FADC data";
    6767
    6868    AddToBranchList("MRawEvtData.fHiGainPixId");
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc

    r1715 r1965  
    2727
    2828#include <math.h>
     29#include <limits.h>
    2930#include <fstream.h>
    3031
     
    120121    {
    121122        const MCerPhotPix &pix = (*this)[i];
     123        if (!pix.IsPixelUsed())
     124            continue;
    122125
    123126        if (id == pix.GetPixId() && pix.IsPixelUsed())
     
    139142    {
    140143        const MCerPhotPix &pix = (*this)[i];
     144        if (!pix.IsPixelUsed())
     145            continue;
    141146
    142147        if (id == pix.GetPixId() && pix.IsPixelCore())
     
    160165    const UInt_t n = geom->GetNumPixels();
    161166
    162     Float_t minval = (*this)[0].GetNumPhotons();
    163 
    164     for (UInt_t i=1; i<fNumPixels; i++)
    165     {
    166         const MCerPhotPix &pix = (*this)[i];
     167    Float_t minval = FLT_MAX;
     168
     169    for (UInt_t i=1; i<fNumPixels; i++)
     170    {
     171        const MCerPhotPix &pix = (*this)[i];
     172        if (!pix.IsPixelUsed())
     173            continue;
    167174
    168175        const UInt_t id = pix.GetPixId();
     
    195202    const UInt_t n = geom->GetNumPixels();
    196203
    197     Float_t maxval = (*this)[0].GetNumPhotons();
    198 
    199     for (UInt_t i=1; i<fNumPixels; i++)
    200     {
    201         const MCerPhotPix &pix = (*this)[i];
     204    Float_t maxval = -FLT_MAX;
     205
     206    for (UInt_t i=1; i<fNumPixels; i++)
     207    {
     208        const MCerPhotPix &pix = (*this)[i];
     209        if (!pix.IsPixelUsed())
     210            continue;
    202211
    203212        const UInt_t id = pix.GetPixId();
     
    229238    {
    230239        const MCerPhotPix &pix = (*this)[i];
     240        if (!pix.IsPixelUsed())
     241            continue;
    231242
    232243        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
     
    247258        return -5.;
    248259
    249     Float_t maxval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
    250 
    251     for (UInt_t i=1; i<fNumPixels; i++)
    252     {
    253         const MCerPhotPix &pix = (*this)[i];
     260    Float_t maxval = -FLT_MAX;
     261
     262    for (UInt_t i=1; i<fNumPixels; i++)
     263    {
     264        const MCerPhotPix &pix = (*this)[i];
     265        if (!pix.IsPixelUsed())
     266            continue;
    254267
    255268        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
     
    272285        return 50.;
    273286
    274     Float_t minval = (*this)[0].GetErrorPhot();
    275 
    276     for (UInt_t i=1; i<fNumPixels; i++)
    277     {
    278         const MCerPhotPix &pix = (*this)[i];
     287    Float_t minval = FLT_MAX;
     288
     289    for (UInt_t i=1; i<fNumPixels; i++)
     290    {
     291        const MCerPhotPix &pix = (*this)[i];
     292        if (!pix.IsPixelUsed())
     293            continue;
    279294
    280295        Float_t testval = pix.GetErrorPhot();
     
    300315        return 50.;
    301316
    302     Float_t maxval = (*this)[0].GetErrorPhot();
    303 
    304     for (UInt_t i=1; i<fNumPixels; i++)
    305     {
    306         const MCerPhotPix &pix = (*this)[i];
     317    Float_t maxval = -FLT_MAX;
     318
     319    for (UInt_t i=1; i<fNumPixels; i++)
     320    {
     321        const MCerPhotPix &pix = (*this)[i];
     322        if (!pix.IsPixelUsed())
     323            continue;
    307324
    308325        Float_t testval = pix.GetErrorPhot();
     
    368385}
    369386*/
     387
     388void MCerPhotEvt::Scale(Double_t f)
     389{
     390    fPixels->ForEach(MCerPhotPix, Scale)(f);
     391}
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h

    r1715 r1965  
    4848    MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
    4949
     50    void Scale(Double_t f);
     51
    5052    MCerPhotPix *GetPixById(int id) const;
    5153
  • trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h

    r1951 r1965  
    4848    void    AddNumPhotons(Float_t f)    { fPhot += f; }
    4949
     50    void    Scale(Float_t f)            { fPhot/=f; }
     51
    5052    void    Print(Option_t *opt = NULL) const;
    5153
  • trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc

    r1540 r1965  
    5757{
    5858    fName  = name  ? name  : "MMcPedestalCopy";
    59     fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
     59    fTitle = title ? title : "Copy MC pedestals into MPedestal Container";
    6060
    6161    //
  • trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc

    r1540 r1965  
    7979{
    8080    fName  = name  ? name  : "MMcPedestalNSBAdd";
    81     fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
     81    fTitle = title ? title : "Add diffuse NSB to the pedestal signal";
    8282
    8383    //
  • trunk/MagicSoft/Mars/mars.cc

    r1330 r1965  
    4747    //       12345678901234567890123456789012345678901234567890
    4848    gLog << "==================================================" << endl;
    49     gLog << "                    MARS V0.8                     " << endl;
     49    gLog << "                    MARS V" << MARSVER << "                      " << endl;
    5050    gLog << "    Magic Analysis and Reconstruction Software    " << endl;
    5151    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r1902 r1965  
    4646// Afterwards the PostProcess functions are executed.                       //
    4747//                                                                          //
    48 //                                                                          //
    49 //  Maybe we can add a TProgressMeter sometimes later to be able to show    //
    50 //  the progress graphically...                                             //
    51 //                                                                          //
     48// If you want to display the progress in a gui you can use SetProgressBar  //
     49// and a TGProgressBar or a MProgressBar. If you set a MStatusDisplay       //
     50// using SetDisplay, the Progress bar from this display is used.            //
    5251//                                                                          //
    5352// You can create a macro from a completely setup eventloop by:             //
     
    7473#include <iostream.h>
    7574
     75#include <TTime.h>          // TTime
    7676#include <TFile.h>          // gFile
    7777#include <TSystem.h>        // gSystem
     
    8787#include "MRead.h"           // for setting progress bar
    8888#include "MProgressBar.h"    // MProgressBar::GetBar
     89#include "MStatusDisplay.h"  // MStatusDisplay::GetBar
    8990#endif
    9091
     
    101102// --------------------------------------------------------------------------
    102103//
    103 // default constructor - emty
     104// default constructor
    104105//
    105106MEvtLoop::MEvtLoop(const char *name) : fParList(NULL), fProgress(NULL)
     
    112113// --------------------------------------------------------------------------
    113114//
    114 // default destructor - emty
     115// destructor
    115116//
    116117MEvtLoop::~MEvtLoop()
     
    171172    if (fLog != &gLog)
    172173        fParList->SetLogStream(fLog);
     174
     175#ifdef __MARS__
     176    //
     177    // Check whether display is still existing
     178    //
     179    if (fDisplay && !gROOT->GetListOfSpecials()->FindObject(fDisplay))
     180        fDisplay = NULL;
     181    if (fDisplay)
     182    {
     183        // Lock display to prevent user from deleting it
     184        fDisplay->Lock();
     185        // Get pointer to update Progress bar
     186        fProgress = fDisplay->GetBar();
     187        // Don't display context menus
     188        fDisplay->SetNoContextMenu();
     189        // Set window and icon name
     190        fDisplay->SetWindowName(TString("Status Display: ")+fName);
     191        fDisplay->SetIconName(fName);
     192        // Set status lines
     193        fDisplay->SetStatusLine1("PreProcessing...");
     194        fDisplay->SetStatusLine2("");
     195        // Start automatic update
     196        fDisplay->StartUpdate();
     197        // Cascade display through childs
     198        fParList->SetDisplay(fDisplay);
     199    }
     200#endif
    173201
    174202    //
     
    188216}
    189217
     218Bool_t MEvtLoop::ProcessGuiEvents(Int_t num)
     219{
     220    if (!fProgress)
     221        return kTRUE;
     222
     223    //
     224    // Check status of display
     225    //
     226    Bool_t rc = kTRUE;
     227
     228    if (fDisplay)
     229        switch (fDisplay->CheckStatus())
     230        {
     231        case MStatusDisplay::kLoopNone:
     232            break;
     233        case MStatusDisplay::kLoopStop:
     234            rc = kFALSE;
     235            fDisplay->ClearStatus();
     236            break;
     237        case MStatusDisplay::kFileExit:
     238            fParList->SetDisplay(NULL);
     239            delete fDisplay;
     240            SetDisplay(NULL);
     241            fProgress = NULL;
     242            gSystem->ProcessEvents();
     243            return kTRUE;
     244        default:
     245            fDisplay->ClearStatus();
     246            *fLog << warn << "Display shows unknown status... cleared." << endl;
     247            break;
     248        }
     249
     250    //
     251    // Check System time (don't loose too much time by updates)
     252    //
     253    static TTime t0 = gSystem->Now();
     254
     255    const TTime t1 = gSystem->Now();
     256    if (t1-t0 < (TTime)20)
     257        return rc;
     258
     259    t0 = t1;
     260
     261    //
     262    // Set new progress bar position
     263    //
     264    fProgress->SetPosition(num);
     265
     266    //
     267    // Handle GUI events (display changes)
     268    //
     269#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
     270    gSystem->ProcessEvents();
     271#else
     272    if (fDisplay)
     273        gSystem->ProcessEvents();
     274    else
     275        gClient->ProcessEventsFor(fProgress);
     276#endif
     277
     278    return rc;
     279}
     280
    190281// --------------------------------------------------------------------------
    191282//
     
    193284// for developers or use in special jobs only!
    194285//
    195 Bool_t MEvtLoop::Process(Int_t maxcnt) const
     286Bool_t MEvtLoop::Process(Int_t maxcnt)
    196287{
    197288    //
     
    208299    *fLog << " events)..." << flush;
    209300
     301    Int_t entries = INT_MAX;
     302
    210303    if (fProgress)
    211304    {
    212305        fProgress->Reset();
    213 
    214         Int_t entries = INT_MAX;
    215 
    216306#ifdef __MARS__
    217307        // limits.h
     
    228318    }
    229319
     320    if (fDisplay)
     321    {
     322        fDisplay->SetStatusLine1("Processing...");
     323        fDisplay->SetStatusLine2("");
     324    }
     325
    230326    Int_t dummy = maxcnt<0 ? 0 : maxcnt;
    231327
     
    246342    if (maxcnt<0)
    247343        // process first and increment if sucessfull
    248         if (fProgress)
    249             while ((rc=fTaskList->Process())==kTRUE)
    250             {
    251                 fProgress->SetPosition(++dummy);
    252 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
    253                 gSystem->ProcessEvents();
    254 #else
    255                 gClient->ProcessEventsFor(fProgress);
    256 #endif
    257                 numcnts++;
    258             }
    259         else
    260             while ((rc=fTaskList->Process())==kTRUE) numcnts++;
     344        while ((rc=fTaskList->Process())==kTRUE)
     345        {
     346            numcnts++;
     347            if (!ProcessGuiEvents(++dummy))
     348                break;
     349        }
    261350    else
    262351        // check for number and break if unsuccessfull
    263         if (fProgress)
    264             while (dummy-- && (rc=fTaskList->Process())==kTRUE)
    265             {
    266                 fProgress->SetPosition(maxcnt - dummy);
     352        while (dummy-- && (rc=fTaskList->Process())==kTRUE)
     353        {
     354            numcnts++;
     355            if (!ProcessGuiEvents(maxcnt - dummy))
     356                break;
     357        }
     358
     359    //
     360    // stop stop-watch, print results
     361    //
     362    clock.Stop();
     363
     364    if (fProgress)
     365    {
     366        fProgress->SetPosition(maxcnt>0 ? TMath::Min(maxcnt, entries) : entries);
    267367#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
    268                 gSystem->ProcessEvents();
     368        gSystem->ProcessEvents();
    269369#else
    270                 gClient->ProcessEventsFor(fProgress);
     370        gClient->ProcessEventsFor(fDisplay ? fDisplay : fProgress);
    271371#endif
    272                 numcnts++;
    273             }
    274         else
    275             while (dummy-- && (rc=fTaskList->Process())==kTRUE) numcnts++;
    276 
    277     //
    278     // stop stop-watch, print results
    279     //
    280     clock.Stop();
     372    }
    281373
    282374    *fLog << all << "Ready!" << endl << endl;
     
    306398    //  execute the post process of all tasks
    307399    //
     400    if (fDisplay)
     401    {
     402        // Set status lines
     403        fDisplay->SetStatusLine1("PostProcessing...");
     404        fDisplay->SetStatusLine2("");
     405    }
    308406    return fTaskList->PostProcess();
    309407}
     
    329427    if (!PostProcess())
    330428        return kFALSE;
     429
     430    if (!fDisplay)
     431        return rc;
     432
     433    // Set status lines
     434    fDisplay->SetStatusLine1(fName);
     435    fDisplay->SetStatusLine2(rc ? "Done." : "ERROR");
     436    // Stop automatic update
     437    fDisplay->StopUpdate();
     438    // Reallow context menus
     439    fDisplay->SetNoContextMenu(kFALSE);
     440    // Reallow user to exit window by File menu
     441    fDisplay->UnLock();
    331442
    332443    //
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.h

    r1880 r1965  
    2727    MTaskList *fTaskList;      //!
    2828
    29     TGProgressBar *fProgress;  //!
     29    TGProgressBar   *fProgress;  //!
    3030
    3131    enum { kIsOwner = BIT(14) };
     
    3535
    3636    void StreamPrimitive(ofstream &out) const;
     37
     38    Bool_t ProcessGuiEvents(Int_t num);
    3739
    3840public:
     
    4446    MTaskList *GetTaskList() const      { return fTaskList; }
    4547
     48    MStatusDisplay *GetDisplay() { return fDisplay; }
     49
    4650    void SetOwner(Bool_t enable=kTRUE);
    4751
     
    5256
    5357    Bool_t PreProcess(const char *tlist="MTaskList");
    54     Bool_t Process(Int_t maxcnt) const;
     58    Bool_t Process(Int_t maxcnt);
    5559    Bool_t PostProcess() const;
    5660
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1902 r1965  
    3737#include "MParContainer.h"
    3838
    39 #include <ctype.h>       // isdigit
    40 #include <fstream.h>     // ofstream, AsciiWrite
    41 
    42 #include <TEnv.h>        // Env::Lookup
    43 #include <TClass.h>      // IsA
    44 #include <TObjArray.h>   // TObjArray
    45 #include <TBaseClass.h>  // GetClassPointer
    46 #include <TMethodCall.h> // TMethodCall, AsciiWrite
    47 #include <TDataMember.h> // TDataMember, AsciiWrite
    48 #include <TVirtualPad.h> // gPad
     39#include <ctype.h>        // isdigit
     40#include <fstream.h>      // ofstream, AsciiWrite
     41
     42#include <TEnv.h>         // Env::Lookup
     43#include <TClass.h>       // IsA
     44#include <TObjArray.h>    // TObjArray
     45#include <TBaseClass.h>   // GetClassPointer
     46#include <TMethodCall.h>  // TMethodCall, AsciiWrite
     47#include <TDataMember.h>  // TDataMember, AsciiWrite
     48#include <TVirtualPad.h>  // gPad
    4949
    5050#include "MLog.h"
     
    5252
    5353#ifndef __COSY__
    54 #include "MEvtLoop.h"    // gListOfPrimitives
     54#include "MEvtLoop.h"     // gListOfPrimitives
    5555#else
    5656TList *gListOfPrimitives; // forard declaration in MParContainer.h
     
    7171
    7272    fReadyToSave = named.fReadyToSave;
     73
     74    fDisplay = named.fDisplay;
    7375}
    7476
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1902 r1965  
    2626class TDataMember;
    2727class TMethodCall;
     28class MStatusDisplay;
    2829
    2930class MParContainer : public TObject
     
    3435
    3536    MLog   *fLog;         // The general log facility for this object, initialized with the global object
     37
     38    MStatusDisplay *fDisplay;
    3639
    3740private:
     
    4952    };
    5053
    51     MParContainer(const char *name="", const char *title="") : fName(name), fTitle(title), fLog(&gLog), fReadyToSave(kFALSE) {  }
    52     MParContainer(const TString &name, const TString &title) : fName(name), fTitle(title), fLog(&gLog), fReadyToSave(kFALSE) {  }
     54    MParContainer(const char *name="", const char *title="") : fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE) {  }
     55    MParContainer(const TString &name, const TString &title) : fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE) {  }
    5356    MParContainer(const MParContainer &named);
    5457    MParContainer& operator=(const MParContainer& rhs);
     
    6467    virtual void        FillBuffer(char *&buffer);
    6568
    66     virtual const char   *GetDescriptor() const { return Form("%s [%s]", fName.Data(), ClassName()); }
     69    virtual const char   *GetDescriptor() const { return fName==ClassName() ? ClassName() : Form("%s [%s]", fName.Data(), ClassName()); }
    6770    virtual const TString GetUniqueName() const;
    6871    virtual const char   *GetName() const       { return fName.Data(); }
     
    8790    virtual void   EnableGraphicalOutput(Bool_t flag=kTRUE) { flag ? SetBit(kEnableGraphicalOutput) : ResetBit(kEnableGraphicalOutput);}
    8891    virtual Bool_t IsGraphicalOutputEnabled() const  { return TestBit(kEnableGraphicalOutput); }
     92
     93    virtual void SetDisplay(MStatusDisplay *d) { fDisplay = d; }
    8994
    9095    TMethodCall *GetterMethod(const char *name) const;
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r1902 r1965  
    138138}
    139139
     140void MParList::SetDisplay(MStatusDisplay *d)
     141{
     142    fContainer->ForEach(MParContainer, SetDisplay)(d);
     143    MParContainer::SetDisplay(d);
     144}
     145
    140146// --------------------------------------------------------------------------
    141147//
     
    149155    //  check if the object (you want to add) exists
    150156    //
    151 
    152157    if (!cont)
    153158        return kFALSE;
  • trunk/MagicSoft/Mars/mbase/MParList.h

    r1880 r1965  
    5050
    5151    void SetLogStream(MLog *log);
     52    void SetDisplay(MStatusDisplay *d);
    5253
    5354    TObject *FindObject(const char *name) const;
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r1935 r1965  
    5757#include "MTaskList.h"
    5858
    59 #include <fstream.h>     // ofstream, SavePrimitive
     59#include <fstream.h>        // ofstream, SavePrimitive
    6060
    6161#include <TClass.h>
     
    7070#include "MInputStreamID.h"
    7171
     72#include "MStatusDisplay.h"
     73
    7274ClassImp(MTaskList);
    7375
     
    133135    fTasks->ForEach(MTask, SetLogStream)(log);
    134136    MParContainer::SetLogStream(log);
     137}
     138
     139void MTaskList::SetDisplay(MStatusDisplay *d)
     140{
     141    fTasks->ForEach(MTask, SetDisplay)(d);
     142    MParContainer::SetDisplay(d);
    135143}
    136144
     
    350358//
    351359Bool_t MTaskList::PreProcess(MParList *pList)
    352 { 
     360{
    353361    *fLog << all << "Preprocessing... " << flush;
    354362
     
    370378    {
    371379        *fLog << all << task->GetName() << "... " << flush;
     380        if (fDisplay)
     381            fDisplay->SetStatusLine2(*task);
    372382
    373383        //
     
    539549    {
    540550        *fLog << all << task->GetName() << "... " << flush;
     551        if (fDisplay)
     552            fDisplay->SetStatusLine2(*task);
    541553
    542554        if (!task->CallPostProcess())
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r1935 r1965  
    4444
    4545    void SetLogStream(MLog *log);
     46    void SetDisplay(MStatusDisplay *d);
    4647
    4748    Bool_t AddToListBefore(MTask *task, const MTask *where, const char *tType="All");
  • trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc

    r1668 r1965  
    162162    AddSetupElements();
    163163
    164     TCanvas *canv2 = AddTab("Errors");
    165     TCanvas *canv3 = AddTab("Phot/Err");
    166     TCanvas *canv4 = AddTab("Levels");
    167     TCanvas *canv5 = AddTab("Pedestals");
     164    fCanvas2 = AddTab("Errors");
     165    fCanvas3 = AddTab("Phot/Err");
     166    fCanvas4 = AddTab("Levels");
     167    fCanvas5 = AddTab("Pedestals");
    168168
    169169    //
     
    184184    fCanvas->cd();
    185185    fDisplay->Draw();
    186     canv2->cd();
     186    fCanvas2->cd();
    187187    fDisplay2->Draw();
    188     canv3->cd();
     188    fCanvas3->cd();
    189189    fDisplay3->Draw();
    190     canv4->cd();
     190    fCanvas4->cd();
    191191    fDisplay4->Draw();
    192     canv5->cd();
     192    fCanvas5->cd();
    193193    fDisplay5->Draw();
    194194
     
    239239    // Display the requested event. This does a Canvas update, too.
    240240    //
    241     MCerPhotEvt  *evt = NULL;
     241    MCerPhotEvt *evt = NULL;
    242242    if (fDisplayRaw)
    243243    {
     
    259259    const MPedestalCam *ped   = (MPedestalCam*)plist->FindObject("MPedestalCam");
    260260
    261     fDisplay->DrawPhotNum(evt);
    262     fDisplay2->DrawErrorPhot(evt);
    263     fDisplay3->DrawRatio(evt);
    264     fDisplay4->DrawLevels(evt, *clean);
    265     fDisplay5->DrawPedestals(ped);
     261    fDisplay->FillPhotNum(*evt);
     262    fCanvas->Modified();
     263    fCanvas->Update();
     264    fDisplay2->FillErrorPhot(*evt);
     265    fCanvas2->Modified();
     266    fCanvas2->Update();
     267    fDisplay3->FillRatio(*evt);
     268    fCanvas3->Modified();
     269    fCanvas3->Update();
     270    fDisplay4->FillLevels(*evt, *clean);
     271    fCanvas4->Modified();
     272    fCanvas4->Update();
     273    fDisplay5->FillPedestals(*ped);
     274    fCanvas5->Modified();
     275    fCanvas5->Update();
    266276}
    267277
  • trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.h

    r1668 r1965  
    2525    MCamDisplay *fDisplay5;
    2626
     27    TCanvas *fCanvas2;
     28    TCanvas *fCanvas3;
     29    TCanvas *fCanvas4;
     30    TCanvas *fCanvas5;
     31
    2732    void AddSetupElements();
    2833    void UpdateDisplay();
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc

    r1836 r1965  
    4343
    4444#include "MRawRunHeader.h"
     45#include "MStatusDisplay.h"
    4546
    4647#include "MMcRunHeader.hxx"
     
    5556{
    5657    fName  = "MRead";
    57     fTitle = "Task to loop over all events in a tree of a Mars file.";
     58    fTitle = "Read tree and run headers from Mars file.";
    5859}
    5960
     
    6869{
    6970    fName  = name  ? name  : "MRead";
    70     fTitle = title ? title : "Task to loop over all events in a tree of a Mars file.";
     71    fTitle = title ? title : "Read tree and run headers from Mars file.";
    7172
    7273    //
     
    144145    *fLog << " '" << GetFileName() << "' (before event #";
    145146    *fLog << GetNumEntry()-1 << ")" << endl;
     147
     148    if (fDisplay)
     149    {
     150        TString txt = GetFileName();
     151        txt += " @ ";
     152        txt += GetNumEntry()-1;
     153        fDisplay->SetStatusLine2(txt);
     154    }
    146155
    147156    if (rawheader)
  • trunk/MagicSoft/Mars/mfileio/Makefile

    r1888 r1965  
    2020# @endcode
    2121
    22 INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mdata -I../manalysis -I../mgeom -I../mhist
     22INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mdata -I../manalysis \
     23           -I../mgeom -I../mhist -I../mmain
    2324
    2425# @code
     
    3536           MReadTree.cc \
    3637           MReadMarsFile.cc \
     38           MRunHeader.cc \
    3739           MWriteFile.cc \
    3840           MWriteAsciiFile.cc \
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r1747 r1965  
    3333//
    3434///////////////////////////////////////////////////////////////////////
     35#include "MGeomCam.h"
    3536
    36 #include "MGeomCam.h"
     37#include <TClass.h>
    3738
    3839#include "MLog.h"
     
    138139}
    139140
     141TObject *MGeomCam::Clone(const char *newname) const
     142{
     143    return (TObject*)IsA()->New();
     144}
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.h

    r1747 r1965  
    2828public:
    2929    MGeomCam(UInt_t npix, Float_t dist, const char *name=NULL, const char *title=NULL);
     30    virtual ~MGeomCam();
    3031
    31     virtual ~MGeomCam();
     32    virtual TObject *Clone(const char *newname=NULL) const;
    3233
    3334    Float_t GetCameraDist() const      { return fCamDist; }
  • trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc

    r1600 r1965  
    214214    // fill the geometry class with the coordinates of the CT1 camera
    215215    //
    216     *fLog << inf << " Create CT1 geometry " << endl;
     216    //*fLog << inf << " Create CT1 geometry " << endl;
    217217
    218218    //
  • trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc

    r1458 r1965  
    6666    //   fill the geometry class with the coordinates of the MAGIC camera
    6767    //
    68     *fLog << inf << " Creating Magic geometry " << endl ;
     68    //*fLog << inf << " Creating Magic geometry " << endl ;
    6969
    7070    //
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.cc

    r1906 r1965  
    3838
    3939#include <TBox.h>
    40 #include <TText.h>
    4140#include <TArrow.h>
     41#include <TLatex.h>
    4242#include <TStyle.h>
    4343#include <TCanvas.h>
    44 //#include <TButton.h>
    4544#include <TClonesArray.h>
    4645
     46#include "MH.h"
    4747#include "MHexagon.h"
    4848
     
    6363// ------------------------------------------------------------------------
    6464//
    65 //  default constructor
     65//  Default Constructor. To be used by the root system ONLY.
     66//
     67MCamDisplay::MCamDisplay()
     68    : fGeomCam(NULL), fAutoScale(kTRUE), fW(0), fH(0)
     69{
     70    fNumPixels = 0;
     71    fRange     = 0;
     72
     73    fPixels    = NULL;
     74    fLegend    = NULL;
     75    fLegText   = NULL;
     76    fArrowX    = NULL;
     77    fArrowY    = NULL;
     78    fLegRadius = NULL;
     79    fLegDegree = NULL;
     80}
     81
     82// ------------------------------------------------------------------------
     83//
     84//  Constructor. Makes a clone of MGeomCam.
    6685//
    6786MCamDisplay::MCamDisplay(MGeomCam *geom)
    68     : fAutoScale(kTRUE), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
    69 {
    70     fGeomCam = (MGeomCam*)geom; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone();
     87    : fGeomCam(NULL), fAutoScale(kTRUE), fW(0), fH(0)
     88{
     89    fGeomCam = (MGeomCam*)geom->Clone();
    7190
    7291    //
    7392    //  create the hexagons of the display
    7493    //
    75     fNumPixels = geom->GetNumPixels();
    76     fRange     = geom->GetMaxRadius();
    77 
    78     //
    79     // Construct all hexagons. Use new-operator with placement
    80     //
     94    fNumPixels = fGeomCam->GetNumPixels();
     95    fRange     = fGeomCam->GetMaxRadius();
    8196
    8297    // root 3.02
     
    85100    //    not get an automatic context menu when clicked with the right mouse button.
    86101
     102    //
     103    // Construct all hexagons. Use new-operator with placement
     104    //
    87105    fPixels = new TClonesArray("MHexagon", fNumPixels);
    88106    for (UInt_t i=0; i<fNumPixels; i++)
    89         new ((*fPixels)[i]) MHexagon((*geom)[i]);
    90 
    91     //
    92     // set the color palette for the TBox elements
    93     //
     107    {
     108        MHexagon &pix = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
     109#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     110        pix.SetBit(/*kNoContextMenu|*/kCannotPick);
     111#endif
     112        pix.SetFillColor(16);
     113    }
     114
     115    //
     116    // set up the Legend
     117    //
     118    const Float_t H = 0.9*fRange;
     119    const Float_t h = 2./kItemsLegend;
     120
     121    const Float_t w = fRange/sqrt(fNumPixels);
     122
     123    fLegend  = new TClonesArray("TBox",  kItemsLegend);
     124    fLegText = new TClonesArray("TText", kItemsLegend);
     125
     126    for (Int_t i = 0; i<kItemsLegend; i++)
     127    {
     128        TBox  &newbox = *new ((*fLegend)[i])  TBox;
     129        TText &newtxt = *new ((*fLegText)[i]) TText;
     130
     131        newbox.SetX1(fRange);
     132        newbox.SetX2(fRange+w);
     133        newbox.SetY1(H*( i   *h - 1.));
     134        newbox.SetY2(H*((i+1)*h - 1.));
     135        newbox.SetFillColor(16);
     136#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     137        newbox.SetBit(/*kNoContextMenu|*/kCannotPick);
     138#endif
     139
     140        newtxt.SetTextSize(0.025);
     141        newtxt.SetTextAlign(12);
     142        newtxt.SetX(fRange+1.5*w);
     143        newtxt.SetY(H*((i+0.5)*h - 1.));
     144#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     145        newtxt.SetBit(/*kNoContextMenu|*/kCannotPick);
     146#endif
     147    }
     148
     149    fArrowX = new TArrow(-fRange*.9, -fRange*.9, -fRange*.6, -fRange*.9, 0.025);
     150    fArrowY = new TArrow(-fRange*.9, -fRange*.9, -fRange*.9, -fRange*.6, 0.025);
     151
     152    TString text;
     153    text += (int)(fRange*.3);
     154    text += "mm";
     155
     156    fLegRadius = new TText(-fRange*.85, -fRange*.85, text);
     157    text = "";
     158    text += (float)((int)(fRange*.3*fGeomCam->GetConvMm2Deg()*10))/10;
     159    text += "\\circ";
     160    text = text.Strip(TString::kLeading);
     161    fLegDegree = new TLatex(-fRange*.85, -fRange*.75, text);
     162    fLegRadius->SetTextSize(0.04);
     163    fLegDegree->SetTextSize(0.04);
     164
    94165#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
    95166    SetPalette(1, 0);
     
    98169#endif
    99170
    100     //
    101     // set up the Legend
    102     //
    103     fLegend  = new TClonesArray("TBox",  kItemsLegend);
    104     fLegText = new TClonesArray("TText", kItemsLegend);
    105 
    106     for (Int_t i = 0; i<kItemsLegend; i++)
    107     {
    108         TBox  *newbox = new ((*fLegend)[i])  TBox;
    109         TText *newtxt = new ((*fLegText)[i]) TText;
    110 
    111         newbox->SetFillColor(fColors[i]);
    112 
    113         newtxt->SetTextSize(0.025);
    114         newtxt->SetTextAlign(12);
    115     }
    116 
    117     fArrowX = new TArrow(-fRange*.9, -fRange*.9, -fRange*.6, -fRange*.9, 0.025);
    118     fArrowY = new TArrow(-fRange*.9, -fRange*.9, -fRange*.9, -fRange*.6, 0.025);
    119 
    120     TString text;
    121     text += (int)(fRange*.3);
    122     text += "mm";
    123 
    124     fLegRadius = new TText(-fRange*.85, -fRange*.85, text);
    125     text = "";
    126     text += (float)((int)(fRange*.3*geom->GetConvMm2Deg()*10))/10;
    127     text += "°";
    128     text = text.Strip(TString::kLeading);
    129     fLegDegree = new TText(-fRange*.85, -fRange*.75, text);
    130     fLegRadius->SetTextSize(0.04);
    131     fLegDegree->SetTextSize(0.04);
    132171}
    133172
     
    152191    delete fLegDegree;
    153192
    154     // delete fGeomCam;
    155 
    156     // Not allocated by MCamDisplay or already deleted by the user
    157     if (!fIsAllocated || !gROOT->GetListOfCanvases()->FindObject(fDrawingPad))
    158         return;
    159 
    160     // If it is not already removed make sure that nothing of this object
    161     // maybe be deleted automatically by the canvas destructor
    162     if (!fDrawingPad->GetListOfPrimitives()->FindObject(this))
    163         return;
    164 
    165     fDrawingPad->RecursiveRemove(this);
    166     delete fDrawingPad;
     193    delete fGeomCam;
    167194}
    168195
     
    237264// ------------------------------------------------------------------------
    238265//
     266// Call this function to draw the camera layout into your canvas.
     267// Setup a drawing canvas. Add this object and all child objects
     268// (hexagons, etc) to the current pad. If no pad exists a new one is
     269// created.
     270//
     271void MCamDisplay::Draw(Option_t *option)
     272{
     273    // root 3.02:
     274    // gPad->SetFixedAspectRatio()
     275
     276    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 750, 600);
     277    pad->SetBorderMode(0);
     278    pad->SetFillColor(16);
     279
     280    //
     281    // All this is necessary to get the background in the correct color
     282    //
     283    pad->Divide(1,1);
     284    pad->cd(1);
     285
     286    gPad->SetBorderMode(0);
     287    gPad->SetFillColor(16);
     288
     289    //
     290    // set the color palette for the TBox elements
     291    //
     292    AppendPad("");
     293
     294    //
     295    // Necessary to visualize the background color (FIXME?)
     296    //
     297    gPad->Modified();
     298    gPad->Update();
     299}
     300
     301
     302void MCamDisplay::SetRange()
     303{
     304    //
     305    // Maintain aspect ratio
     306    //
     307    const float ratio = 1.15;
     308
     309    const float w = gPad->GetWw();
     310    const float h = gPad->GetWh()*ratio;
     311
     312    if (h<w)
     313        gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 0.9999999);
     314    else
     315        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2);
     316
     317    gPad->Range(-fRange, -fRange, (2*ratio-1)*fRange, fRange);
     318}
     319
     320// ------------------------------------------------------------------------
     321//
    239322// This is called at any time the canvas should get repainted.
    240 // Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
     323// Here we maintain an aspect ratio of 1.15. This makes sure,
    241324// that the camera image doesn't get distorted by resizing the canvas.
    242325//
    243326void MCamDisplay::Paint(Option_t *opt)
    244327{
    245     const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
    246     const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
    247 
    248     //
    249     // Check for a change in width or height, and make sure, that the
    250     // first call also sets the range
    251     //
    252     if (w*fH == h*fW && fW && fH)
     328    if (!fPixels)
    253329        return;
    254330
    255331    //
    256     // Calculate aspect ratio (5/4=1.25 recommended)
    257     //
    258     const Double_t ratio = (Double_t)w/h;
    259 
    260     Float_t x;
    261     Float_t y;
    262 
    263     if (ratio>1.25)
    264     {
    265         x = (ratio*2-1)*fRange;
    266         y = fRange;
    267     }
    268     else
    269     {
    270         x = fRange*1.5;
    271         y = fRange*1.25/ratio;
    272     }
    273 
    274     fH = h;
    275     fW = w;
    276 
    277     //
    278     // Set new range
    279     //
    280     gPad->Range(-fRange, -y, x, y);
    281 
    282     //
    283     // Make sure, that the correct aspect is always displayed also
    284     // if - by chance - there is not update for the pad after the
    285     // Paint function was called.
    286     //
    287     gPad->Update();
     332    // Maintain aspect ratio
     333    //
     334    SetRange();
     335
     336    //
     337    // Maintain colors
     338    //
     339    SetPalette();
     340
     341    //
     342    // Paint primitives
     343    //
     344    for (UInt_t i=0; i<fNumPixels; i++)
     345        (*this)[i].Paint();
     346
     347    for (Int_t i=0; i<kItemsLegend; i++)
     348    {
     349        GetBox(i)->Paint();
     350        GetText(i)->Paint();
     351    }
     352
     353    fArrowX->Paint(">");
     354    fArrowY->Paint(">");
     355
     356    fLegRadius->Paint();
     357    fLegDegree->Paint();
    288358}
    289359
     
    321391        gStyle->SetPalette(ncolors, colors);
    322392
    323     if (fDrawingPad)
     393    //
     394    // Change the colors of the pixels
     395    //
     396    for (unsigned int i=0; i<fNumPixels; i++)
    324397    {
    325398        //
    326         // Set the colors of the legend
     399        // Get the old color index and check whether it is
     400        // background or transparent
    327401        //
    328         for (int i=0; i<kItemsLegend; i++)
     402        Int_t col = (*this)[i].GetFillColor();
     403        if (col==10 || col==16)
     404            continue;
     405
     406        //
     407        // Search for the color index (level) in the color table
     408        //
     409        int idx;
     410        for (idx=0; idx<kItemsLegend; idx++)
     411            if (col==fColors[idx])
     412                break;
     413
     414        //
     415        // Should not happen
     416        //
     417        if (idx==kItemsLegend)
    329418        {
    330             Int_t col = GetBox(i)->GetFillColor();
    331 
    332             //
    333             // Make sure, that the legend is already colored
    334             //
    335             if (col==10 || col==22)
    336                 continue;
    337             GetBox(i)->SetFillColor(gStyle->GetColorPalette(i));
     419            cout << "MCamDisplay::SetPalette: Strange... FIXME!" << endl;
     420            continue;
    338421        }
    339422
    340423        //
    341         // Change the colors of the pixels
     424        // Convert the old color index (level) into the new one
    342425        //
    343         for (unsigned int i=0; i<fNumPixels; i++)
    344         {
    345             //
    346             // Get the old color index and check whether it is
    347             // background or transparent
    348             //
    349             Int_t col = (*this)[i].GetFillColor();
    350             if (col==10 || col==22)
    351                 continue;
    352 
    353             //
    354             // Search for the color index (level) in the color table
    355             //
    356             int idx;
    357             for (idx=0; idx<kItemsLegend; idx++)
    358                 if (col==fColors[idx])
    359                     break;
    360             //
    361             // Should not happen
    362             //
    363             if (idx==kItemsLegend)
    364             {
    365                 cout << "MCamDisplay::SetPalette: Strange... FIXME!" << endl;
    366                 continue;
    367             }
    368 
    369             //
    370             // Convert the old color index (level) into the new one
    371             //
    372             (*this)[i].SetFillColor(gStyle->GetColorPalette(idx));
    373         }
    374 
    375         //
    376         // Update the pad on the screen
    377         //
    378         fDrawingPad->Modified();
    379         fDrawingPad->Update();
     426        (*this)[i].SetFillColor(gStyle->GetColorPalette(idx));
    380427    }
    381428
     
    384431    //
    385432    for (int i=0; i<kItemsLegend; i++)
     433    {
    386434        fColors[i] = gStyle->GetColorPalette(i);
     435        GetBox(i)->SetFillColor(fColors[i]);
     436    }
    387437}
    388438
     
    402452}
    403453
    404 // ------------------------------------------------------------------------
    405 //
    406 // Call this function to draw the camera layout into your canvas.
    407 // Setup a drawing canvas. Add this object and all child objects
    408 // (hexagons, etc) to the current pad. If no pad exists a new one is
    409 // created.
    410 //
    411 void MCamDisplay::Draw(Option_t *option)
    412 {
    413     // root 3.02:
    414     // gPad->SetFixedAspectRatio()
    415 
    416     if (fDrawingPad)
    417         return;
    418 
    419     //
    420     // if no canvas is yet existing to draw into, create a new one
    421     //
     454void MCamDisplay::SetPalette()
     455{
     456    for (int i=0; i<kItemsLegend; i++)
     457        GetBox(i)->SetFillColor(fColors[i]);
     458}
     459
     460void MCamDisplay::DrawPixelNumbers()
     461{
     462    for (int i=0; i<kItemsLegend; i++)
     463        fColors[i] = 16;
     464
    422465    if (!gPad)
    423     {
    424         fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 750, 600);
    425         fIsAllocated = kTRUE;
    426     }
    427     else
    428     {
    429         fDrawingPad = gPad;
    430         fIsAllocated = kFALSE;
    431     }
    432 
    433     //
    434     // Setup the correct environment
    435     //
    436     fDrawingPad->SetBorderMode(0);
    437     fDrawingPad->SetFillColor(22);
    438 
    439     //
    440     // Set the initial coordinate range
    441     //
    442     Paint();
    443 
    444     /*
    445      //
    446      // Create and draw the buttons which allows changing the
    447      // color palette of the display
    448      //
    449      TButton *but;
    450      char txt[100];
    451      sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(1,0);", this);
    452      but = new TButton("Pretty", txt, 0.01, 0.95, 0.15, 0.99);
    453      but->Draw();
    454      sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(51,0);", this);
    455      but = new TButton("Deap Sea", txt, 0.16, 0.95, 0.30, 0.99);
    456      but->Draw();
    457      sprintf(txt, "((MCamDisplay*)0x%lx)->SetPalette(52,0);", this);
    458      but = new TButton("Blue Inv", txt, 0.31, 0.95, 0.45, 0.99);
    459      but->Draw();
    460      */
    461 
    462     //
    463     // Draw all pixels of the camera
    464     //  (means apend all pixelobjects to the current pad)
    465     //
    466     for (UInt_t i=0; i<fNumPixels; i++)
    467     {
    468 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    469         (*this)[i].SetBit(/*kNoContextMenu|*/kCannotPick);
    470 #endif
    471         (*this)[i].SetFillColor(22);
    472         (*this)[i].Draw();
    473     }
    474 
    475     fArrowX->Draw();
    476     fArrowY->Draw();
    477 
    478     fLegRadius->Draw();
    479     fLegDegree->Draw();
    480 
    481     //
    482     // initialize and draw legend
    483     //
    484     const Float_t H = 0.9*fRange;
    485     const Float_t h = 2./kItemsLegend;
    486 
    487     const Float_t w = fRange/sqrt(fNumPixels);
    488 
    489     for (Int_t i=0; i<kItemsLegend; i++)
    490     {
    491         TBox *box = GetBox(i);
    492         box->SetX1(fRange);
    493         box->SetX2(fRange+w);
    494         box->SetY1(H*( i   *h - 1.));
    495         box->SetY2(H*((i+1)*h - 1.));
    496         box->SetFillColor(22);
    497 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    498         box->SetBit(/*kNoContextMenu|*/kCannotPick);
    499 #endif
    500         box->Draw();
    501 
    502         TText *txt = GetText(i);
    503         txt->SetX(fRange+1.5*w);
    504         txt->SetY(H*((i+0.5)*h - 1.));
    505 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    506         txt->SetBit(/*kNoContextMenu|*/kCannotPick);
    507 #endif
    508         txt->Draw();
    509     }
    510 
    511     //
    512     // Append this object, so that the aspect ratio is maintained
    513     // (Paint-function is called)
    514     // Add it here so that root will have it first in the internal list:
    515     // This means, that root 'sees' the whole camera instead of all the
    516     // single hexagons.
    517     //
    518     AppendPad(option);
    519 
    520     //fDrawingPad->SetEditable(kFALSE);
    521 }
    522 
    523 void MCamDisplay::DrawPixelNumbers()
    524 {
    525     if (!fDrawingPad)
    526466        Draw();
    527 
    528     fDrawingPad->cd();
    529467
    530468    TText txt;
     
    545483// ------------------------------------------------------------------------
    546484//
    547 // Call this function to draw the number of photo electron into the
     485// Call this function to fill the number of photo electron into the
    548486// camera.
    549487//
    550 void MCamDisplay::DrawPhotNum(const MCerPhotEvt *event)
    551 {
    552     if (!event)
    553         return;
    554 
    555     Draw();
    556 
    557     fDrawingPad->cd();
    558 
    559     for (int i=0; i<kItemsLegend; i++)
    560         GetBox(i)->SetFillColor(fColors[i]);
    561 
     488void MCamDisplay::FillPhotNum(const MCerPhotEvt &event)
     489{
    562490    //
    563491    // Reset pixel colors to default value
     
    573501    if (fAutoScale)
    574502    {
    575         min = event->GetNumPhotonsMin(fGeomCam);
    576         max = event->GetNumPhotonsMax(fGeomCam);
    577 
    578         if (max < 20.)
    579             max = 20.;
     503        min = event.GetNumPhotonsMin(fGeomCam);
     504        max = event.GetNumPhotonsMax(fGeomCam);
     505
     506        if (max < 1.)
     507            max = 1.;
    580508
    581509        UpdateLegend(min, max);
     
    585513    //   update the colors in the picture
    586514    //
    587     const Int_t entries = event->GetNumPixels();
     515    const Int_t entries = event.GetNumPixels();
    588516
    589517    for (Int_t i=0; i<entries; i++)
    590518    {
    591         const MCerPhotPix &pix = (*event)[i];
     519        const MCerPhotPix &pix = event[i];
    592520
    593521        if (!pix.IsPixelUsed())
     
    596524        SetPixColor(pix, i, min, max);
    597525    }
    598 
    599     //
    600     // Update display physically
    601     //
    602     fDrawingPad->Modified();
    603     fDrawingPad->Update();
    604 }
    605 
    606 // ------------------------------------------------------------------------
    607 //
    608 // Call this function to draw the number of photo electron into the
     526}
     527
     528// ------------------------------------------------------------------------
     529//
     530// Call this function to fill the number of photo electron into the
    609531// camera.
    610532//
    611 void MCamDisplay::DrawPedestals(const MPedestalCam *event)
    612 {
    613     if (!event)
    614         return;
    615 
    616     Draw();
    617 
    618     fDrawingPad->cd();
    619 
    620     for (int i=0; i<kItemsLegend; i++)
    621         GetBox(i)->SetFillColor(fColors[i]);
    622 
     533void MCamDisplay::FillPedestals(const MPedestalCam &event)
     534{
    623535    //
    624536    // Reset pixel colors to default value
     
    634546    if (fAutoScale)
    635547    {
    636         min = event->GetMeanMin(fGeomCam);
    637         max = event->GetMeanMax(fGeomCam);
     548        min = event.GetMeanMin(fGeomCam);
     549        max = event.GetMeanMax(fGeomCam);
    638550
    639551        if (max < 20.)
     
    646558    //   update the colors in the picture
    647559    //
    648     const Int_t entries = event->GetSize();
     560    const Int_t entries = event.GetSize();
    649561
    650562    for (Int_t i=0; i<entries; i++)
    651         SetPixColorPedestal((*event)[i], i, min, max);
    652 
    653     //
    654     // Update display physically
    655     //
    656     fDrawingPad->Modified();
    657     fDrawingPad->Update();
    658 }
    659 
    660 // ------------------------------------------------------------------------
    661 //
    662 // Call this function to draw the error of number of photo electron
     563        SetPixColorPedestal(event[i], i, min, max);
     564}
     565
     566// ------------------------------------------------------------------------
     567//
     568// Call this function to fill the error of number of photo electron
    663569// into the camera.
    664570//
    665 void MCamDisplay::DrawErrorPhot(const MCerPhotEvt *event)
    666 {
    667     if (!event)
    668         return;
    669 
    670     if (!fDrawingPad)
    671         Draw();
    672 
    673     fDrawingPad->cd();
    674 
    675     for (int i=0; i<kItemsLegend; i++)
    676         GetBox(i)->SetFillColor(fColors[i]);
    677 
     571void MCamDisplay::FillErrorPhot(const MCerPhotEvt &event)
     572{
    678573    //
    679574    // Reset pixel colors to default value
     
    689584    if (fAutoScale)
    690585    {
    691         min = event->GetErrorPhotMin(fGeomCam);
    692         max = event->GetErrorPhotMax(fGeomCam);
     586        min = event.GetErrorPhotMin(fGeomCam);
     587        max = event.GetErrorPhotMax(fGeomCam);
    693588
    694589        if (max < 20.)
     
    701596    //   update the colors in the picture
    702597    //
    703     const Int_t entries = event->GetNumPixels();
     598    const Int_t entries = event.GetNumPixels();
    704599
    705600    for (Int_t i=0; i<entries; i++)
    706601    {
    707         const MCerPhotPix &pix = (*event)[i];
     602        const MCerPhotPix &pix = event[i];
    708603
    709604        if (!pix.IsPixelUsed())
     
    712607        SetPixColorError(pix, i, min, max);
    713608    }
    714 
    715     //
    716     // Update display physically
    717     //
    718     fDrawingPad->Modified();
    719     fDrawingPad->Update();
    720 }
    721 
    722 // ------------------------------------------------------------------------
    723 //
    724 // Call this function to draw the ratio of the number of photons
     609}
     610
     611// ------------------------------------------------------------------------
     612//
     613// Call this function to fill the ratio of the number of photons
    725614// divided by its error
    726615//
    727 void MCamDisplay::DrawRatio(const MCerPhotEvt *event)
    728 {
    729     if (!event)
    730         return;
    731 
    732     if (!fDrawingPad)
    733         Draw();
    734 
    735     fDrawingPad->cd();
    736 
    737     for (int i=0; i<kItemsLegend; i++)
    738         GetBox(i)->SetFillColor(fColors[i]);
    739 
     616void MCamDisplay::FillRatio(const MCerPhotEvt &event)
     617{
    740618    //
    741619    // Reset pixel colors to default value
     
    751629    if (fAutoScale)
    752630    {
    753         min = event->GetRatioMin();
    754         max = event->GetRatioMax();
     631        min = event.GetRatioMin();
     632        max = event.GetRatioMax();
    755633
    756634        UpdateLegend(min, max);
     
    760638    //   update the colors in the picture
    761639    //
    762     const Int_t entries = event->GetNumPixels();
     640    const Int_t entries = event.GetNumPixels();
    763641
    764642    for (Int_t i=0; i<entries; i++)
    765643    {
    766         const MCerPhotPix &pix = (*event)[i];
     644        const MCerPhotPix &pix = event[i];
    767645
    768646        if (!pix.IsPixelUsed())
     
    771649        SetPixColorRatio(pix, min, max);
    772650    }
    773 
    774     //
    775     // Update display physically
    776     //
    777     fDrawingPad->Modified();
    778     fDrawingPad->Update();
    779 }
    780 
    781 // ------------------------------------------------------------------------
    782 //
    783 // Draw the colors in respect to the cleaning levels
    784 //
    785 void MCamDisplay::DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2)
    786 {
    787     if (!event)
    788         return;
    789 
    790     if (!fDrawingPad)
    791         Draw();
    792 
    793     fDrawingPad->cd();
    794 
    795     for (int i=0; i<kItemsLegend; i++)
    796         GetBox(i)->SetFillColor(fColors[i]);
    797 
     651}
     652
     653// ------------------------------------------------------------------------
     654//
     655// Fill the colors in respect to the cleaning levels
     656//
     657void MCamDisplay::FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2)
     658{
    798659    //
    799660    // Reset pixel colors to default value
     
    804665    //   update the colors in the picture
    805666    //
    806     const Int_t entries = event->GetNumPixels();
     667    const Int_t entries = event.GetNumPixels();
    807668
    808669    for (Int_t i=0; i<entries; i++)
    809670    {
    810         const MCerPhotPix &pix = (*event)[i];
     671        const MCerPhotPix &pix = event[i];
    811672
    812673        if (!pix.IsPixelUsed())
     
    815676        SetPixColorLevel(pix, lvl1, lvl2);
    816677    }
    817 
    818     //
    819     // Update display physically
    820     //
    821     fDrawingPad->Modified();
    822     fDrawingPad->Update();
    823 }
    824 
    825 // ------------------------------------------------------------------------
    826 //
    827 // Draw the colors in respect to the cleaning levels
    828 //
    829 void MCamDisplay::DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean)
    830 {
    831     DrawLevels(event, clean.GetCleanLvl1(), clean.GetCleanLvl2());
    832 }
    833 
    834 // ------------------------------------------------------------------------
    835 //
    836 // reset the all pixel colors to a default value
     678}
     679
     680// ------------------------------------------------------------------------
     681//
     682// Fill the colors in respect to the cleaning levels
     683//
     684void MCamDisplay::FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean)
     685{
     686    FillLevels(event, clean.GetCleanLvl1(), clean.GetCleanLvl2());
     687}
     688
     689// ------------------------------------------------------------------------
     690//
     691// Reset the all pixel colors to a default value
    837692//
    838693void MCamDisplay::Reset()
     
    844699// ------------------------------------------------------------------------
    845700//
    846 //   Here we calculate the color index for the current value.
    847 //   The color index is defined with the class TStyle and the
    848 //   Color palette inside. We use the command gStyle->SetPalette(1,0)
    849 //   for the display. So we have to convert the value "wert" into
    850 //   a color index that fits the color palette.
    851 //   The range of the color palette is defined by the values fMinPhe
    852 //   and fMaxRange. Between this values we have 50 color index, starting
    853 //   with 0 up to 49.
     701//  Here we calculate the color index for the current value.
     702//  The color index is defined with the class TStyle and the
     703//  Color palette inside. We use the command gStyle->SetPalette(1,0)
     704//  for the display. So we have to convert the value "wert" into
     705//  a color index that fits the color palette.
     706//  The range of the color palette is defined by the values fMinPhe
     707//  and fMaxRange. Between this values we have 50 color index, starting
     708//  with 0 up to 49.
    854709//
    855710Int_t MCamDisplay::GetColor(Float_t val, Float_t min, Float_t max)
     
    877732// ------------------------------------------------------------------------
    878733//
    879 //    change the text on the legend according to the range of the
    880 //    Display
     734//  Change the text on the legend according to the range of the Display
    881735//
    882736void MCamDisplay::UpdateLegend(Float_t minphe, Float_t maxphe)
    883737{
    884     char text[10];
    885 
    886738    for (Int_t i=0; i<kItemsLegend; i+=3)
    887739    {
    888740        const Float_t val = minphe + (Float_t)i/kItemsLegend * (maxphe-minphe) ;
    889741
    890         sprintf(text, "%5.1f", val);
    891 
    892742        TText &txt = *GetText(i);
    893 
    894         txt.SetText(txt.GetX(), txt.GetY(), text);
     743        txt.SetText(txt.GetX(), txt.GetY(), Form("%5.1f", val));
    895744    }
    896745}
     
    902751void MCamDisplay::SavePrimitive(ofstream &out, Option_t *opt)
    903752{
     753    cout << "MCamDisplay::SavePrimitive: Must be rewritten!" << endl;
     754    /*
    904755    if (!gROOT->ClassSaved(TCanvas::Class()))
    905756        fDrawingPad->SavePrimitive(out, opt);
     
    907758    out << "   " << fDrawingPad->GetName() << "->SetWindowSize(";
    908759    out << fDrawingPad->GetWw() << "," << fDrawingPad->GetWh() << ");" << endl;
     760    */
    909761}
    910762
     
    951803{
    952804    (*this)[pixnum].SetFillColor(GetColor(color, min, max));
    953 
    954 }
     805}
     806
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.h

    r1904 r1965  
    1212class TText;
    1313class TArrow;
    14 class TVirtualPad;
    1514
    1615class MGeomCam;
     
    4645    UInt_t         fW;           // Width of canvas
    4746    UInt_t         fH;           // Height of canvas
    48     TVirtualPad   *fDrawingPad;  // pad in which we are drawing
    49     Bool_t         fIsAllocated;
    5047
    5148    TBox  *GetBox(Int_t i)  { return (TBox*) fLegend->At(i); }
     
    6259
    6360    void UpdateLegend(Float_t min, Float_t max);
    64     void Paint(Option_t *option="");
     61    void SetRange();
     62    void SetPalette();
    6563
    6664public:
     65    MCamDisplay();
    6766    MCamDisplay(MGeomCam *geom);
    6867    ~MCamDisplay();
    6968
    7069    void SetAutoScale(Bool_t input=kTRUE) { fAutoScale = input; }
    71     void DrawPhotNum(const MCerPhotEvt *event);
    72     void DrawRatio(const MCerPhotEvt *event);
    73     void DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2);
    74     void DrawErrorPhot(const MCerPhotEvt *event);
    75     void DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean);
    76     void DrawPedestals(const MPedestalCam *event);
     70    void FillPhotNum(const MCerPhotEvt &event);
     71    void FillRatio(const MCerPhotEvt &event);
     72    void FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2);
     73    void FillErrorPhot(const MCerPhotEvt &event);
     74    void FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean);
     75    void FillPedestals(const MPedestalCam &event);
    7776
    7877    void DrawPixelNumbers();
    7978
    80     virtual void  Reset();
    81     virtual void  Draw(Option_t *option="");
    82     virtual void  SavePrimitive(ofstream &out, Option_t *);
    83     virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
     79    void     Paint(Option_t *option="");
     80    void     Reset();
     81    void     Draw(Option_t *option="");
     82    void     SavePrimitive(ofstream &out, Option_t *);
     83    Int_t    DistancetoPrimitive(Int_t px, Int_t py);
    8484    //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
    8585
  • trunk/MagicSoft/Mars/mgui/MHexagon.cc

    r1880 r1965  
    224224void MHexagon::PaintHexagon(Float_t inX, Float_t inY, Float_t inD)
    225225{
    226 
    227226    const Int_t np = 6;
    228227
     
    230229    const Float_t dy[np+1] = { .2886,  .5772,  .2886, -.2886, -.5772, -.2886, .2886 };
    231230
    232     static Float_t x[np+1], y[np+1];
    233 
    234231    TAttLine::Modify();    // Change line attributes only if neccessary
    235232    TAttFill::Modify();    // Change fill attributes only if neccessary
    236233
     234    //
    237235    //  calculate the positions of the pixel corners
    238 
    239     for (Int_t i=0; i<=np; i++)
     236    //
     237    Float_t x[np+1], y[np+1];
     238    for (Int_t i=0; i<np+1; i++)
    240239    {
    241         x[i] = inX + dx[i]* inD;
    242         y[i] = inY + dy[i]* inD;
     240        x[i] = inX + dx[i]*inD;
     241        y[i] = inY + dy[i]*inD;
    243242    }
    244243
    245     //   paint the pixel (hopefully)
    246 
     244    //
     245    //   paint the pixel
     246    //
    247247    if (GetFillColor())
    248248        gPad->PaintFillArea(np, x, y);
     
    250250    if (GetLineStyle())
    251251        gPad->PaintPolyLine(np+1, x, y);
    252 
    253252}
    254253
  • trunk/MagicSoft/Mars/mgui/Makefile

    r1946 r1965  
    2222#  connect the include files defined in the config.mk file
    2323#
    24 INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage
     24INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage -I../mhist
    2525
    2626#------------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r1715 r1965  
    7272
    7373#include <TClass.h>
     74#include <TCanvas.h>
    7475
    7576#include "MDataChain.h"
     
    8283
    8384#include "MParList.h"
     85#include "MStatusDisplay.h"
    8486
    8587ClassImp(MFillH);
     
    99101
    100102    fIndex  = NULL;
     103    fCanvas = NULL;
    101104}
    102105
     
    143146
    144147    fTitle = "Fill " + fHName;
    145     if (!par)
     148    if (fParContainerName.IsNull())
    146149        return;
    147150
     
    313316}
    314317
     318Bool_t MFillH::DrawToDisplay()
     319{
     320    if (!fDisplay)
     321        return kTRUE;
     322
     323    fCanvas = &fDisplay->AddTab(fH->GetName());
     324    fH->Draw();
     325
     326    return kTRUE;
     327}
     328
    315329// --------------------------------------------------------------------------
    316330//
     
    353367        if (!obj)
    354368        {
     369            /*
    355370            if (cls==name)
    356                 *fLog << inf << "Object '" << fHName << "' not found in parlist... creating." << endl;
     371            *fLog << inf << "Object '" << fHName << "' not found in parlist... creating." << endl;
     372            */
    357373            obj = pList->FindCreateObj(cls, name);
    358374        }
     
    369385        if (!obj->InheritsFrom(tcls))
    370386        {
    371             *fLog << err << dbginf << obj->GetName() << " doesn't inherit ";
     387            *fLog << err << obj->GetName() << " doesn't inherit ";
    372388            *fLog << "from " << tcls->GetName() << " - cannot be used for MFillH...";
    373389            *fLog << "aborting." << endl;
     
    383399    if (!fH->SetupFill(pList))
    384400    {
    385         *fLog << err << dbginf << "Error: calling SetupFill for ";
     401        *fLog << err << "ERROR - Calling SetupFill for ";
    386402        *fLog << fH->GetDescriptor() << "... aborting." << endl;
    387403        return kFALSE;
     
    392408    //
    393409    if (fParContainer)
    394         return kTRUE;
    395 
    396     //
    397     // If a name is given try to find the input container in the
    398     // list. If it could not be found we cannot proceed.
     410        return DrawToDisplay();
     411
     412    //
     413    // This case means, that the MH sets up its container to be filled
     414    // by itself. Check there if it has something to be filled with!
    399415    //
    400416    if (fParContainerName.IsNull())
    401417    {
    402         fParContainer = NULL; 
    403         return kTRUE;
     418        fParContainer = NULL;
     419        return DrawToDisplay();
    404420    }
    405421
    406422    fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
    407 
    408423    if (fParContainer)
    409         return kTRUE;
    410 
    411     *fLog << err << dbginf << "'" << fParContainerName << "' [MParContainer] not found... aborting." << endl;
     424        return DrawToDisplay();
     425
     426    *fLog << err << fParContainerName << " [MParContainer] not found... aborting." << endl;
    412427    return kFALSE;
    413428}
     
    443458    if (!fH->Finalize())
    444459    {
    445         *fLog << err << dbginf << "Error: calling Finalize for ";
     460        *fLog << err << "ERROR - Calling Finalize for ";
    446461        *fLog << fH->GetDescriptor() << "... aborting." << endl;
    447462        return kFALSE;
     
    449464
    450465    fH->SetReadyToSave();
     466
     467    if (fDisplay)
     468    {
     469        fCanvas->cd();
     470        fH->DrawClone("nonew");
     471    }
     472
    451473    return kTRUE;
    452474}
  • trunk/MagicSoft/Mars/mhist/MFillH.h

    r1574 r1965  
    77
    88class MH;
     9class MMap;
    910class MData;
    1011class MParList;
    1112
    12 class MMap;
     13class TCanvas;
    1314
    1415class MFillH : public MTask
     
    2425    MMap  *fMapIdx;   //! Map to map key-index-pair for an MHArray (MMap see MFillH.cc)
    2526
     27    TCanvas *fCanvas;
     28
    2629    TString ExtractName(const char *name) const;
    2730    TString ExtractClass(const char *name) const;
     
    3033
    3134    void StreamPrimitive(ofstream &out) const;
     35
     36    Bool_t DrawToDisplay();
    3237
    3338public:
  • trunk/MagicSoft/Mars/mhist/MH.cc

    r1880 r1965  
    585585    //
    586586    TH1 *h1 = (TH1*)((TH1&)hist1).DrawCopy();
     587    gPad->SetBorderMode(0);
    587588    gPad->Update();
    588589
     
    653654    //
    654655    hist1.Draw();
     656    gPad->SetBorderMode(0);
    655657    gPad->Update();
    656658
     
    710712}
    711713
     714// --------------------------------------------------------------------------
     715//
     716// If the opt string contains 'nonew' or gPad is not given NULL is returned.
     717// Other wise the present gPad is cleared and returned.
     718//
     719TVirtualPad *MH::GetNewPad(Option_t *opt)
     720{
     721    TString str(opt);
     722
     723    if (!str.Contains("nonew", TString::kIgnoreCase) || !gPad)
     724        return NULL;
     725
     726    gPad->Clear();
     727    return gPad;
     728}
     729
     730// --------------------------------------------------------------------------
     731//
     732// The object is cloned and drawn to the present pad. The kCanDelete
     733// bit is set for the clone.
     734//
     735TObject *MH::DrawClone(Option_t *opt="") const
     736{
     737    gROOT->SetSelectedPad(NULL);
     738
     739    TObject *o = MParContainer::DrawClone(opt);
     740    o->SetBit(kCanDelete);
     741    return o;
     742}
     743
     744// --------------------------------------------------------------------------
     745//
     746// If the opt string contains 'nonew' or gPad is not given a new canvas
     747// with size w/h is created. Otherwise the object is cloned and drawn
     748// to the present pad. The kCanDelete bit is set for the clone.
     749//
     750TObject *MH::DrawClone(Option_t *opt, Int_t w, Int_t h) const
     751{
     752    TVirtualPad *p = GetNewPad(opt);
     753    if (!p)
     754        p = MakeDefCanvas(this, w, h);
     755
     756    return MH::DrawClone(opt);
     757}
  • trunk/MagicSoft/Mars/mhist/MH.h

    r1879 r1965  
    1515class MBinning;
    1616class MParList;
    17 
     17#include <iostream.h>
     18#include <TClass.h>
    1819class MH : public MParContainer
    1920{
     21private:
     22    /*
     23    void Draw(Option_t *opt="")
     24    {
     25        cout << "MH::Draw" << endl;
     26        MParContainer::Draw(opt);
     27        }
     28        */
     29
    2030public:
    2131    MH(const char *name=NULL, const char *title=NULL);
     
    5969    static void Draw(TH1 &hist1, TH1 &hist2, const TString title);
    6070
     71    void Draw(Option_t *o="") { MParContainer::Draw(o); }
     72    TObject *DrawClone(Option_t *opt="") const;
     73    TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const;
     74
     75    static TVirtualPad *GetNewPad(Option_t *opt);
     76
    6177    static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
    6278    static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0);
     79
     80
    6381
    6482    ClassDef(MH, 1) //A histogram base class for Mars histograms
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r1838 r1965  
    600600MParContainer *MH3::New() const
    601601{
    602   cout << "1" <<endl;
    603602    MH3 *h = NULL;
    604   cout << "1a" <<endl;
    605 
    606   if (fData[0] == NULL)
    607     {
    608       h=new MH3(fDimension);
    609     }
    610   else
    611     switch (fDimension)
    612     {
    613     case 1:
    614         h=new MH3(fData[0]->GetRule());
    615         break;
    616     case 2:
    617         h=new MH3(fData[0]->GetRule(), fData[1]->GetRule());
    618         break;
    619     case 3:
    620         h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule());
    621         break;
    622     }
     603
     604    if (fData[0] == NULL)
     605        h=new MH3(fDimension);
     606    else
     607        switch (fDimension)
     608        {
     609        case 1:
     610            h=new MH3(fData[0]->GetRule());
     611            break;
     612        case 2:
     613            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule());
     614            break;
     615        case 3:
     616            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule());
     617            break;
     618        }
    623619    switch (fDimension)
    624620    {
  • trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc

    r1715 r1965  
    3030#include "MHCerPhotEvt.h"
    3131
     32#include <TCanvas.h>
     33
    3234#include "MLog.h"
    3335#include "MLogManip.h"
     
    3537#include "MParList.h"
    3638#include "MCerPhotEvt.h"
     39#include "MCamDisplay.h"
     40
     41#include "MGeomCam.h"
     42#include "MGeomPix.h"
    3743
    3844ClassImp(MHCerPhotEvt);
     
    4046// --------------------------------------------------------------------------
    4147//
    42 // Setup four histograms for Width, Length
    43 //
    44 MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
    45     : fEvt(NULL)
    46 {
    47     //
    48     //   set the name and title of this object
    49     //
    50     fName  = name  ? name  : "MHCerPhotEvt";
    51     fTitle = title ? title : "Sum up camera events";
    52 
     48// Reset all pixels to 0 and reset fEntries to 0.
     49//
     50void MHCerPhotEvt::Clear()
     51{
     52    fSum.Reset();
    5353    fSum.InitSize(577);
    5454    for (int i=0; i<577; i++)
     55    {
    5556        fSum.AddPixel(i, 0, 0);
     57        fSum[i].SetPixelUnused();
     58    }
     59
     60    fEntries = 0;
     61}
     62
     63// --------------------------------------------------------------------------
     64//
     65// Setup four histograms for Width, Length
     66//
     67MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
     68    : fEvt(NULL), fCam(NULL), fDispl(NULL)
     69{
     70    //
     71    //   set the name and title of this object
     72    //
     73    fName  = name  ? name  : "MHCerPhotEvt";
     74    fTitle = title ? title : "Average of MCerPhotEvts";
     75
     76    Clear();
     77}
     78
     79MHCerPhotEvt::~MHCerPhotEvt()
     80{
     81    if (fDispl)
     82        delete fDispl;
    5683}
    5784
     
    7299        *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
    73100
     101    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
     102    if (!fCam)
     103        *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
     104
     105    Clear();
     106
    74107    return kTRUE;
    75108}
     
    95128        const MCerPhotPix &pix = (*evt)[i];
    96129
    97         fSum[pix.GetPixId()].AddNumPhotons(pix.GetNumPhotons());
    98     }
     130        const Int_t id = pix.GetPixId();
     131
     132        const Double_t ratio = fCam ? fCam->GetPixRatio(id) : 1;
     133
     134        const Double_t val = pix.GetNumPhotons()/ratio;
     135
     136        fSum[id].SetPixelUsed();
     137        fSum[id].AddNumPhotons(val);
     138    }
     139
     140    fEntries++;
     141
    99142    return kTRUE;
    100143}
    101144
     145Bool_t MHCerPhotEvt::Finalize()
     146{
     147    fSum.Scale(fEntries);
     148    return kTRUE;
     149}
     150
     151TObject *MHCerPhotEvt::DrawClone(Option_t *opt) const
     152{
     153    return MH::DrawClone(opt, 750, 600);
     154}
     155
     156void MHCerPhotEvt::Draw(Option_t *)
     157{
     158    if (!fCam)
     159    {
     160        *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
     161        return;
     162    }
     163
     164    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
     165    pad->SetBorderMode(0);
     166
     167    //
     168    // All this is necessary to get the background in the correct color
     169    //
     170    pad->Divide(1,1);
     171    pad->cd(1);
     172
     173    gPad->SetBorderMode(0);
     174    gPad->SetFillColor(gPad->GetFillColor());
     175
     176    //
     177    // set the color palette for the TBox elements
     178    //
     179    AppendPad("");
     180
     181    //
     182    // Necessary to visualize the background color (FIXME?)
     183    //
     184    gPad->Modified();
     185    gPad->Update();
     186}
     187
     188void MHCerPhotEvt::Paint(Option_t *option="")
     189{
     190    if (!fCam)
     191    {
     192        *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
     193        return;
     194    }
     195
     196    if (!fDispl)
     197        fDispl = new MCamDisplay(fCam);
     198
     199    fDispl->FillPhotNum(fSum);
     200    fDispl->Paint();
     201}
  • trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h

    r1715 r1965  
    1111
    1212class TH1D;
     13class MGeamCam;
     14class MCamDisplay;
    1315
    1416class MHCerPhotEvt : public MH
     
    1618private:
    1719    MCerPhotEvt  fSum;
    18     MCerPhotEvt *fEvt; //!
     20    Int_t        fEntries;
     21    MCerPhotEvt *fEvt;   //!
     22    MGeomCam    *fCam;
     23    MCamDisplay *fDispl; //!
    1924
    2025public:
    2126    MHCerPhotEvt(const char *name=NULL, const char *title=NULL);
     27    ~MHCerPhotEvt();
     28
     29    //    TObject *Clone(const char *newname="") const;
     30
     31    void Clear();
    2232
    2333    Bool_t SetupFill(const MParList *pList);
    2434    Bool_t Fill(const MParContainer *par);
     35    Bool_t Finalize();
    2536
    2637    TH1 *GetHistByName(const TString name) { return NULL; }
     
    2839    const MCerPhotEvt &GetSum() const { return fSum; }
    2940
    30     ClassDef(MHCerPhotEvt, 1) // Container which holds histograms for the source independent image parameters
     41    TObject *DrawClone(Option_t *opt) const;
     42    void Draw(Option_t *);
     43    void Paint(Option_t *option="");
     44
     45    ClassDef(MHCerPhotEvt, 1) // Histogram to sum camera events
    3146};
    3247
  • trunk/MagicSoft/Mars/mhist/MHStarMap.cc

    r1956 r1965  
    6868    fTitle = title ? title : "Container for a Star Map" ;
    6969
    70     *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl;
    71 
    7270    //
    7371    //   loop over all Pixels and create two histograms
     
    137135        return kTRUE;
    138136    }
     137
     138    *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl;
    139139
    140140    return kTRUE;
     
    293293}
    294294
    295 
    296295// --------------------------------------------------------------------------
    297296//
     
    304303TObject *MHStarMap::DrawClone(Option_t *opt) const
    305304{
    306     TCanvas *c=MakeDefCanvas(fStarMap, 500, 500);
    307 
    308     //
    309     // This is necessary to get the expected bahviour of DrawClone
    310     //
    311     gROOT->SetSelectedPad(NULL);
    312 
    313     PrepareDrawing();
    314 
    315     fStarMap->DrawCopy("colz");
    316 
    317     c->Modified();
    318     c->Update();
    319 
    320     return c;
     305    return MH::DrawClone(opt, 500, 500);
    321306}
    322307
     
    329314void MHStarMap::Draw(Option_t *)
    330315{
    331     if (!gPad)
    332         MakeDefCanvas(fStarMap, 500, 500);
    333 
     316    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 500, 500);
     317    pad->SetBorderMode(0);
     318
     319    pad->Divide(1,1);
     320
     321    pad->cd(1);
     322    gPad->SetBorderMode(0);
     323
     324    AppendPad("");
     325}
     326
     327void MHStarMap::Paint(Option_t *opt="")
     328{
     329    //
     330    // Maintain aspect ratio
     331    //
     332    const float w = gPad->GetWw();
     333    const float h = gPad->GetWh();
     334
     335    if (h<w)
     336        gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 1);
     337    else
     338        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2);
     339
     340    //
     341    // Maintain colors
     342    //
    334343    PrepareDrawing();
    335344
    336     fStarMap->Draw("colz");
    337 
    338     gPad->Modified();
    339     gPad->Update();
    340 }
     345    //
     346    // Paint Histogram
     347    //
     348    fStarMap->Paint("colz");
     349}
  • trunk/MagicSoft/Mars/mhist/MHStarMap.h

    r1574 r1965  
    1515{
    1616private:
    17     TH2F *fStarMap;
     17    TH2F *fStarMap; //->
    1818
    1919    Float_t fMm2Deg;
     
    2222
    2323    void PrepareDrawing() const;
     24
     25    void Paint(Option_t *opt="");
    2426
    2527public:
  • trunk/MagicSoft/Mars/mhist/Makefile

    r1940 r1965  
    2323#
    2424INCLUDES = -I. -I../mbase -I../mraw -I../manalysis -I../mmc \
    25            -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage
     25           -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \
     26           -I../mmain
    2627
    2728#------------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mimage/MHHillas.cc

    r1940 r1965  
    3131//
    3232/////////////////////////////////////////////////////////////////////////////
    33 
    3433#include "MHHillas.h"
    3534
     
    110109    fSize->GetXaxis()->SetTitleOffset(1.2);
    111110    fSize->GetXaxis()->SetLabelOffset(-0.015);
     111    fSize->SetFillStyle(4000);
    112112
    113113    bins.Apply(*fSize);
     
    280280void MHHillas::SetColors() const
    281281{
    282     // FIXME: This must be redone each time the canvas is repainted....
    283282    gStyle->SetPalette(51, NULL);
    284283    Int_t c[50];
     
    298297TObject *MHHillas::DrawClone(Option_t *opt) const
    299298{
    300     TCanvas *c = MakeDefCanvas(this, 720, 810);
    301     c->Divide(2,3);
    302 
    303     gROOT->SetSelectedPad(NULL);
    304 
    305     c->cd(1);
    306     DrawCopy(*fWidth, *fLength, "Width / Length");
    307 
    308     c->cd(2);
    309     gPad->SetLogx();
    310     fSize->DrawCopy();
    311 
    312     c->cd(3);
    313     DrawCopy(*fCorePix, *fUsedPix, "Number of core/used Pixels");
    314 
    315     c->cd(4);
    316     fDelta->DrawCopy();
    317 
    318     c->cd(5);
    319     fDistC->DrawCopy();
    320 
    321     c->cd(6);
    322     SetColors();
    323     fCenter->DrawCopy("colz");
    324 
    325     c->Modified();
    326     c->Update();
    327 
    328     return c;
     299    return MH::DrawClone(opt, 720, 810);
    329300}
    330301
     
    337308void MHHillas::Draw(Option_t *)
    338309{
    339     if (!gPad)
    340         MakeDefCanvas(this, 720, 810);
    341 
    342     gPad->Divide(2,3);
    343 
    344     gPad->cd(1);
    345     MH::Draw(*fWidth, *fLength, "Width / Length");
    346 
    347     gPad->cd(2);
     310    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 720, 810);
     311    pad->SetBorderMode(0);
     312
     313    AppendPad("");
     314
     315    pad->Divide(2,3);
     316
     317    pad->cd(1);
     318    MH::Draw(*fWidth, *fLength, "Width'n'Length");
     319
     320    pad->cd(2);
     321    gPad->SetBorderMode(0);
    348322    gPad->SetLogx();
    349323    fSize->Draw();
    350324
    351     gPad->cd(3);
     325    pad->cd(3);
     326    gPad->SetBorderMode(0);
    352327    MH::Draw(*fCorePix, *fUsedPix, "Number of core/used Pixels");
    353328
    354     gPad->cd(4);
     329    pad->cd(4);
     330    gPad->SetBorderMode(0);
    355331    fDelta->Draw();
    356332
    357     gPad->cd(5);
     333    pad->cd(5);
     334    gPad->SetBorderMode(0);
    358335    fDistC->Draw();
    359336
    360     gPad->cd(6);
     337    pad->cd(6);
     338    gPad->SetBorderMode(0);
    361339    SetColors();
    362340    fCenter->Draw("colz");
    363341
    364     gPad->Modified();
    365     gPad->Update();
     342    pad->Modified();
     343    pad->Update();
    366344}
    367345
     
    387365    return NULL;
    388366}
     367
     368void MHHillas::Paint(Option_t *opt="")
     369{
     370    SetColors();
     371    MH::Paint();
     372}
  • trunk/MagicSoft/Mars/mimage/MHHillas.h

    r1940 r1965  
    1414private:
    1515
    16     TH1F *fLength; //->
    17     TH1F *fWidth;  //->
     16    TH1F *fLength;  //-> Length
     17    TH1F *fWidth;   //-> Width
    1818
    19     TH1F *fDistC;  //->
    20     TH1F *fDelta;  //->
     19    TH1F *fDistC;   //-> Distance to Camera Center
     20    TH1F *fDelta;   //-> Angle between Length axis and x-axis
    2121
    22     TH1F *fSize;   //->
    23     TH2F *fCenter; //->
     22    TH1F *fSize;    //-> Sum of used pixels
     23    TH2F *fCenter;  //-> Center
    2424
    25     TH1F *fUsedPix; //->
    26     TH1F *fCorePix; //->
     25    TH1F *fUsedPix; //-> Number of used pixels
     26    TH1F *fCorePix; //-> Number of core pixels
    2727
    2828    void SetColors() const;
     
    3030    Float_t fMm2Deg;
    3131    Bool_t  fUseMmScale;
     32
     33    void Paint(Option_t *opt="");
    3234
    3335public:
     
    5557    TObject *DrawClone(Option_t *opt=NULL) const;
    5658
     59    //Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
     60
    5761    ClassDef(MHHillas, 1) // Container which holds histograms for the source independent image parameters
    5862};
  • trunk/MagicSoft/Mars/mimage/MHHillasExt.cc

    r1945 r1965  
    3030//
    3131/////////////////////////////////////////////////////////////////////////////
    32 
    3332#include "MHHillasExt.h"
    3433
     
    5756// Setup four histograms for Width, Length
    5857//
    59 MHHillasExt::MHHillasExt(const char *name, const char *title,
    60                          const char *hil)
    61     : fMm2Deg(1), fUseMmScale(kTRUE)
     58MHHillasExt::MHHillasExt(const char *name, const char *title)
     59    : fMm2Deg(1), fUseMmScale(kTRUE), fHilName("MHillas")
    6260{
    6361    //
     
    6664    fName  = name  ? name  : "MHHillasExt";
    6765    fTitle = title ? title : "Container for extended Hillas histograms";
    68 
    69     fHilName = hil;
    70     //*fLog << "MHHillasExt : fHilName = " << fHilName << endl;
    7166
    7267    //
     
    108103    fHM3Trans.SetYTitle("Counts");
    109104
     105    fHConc.SetFillStyle(4000);
     106    fHConc1.SetFillStyle(4000);
     107    fHAsym.SetFillStyle(4000);
     108    fHM3Long.SetFillStyle(4000);
     109    fHM3Trans.SetFillStyle(4000);
    110110
    111111    MBinning bins;
     
    121121    bins.SetEdges(101, -593, 593);
    122122    bins.Apply(fHAsym);
    123 }
    124 
    125 // --------------------------------------------------------------------------
    126 //
    127 // Delete the four histograms
    128 //
    129 MHHillasExt::~MHHillasExt()
    130 {
    131123}
    132124
     
    143135Bool_t MHHillasExt::SetupFill(const MParList *plist)
    144136{
    145     TObject *obj = plist->FindObject(fHilName, "MHillas");
    146     if (!obj)
    147     {
    148       *fLog << err << dbginf << "Sorry '" << fHilName
    149             << "' not found in parameter list... aborting." << endl;
     137    fHillasExt = (MHillasExt*)plist->FindObject(fHilName, "MHillasExt");
     138    if (!fHillasExt)
     139    {
     140        *fLog << err << fHilName << "[MHillasExt] not found in parameter list... aborting." << endl;
    150141        return kFALSE;
    151142    }
    152     if (!obj->InheritsFrom(MHillasExt::Class()))
    153     {
    154         *fLog << err << dbginf << "Sorry 'MHillas' doesn't inherit from MHillasExt... aborting." << endl;
    155         return kFALSE;
    156     }
    157     fHillasExt = (MHillasExt*)obj;
    158143
    159144    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     
    184169    const MHillasSrc *src = (MHillasSrc*)par;
    185170
    186     const Double_t scale = TMath::Sign(fUseMmScale?1:fMm2Deg, src ? src->GetCosDeltaAlpha() : 1);
     171    const Double_t scale = TMath::Sign(fUseMmScale?1:fMm2Deg, (src ? src->GetCosDeltaAlpha() : 1));
    187172
    188173    fHConc.Fill(fHillasExt->GetConc());
     
    266251TObject *MHHillasExt::DrawClone(Option_t *opt) const
    267252{
    268     TCanvas &c = *MakeDefCanvas(this, 720, 540);
    269     c.Divide(2, 2);
    270 
    271     gROOT->SetSelectedPad(NULL);
    272 
    273     c.cd(1);
    274     DrawCopy(fHConc1, fHConc, "Concentrations");
    275 
    276     c.cd(2);
    277     ((TH1&)fHAsym).DrawCopy();
    278 
    279     c.cd(3);
    280     ((TH1&)fHM3Long).DrawCopy();
    281 
    282     c.cd(4);
    283     ((TH1&)fHM3Trans).DrawCopy();
    284 
    285     c.Modified();
    286     c.Update();
    287 
    288     return &c;
     253    return MH::DrawClone(opt, 720, 540);
    289254}
    290255
     
    297262void MHHillasExt::Draw(Option_t *)
    298263{
    299     if (!gPad)
    300         MakeDefCanvas(this, 720, 540);
    301 
    302     gPad->Divide(2, 2);
    303 
    304     gPad->cd(1);
     264    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 720, 540);
     265    pad->SetBorderMode(0);
     266
     267    AppendPad("");
     268
     269    pad->Divide(2, 2);
     270
     271    pad->cd(1);
     272    gPad->SetBorderMode(0);
    305273    MH::Draw(fHConc1, fHConc, "Concentrations");
    306274
    307     gPad->cd(2);
     275    pad->cd(2);
     276    gPad->SetBorderMode(0);
    308277    fHAsym.Draw();
    309278
    310     gPad->cd(3);
     279    pad->cd(3);
     280    gPad->SetBorderMode(0);
    311281    fHM3Long.Draw();
    312282
    313     gPad->cd(4);
     283    pad->cd(4);
     284    gPad->SetBorderMode(0);
    314285    fHM3Trans.Draw();
    315286
    316     gPad->Modified();
    317     gPad->Update();
     287    pad->Modified();
     288    pad->Update();
    318289}
    319290
  • trunk/MagicSoft/Mars/mimage/MHHillasExt.h

    r1940 r1965  
    2828
    2929public:
    30     //MHHillasExt(const char *name=NULL, const char *title=NULL);
    31     MHHillasExt(const char *name=NULL, const char *title=NULL,
    32                 const char *hil="MHillas");
     30    MHHillasExt(const char *name=NULL, const char *title=NULL);
    3331
    34     ~MHHillasExt();
     32    void SetHillasName(const char *name) { fHilName = name; }
    3533
    3634    void SetMmScale(Bool_t mmscale=kTRUE);
  • trunk/MagicSoft/Mars/mimage/MHHillasSrc.cc

    r1940 r1965  
    211211TObject *MHHillasSrc::DrawClone(Option_t *opt) const
    212212{
    213     TCanvas *c = MakeDefCanvas(this, 700, 500);
    214     c->Divide(2, 2);
    215 
    216     // FIXME: Display Source position
    217 
    218     gROOT->SetSelectedPad(NULL);
    219 
    220     //
    221     // This is necessary to get the expected bahviour of DrawClone
    222     //
    223     c->cd(1);
    224     fAlpha->DrawCopy();
    225 
    226     c->cd(2);
    227     fDist->DrawCopy();
    228 
    229     c->cd(3);
    230     fHeadTail->DrawCopy();
    231 
    232     c->cd(4);
    233     gPad->SetLogy();
    234     fCosDA->DrawCopy();
    235 
    236     c->Modified();
    237     c->Update();
    238 
    239     return c;
     213    return MH::DrawClone(opt, 700, 500);
    240214}
    241215
     
    248222void MHHillasSrc::Draw(Option_t *)
    249223{
    250     if (!gPad)
    251         MakeDefCanvas(this, 700, 500);
     224    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 700, 500);
     225    pad->SetBorderMode(0);
     226
     227    AppendPad("");
    252228
    253229    // FIXME: Display Source position
    254230
    255     gPad->Divide(2, 2);
    256 
    257     gPad->cd(1);
     231    pad->Divide(2, 2);
     232
     233    pad->cd(1);
     234    gPad->SetBorderMode(0);
    258235    fAlpha->Draw();
    259236
    260     gPad->cd(2);
     237    pad->cd(2);
     238    gPad->SetBorderMode(0);
    261239    fDist->Draw();
    262240
    263     gPad->cd(1);
     241    pad->cd(3);
     242    gPad->SetBorderMode(0);
    264243    fHeadTail->Draw();
    265244
    266     gPad->cd(2);
     245    pad->cd(4);
     246    gPad->SetBorderMode(0);
    267247    gPad->SetLogy();
    268248    fCosDA->Draw();
    269249
    270     gPad->Modified();
    271     gPad->Update();
     250    pad->Modified();
     251    pad->Update();
    272252}
    273253
  • trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc

    r1940 r1965  
    188188TObject *MHNewImagePar::DrawClone(Option_t *opt) const
    189189{
    190     TCanvas *c = MakeDefCanvas(this, 300, 600);
    191     c->Divide(1, 2);
    192 
    193     gROOT->SetSelectedPad(NULL);
    194 
    195     c->cd(1);
    196     fLeakage1->DrawCopy();
    197 
    198     c->cd(2);
    199     fLeakage2->DrawCopy();
    200 
    201     c->Modified();
    202     c->Update();
    203 
    204     return c;
     190    return MH::DrawClone(opt, 300, 600);
    205191}
    206192
     
    213199void MHNewImagePar::Draw(Option_t *)
    214200{
    215     if (!gPad)
    216         MakeDefCanvas(this, 300, 600);
    217 
    218     gPad->Divide(2, 2);
    219 
    220     gPad->cd(1);
     201    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 300, 600);
     202    pad->SetBorderMode(0);
     203
     204    AppendPad("");
     205
     206    pad->Divide(1, 2);
     207
     208    pad->cd(1);
     209    pad->SetBorderMode(0);
    221210    fLeakage1->Draw();
    222211
    223     gPad->cd(2);
     212    pad->cd(2);
     213    pad->SetBorderMode(0);
    224214    fLeakage2->Draw();
    225215
    226     gPad->Modified();
    227     gPad->Update();
     216    pad->Modified();
     217    pad->Update();
    228218}
    229219
  • trunk/MagicSoft/Mars/mimage/MHillasCalc.cc

    r1940 r1965  
    5757{
    5858    fName  = name  ? name  : "MHillasCalc";
    59     fTitle = title ? title : "Task to calculate Hillas parameters";
     59    fTitle = title ? title : "Calculate Hillas parameters";
    6060
    6161    fHilName = hil;
  • trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc

    r1940 r1965  
    6969
    7070static const TString gsDefName  = "MImgCleanStd";
    71 static const TString gsDefTitle = "Task to perform a standard image cleaning";
     71static const TString gsDefTitle = "Perform standard image cleaning";
    7272
    7373// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mmain/MProgressBar.cc

    r1540 r1965  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  9/2002 <mailto:tbretz@astro-uni-wuerzburg.de>
     18!   Author(s): Thomas Bretz, 9/2002 <mailto:tbretz@astro-uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2002
     20!   Copyright: MAGIC Software Development, 2000-2003
    2121!
    2222!
     
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // MHillasSrc
     27// MProgressBar
     28//
     29// Simple window with progress bar. Can be used in an eventloop.
    2830//
    2931/////////////////////////////////////////////////////////////////////////////
  • trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc

    r1957 r1965  
    2727// MStatusDisplay
    2828//
    29 //  upon an idea of Robert Wagner
     29// This status display can be used (and is used) to display results in
     30// a tabbed window. The window can be written to and read from a root file
     31// (see Read and Write) or printed as a postscript file (see SaveAsPS).
     32//
     33// It has also to half status lines which can be used to display the status
     34// or something going on. Together with the status lines it has a progress
     35// bar which can display the progress of a job or loop.
     36// Access the progress bar by GetProgressBar()
     37//
     38// To add a new tab and get a pointer to the newly created TCanvas
     39// use AddTab.
     40//
     41// If you have a MStatusDisplay and you are not sure whether it was
     42// destroyed by the user meanwhile use:
     43//   gROOT->GetListOfSpecials()->FindObject(pointer);
     44// Each MStatusDisplay is added to list list by its constructor and
     45// removed from the list by the destructor.
     46//
     47// You can redirect an output to a MLog-logstream by calling SetLogStream().
     48// To disable redirction call SetLogStream(NULL)
     49//
     50// Because updates to the tabs are only done/displayed if a tab is active
     51// using the gui doesn't make things slower (<1%) if the first (legend
     52// tab) is displayed. This gives you the possibility to look into
     53// the current progress of a loop without loosing more time than the
     54// single update of the tab.
    3055//
    3156/////////////////////////////////////////////////////////////////////////////
     
    3459#include <iostream.h>
    3560
    36 #include <TCanvas.h>        // TCanvas
    37 #include <TSystem.h>        // gSystem
    38 
    39 #include <TGTab.h>          // TGTab
    40 #include <TGLabel.h>        // TGLabel
    41 #include <TGButton.h>       // TGPictureButton
    42 #include <TGProgressBar.h>  // TGHProgressBar
     61#include <TLine.h>                // TLine
     62#include <TText.h>                // TText
     63#include <TFile.h>                // gFile
     64#include <TFrame.h>               // TFrame
     65#include <TStyle.h>               // gStyle
     66#include <TCanvas.h>              // TCanvas
     67#include <TSystem.h>              // gSystem
     68#include <TDatime.h>              // TDatime
     69#include <TRandom.h>              // TRandom
     70#include <TObjArray.h>            // TObjArray
     71#include <TPostScript.h>          // TPostScript
     72
     73#include <TGTab.h>                // TGTab
     74#include <TGLabel.h>              // TGLabel
     75#include <TG3DLine.h>             // TGHorizontal3DLine
     76#include <TGButton.h>             // TGPictureButton
     77#include <TGListBox.h>            // TGListBox
     78#include <TGProgressBar.h>        // TGHProgressBar
    4379
    4480#include <TRootEmbeddedCanvas.h>  // TRootEmbeddedCanvas
    4581
    46 #include "MGList.h"
     82#include "MLog.h"                 // MLog
     83#include "MLogManip.h"            // inf, warn, err
     84
     85#include "MGList.h"               // MGList
     86#include "MGMenu.h"               // MGMenu, TGMenu
     87#include "MParContainer.h"        // MParContainer::GetDescriptor
    4788
    4889ClassImp(MStatusDisplay);
    4990
     91// --------------------------------------------------------------------------
     92//
     93// Add menu bar to the GUI
     94//
     95void MStatusDisplay::AddMenuBar()
     96{
     97    //
     98    // File Menu
     99    //
     100    MGPopupMenu *filemenu = new MGPopupMenu(gClient->GetRoot());
     101    // filemenu->AddEntry("S&ave [F2]", kFileSave);
     102    // filemenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs);
     103    filemenu->AddEntry("Save As status.&ps", kFileSaveAsPS);
     104    // filemenu->AddEntry("Save As status.&gif", kFileSaveAsGIF);
     105    // filemenu->AddEntry("Save As status.&C", kFileSaveAsC);
     106    filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot);
     107    filemenu->AddSeparator();
     108    filemenu->AddEntry("Print with &lpr", kFilePrint);
     109    filemenu->AddEntry("Set printer &name", kFilePrinterName);
     110    filemenu->AddSeparator();
     111    filemenu->AddEntry("E&xit", kFileExit);
     112    filemenu->Associate(this);
     113
     114    //
     115    // Tab Menu
     116    //
     117    MGPopupMenu *tabmenu = new MGPopupMenu(gClient->GetRoot());
     118    // tabmenu->AddEntry("S&ave [F2]", kFileSave);
     119    // tabmenu->AddEntry("Save &As... [Shift-F2]", kFileSaveAs);
     120    tabmenu->AddEntry("Save As tab-i.&ps", kTabSaveAsPS);
     121    // tabmenu->AddEntry("Save As tab-i.&gif", kTabSaveAsGIF);
     122    // tabmenu->AddEntry("Save As tab-i.&C", kTabSaveAsC);
     123    tabmenu->AddEntry("Save As tab-i.&root", kTabSaveAsRoot);
     124    tabmenu->AddSeparator();
     125    tabmenu->AddEntry("Print with &lpr", kFilePrint);
     126    tabmenu->AddSeparator();
     127    tabmenu->AddEntry("Next [&+]",     kTabNext);
     128    tabmenu->AddEntry("Previous [&-]", kTabPrevious);
     129    tabmenu->Associate(this);
     130
     131    //
     132    // Loop Menu
     133    //
     134    MGPopupMenu *loopmenu = new MGPopupMenu(gClient->GetRoot());
     135    loopmenu->AddEntry("&Stop", kLoopStop);
     136    loopmenu->Associate(this);
     137
     138    //
     139    // Menu Bar
     140    //
     141    MGMenuBar *menubar = new MGMenuBar(this, 1, 1, kHorizontalFrame);
     142    menubar->AddPopup("&File", filemenu, NULL);
     143    menubar->AddPopup("&Tab",  tabmenu,  NULL);
     144    menubar->AddPopup("&Loop", loopmenu, NULL);
     145    menubar->BindKeys(this);
     146    AddFrame(menubar);
     147
     148    //
     149    // Line below menu bar
     150    //
     151    TGLayoutHints *laylinesep  = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
     152    fList->Add(laylinesep);
     153
     154    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
     155    AddFrame(linesep, laylinesep);
     156
     157    //
     158    // Add everything to autodel list
     159    //
     160    fList->Add(filemenu);
     161    fList->Add(loopmenu);
     162    fList->Add(menubar);
     163    fList->Add(tabmenu);
     164    fList->Add(linesep);
     165}
     166
     167// --------------------------------------------------------------------------
     168//
     169// Add the title tab
     170//
     171void MStatusDisplay::AddMarsTab()
     172{
     173    // Create Tab1
     174    TGCompositeFrame *f = fTab->AddTab("-=MARS=-");
     175
     176    // Add MARS version
     177    TString txt = "Official Release: V";
     178    TGLabel *l = new TGLabel(f, txt+MARSVER);
     179    fList->Add(l);
     180
     181    TGLayoutHints *layb = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 10, 10);
     182    fList->Add(layb);
     183    f->AddFrame(l, layb);
     184
     185    // Add root version
     186    txt = "Using ROOT v";
     187    l = new TGLabel(f, txt+ROOTVER);
     188    fList->Add(l);
     189
     190    TGLayoutHints *lay = new TGLayoutHints(kLHintsCenterX|kLHintsTop);
     191    fList->Add(lay);
     192    f->AddFrame(l, lay);
     193
     194    // Add Mars logo picture
     195    const TGPicture *pic2 = fList->GetPicture("marslogo.xpm");
     196    if (pic2)
     197    {
     198        TGPictureButton *mars  = new TGPictureButton(f, pic2, kPicMars);
     199        fList->Add(mars);
     200        mars->Associate(this);
     201
     202        TGLayoutHints *lay2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 10, 10, 10, 10);
     203        fList->Add(lay2);
     204        f->AddFrame(mars, lay2);
     205    }
     206
     207    // Add date and time
     208    TDatime d;
     209    l = new TGLabel(f, d.AsString());
     210    fList->Add(l);
     211    f->AddFrame(l, lay);
     212
     213    // Add copyright notice
     214    l = new TGLabel(f, "(c) MAGIC Software Development, 2000-2003");
     215    fList->Add(l);
     216    f->AddFrame(l, layb);
     217}
     218
     219// --------------------------------------------------------------------------
     220//
     221// Adds the logbook tab to the GUI if it was not added previously.
     222//
     223// The logbook is updated four times a second only if the tab is visible.
     224//
     225// You can redirect an output to a MLog-logstream by calling SetLogStream().
     226// To disable redirction call SetLogStream(NULL)
     227//
     228void MStatusDisplay::SetLogStream(MLog *log)
     229{
     230    if (log && fLogBox==NULL)
     231    {
     232        fLogIdx = fTab->GetNumberOfTabs();
     233
     234        // Create Tab1
     235        TGCompositeFrame *f = fTab->AddTab("-Logbook-");
     236
     237        // Create TGListBox for logging contents
     238        fLogBox = new TGListBox(f, 1, 1);
     239        fLogBox->ChangeBackground(TGFrame::GetBlackPixel());
     240
     241        // Add List box to the tab
     242        TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY);//, 5, 6, 5);
     243        f->AddFrame(fLogBox, lay);
     244
     245        // layout and map tab
     246        Layout();
     247        MapSubwindows();
     248
     249        // make it visible
     250        gClient->ProcessEventsFor(fTab);
     251    }
     252
     253    if (log)
     254    {
     255        fLog = log;
     256
     257        log->SetOutputGui(fLogBox, kTRUE);
     258        log->DisableOutputDevice(MLog::eStdout);
     259        log->EnableOutputDevice(MLog::eGui);
     260
     261        fLogTimer.Start();
     262    }
     263    else
     264    {
     265        fLogTimer.Stop();
     266
     267        fLog->DisableOutputDevice(MLog::eGui);
     268        fLog->EnableOutputDevice(MLog::eStdout);
     269        fLog->SetOutputGui(NULL);
     270
     271        fLog = &gLog;
     272    }
     273}
     274
     275// --------------------------------------------------------------------------
     276//
     277// Add the Tabs and the predifined Tabs to the GUI
     278//
     279void MStatusDisplay::AddTabs()
     280{
     281    fTab = new TGTab(this, 300, 300);
     282
     283    AddMarsTab();
     284
     285    // Add fTab to Frame
     286    TGLayoutHints *laytabs = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY, 5, 6, 5);
     287    AddFrame(fTab, laytabs);
     288
     289    fList->Add(fTab);
     290    fList->Add(laytabs);
     291}
     292
     293// --------------------------------------------------------------------------
     294//
     295// Add the progress bar to the GUI
     296//
    50297void MStatusDisplay::AddProgressBar()
    51298{
    52     TGLayoutHints *laybar=new TGLayoutHints(kLHintsExpandX, 10,10,10,10);
     299    TGLayoutHints *laybar=new TGLayoutHints(kLHintsExpandX, 5, 6, 5, 5);
    53300    fList->Add(laybar);
    54301
     
    59306}
    60307
    61 enum {
    62     kPicMagic,
    63     kPicMars
    64 };
    65 
    66 void MStatusDisplay::AddTabs()
    67 {
    68     fTab = new TGTab(this, 300, 300);
    69 
    70     //
    71     // Create Tab1
    72     //
    73     TGCompositeFrame *f = fTab->AddTab("-=MARS=-");
    74 
    75     /*
    76     TGHorizontalFrame *hf = new TGHorizontalFrame(f, 1, 1);
    77 
    78     TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY, 10., 10., 10., 10.);
    79     fList->Add(lay);
    80     f->AddFrame(hf, lay);
    81 
    82     const TGPicture *pic1 = fList->GetPicture("magiclogo.xpm");
    83     if (pic1)
    84     {
    85         TGPictureButton *magic = new TGPictureButton(hf, pic1, kPicMagic);
    86         fList->Add(magic);
    87         magic->Associate(this);
    88 
    89         TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft|kLHintsTop,  10., 10., 20., 10.);
    90         fList->Add(lay1);
    91         hf->AddFrame(magic, lay1);
    92     }
    93     */
    94     const TGPicture *pic2 = fList->GetPicture("marslogo.xpm");
    95     if (pic2)
    96     {
    97         TGPictureButton *mars  = new TGPictureButton(f, pic2, kPicMars);
    98         fList->Add(mars);
    99         mars->Associate(this);
    100 
    101         TGLayoutHints *lay2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 10., 10., 10., 10.);
    102         fList->Add(lay2);
    103         f->AddFrame(mars, lay2);
    104     }
    105 
    106     //
    107     // Crete second gui elemet for tab1 (TGVertical Frame)
    108     //
    109     TGLayoutHints *laytabs = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
    110     AddFrame(fTab, laytabs);
    111 
    112     fList->Add(fTab);
    113     fList->Add(laytabs);
    114 }
    115 
    116 void MStatusDisplay::AddStatusLine1()
    117 {
    118     TGCompositeFrame *f = new TGCompositeFrame(this, 1, 1, kSunkenFrame);
     308
     309// --------------------------------------------------------------------------
     310//
     311// Adds the status lines to the GUI
     312//
     313void MStatusDisplay::AddStatusLines()
     314{
     315    TGHorizontalFrame *hf = new TGHorizontalFrame(this, 1, 1);
     316
     317    TGCompositeFrame *f = new TGCompositeFrame(hf, 1, 1, kSunkenFrame);
    119318
    120319    fLine1 = new TGLabel(f, "");
    121320
    122     TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 5, 5, 2, 2);
     321    TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 0, 5);
    123322    f->AddFrame(fLine1, lay);
    124     AddFrame(f, lay);
     323    hf->AddFrame(f, lay);
    125324
    126325    fList->Add(f);
    127326    fList->Add(fLine1);
    128327    fList->Add(lay);
    129 }
    130 
    131 void MStatusDisplay::AddStatusLine2()
    132 {
    133     TGCompositeFrame *f = new TGCompositeFrame(this, 1, 1, kSunkenFrame);
     328
     329    f = new TGCompositeFrame(hf, 1, 1, kSunkenFrame);
    134330
    135331    fLine2 = new TGLabel(f, "");
    136 
    137     TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 5, 5, 2, 2);
    138332    f->AddFrame(fLine2, lay);
    139     AddFrame(f, lay);
    140 
     333    hf->AddFrame(f, lay);
     334
     335    TGLayoutHints *layf = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 5, 0, 0, 3);
     336    AddFrame(hf, layf);
     337
     338    fList->Add(layf);
    141339    fList->Add(f);
    142340    fList->Add(fLine2);
    143     fList->Add(lay);
    144 }
    145 
     341    fList->Add(hf);
     342}
     343
     344// --------------------------------------------------------------------------
     345//
     346// Change the text in the status line 1
     347//
    146348void MStatusDisplay::SetStatusLine1(const char *txt)
    147349{
    148350    fLine1->SetText(txt);
    149 }
    150 
     351    gClient->ProcessEventsFor(fLine1);
     352}
     353
     354// --------------------------------------------------------------------------
     355//
     356// Change the text in the status line 2
     357//
    151358void MStatusDisplay::SetStatusLine2(const char *txt)
    152359{
    153360    fLine2->SetText(txt);
     361    gClient->ProcessEventsFor(fLine2);
     362}
     363
     364// --------------------------------------------------------------------------
     365//
     366// Display information about the name of a container
     367//
     368void MStatusDisplay::SetStatusLine2(const MParContainer &cont)
     369{
     370    TString txt = cont.GetDescriptor();
     371    txt += ": ";
     372    txt += cont.GetTitle();
     373
     374    cout << txt << endl;
     375
     376    SetStatusLine2(txt);
    154377}
    155378
     
    164387//   always by deleting the corresponding object.
    165388//
    166 MStatusDisplay::MStatusDisplay() : TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 1, 1)
    167 {
     389// Update time default: 10s
     390//
     391MStatusDisplay::MStatusDisplay(Long_t t)
     392: TGMainFrame(gClient->GetRoot(), 1, 1), fTimer(this, t, kTRUE), fLog(&gLog), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL)
     393{
     394    gROOT->GetListOfSpecials()->Add(this);
     395
     396    //
     397    // Create a list handling GUI widgets
     398    //
    168399    fList = new MGList;
    169400    fList->SetOwner();
    170401
    171     SetWMSizeHints(640, 480, 1280, 1024, 10, 10); // set the smallest and biggest size of the Main frame
     402    //
     403    // set the smallest and biggest size of the Main frame
     404    // and move it to its appearance position
     405    SetWMSizeHints(640, 548, 1280, 1024, 10, 10);
    172406    Move(rand()%100+50, rand()%100+50);
    173407
    174     fLayCanvas = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 3, 3, 3, 3);
     408    //
     409    // Create the layout hint for the root embedded canavses
     410    //
     411    fLayCanvas = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY);
    175412    fList->Add(fLayCanvas);
    176413
     414    //
     415    // Add Widgets (from top to bottom)
     416    //
     417    AddMenuBar();
    177418    AddTabs();
    178419    AddProgressBar();
    179     AddStatusLine1();
    180     AddStatusLine2();
    181 
     420    AddStatusLines();
     421
     422    //
     423    // Now do an automatic layout of the widgets and display the window
     424    //
     425    Layout();
    182426    MapSubwindows();
    183 
    184     Layout();
    185427
    186428    SetWindowName("Status Display");
     
    188430
    189431    MapWindow();
     432
     433    //lient->ProcessEventsFor(this);
     434    gSystem->ProcessEvents();
    190435}
    191436
     
    198443{
    199444    delete fList;
     445
     446    gROOT->GetListOfSpecials()->Remove(this);
    200447}
    201448
    202 TCanvas *MStatusDisplay::GetCanvas(TGCompositeFrame *cf)
     449// --------------------------------------------------------------------------
     450//
     451// Takes a TGCompositeFrame as argument. Searches for the first
     452// TRootEmbeddedCanvas which is contained by it and returns a pointer
     453// to the corresponding TCanvas. If it isn't found NULL is returned.
     454//
     455TCanvas *MStatusDisplay::GetCanvas(TGCompositeFrame *cf) const
    203456{
    204457    TIter Next(cf->GetList());
     
    212465}
    213466
    214 TCanvas *MStatusDisplay::GetCanvas(int i)
     467// --------------------------------------------------------------------------
     468//
     469// Returns GetCanvas of the i-th Tab.
     470//
     471TCanvas *MStatusDisplay::GetCanvas(int i) const
    215472{
    216473    if (i<0 || i>=fTab->GetNumberOfTabs())
    217474    {
    218         cout << "MStatusDisplay::GetCanvas: Out of range." << endl;
     475        *fLog << warn << "MStatusDisplay::GetCanvas: Out of range." << endl;
    219476        return NULL;
    220477    }
     
    223480}
    224481
    225 TCanvas *MStatusDisplay::GetCanvas(const TString &name)
     482// --------------------------------------------------------------------------
     483//
     484// Searches for a TRootEmbeddedCanvas in the TGCompositeFramme of the
     485// Tab with the name 'name'. Returns the corresponding TCanvas or
     486// NULL if something isn't found.
     487//
     488TCanvas *MStatusDisplay::GetCanvas(const TString &name) const
    226489{
    227490    TGFrameElement *f;
     
    249512}
    250513
     514// --------------------------------------------------------------------------
     515//
     516// Calls TCanvas::cd(), for the canvas returned by GetCanvas.
     517//
     518Bool_t MStatusDisplay::CdCanvas(const TString &name)
     519{
     520    TCanvas *c = GetCanvas(name);
     521    if (!c)
     522        return kFALSE;
     523
     524    c->cd();
     525    return kTRUE;
     526}
     527
     528// --------------------------------------------------------------------------
     529//
     530// Adds a new tab with the name 'name'. Adds a TRootEmbeddedCanvas to the
     531// tab and returns a reference to the corresponding TCanvas.
     532//
    251533TCanvas &MStatusDisplay::AddTab(const char *name)
    252534{
     535    // Add new tab
    253536    TGCompositeFrame *f = fTab->AddTab(name);
    254537
    255     TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas(name, f, 100, 100, 0);
     538    // create root embedded canvas and add it to the tab
     539    TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas(name, f, f->GetWidth(), f->GetHeight(), 0);
    256540    f->AddFrame(ec, fLayCanvas);
    257541    fList->Add(ec);
    258542
     543    // set background and border mode of the canvas
    259544    TCanvas &c = *ec->GetCanvas();
    260545
    261     c.SetFillColor(/*165*/17);
     546    c.SetFillColor(16/*165*//*17*//*203*/);
    262547    c.SetBorderMode(0);
    263548
     549    // If kNoContaxtMenu set set kNoCOntextMenu of the canvas
     550    if (TestBit(kNoContextMenu))
     551        c.SetBit(kNoContextMenu);
     552
     553    // layout and map new tab
     554    Layout();
    264555    MapSubwindows();
    265     Layout();
    266     // MapWindow();
    267 
    268     cout << "Adding Tab '" << name << "' (TCanvas=" << &c << ")" <<  ec << endl;
    269 
     556
     557    // display new tab in the main frame
     558    gClient->ProcessEventsFor(fTab);
     559
     560    *fLog << inf << "Adding Tab '" << name << "' (" << f->GetWidth() << "x";
     561    *fLog << f->GetHeight() << ", TCanvas=" << &c << ")" << endl;
     562
     563    // return pointer to new canvas
    270564    return c;
    271565}
    272566
     567// --------------------------------------------------------------------------
     568//
     569// Update a canvas in a tab, takes the corresponding TGCompositeFrame
     570// as an argument
     571//
     572void MStatusDisplay::UpdateTab(TGCompositeFrame *f)
     573{
     574    if (!f)
     575        return;
     576
     577    TCanvas *c=GetCanvas(f);
     578    if (!c)
     579        return;
     580
     581    c->Modified();
     582    c->Update();
     583    c->Paint();
     584}
     585
     586// --------------------------------------------------------------------------
     587//
     588// Saves the given canvas (pad) or all pads (num<0) as a temporary
     589// postscript file and prints it using 'lpr'. If a printer name is set
     590// via SetPrinter 'lpr -Pname' is used.
     591//
     592Int_t MStatusDisplay::PrintToLpr(Int_t num) const
     593{
     594    TString name = "mars";
     595
     596    for (int i=0; i<6; i++)
     597        name += (char)(gRandom->Uniform(25)+65);
     598
     599    name += ".ps";
     600
     601    const Int_t pages = SaveAsPS(num, name);
     602    if (!pages)
     603    {
     604        *fLog << warn << "MStatusDisplay::PrintToLpr: Sorry, couldn't save file as temporary postscript!" << endl;
     605        return 0;
     606    }
     607
     608    TString cmd="lpr ";
     609    if (!fPrinter.IsNull())
     610    {
     611        cmd += "-P";
     612        cmd += fPrinter;
     613        cmd += " ";
     614    }
     615    cmd += name;
     616
     617    gSystem->Exec(cmd);
     618    gSystem->Unlink(name);
     619
     620    return pages;
     621}
     622
     623// --------------------------------------------------------------------------
     624//
     625// Process the kC_COMMAND, kCM_MENU  messages
     626//
     627Bool_t MStatusDisplay::ProcessMessageCommandMenu(Long_t id)
     628{
     629    //cout << "Menu #" << id << endl;
     630    switch (id)
     631    {
     632    case kLoopStop:
     633    case kFileExit:
     634        if (id==kFileExit && !TestBit(kIsLocked))
     635            delete this;
     636        fStatus = (Status_t)id;
     637        return kTRUE;
     638/*
     639    case kFileSave:
     640        cout << "Save..." << endl;
     641        return kTRUE;
     642
     643    case kFileSaveAs:
     644        cout << "SaveAs..." << endl;
     645        return kTRUE;
     646*/
     647    case kFileSaveAsPS:
     648        //cout << "FileSaveAsPS..." << endl;
     649        SaveAsPS();
     650        return kTRUE;
     651/*
     652    case kFileSaveAsGIF:
     653        cout << "FileSaveAsGIF..." << endl;
     654        SaveAsGIF();
     655        return kTRUE;
     656
     657    case kFileSaveAsC:
     658        cout << "FileSaveAsC..." << endl;
     659        SaveAsC();
     660        return kTRUE;
     661*/
     662    case kFileSaveAsRoot:
     663        SaveAsRoot();
     664        return kTRUE;
     665
     666    case kFilePrint:
     667        PrintToLpr();
     668        return kTRUE;
     669
     670    case kTabSaveAsPS:
     671        SaveAsPS(fTab->GetCurrent());
     672        return kTRUE;
     673/*
     674    case kTabSaveAsGIF:
     675        cout << "TabSaveAsGIF... " << fTab->GetCurrent() <<  endl;
     676        SaveAsGIF(fTab->GetCurrent());
     677        return kTRUE;
     678
     679    case kTabSaveAsC:
     680        cout << "TabSaveAsC... " << fTab->GetCurrent() <<  endl;
     681        SaveAsC(fTab->GetCurrent());
     682        return kTRUE;
     683*/
     684    case kTabSaveAsRoot:
     685        SaveAsRoot(fTab->GetCurrent());
     686        return kTRUE;
     687
     688    case kTabPrint:
     689        PrintToLpr(fTab->GetCurrent());
     690        return kTRUE;
     691
     692    case kTabNext:
     693        fTab->SetTab(fTab->GetCurrent()+1);
     694        return kTRUE;
     695
     696    case kTabPrevious:
     697        fTab->SetTab(fTab->GetCurrent()-1);
     698        return kTRUE;
     699    }
     700    return kTRUE;
     701
     702    cout << "Command-Menu: Id=" << id << endl;
     703}
     704
     705// --------------------------------------------------------------------------
     706//
     707// Process the kC_COMMAND messages
     708//
     709Bool_t MStatusDisplay::ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2)
     710{
     711    switch (submsg)
     712    {
     713    case kCM_MENU:
     714        return ProcessMessageCommandMenu(mp1);
     715
     716    case kCM_MENUSELECT:
     717        cout << "Menuselect #" << mp1 << endl;
     718        return kTRUE;
     719
     720    case kCM_TAB:
     721        for (int i=1; i<fTab->GetNumberOfTabs(); i++)
     722            fTab->GetTabContainer(i)->UnmapWindow();
     723        UpdateTab(fTab->GetTabContainer(mp1));
     724        fTab->GetTabContainer(mp1)->MapWindow();
     725        /*
     726        if (mp1>0)
     727            fMenu->AddPopup("&CaOs", fCaOs, NULL);
     728        else
     729            fMenu->RemovePopup("CaOs");
     730        fMenu->Resize(fMenu->GetDefaultSize());
     731        MapSubwindows();
     732        MapWindow();
     733        */
     734        return kTRUE;
     735
     736    case kCM_BUTTON:
     737        if (mp1==kPicMars)
     738            return kTRUE;
     739        return kTRUE;
     740    }
     741
     742    cout << "Command: " << "Submsg:" << submsg << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
     743    return kTRUE;
     744}
     745
     746// --------------------------------------------------------------------------
     747//
     748// Process the messages from the GUI
     749//
    273750Bool_t MStatusDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
    274751{
    275     cout << "Msg: " << GET_MSG(msg) << " Submsg:" << GET_SUBMSG(msg) << " Mp1=";
    276     cout << mp1 << " Mp2=" << mp2 << endl;
     752    switch (GET_MSG(msg))
     753    {
     754    case kC_COMMAND:
     755        return ProcessMessageCommand(GET_SUBMSG(msg), mp1, mp2);
     756    }
     757
     758    cout << "Msg: " << GET_MSG(msg) << " Submsg:" << GET_SUBMSG(msg);
     759    cout << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
    277760
    278761    return kTRUE;
     
    292775}
    293776
     777// --------------------------------------------------------------------------
     778//
     779// Calls SetBit(kNoContextMenu) for all TCanvas objects found in the
     780// Tabs.
     781//
     782void MStatusDisplay::SetNoContextMenu(Bool_t flag=kTRUE)
     783{
     784    flag ? SetBit(kNoContextMenu) : ResetBit(kNoContextMenu);
     785    for (int i=1; i<fTab->GetNumberOfTabs(); i++)
     786    {
     787        TCanvas *c = GetCanvas(i);
     788        if (c)
     789            flag ? c->SetBit(kNoContextMenu) : c->ResetBit(kNoContextMenu);
     790    }
     791}
     792
     793// --------------------------------------------------------------------------
     794//
     795// Updates the canvas (if existing) in the currenly displayed Tab.
     796// The update intervall is controlled by StartUpdate and StopUpdate
     797//
     798Bool_t MStatusDisplay::HandleTimer(TTimer *timer)
     799{
     800    const Int_t c = fTab->GetCurrent();
     801
     802    // Skip Legend Tab
     803    if (c==0)
     804        return kTRUE;
     805
     806    if (timer==&fTimer)
     807    {
     808        TGCompositeFrame *f=fTab->GetCurrentContainer();
     809        if (f!=fLogBox)
     810            return kTRUE;
     811
     812        UpdateTab(f);
     813        return kTRUE;
     814    }
     815    if (timer==&fLogTimer && c==fLogIdx)
     816    {
     817        fLog->UpdateGui();
     818
     819        if (!fLogBox->TestBit(kHasChanged))
     820            return kTRUE;
     821
     822        fLogBox->MapSubwindows();
     823        fLogBox->Layout();
     824        fLogBox->ResetBit(kHasChanged);
     825        return kTRUE;
     826    }
     827
     828    return kTRUE;
     829}
     830
     831// --------------------------------------------------------------------------
     832//
     833// Draws a clone of a canvas into a new canvas. Taken from TCanvas.
     834//
     835void MStatusDisplay::DrawClonePad(TCanvas &newc, const TCanvas &oldc) const
     836{
     837    //copy pad attributes
     838    newc.Range(oldc.GetX1(),oldc.GetY1(),oldc.GetX2(),oldc.GetY2());
     839    newc.SetTickx(oldc.GetTickx());
     840    newc.SetTicky(oldc.GetTicky());
     841    newc.SetGridx(oldc.GetGridx());
     842    newc.SetGridy(oldc.GetGridy());
     843    newc.SetLogx(oldc.GetLogx());
     844    newc.SetLogy(oldc.GetLogy());
     845    newc.SetLogz(oldc.GetLogz());
     846    newc.SetBorderSize(oldc.GetBorderSize());
     847    newc.SetBorderMode(oldc.GetBorderMode());
     848    ((TAttLine&)oldc).Copy((TAttLine&)newc);
     849    ((TAttFill&)oldc).Copy((TAttFill&)newc);
     850    ((TAttPad&)oldc).Copy((TAttPad&)newc);
     851
     852    //copy primitives
     853    TObject *obj;
     854    TIter next(oldc.GetListOfPrimitives());
     855    while ((obj=next())) {
     856        gROOT->SetSelectedPad(&newc);
     857        newc.GetListOfPrimitives()->Add(obj->Clone(),obj->GetDrawOption());
     858    }
     859    newc.Modified();
     860    newc.Update();
     861}
     862
     863// --------------------------------------------------------------------------
     864//
     865// Reads the contents of a saved MStatusDisplay from a file.
     866//
     867Int_t MStatusDisplay::Read(const char *name)
     868{
     869    if (!gFile)
     870    {
     871        *fLog << warn << "MStatusDisplay::Read: No file found. Please create a TFile first." << endl;
     872        return 0;
     873    }
     874
     875    if (!gFile->IsOpen())
     876    {
     877        *fLog << warn << "MStatusDisplay::Read: File not open. Please open the TFile first." << endl;
     878        return 0;
     879    }
     880
     881    TObjArray list;
     882
     883    const Int_t n = list.Read(name);
     884    if (n==0)
     885    {
     886        *fLog << warn << "MStatusDisplay::Read: No objects read." << endl;
     887        return 0;
     888    }
     889
     890    TIter Next(&list);
     891    TCanvas *c;
     892    while ((c=(TCanvas*)Next()))
     893        DrawClonePad(AddTab(c->GetName()), *c);
     894
     895    *fLog << inf << "MStatusDisplay: Key " << name << " with " << n << " keys read from file." << endl;
     896
     897    return n;
     898}
     899
     900// --------------------------------------------------------------------------
     901//
     902// Writes the contents of a MStatusDisplay to a file.
     903//
     904Int_t MStatusDisplay::Write(Int_t num, const char *name, Int_t option, Int_t bufsize)
     905{
     906    if (!gFile)
     907    {
     908        *fLog << warn << "MStatusDisplay::Write: No file found. Please create a TFile first." << endl;
     909        return 0;
     910    }
     911
     912    if (!gFile->IsOpen())
     913    {
     914        *fLog << warn << "MStatusDisplay::Write: File not open. Please open the TFile first." << endl;
     915        return 0;
     916    }
     917
     918    if (!gFile->IsWritable())
     919    {
     920        *fLog << warn << "MStatusDisplay::Write: File not writable." << endl;
     921        return 0;
     922    }
     923
     924    if (num==0)
     925    {
     926        *fLog << warn << "MStatusDisplay::Write: Tab doesn't contain an embedded Canvas... skipped." << endl;
     927        return 0;
     928    }
     929
     930    if (num>=fTab->GetNumberOfTabs())
     931    {
     932        *fLog << warn << "MStatusDisplay::Write: Tab doesn't exist... skipped." << endl;
     933        return 0;
     934    }
     935
     936    TObjArray list;
     937
     938    const Int_t from = num<0 ? 1 : num;
     939    const Int_t to   = num<0 ? fTab->GetNumberOfTabs() : num+1;
     940
     941    TCanvas *c;
     942    for (int i=from; i<to; i++)
     943        if ((c = GetCanvas(i)))
     944            list.Add(c);
     945
     946    const Int_t n = list.Write(name, kSingleKey);
     947
     948    *fLog << inf << "MStatusDisplay: " << n << " keys written to file as key " << name << "." << endl;
     949
     950    return n;
     951}
     952
     953// --------------------------------------------------------------------------
     954//
     955// Use this to start the synchronous (GUI eventloop driven) tab update.
     956// Can also be used to change the update intervall. If millisec<0
     957// the intervall given in SetUpdateTime is used. If the intervall in
     958// SetUpdateTime is <0 nothing is done. (Call SetUpdateTime(-1) to
     959// disable the automatic update in a MEventloop.
     960//
     961void MStatusDisplay::StartUpdate(Int_t millisec=-1)
     962{
     963    if (fTimer.GetTime()<TTime(0))
     964        return;
     965    fTimer.Start(millisec);
     966}
     967
     968// --------------------------------------------------------------------------
     969//
     970// Stops the automatic GUI update
     971//
     972void MStatusDisplay::StopUpdate()
     973{
     974    fTimer.Stop();
     975}
     976
     977// --------------------------------------------------------------------------
     978//
     979// Set the update interval for the GUI update, see StartUpdate.
     980//
     981void MStatusDisplay::SetUpdateTime(Long_t t)
     982{
     983    fTimer.SetTime(t);
     984}
     985
     986// --------------------------------------------------------------------------
     987//
     988// Set the background color in a canvas
     989//
     990void MStatusDisplay::CanvasSetFillColor(TPad &p, Int_t col) const
     991{
     992    TObject *obj;
     993
     994    TIter Next(p.GetListOfPrimitives());
     995    while ((obj=Next()))
     996    {
     997        if (obj->InheritsFrom(TPad::Class()))
     998            CanvasSetFillColor(*(TPad*)obj, col);
     999        if (obj->InheritsFrom(TFrame::Class()))
     1000            ((TFrame*)obj)->SetFillColor(col);
     1001    }
     1002
     1003    p.SetFillColor(col);
     1004}
     1005
     1006void MStatusDisplay::AddExtension(TString &name, const TString &ext, Int_t num) const
     1007{
     1008    if (name.IsNull())
     1009    {
     1010        name = "status";
     1011        if (num>0)
     1012        {
     1013            name += "-";
     1014            name += num;
     1015        }
     1016    }
     1017
     1018    if (name.EndsWith("."+ext))
     1019        return;
     1020
     1021    name += ".";
     1022    name += ext;
     1023}
     1024
     1025// --------------------------------------------------------------------------
     1026//
     1027// In case of num<0 all tabs are written into the PS file. If num>0
     1028// the canvas in the corresponding tab is written to the file.
     1029// Name is the name of the file (with or without extension).
     1030//
     1031// Returns the number of pages written.
     1032//
     1033// To write all tabs you can also use SaveAsPS(name)
     1034//
     1035Int_t MStatusDisplay::SaveAsPS(Int_t num, TString name) const
     1036{
     1037    if (num>=fTab->GetNumberOfTabs())
     1038    {
     1039        *fLog << warn << "Tab #" << num << " doesn't exist..." << endl;
     1040        return 0;
     1041    }
     1042    if (num==0)
     1043    {
     1044        *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl;
     1045        return 0;
     1046    }
     1047    if (fTab->GetNumberOfTabs()<2 || !gPad)
     1048    {
     1049        *fLog << warn << "Sorry, you must have at least one existing canvas (gPad!=NULL)" << endl;
     1050        return 0;
     1051    }
     1052
     1053    AddExtension(name, "ps", num);
     1054
     1055    if (num<0)
     1056        *fLog << inf << "Open ps-File: " << name << endl;
     1057
     1058    TPad       *padsav = (TPad*)gPad;
     1059    TVirtualPS *psave  = gVirtualPS;
     1060
     1061    TPostScript ps(name, 112);
     1062    ps.SetBit(TPad::kPrintingPS);
     1063    ps.PrintFast(13, "/nan {1} def ");
     1064
     1065    gVirtualPS = &ps;
     1066
     1067    //
     1068    // Create a list to delete the canvas clones
     1069    //
     1070    TList l;
     1071    l.SetOwner();
     1072
     1073    //
     1074    // Create some GUI elements for a page legend
     1075    //
     1076    TLine line;
     1077
     1078    int page = 1;
     1079
     1080    //
     1081    // Maintain tab numbers
     1082    //
     1083    const Int_t from = num<0 ? 1 : num;
     1084    const Int_t to   = num<0 ? fTab->GetNumberOfTabs() : num+1;
     1085
     1086    for (int i=from; i<to; i++)
     1087    {
     1088        TCanvas *c;
     1089        if (!(c = GetCanvas(i)))
     1090        {
     1091            if (num<0)
     1092                *fLog << inf << " - ";
     1093            *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl;
     1094            continue;
     1095        }
     1096
     1097        //
     1098        // Init page and page size, make sure, that the canvas in the file
     1099        // has the same Aspect Ratio than on the screen.
     1100        //
     1101        ps.NewPage();
     1102
     1103        Float_t psw = 26; // A4 - width
     1104        Float_t psh = 20; // A4 - height
     1105
     1106        const Float_t cw = c->GetWw();
     1107        const Float_t ch = c->GetWh();
     1108
     1109        if (psw/psh>cw/ch)
     1110            psw = cw/ch*psh;
     1111        else
     1112            psh = ch/cw*psw;
     1113
     1114        ps.Range(psw, psh); // A4
     1115
     1116        //
     1117        // Clone canvas and change background color and schedule for
     1118        // deletion
     1119        //
     1120        TCanvas *n = (TCanvas*)c->Clone();
     1121        CanvasSetFillColor(*n, kWhite);
     1122        l.Add(n);
     1123
     1124        //
     1125        // Paint canvas into root file
     1126        //
     1127        if (num<0)
     1128            *fLog << inf << " - ";
     1129        *fLog << "Writing Tab #" << i << ": " << c->GetName() << " (" << n << ") ";
     1130        if (num>0)
     1131            *fLog << "to " << name;
     1132        *fLog << "..." << flush;
     1133
     1134        n->SetBatch(kTRUE);
     1135        n->Paint();
     1136
     1137        //
     1138        // Use the canvas as coordinate system for the overlaying text
     1139        //
     1140        gPad = n;
     1141
     1142        //
     1143        // Print overlaying text (NDC = %)
     1144        //
     1145        ps.SetTextColor(kBlack);
     1146        ps.SetTextSize(0.015);
     1147        ps.SetTextFont(22);
     1148        ps.SetTextAlign(11); // left top
     1149        ps.TextNDC(0, 1.02, TString("  ")+n->GetName());
     1150        ps.SetTextAlign(21); // cent top
     1151        ps.TextNDC(0.5, 1.02, "MARS - Magic Analysis and Reconstruction Software");
     1152        ps.SetTextAlign(31); // right top
     1153        ps.TextNDC(1, 1.02, Form("Page No.%i (%i)  ", page++, i));
     1154        line.PaintLineNDC(0, 1.015, 1, 1.015);
     1155
     1156        //
     1157        // Finish drawing page
     1158        //
     1159        n->SetBatch(kFALSE);
     1160        if (num<0)
     1161            *fLog << "done." << endl;
     1162    }
     1163
     1164    gPad = NULL; // Important!
     1165
     1166    l.Delete();
     1167
     1168    ps.Close();
     1169
     1170    gVirtualPS = psave;
     1171    padsav->cd();
     1172
     1173    *fLog << inf << "done." << endl;
     1174
     1175    return page-1;
     1176}
     1177
     1178/*
     1179void MStatusDisplay::SaveAsGIF(Int_t num, TString name) const
     1180{
     1181    AddExtension(name, "gif", num);
     1182
     1183    cout << "Open gif-File: " << name << endl;
     1184    cout << " SORRY, not implemented." << endl;
     1185}
     1186
     1187void MStatusDisplay::SaveAsC(Int_t num, TString name) const
     1188{
     1189    AddExtension(name, "C", num);
     1190
     1191    cout << "Open C-File: " << name << endl;
     1192    cout << " SORRY, not implemented." << endl;
     1193}
     1194*/
     1195
     1196// --------------------------------------------------------------------------
     1197//
     1198// In case of num<0 all tabs are written into the PS file. If num>0
     1199// the canvas in the corresponding tab is written to the file.
     1200// Name is the name of the file (with or without extension).
     1201//
     1202// Returns the number of keys written.
     1203//
     1204// To write all tabs you can also use SaveAsPS(name)
     1205//
     1206Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name)
     1207{
     1208    if (num>=fTab->GetNumberOfTabs())
     1209    {
     1210        *fLog << warn << "Tab #" << num << " doesn't exist..." << endl;
     1211        return 0;
     1212    }
     1213    if (num==0)
     1214    {
     1215        *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl;
     1216        return 0;
     1217    }
     1218    if (fTab->GetNumberOfTabs()<2 || !gPad)
     1219    {
     1220        *fLog << warn << "Sorry, you must have at least one existing canvas." << endl;
     1221        return 0;
     1222    }
     1223
     1224    AddExtension(name, "root", num);
     1225
     1226    TFile *fsave = gFile;
     1227    TFile file(name, "RECREATE", "MARS - Status Window Contents", 9);
     1228    const Int_t keys = Write(num);
     1229    gFile = fsave;
     1230
     1231    return keys;
     1232}
  • trunk/MagicSoft/Mars/mmain/MStatusDisplay.h

    r1957 r1965  
    1010#endif
    1111
     12#ifndef ROOT_TTimer
     13#include <TTimer.h>
     14#endif
     15
     16class MLog;
    1217class MGList;
     18class MParContainer;
    1319
     20class TPad;
     21class TTimer;
    1422class TCanvas;
    1523
    1624class TGTab;
    1725class TGLabel;
     26class TGListBox;
    1827class TGProgressBar;
    1928class TGHProgressBar;
    2029
    21 class MStatusDisplay : public TGTransientFrame
     30class MStatusDisplay : public TGMainFrame
    2231{
     32public:
     33    typedef enum {
     34        kLoopNone,
     35        kLoopStop,
     36        kFileSave,
     37        kFileSaveAs,
     38        kFileSaveAsPS,
     39        kFileSaveAsRoot,
     40        kFileSaveAsGIF,
     41        kFileSaveAsC,
     42        kFilePrint,
     43        kFilePrinterName,
     44        kTabSave,
     45        kTabSaveAs,
     46        kTabSaveAsPS,
     47        kTabSaveAsRoot,
     48        kTabSaveAsGIF,
     49        kTabSaveAsC,
     50        kTabPrint,
     51        kTabNext,
     52        kTabPrevious,
     53        kFileExit,
     54        kPicMagic,
     55        kPicMars
     56    } Status_t;
     57
    2358private:
    2459    MGList         *fList;
     
    2762    TGLayoutHints  *fLayCanvas;
    2863
     64    TTimer fTimer;
    2965
    3066    TGLabel *fLine1;
    3167    TGLabel *fLine2;
    3268
     69    Status_t fStatus;
     70
     71    TString fPrinter;
     72
     73    MLog *fLog;
     74    Int_t fLogIdx;
     75    TTimer fLogTimer;
     76    TGListBox *fLogBox;
     77
     78    void AddMenuBar();
    3379    void AddProgressBar();
     80    void AddMarsTab();
     81    void AddLogTab();
    3482    void AddTabs();
    35     void AddStatusLine1();
    36     void AddStatusLine2();
     83    void AddStatusLines();
    3784
    38     TCanvas *GetCanvas(TGCompositeFrame *f);
     85    TCanvas *GetCanvas(TGCompositeFrame *f) const;
    3986
     87    Bool_t ProcessMessageCommandMenu(Long_t mp1);
     88    Bool_t ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2);
    4089    Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
    4190    void   CloseWindow();
    4291
     92    Bool_t HandleTimer(TTimer *timer=NULL);
     93    void UpdateTab(TGCompositeFrame *f);
     94
     95    void DrawClonePad(TCanvas &newc, const TCanvas &oldc) const;
     96    void CanvasSetFillColor(TPad &c, Int_t col) const;
     97
     98    void AddExtension(TString &name, const TString &ext, Int_t num) const;
     99
     100    enum {
     101        kIsLocked = BIT(14)
     102    };
    43103public:
    44      MStatusDisplay();
     104     MStatusDisplay(Long_t t=1000);
    45105     virtual ~MStatusDisplay();
     106
     107     void SetLogStream(MLog *log);
     108
     109     void StartUpdate(Int_t millisec=-1);
     110     void StopUpdate();                 
     111     void SetUpdateTime(Long_t t);       
    46112
    47113     TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
     
    49115     void SetStatusLine1(const char *txt);
    50116     void SetStatusLine2(const char *txt);
     117     void SetStatusLine2(const MParContainer &cont);
     118
     119     void SetPrinter(const TString &lpr) { fPrinter = lpr; }
    51120
    52121     TCanvas &AddTab(const char *name);
    53122
    54      TCanvas *GetCanvas(int i);
    55      TCanvas *GetCanvas(const TString &name);
     123     TCanvas *GetCanvas(int i) const;
     124     TCanvas *GetCanvas(const TString &name) const;
     125
     126     Int_t Read(const char *name="MStatusDisplay");
     127     Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
     128     {
     129         return Write(-1, name, option, bufsize);
     130     }
     131     Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0);
     132
     133     Bool_t CdCanvas(const TString &name);
     134
     135     void SetNoContextMenu(Bool_t flag=kTRUE);
     136
     137     Int_t SaveAsPS(TString name="") const { return SaveAsPS(-1, name); }
     138     //Bool_t SaveAsGIF(TString name="") const { return SaveAsGIF(-1, name); }
     139     //Bool_t SaveAsC(TString name="") const { return SaveAsC(-1, name); }
     140     Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
     141     Int_t PrintToLpr() const { return PrintToLpr(-1); }
     142
     143     Int_t SaveAsPS(Int_t num, TString name="") const;
     144     //Bool_t SaveAsGIF(Int_t num, TString name="") const;
     145     //Bool_t SaveAsC(Int_t num, TString name="") const;
     146     Int_t SaveAsRoot(Int_t num, TString name="");
     147     Int_t PrintToLpr(Int_t num) const;
     148
     149     Status_t CheckStatus() const { return fStatus; }
     150     void ClearStatus() { fStatus = kLoopNone; }
     151
     152     void Lock() { SetBit(kIsLocked); }
     153     void UnLock() { ResetBit(kIsLocked); }
    56154
    57155     ClassDef(MStatusDisplay, 0)   // Window for a status display
  • trunk/MagicSoft/Mars/mmain/MainLinkDef.h

    r1527 r1965  
    88
    99#pragma link C++ class MMars+;
     10#pragma link C++ class MEvtDisp+;
    1011#pragma link C++ class MAnalysis+;
    11 #pragma link C++ class MEvtDisp+;
     12//#pragma link C++ class MTextEntry+;
    1213#pragma link C++ class MDataCheck+;
    1314#pragma link C++ class MMonteCarlo+;
    1415#pragma link C++ class MProgressBar+;
    1516#pragma link C++ class MCameraDisplay+;
     17#pragma link C++ class MStatusDisplay+;
    1618
    1719#endif
  • trunk/MagicSoft/Mars/mmain/Makefile

    r1941 r1965  
    3232SRCFILES = MBrowser.cc \
    3333           MEvtDisp.cc \
     34           MStatusDisplay.cc \
    3435           MDataCheck.cc \
    3536           MMars.cc \
     37           MGMenu.cc \
    3638           MAnalysis.cc \
    3739           MMonteCarlo.cc \
Note: See TracChangeset for help on using the changeset viewer.