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 //
36  const TGGC* iContext,
37  const TGGC* iHighlightContext,
39  : m_collection(iItem),
40  m_renderer(iContext, iHighlightContext),
41  m_bodyRenderer(iContext, iHighlightContext, FWTextTableCellRenderer::kJustifyRight),
42  m_widget(iWidget) {
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  edm::TypeWithDict type(*(m_collection->modelType()->GetTypeInfo()));
49 
50  dataChanged();
51 }
52 
53 // FWCollectionSummaryTableManager::FWCollectionSummaryTableManager(const FWCollectionSummaryTableManager& rhs)
54 // {
55 // // do actual copying here;
56 // }
57 
59 
60 //
61 // assignment operators
62 //
63 // const FWCollectionSummaryTableManager& FWCollectionSummaryTableManager::operator=(const FWCollectionSummaryTableManager& rhs)
64 // {
65 // //An exception safe implementation is
66 // FWCollectionSummaryTableManager temp(rhs);
67 // swap(rhs);
68 //
69 // return *this;
70 // }
71 
72 //
73 // member functions
74 //
75 namespace {
76  template <typename S>
77  void doSort(const FWEventItem& iItem,
78  const FWItemValueGetter& iGetter,
79  int iCol,
80  std::multimap<double, int, S>& iMap,
81  std::vector<int>& oNewSort) {
82  int size = iItem.size();
83  for (int index = 0; index < size; ++index) {
84  iMap.insert(std::make_pair(iGetter.valueFor(iItem.modelData(index), iCol), index));
85  }
86  std::vector<int>::iterator itVec = oNewSort.begin();
87  for (typename std::map<double, int, S>::iterator it = iMap.begin(), itEnd = iMap.end(); it != itEnd;
88  ++it, ++itVec) {
89  *itVec = it->second;
90  }
91  }
92 } // namespace
93 
94 void FWCollectionSummaryTableManager::implSort(int iCol, bool iSortOrder) {
95  if (iSortOrder) {
96  std::multimap<double, int, std::greater<double> > s;
98  } else {
99  std::multimap<double, int, std::less<double> > s;
101  }
102 }
103 
104 void FWCollectionSummaryTableManager::buttonReleasedInRowHeader(Int_t row, Event_t* event, Int_t relX, Int_t relY) {
105  Int_t realRow = unsortedRowNumber(row);
106  int hit = m_renderer.clickHit(relX, relY);
108  return;
109  }
111  m_widget->itemColorClicked(realRow, event->fXRoot, event->fYRoot + 12 - relY);
112  return;
113  }
117  dp.setIsVisible(!dp.isVisible());
118  }
119  m_collection->setDisplayProperties(realRow, dp);
120 }
121 
122 //
123 // const member functions
124 //
126 
128 
129 std::vector<std::string> FWCollectionSummaryTableManager::getTitles() const {
130  //return titles;
131  return m_collection->valueGetter().getTitles();
132 }
133 
134 int FWCollectionSummaryTableManager::unsortedRowNumber(int iSortedRowNumber) const {
135  return m_sortedToUnsortedIndicies[iSortedRowNumber];
136 }
137 
139  if (!m_collection->valueGetter().numValues()) {
140  return nullptr;
141  }
142  if (iSortedRowNumber >= static_cast<int>(m_collection->size())) {
143  m_bodyRenderer.setData("", false);
144  return &m_bodyRenderer;
145  }
146  int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
147  std::stringstream s;
148  s.setf(std::ios_base::fixed, std::ios_base::floatfield);
149  s.precision(m_collection->valueGetter().precision(iCol));
150  double v = m_collection->valueGetter().valueFor(m_collection->modelData(index), iCol);
151  s << v;
153  return &m_bodyRenderer;
154 }
155 
157 
159  if (iSortedRowNumber >= static_cast<int>(m_collection->size())) {
160  return nullptr;
161  }
162  int index = m_sortedToUnsortedIndicies[iSortedRowNumber];
164  return &m_renderer;
165 }
166 
170  for (int i = 0; i < static_cast<int>(m_collection->size()); ++i) {
171  m_sortedToUnsortedIndicies.push_back(i);
172  }
174 }
175 //
176 // static member functions
177 //
size
Write out results.
type
Definition: HCALResponse.h:21
FWCollectionSummaryModelCellRenderer m_renderer
const FWItemValueGetter & valueGetter() const
one value from the model which is normally used for the popup
Definition: FWEventItem.h:112
std::vector< std::string > getTitles() const override
returns the title names for each column
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
bool isSelected() const
Definition: FWEventItem.h:65
void setDisplayProperties(int iIndex, const FWDisplayProperties &) const
Definition: FWEventItem.cc:247
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
int numberOfRows() const override
Number of rows in the table.
void buttonReleasedInRowHeader(Int_t row, Event_t *event, Int_t relX, Int_t relY) override
FWTableCellRendererBase * rowHeader(int iSortedRowNumber) const override
Returns the renderer for the row header for the sorted row number iSortedRowNumber.
void itemColorClicked(int iIndex, Int_t iRootX, Int_t iRootY)
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:181
void setData(const std::string &, bool isSelected)
size_t size() const
Definition: FWEventItem.cc:457
std::vector< std::string > getTitles() const
void setData(const FWEventItem *iItem, int iIndex)
double valueFor(const void *, int idx) const
void implSort(int iCol, bool iSortOrder) override
Called by &#39;sort&#39; method to actually handle the sorting of the rows. Arguments are the same as &#39;sort&#39;...
FWModelChangeSignal changed_
Definition: FWEventItem.h:178
const TClass * modelType() const
Definition: FWEventItem.cc:464
int numberOfColumns() const override
Number of columns in the table.
FWCollectionSummaryTableManager(FWEventItem *iCollection, const TGGC *iContext, const TGGC *iHighlightContext, FWCollectionSummaryWidget *)
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const override
UInt_t precision(int idx) const
void setIsVisible(bool iSet)
int unsortedRowNumber(int iSortedRowNumber) const override
when passed the index to the sorted order of the rows it returns the original row number from the und...
Definition: event.py:1
bool hasRowHeaders() const override
Returns &#39;true&#39; if this table has row headers. Defaults return value is false.