LCOV - code coverage report
Current view: top level - MUON/MUONgraphics - AliMUONPainterRegistry.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 72 1.4 %
Date: 2016-06-14 17:26:59 Functions: 1 21 4.8 %

          Line data    Source code
       1             : /**************************************************************************
       2             : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             : *                                                                        *
       4             : * Author: The ALICE Off-line Project.                                    *
       5             : * Contributors are mentioned in the code where appropriate.              *
       6             : *                                                                        *
       7             : * Permission to use, copy, modify and distribute this software and its   *
       8             : * documentation strictly for non-commercial purposes is hereby granted   *
       9             : * without fee, provided that the above copyright notice appears in all   *
      10             : * copies and that both the copyright notice and this permission notice   *
      11             : * appear in the supporting documentation. The authors make no claims     *
      12             : * about the suitability of this software for any purpose. It is          *
      13             : * provided "as is" without express or implied warranty.                  *
      14             : **************************************************************************/
      15             : 
      16             : // $Id$
      17             : 
      18             : #include "AliMUONPainterRegistry.h"
      19             : 
      20             : #include "AliMpManuIterator.h"
      21             : #include "AliMUON2DMap.h"
      22             : #include "AliMUONCalibParamND.h"
      23             : #include "AliMUONPainterMatrix.h"
      24             : #include "AliLog.h"
      25             : #include <TGMenu.h>
      26             : #include <TGWindow.h>
      27             : #include <THashList.h>
      28             : #include <TObjArray.h>
      29             : #include <TString.h>
      30             : #include <Riostream.h>
      31             : 
      32             : ///\class AliMUONPainterRegistry
      33             : ///
      34             : /// Registry for AliMUONVPainter related stuff : painter data sources
      35             : /// and painter matrices
      36             : ///
      37             : ///\author Laurent Aphecetche, Subatech
      38             : 
      39             : using std::cout;
      40             : using std::endl;
      41             : ///\cond CLASSIMP
      42          12 : ClassImp(AliMUONPainterRegistry)
      43             : ///\endcond
      44             : 
      45             : AliMUONPainterRegistry* AliMUONPainterRegistry::fgInstance(0x0);
      46             : 
      47             : //_____________________________________________________________________________
      48           0 : AliMUONPainterRegistry::AliMUONPainterRegistry() : TObject(), TQObject(),
      49           0 : fPainterMatrices(new TObjArray),
      50           0 : fHistoryMenu(0x0),
      51           0 : fMenuBar(0x0),
      52           0 : fHistoryCounter(0)
      53           0 : {
      54             :   /// ctor
      55           0 :   fPainterMatrices->SetOwner(kTRUE);
      56           0 : }
      57             : 
      58             : //_____________________________________________________________________________
      59           0 : AliMUONPainterRegistry::~AliMUONPainterRegistry()
      60           0 : {
      61             :   /// dtor
      62           0 :   delete fPainterMatrices;
      63           0 : }
      64             : 
      65             : //_____________________________________________________________________________
      66             : Int_t 
      67             : AliMUONPainterRegistry::FindIndexOf(AliMUONPainterMatrix* group) const
      68             : {
      69             :   /// Get the index of a given painterMatrix
      70           0 :   return fPainterMatrices->IndexOf(group);
      71             : }
      72             : 
      73             : //_____________________________________________________________________________
      74             : AliMUONPainterMatrix*
      75             : AliMUONPainterRegistry::PainterMatrix(const char* name) const
      76             : {
      77             :   /// Get a painterMatrix by name
      78           0 :   return static_cast<AliMUONPainterMatrix*>(fPainterMatrices->FindObject(name));
      79             : }
      80             : 
      81             : //_____________________________________________________________________________
      82             : void
      83             : AliMUONPainterRegistry::HistoryMenuActivated(Int_t i)
      84             : {
      85             :   /// A painterMatrix was chosen from the history menu
      86             :   
      87           0 :   TGMenuEntry* entry = fHistoryMenu->GetEntry(i);
      88             :   
      89           0 :   AliMUONPainterMatrix* group = reinterpret_cast<AliMUONPainterMatrix*>(entry->GetUserData());
      90             :   
      91           0 :   PainterMatrixWantToShow(group);
      92           0 : }
      93             : 
      94             : //_____________________________________________________________________________
      95             : AliMUONPainterRegistry*
      96             : AliMUONPainterRegistry::Instance()
      97             : {
      98             :   /// Get unique instance of this class
      99           0 :   if ( !fgInstance ) fgInstance = new AliMUONPainterRegistry;
     100           0 :   return fgInstance;
     101           0 : }
     102             : 
     103             : //_____________________________________________________________________________
     104             : AliMUONPainterMatrix* 
     105             : AliMUONPainterRegistry::PainterMatrix(Int_t i) const
     106             : {
     107             :   /// Get one painter matrix
     108           0 :   if ( i >= 0 && i <= fPainterMatrices->GetLast() )
     109             :   {
     110           0 :     return static_cast<AliMUONPainterMatrix*>(fPainterMatrices->At(i));
     111             :   }
     112             :   else
     113             :   {
     114           0 :     AliError(Form("Index out of bounds : %d / %d",i,fPainterMatrices->GetLast()+1));
     115           0 :     return 0x0;
     116             :   }
     117           0 : }
     118             : 
     119             : //_____________________________________________________________________________
     120             : void 
     121             : AliMUONPainterRegistry::PainterMatrixWantToShow(const AliMUONPainterMatrix* group)
     122             : {
     123             :   /// A given paintermatrix want to appear on screen
     124           0 :   Long_t param[] = { (Long_t)group };
     125             :   
     126           0 :   Emit("PainterMatrixWantToShow(AliMUONPainterMatrix*)",param);  
     127           0 : }
     128             : 
     129             : //_____________________________________________________________________________
     130             : void
     131             : AliMUONPainterRegistry::AddToHistory(AliMUONPainterMatrix* group)
     132             : {
     133             :   /// Add a matrix to the history
     134             :   
     135           0 :   if ( !fHistoryMenu && fMenuBar ) 
     136             :   {
     137           0 :     fHistoryMenu =  new TGPopupMenu(gClient->GetRoot());
     138             :     TGPopupMenu* before = 0x0; //FIXME: could try to find a place where to put it (e.g. before Help ?)
     139             :     
     140           0 :     fMenuBar->AddPopup("&History",fHistoryMenu, new TGLayoutHints(kLHintsNormal),before);
     141             :     
     142           0 :     fHistoryMenu->Connect("Activated(Int_t)",
     143           0 :                           "AliMUONPainterRegistry",this,
     144             :                           "HistoryMenuActivated(Int_t)");
     145           0 :   }
     146             :   
     147           0 :   if ( fHistoryMenu ) 
     148             :   {
     149           0 :     TIter next(fHistoryMenu->GetListOfEntries());
     150             :     TGMenuEntry* e(0x0);
     151             :     
     152           0 :     while ( ( e = static_cast<TGMenuEntry*>(next()) ) )
     153             :     {
     154           0 :       if ( e->GetUserData() == group ) 
     155             :       {
     156           0 :         fHistoryMenu->DeleteEntry(e);
     157             :         break;
     158             :       }
     159             :     }
     160             :     
     161           0 :     e = static_cast<TGMenuEntry*>(fHistoryMenu->GetListOfEntries()->First());
     162             :     
     163           0 :     fHistoryMenu->AddEntry(group->GetName(),++fHistoryCounter,(void*)group,0x0,e);
     164           0 :   }
     165             :   else
     166             :   {
     167           0 :     AliError("fHistoryMenu is null. We probably did not find the relevant menu entry ?");
     168             :   }
     169           0 : }
     170             : 
     171             : //_____________________________________________________________________________
     172             : void 
     173             : AliMUONPainterRegistry::PainterMatrixWasRegistered(const AliMUONPainterMatrix* group)
     174             : {
     175             :   /// A new painter matrix was registered
     176           0 :   Long_t param[] = { (Long_t)group };
     177             :   
     178           0 :   Emit("PainterMatrixWasRegistered(AliMUONPainterMatrix*)",param);
     179           0 : }
     180             : 
     181             : //_____________________________________________________________________________
     182             : void 
     183             : AliMUONPainterRegistry::PainterMatrixWasUnregistered(const AliMUONPainterMatrix* group)
     184             : {
     185             :   /// A painter matrix was unregistered
     186           0 :   Long_t param[] = { (Long_t)group };
     187             :   
     188           0 :   Emit("PainterMatrixWasUnregistered(AliMUONPainterMatrix*)",param);
     189           0 : }
     190             : 
     191             : //_____________________________________________________________________________
     192             : void 
     193             : AliMUONPainterRegistry::Print(Option_t* opt) const
     194             : {
     195             :   /// Printout
     196           0 :   TString sopt(opt);
     197           0 :   sopt.ToUpper();
     198             :   
     199           0 :   cout << "Number of painter matrices = " << NumberOfPainterMatrices() << endl;
     200             :   
     201           0 :   if ( sopt.Contains("FULL") || sopt.Contains("MATRIX") )
     202             :   {
     203           0 :     TIter next(fPainterMatrices);
     204             :     AliMUONPainterMatrix* matrix;
     205             :     
     206           0 :     while ( ( matrix = static_cast<AliMUONPainterMatrix*>(next()) ) )
     207             :     {
     208           0 :       matrix->Print();
     209             :     }
     210           0 :   }
     211             :   
     212           0 : }
     213             : 
     214             : //_____________________________________________________________________________
     215             : Int_t
     216             : AliMUONPainterRegistry::Register(AliMUONPainterMatrix* group)
     217             : {
     218             :   /// group is adopted, i.e. the registry becomes the owner of it.
     219           0 :   fPainterMatrices->AddLast(group);
     220             :   
     221           0 :   PainterMatrixWasRegistered(group);
     222             :   
     223           0 :   return fPainterMatrices->IndexOf(group);
     224             : }
     225             : 
     226             : //_____________________________________________________________________________
     227             : Int_t 
     228             : AliMUONPainterRegistry::NumberOfPainterMatrices() const
     229             : {
     230             :   /// The number of painter matrices we handle
     231           0 :   return fPainterMatrices->GetLast()+1;
     232             : }
     233             : 
     234             : //_____________________________________________________________________________
     235             : Bool_t 
     236             : AliMUONPainterRegistry::Unregister(AliMUONPainterMatrix* group)
     237             : {
     238             :   /// Unregister some matrix
     239             :   
     240           0 :   if (!group) return kFALSE;
     241             :   
     242           0 :   PainterMatrixWasUnregistered(group);
     243             :   
     244           0 :   TObject* o = fPainterMatrices->Remove(group);
     245           0 :   if ( o ) 
     246             :   {
     247           0 :     delete o;
     248             :   }
     249             :   else
     250             :   {
     251           0 :     AliError(Form("Could not unregister group named %s",group->GetName()));
     252             :   }
     253             :   return ( o != 0x0 );
     254           0 : }

Generated by: LCOV version 1.11