CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Fireworks/Core/interface/CmsShowNavigator.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef Fireworks_Core_CmsShowNavigator_h
00003 #define Fireworks_Core_CmsShowNavigator_h
00004 //
00005 // Package:     newVersion
00006 // Class  :     CmsShowNavigator
00007 // $Id: CmsShowNavigator.h,v 1.56 2012/07/06 23:33:29 amraktad Exp $
00008 //
00009 
00010 // system include files
00011 #include <string>
00012 #include <sigc++/sigc++.h>
00013 
00014 // user include files
00015 #include "Fireworks/Core/interface/FWNavigatorBase.h"
00016 #include "Fireworks/Core/interface/FWEventSelector.h"
00017 #include "Fireworks/Core/interface/FWConfigurable.h"
00018 #include "Fireworks/Core/interface/FWFileEntry.h"
00019 
00020 #include "DataFormats/FWLite/interface/Event.h"
00021 
00022 #include "TEventList.h"
00023 
00024 // forward declarations
00025 class TEventList;
00026 class CSGAction;
00027 class CmsShowMain;
00028 class TFile;
00029 class TGWindow;
00030 class FWGUIEventFilter;
00031 
00032 namespace edm {
00033    class EventBase;
00034    class EventID;
00035 }
00036 
00037 class CmsShowNavigator : public FWNavigatorBase
00038 {
00039 public:
00040    enum EFilterState { kOff, kOn, kWithdrawn };
00041    enum EFilterMode  { kOr = 1, kAnd = 2 };
00042    
00043 private:
00044    typedef std::list<FWFileEntry*> FQBase_t;
00045    typedef FQBase_t::iterator      FQBase_i;
00046 
00047 
00048    struct FileQueue_t : public FQBase_t
00049    {
00050       struct iterator : public FQBase_i
00051       {
00052       private:
00053          bool m_isSet;
00054 
00055       public:
00056          iterator() : m_isSet(false) {}
00057          iterator(FQBase_i i) : FQBase_i(i), m_isSet(true) {}
00058 
00059          bool isSet() const { return m_isSet; }
00060 
00061          iterator& previous(FileQueue_t& cont)
00062          {
00063             // Go back one element, set to end() when falling off the end.
00064             if (*this == cont.begin())
00065                *this = cont.end();
00066             else
00067                FQBase_i::operator--();
00068             return *this;
00069          }
00070       };
00071 
00072       FileQueue_t() : FQBase_t() {}
00073 
00074       iterator begin() { return iterator(FQBase_t::begin()); }
00075       iterator end()   { return iterator(FQBase_t::end()); }
00076    };
00077 
00078    typedef FileQueue_t::iterator FileQueue_i;
00079 
00080 public:
00081    CmsShowNavigator(const CmsShowMain &);
00082    virtual ~CmsShowNavigator();
00083 
00084    //configuration management interface
00085    virtual void addTo(FWConfiguration&) const;
00086    virtual void setFrom(const FWConfiguration&);
00087 
00088    Int_t realEntry(Int_t rawEntry);
00089    bool  openFile(const std::string& fileName);
00090    bool  appendFile(const std::string& fileName, bool checkFileQueueSize, bool live);
00091 
00092    virtual void nextEvent();
00093    virtual void previousEvent();
00094    virtual bool nextSelectedEvent();
00095    virtual bool previousSelectedEvent();
00096    virtual void firstEvent();
00097    virtual void lastEvent();
00098    virtual void goToRunEvent(edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t);
00099    void goTo(FileQueue_i fi, int event);
00100 
00101    void eventFilterEnableCallback(Bool_t);
00102    void filterEvents();
00103    void filterEventsAndReset();
00104   
00105    void setMaxNumberOfFilesToChain( unsigned int i ) {
00106       m_maxNumberOfFilesToChain = i;
00107    }
00108    
00109    virtual bool isLastEvent();
00110    virtual bool isFirstEvent();
00111 
00112    void showEventFilterGUI(const TGWindow* p);
00113    void applyFiltersFromGUI();
00114    void toggleFilterEnable();
00115    void withdrawFilter();
00116    void resumeFilter();
00117    
00118    virtual const edm::EventBase* getCurrentEvent() const;
00119 
00120    const char* frameTitle();
00121    const char* filterStatusMessage();
00122    int  getNSelectedEvents();
00123    int  getNTotalEvents();
00124    bool canEditFiltersExternally();
00125    bool filesNeedUpdate() const { return m_filesNeedUpdate; }
00126    int  getFilterState() { return m_filterState; }
00127 
00128    void editFiltersExternally();
00129 
00130    void activateNewFileOnNextEvent() { m_newFileOnNextEvent = true; }
00131    void resetNewFileOnNextEvent()    { m_newFileOnNextEvent = false; }
00132 
00133    std::vector<std::string>& getProcessList() const;
00134 
00135    sigc::signal<void, const TFile*> fileChanged_;
00136    sigc::signal<void> preFiltering_;
00137    sigc::signal<void, bool> postFiltering_;
00138    sigc::signal<void, bool> editFiltersExternally_;
00139    sigc::signal<void, int> filterStateChanged_;
00140 
00141 private:
00142    CmsShowNavigator(const CmsShowNavigator&);    // stop default
00143    const CmsShowNavigator& operator=(const CmsShowNavigator&);    // stop default
00144 
00145    void setCurrentFile(FileQueue_i);
00146    void updateFileFilters();
00147    void updateSelectorsInfo();
00148 
00149    void removeFilter(std::list<FWEventSelector*>::iterator);
00150    void addFilter(FWEventSelector*);
00151    void changeFilter(FWEventSelector*, bool filterNeedUpdate);
00152 
00153    void newFile(FileQueue_i);
00154 
00155    // ---------- member data --------------------------------
00156    
00157    std::list<FWEventSelector*>  m_selectors;
00158    FileQueue_t m_files;
00159    FileQueue_i m_currentFile;
00160    int m_currentEvent;
00161 
00162    EFilterState m_filterState;
00163    int          m_filterMode;
00164    bool         m_filesNeedUpdate;
00165    bool         m_newFileOnNextEvent;
00166    
00167    unsigned int m_maxNumberOfFilesToChain;
00168    // entry is an event index nubmer which runs from 0 to
00169    // #events or #selected_events depending on if we filter
00170    // events or not
00171    const CmsShowMain &m_main;
00172    FWGUIEventFilter*  m_guiFilter;
00173 };
00174 
00175 #endif