CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: FWCollectionSummaryTableManager.cc,v 1.13 2012/06/26 22:13:03 wmtan Exp $
12 //
13 
14 // system include files
15 #include <sstream>
16 #include <boost/bind.hpp>
17 #include "TClass.h"
18 
19 // user include files
24 
25 //
26 // constants, enums and typedefs
27 //
28 
29 //
30 // static data member definitions
31 //
32 
33 //
34 // constructors and destructor
35 //
36 FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(FWEventItem* iItem, const TGGC* iContext, const TGGC* iHighlightContext,
37  FWCollectionSummaryWidget* iWidget):
38  m_collection(iItem),
39  m_renderer(iContext,iHighlightContext),
40  m_bodyRenderer(iContext, iHighlightContext, FWTextTableCellRenderer::kJustifyRight),
41  m_widget(iWidget)
42 {
43  m_collection->changed_.connect(boost::bind(&FWTableManagerBase::dataChanged,this));
45 
46  //try to find the default columns
47  std::vector<std::pair<std::string,std::string> > s_names;
48  Reflex::Type type = Reflex::Type::ByTypeInfo(*(m_collection->modelType()->GetTypeInfo()));
49 
50 
51  dataChanged();
52 }
53 
54 // FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(const FWCollectionSummaryTableManager& rhs)
55 // {
56 // // do actual copying here;
57 // }
58 
60 {
61 }
62 
63 //
64 // assignment operators
65 //
66 // const FWCollectionSummaryTableManager& FWCollectionSummaryTableManager::operator=(const FWCollectionSummaryTableManager& rhs)
67 // {
68 // //An exception safe implementation is
69 // FWCollectionSummaryTableManager temp(rhs);
70 // swap(rhs);
71 //
72 // return *this;
73 // }
74 
75 //
76 // member functions
77 //
78 namespace {
79  template<typename S>
80  void doSort(const FWEventItem& iItem,
81  const FWItemValueGetter& iGetter, int iCol,
82  std::multimap<double,int,S>& iMap,
83  std::vector<int>& oNewSort) {
84  int size = iItem.size();
85  for(int index = 0; index < size; ++index) {
86  iMap.insert(std::make_pair(iGetter.valueFor(iItem.modelData(index), iCol),
87  index));
88  }
89  std::vector<int>::iterator itVec = oNewSort.begin();
90  for(typename std::map<double,int,S>::iterator it = iMap.begin(), itEnd = iMap.end();
91  it != itEnd;
92  ++it,++itVec) {
93  *itVec = it->second;
94  }
95  }
96 }
97 
98 void
100 {
101  if(iSortOrder) {
102  std::multimap<double,int, std::greater<double> > s;
104  } else {
105  std::multimap<double,int, std::less<double> > s;
107  }
108 }
109 
110 void
111 FWCollectionSummaryTableManager::buttonReleasedInRowHeader(Int_t row, Event_t* event, Int_t relX, Int_t relY)
112 {
113  Int_t realRow = unsortedRowNumber(row);
114  int hit = m_renderer.clickHit(relX,relY);
116  return;
117  }
119  m_widget->itemColorClicked(realRow,event->fXRoot, event->fYRoot+12-relY);
120  return;
121  }
125  dp.setIsVisible(!dp.isVisible());
126  }
127  m_collection->setDisplayProperties(realRow,dp);
128 }
129 
130 //
131 // const member functions
132 //
133 int
135 {
136  return m_collection->size();
137 }
138 
139 int
141  return m_collection->valueGetter().numValues();
142 }
143 
144 std::vector<std::string>
146 
147 
148 
149  //return titles;
150  return m_collection->valueGetter().getTitles();
151 }
152 
153 int
155 {
156  return m_sortedToUnsortedIndicies[iSortedRowNumber];
157 }
158 
160 FWCollectionSummaryTableManager::cellRenderer(int iSortedRowNumber, int iCol) const
161 {
163  return 0;
164  }
165  if(iSortedRowNumber >= static_cast<int>(m_collection->size())) {
166  m_bodyRenderer.setData("",false);
167  return &m_bodyRenderer;
168  }
169  int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
170  std::stringstream s;
171  s.setf(std::ios_base::fixed,std::ios_base::floatfield);
172  s.precision( m_collection->valueGetter().precision(iCol));
173  double v = m_collection->valueGetter().valueFor(m_collection->modelData(index), iCol);
174  s <<v;
176  return &m_bodyRenderer;
177 }
178 
179 bool
181 {
182  return true;
183 }
184 
187 {
188  if(iSortedRowNumber >= static_cast<int>(m_collection->size())) {
189  return 0;
190  }
191  int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
193  index);
194  return &m_renderer;
195 }
196 
197 void
199 {
202  for(int i=0; i< static_cast<int>(m_collection->size());++i) {
203  m_sortedToUnsortedIndicies.push_back(i);
204  }
206 }
207 //
208 // static member functions
209 //
virtual FWTableCellRendererBase * rowHeader(int iSortedRowNumber) const
Returns the renderer for the row header for the sorted row number iSortedRowNumber.
type
Definition: HCALResponse.h:22
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:277
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:199
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
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:548
std::vector< std::string > getTitles() const
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:196
virtual int numberOfColumns() const
Number of columns in the table.
const TClass * modelType() const
Definition: FWEventItem.cc:561
FWCollectionSummaryTableManager(FWEventItem *iCollection, const TGGC *iContext, const TGGC *iHighlightContext, FWCollectionSummaryWidget *)
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:567
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535
UInt_t precision(int idx) const
void setIsVisible(bool iSet)
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const
tuple size
Write out results.
mathSSE::Vec4< T > v