CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

FWCollectionSummaryTableManager Class Reference

#include <Fireworks/Core/interface/FWCollectionSummaryTableManager.h>

Inheritance diagram for FWCollectionSummaryTableManager:
FWTableManagerBase

List of all members.

Public Member Functions

virtual void buttonReleasedInRowHeader (Int_t row, Event_t *event, Int_t relX, Int_t relY)
virtual FWTableCellRendererBasecellRenderer (int iSortedRowNumber, int iCol) const
 FWCollectionSummaryTableManager (FWEventItem *iCollection, const TGGC *iContext, const TGGC *iHighlightContext, FWCollectionSummaryWidget *)
virtual std::vector< std::string > getTitles () const
 returns the title names for each column
virtual bool hasRowHeaders () const
 Returns 'true' if this table has row headers. Defaults return value is false.
virtual int numberOfColumns () const
 Number of columns in the table.
virtual int numberOfRows () const
 Number of rows in the table.
virtual FWTableCellRendererBaserowHeader (int iSortedRowNumber) const
 Returns the renderer for the row header for the sorted row number iSortedRowNumber.
virtual int unsortedRowNumber (int iSortedRowNumber) const
 when passed the index to the sorted order of the rows it returns the original row number from the underlying data
virtual ~FWCollectionSummaryTableManager ()

Protected Member Functions

virtual void implSort (int iCol, bool iSortOrder)
 Called by 'sort' method to actually handle the sorting of the rows. Arguments are the same as 'sort'.

Private Member Functions

void dataChanged ()
 Classes which inherit from FWTableManagerBase must call this when their underlying data changes.
 FWCollectionSummaryTableManager (const FWCollectionSummaryTableManager &)
const
FWCollectionSummaryTableManager
operator= (const FWCollectionSummaryTableManager &)

Private Attributes

FWTextTableCellRenderer m_bodyRenderer
FWEventItemm_collection
FWCollectionSummaryModelCellRenderer m_renderer
std::vector< int > m_sortedToUnsortedIndicies
std::vector< boost::shared_ptr
< FWItemValueGetter > > 
m_valueGetters
FWCollectionSummaryWidgetm_widget

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 36 of file FWCollectionSummaryTableManager.h.


Constructor & Destructor Documentation

FWCollectionSummaryTableManager::FWCollectionSummaryTableManager ( FWEventItem iCollection,
const TGGC *  iContext,
const TGGC *  iHighlightContext,
FWCollectionSummaryWidget iWidget 
)

Definition at line 36 of file FWCollectionSummaryTableManager.cc.

References FWEventItem::changed_, FWTableManagerBase::dataChanged(), dataChanged(), eta(), FWEventItem::itemChanged_, m_collection, m_valueGetters, FWEventItem::modelType(), phi, and FWEventItem::purpose().

                                   :
