CMS 3D CMS Logo

FWCollectionSummaryTableManager.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWCollectionSummaryTableManager
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Sun Feb 22 10:13:39 CST 2009
11 //
12 
13 // system include files
14 #include <sstream>
15 #include <boost/bind.hpp>
16 #include "TClass.h"
17 
18 // user include files
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
35 FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(FWEventItem* iItem, const TGGC* iContext, const TGGC* iHighlightContext,
36  FWCollectionSummaryWidget* iWidget):
37  m_collection(iItem),
38  m_renderer(iContext,iHighlightContext),
39  m_bodyRenderer(iContext, iHighlightContext, FWTextTableCellRenderer::kJustifyRight),
40  m_widget(iWidget)
41 {
42  m_collection->changed_.connect(boost::bind(&FWTableManagerBase::dataChanged,this));
44 
45  //try to find the default columns
46  std::vector<std::pair<std::string,std::string> > s_names;
47  edm::TypeWithDict type(*(m_collection->modelType()->GetTypeInfo()));
48 
49 
50  dataChanged();
51 }
52 
53 // FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(const FWCollectionSummaryTableManager& rhs)
54 // {
55 // // do actual copying here;
56 // }
57 
59 {
60 }
61 
62 //
63 // assignment operators
64 //
65 // const FWCollectionSummaryTableManager& FWCollectionSummaryTableManager::operator=(const FWCollectionSummaryTableManager& rhs)
66 // {
67 // //An exception safe implementation is
68 // FWCollectionSummaryTableManager temp(rhs);
69 // swap(rhs);
70 //
71 // return *this;
72 // }
73 
74 //
75 // member functions
76 //
77 namespace {
78  template<typename S>
79  void doSort(const FWEventItem& iItem,
80  const FWItemValueGetter& iGetter, int iCol,
81  std::multimap<double,int,S>& iMap,
82  std::vector<int>& oNewSort) {
83  int size = iItem.size();
84  for(int index = 0; index < size; ++index) {
85  iMap.insert(std::make_pair(iGetter.valueFor(iItem.modelData(index), iCol),
86  index));
87  }
88  std::vector<int>::iterator itVec = oNewSort.begin();
89  for(typename std::map<double,int,S>::iterator it = iMap.begin(), itEnd = iMap.end();
90  it != itEnd;
91  ++it,++itVec) {
92  *itVec = it->second;
93  }
94  }
95 }
96 
97 void
99 {
100  if(iSortOrder) {
101  std::multimap<double,int, std::greater<double> > s;
103  } else {
104  std::multimap<double,int, std::less<double> > s;
106  }
107 }
108 
109 void
110 FWCollectionSummaryTableManager::buttonReleasedInRowHeader(Int_t row, Event_t* event, Int_t relX, Int_t relY)
111 {
112  Int_t realRow = unsortedRowNumber(row);
113  int hit = m_renderer.clickHit(relX,relY);
115  return;
116  }
118  m_widget->itemColorClicked(realRow,event->fXRoot, event->fYRoot+12-relY);
119  return;
120  }
124  dp.setIsVisible(!dp.isVisible());
125  }
126  m_collection->setDisplayProperties(realRow,dp);
127 }
128 
129 //
130 // const member functions
131 //
132 int
134 {
135  return m_collection->size();
136 }
137 
138 int
140  return m_collection->valueGetter().numValues();
141 }
142 
143 std::vector<std::string>
145 
146 
147 
148  //return titles;
149  return m_collection->valueGetter().getTitles();
150 }
151 
152 int
154 {
155  return m_sortedToUnsortedIndicies[iSortedRowNumber];
156 }
157 
159 FWCollectionSummaryTableManager::cellRenderer(int iSortedRowNumber, int iCol) const
160 {
162  return 0;
163  }
164  if(iSortedRowNumber >= static_cast<int>(m_collection->size())) {
165  m_bodyRenderer.setData("",false);
166  return &m_bodyRenderer;
167  }
168  int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
169  std::stringstream s;
170  s.setf(std::ios_base::fixed,std::ios_base::floatfield);
171  s.precision( m_collection->valueGetter().precision(iCol));
172  double v = m_collection->valueGetter().valueFor(m_collection->modelData(index), iCol);
173  s <<v;
175  return &m_bodyRenderer;
176 }
177 
178 bool
180 {
181  return true;
182 }
183 
186 {
187  if(iSortedRowNumber >= static_cast<int>(m_collection->size())) {
188  return 0;
189  }
190  int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
192  index);
193  return &m_renderer;
194 }
195 
196 void
198 {
201  for(int i=0; i< static_cast<int>(m_collection->size());++i) {
202  m_sortedToUnsortedIndicies.push_back(i);
203  }
205 }
206 //
207 // static member functions
208 //
virtual FWTableCellRendererBase * rowHeader(int iSortedRowNumber) const
Returns the renderer for the row header for the sorted row number iSortedRowNumber.
size
Write out results.
type
Definition: HCALResponse.h:21
FWCollectionSummaryModelCellRenderer m_renderer
int i
Definition: DBlmapReader.cc:9
const FWItemValueGetter & valueGetter() const
one value from the model which is normally used for the popup
Definition: FWEventItem.h:119
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
virtual void implSort(int iCol, bool iSortOrder)
Called by &#39;sort&#39; method to actually handle the sorting of the rows. Arguments are the same as &#39;sort&#39;...
bool isSelected() const
Definition: FWEventItem.h:71
void setDisplayProperties(int iIndex, const FWDisplayProperties &) const
Definition: FWEventItem.cc:278
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
virtual bool hasRowHeaders() const
Returns &#39;true&#39; if this table has row headers. Defaults return value is false.
virtual std::vector< std::string > getTitles() const
returns the title names for each column
virtual int numberOfRows() const
Number of rows in the table.
void itemColorClicked(int iIndex, Int_t iRootX, Int_t iRootY)
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:203
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 und...
void setData(const std::string &, bool isSelected)
size_t size() const
Definition: FWEventItem.cc:550
std::vector< std::string > getTitles() const
auto dp
Definition: deltaR.h:22
void setData(const FWEventItem *iItem, int iIndex)
double valueFor(const void *, int idx) const
virtual void buttonReleasedInRowHeader(Int_t row, Event_t *event, Int_t relX, Int_t relY)
FWModelChangeSignal changed_
Definition: FWEventItem.h:200
virtual int numberOfColumns() const
Number of columns in the table.
const TClass * modelType() const
Definition: FWEventItem.cc:563
FWCollectionSummaryTableManager(FWEventItem *iCollection, const TGGC *iContext, const TGGC *iHighlightContext, FWCollectionSummaryWidget *)
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:569
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:537
UInt_t precision(int idx) const
void setIsVisible(bool iSet)
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const
Definition: event.py:1