m_collection(iItem),
m_renderer(iContext,iHighlightContext),
m_bodyRenderer(iContext, iHighlightContext, FWTextTableCellRenderer::kJustifyRight),
m_widget(iWidget)
{
   m_collection->changed_.connect(boost::bind(&FWTableManagerBase::dataChanged,this));
   m_collection->itemChanged_.connect(boost::bind(&FWCollectionSummaryTableManager::dataChanged,this));
   
   //try to find the default columns
   std::vector<std::pair<std::string,std::string> > s_names;
   ROOT::Reflex::Type type = ROOT::Reflex::Type::ByTypeInfo(*(m_collection->modelType()->GetTypeInfo()));

   if ( type.Name() == "CaloTower" ){
     if ( m_collection->purpose() == "ECal" ){
       s_names.push_back(std::pair<std::string,std::string>("emEt","GeV"));
       boost::shared_ptr<FWItemValueGetter> trans( new FWItemValueGetter(type,s_names));
       if(trans->isValid()) m_valueGetters.push_back(trans);
     }
     else if ( m_collection->purpose() == "HCal" ){
       s_names.push_back(std::pair<std::string,std::string>("hadEt","GeV"));
       boost::shared_ptr<FWItemValueGetter> hadEt( new FWItemValueGetter(type,s_names));
       if(hadEt->isValid()) m_valueGetters.push_back(hadEt);
     }
     else if (m_collection->purpose() == "HCal Outer"){
        s_names.push_back(std::pair<std::string,std::string>("outerEt","GeV"));
        boost::shared_ptr<FWItemValueGetter> outerEt( new FWItemValueGetter(type,s_names));
        if(outerEt->isValid()) m_valueGetters.push_back(outerEt);
     }
   } else {
     s_names.push_back(std::pair<std::string,std::string>("pt","GeV"));
     s_names.push_back(std::pair<std::string,std::string>("et","GeV"));
     s_names.push_back(std::pair<std::string,std::string>("energy","GeV"));
     boost::shared_ptr<FWItemValueGetter> trans( new FWItemValueGetter(type,s_names));
     if(trans->isValid()) m_valueGetters.push_back(trans);
   }

   
   s_names.clear();
   s_names.push_back(std::pair<std::string,std::string>("eta",""));
   boost::shared_ptr<FWItemValueGetter> eta( new FWItemValueGetter(type,s_names));
   if(eta->isValid()) {
      s_names.clear();
      s_names.push_back(std::pair<std::string,std::string>("phi",""));
      boost::shared_ptr<FWItemValueGetter> phi( new FWItemValueGetter(type,s_names));
      if(phi->isValid()) {
         m_valueGetters.push_back(eta);
         m_valueGetters.push_back(phi);
      }
   }
   
   dataChanged();
}
FWCollectionSummaryTableManager::~FWCollectionSummaryTableManager ( ) [virtual]

Definition at line 96 of file FWCollectionSummaryTableManager.cc.

{
}
FWCollectionSummaryTableManager::FWCollectionSummaryTableManager ( const FWCollectionSummaryTableManager ) [private]

Member Function Documentation

void FWCollectionSummaryTableManager::buttonReleasedInRowHeader ( Int_t  row,
Event_t *  event,
Int_t  relX,
Int_t  relY 
) [virtual]
FWTableCellRendererBase * FWCollectionSummaryTableManager::cellRenderer ( int  iSortedRowNumber,
int  iCol 
) const [virtual]

Returns the particular renderer used to handle the requested cell. Arguments: iSortedRowNumber: the row number from the present sort (i.e. the cell number of the view) iCol: the column number of the cell. The returned value must be used immediately and not held onto since the same Renderer can be used for subsequent calls

Implements FWTableManagerBase.

Definition at line 200 of file FWCollectionSummaryTableManager.cc.

References getHLTprescales::index, m_bodyRenderer, m_collection, m_sortedToUnsortedIndicies, m_valueGetters, FWEventItem::modelData(), FWEventItem::modelInfo(), asciidump::s, FWTextTableCellRenderer::setData(), FWEventItem::size(), and v.

{
   if(iCol >= static_cast<int>(m_valueGetters.size())) {
      return 0;
   }
   if(iSortedRowNumber >= static_cast<int>(m_collection->size())) {
      m_bodyRenderer.setData("",false);
      return &m_bodyRenderer;
   }
   int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
   std::stringstream s;
   s.setf(std::ios_base::fixed,std::ios_base::floatfield);
   s.precision(1);
   double v = m_valueGetters[iCol]->valueFor(m_collection->modelData(index));
   s <<v;
   m_bodyRenderer.setData(s.str(),
                          m_collection->modelInfo(index).isSelected());
   return &m_bodyRenderer;
}
void FWCollectionSummaryTableManager::dataChanged ( void  ) [private]

Classes which inherit from FWTableManagerBase must call this when their underlying data changes.

Reimplemented from FWTableManagerBase.

Definition at line 239 of file FWCollectionSummaryTableManager.cc.

References i, m_collection, m_sortedToUnsortedIndicies, and FWEventItem::size().

Referenced by FWCollectionSummaryTableManager().

std::vector< std::string > FWCollectionSummaryTableManager::getTitles ( ) const [virtual]

returns the title names for each column

Implements FWTableManagerBase.

Definition at line 182 of file FWCollectionSummaryTableManager.cc.

References m_valueGetters.

                                                 {
   std::vector<std::string> titles;
   titles.reserve(m_valueGetters.size());
   for(std::vector<boost::shared_ptr<FWItemValueGetter> >::const_iterator it = m_valueGetters.begin(), itEnd=m_valueGetters.end();
       it != itEnd;
       ++it) {
      titles.push_back((*it)->valueName());
   }
   return titles;
}
bool FWCollectionSummaryTableManager::hasRowHeaders ( ) const [virtual]

Returns 'true' if this table has row headers. Defaults return value is false.

Reimplemented from FWTableManagerBase.

Definition at line 221 of file FWCollectionSummaryTableManager.cc.

{
   return true;
}
void FWCollectionSummaryTableManager::implSort ( int  iCol,
bool  iSortOrder 
) [protected, virtual]

Called by 'sort' method to actually handle the sorting of the rows. Arguments are the same as 'sort'.

Implements FWTableManagerBase.

Definition at line 136 of file FWCollectionSummaryTableManager.cc.

References m_collection, m_sortedToUnsortedIndicies, m_valueGetters, and asciidump::s.

{
   if(iSortOrder) {
      std::multimap<double,int, std::greater<double> > s;
      doSort(*m_collection, *(m_valueGetters[iCol]), s, m_sortedToUnsortedIndicies);
   } else {
      std::multimap<double,int, std::less<double> > s;
      doSort(*m_collection, *(m_valueGetters[iCol]), s, m_sortedToUnsortedIndicies);
   }
}
int FWCollectionSummaryTableManager::numberOfColumns ( ) const [virtual]

Number of columns in the table.

Implements FWTableManagerBase.

Definition at line 177 of file FWCollectionSummaryTableManager.cc.

References m_valueGetters.

                                                       {
   return m_valueGetters.size();
}
int FWCollectionSummaryTableManager::numberOfRows ( ) const [virtual]

Number of rows in the table.

Implements FWTableManagerBase.

Definition at line 171 of file FWCollectionSummaryTableManager.cc.

References m_collection, and FWEventItem::size().

{
   return m_collection->size();
}
const FWCollectionSummaryTableManager& FWCollectionSummaryTableManager::operator= ( const FWCollectionSummaryTableManager ) [private]
FWTableCellRendererBase * FWCollectionSummaryTableManager::rowHeader ( int  iSortedRowNumber) const [virtual]

Returns the renderer for the row header for the sorted row number iSortedRowNumber.

Reimplemented from FWTableManagerBase.

Definition at line 227 of file FWCollectionSummaryTableManager.cc.

References getHLTprescales::index, m_collection, m_renderer, m_sortedToUnsortedIndicies, FWCollectionSummaryModelCellRenderer::setData(), and FWEventItem::size().

{
   if(iSortedRowNumber >= static_cast<int>(m_collection->size())) {
      return 0;
   }
   int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
   m_renderer.setData(m_collection,
                      index);
   return &m_renderer;
}
int FWCollectionSummaryTableManager::unsortedRowNumber ( int  iSortedRowNumber) const [virtual]

when passed the index to the sorted order of the rows it returns the original row number from the underlying data

Implements FWTableManagerBase.

Definition at line 194 of file FWCollectionSummaryTableManager.cc.

References m_sortedToUnsortedIndicies.

Referenced by buttonReleasedInRowHeader().

{
   return m_sortedToUnsortedIndicies[iSortedRowNumber];
}

Member Data Documentation

Definition at line 72 of file FWCollectionSummaryTableManager.h.

Referenced by cellRenderer().

Definition at line 71 of file FWCollectionSummaryTableManager.h.

Referenced by buttonReleasedInRowHeader(), and rowHeader().

std::vector<boost::shared_ptr<FWItemValueGetter> > FWCollectionSummaryTableManager::m_valueGetters [private]

Definition at line 73 of file FWCollectionSummaryTableManager.h.

Referenced by buttonReleasedInRowHeader().