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  }
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));
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 //
FWCollectionSummaryModelCellRenderer::kHitColor
Definition: FWCollectionSummaryModelCellRenderer.h:36
FWCollectionSummaryTableManager::m_collection
FWEventItem * m_collection
Definition: FWCollectionSummaryTableManager.h:69
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
FWCollectionSummaryTableManager::getTitles
std::vector< std::string > getTitles() const override
returns the title names for each column
Definition: FWCollectionSummaryTableManager.cc:129
FWEventItem::modelInfo
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
mps_fire.i
i
Definition: mps_fire.py:355
FWCollectionSummaryTableManager::numberOfColumns
int numberOfColumns() const override
Number of columns in the table.
Definition: FWCollectionSummaryTableManager.cc:127
FWCollectionSummaryTableManager::m_bodyRenderer
FWTextTableCellRenderer m_bodyRenderer
Definition: FWCollectionSummaryTableManager.h:73
FWEventItem::valueGetter
const FWItemValueGetter & valueGetter() const
one value from the model which is normally used for the popup
Definition: FWEventItem.h:112
FWItemValueGetter.h
FWCollectionSummaryTableManager::implSort
void implSort(int iCol, bool iSortOrder) override
Called by 'sort' method to actually handle the sorting of the rows. Arguments are the same as 'sort'.
Definition: FWCollectionSummaryTableManager.cc:94
FWCollectionSummaryTableManager::m_widget
FWCollectionSummaryWidget * m_widget
Definition: FWCollectionSummaryTableManager.h:74
FWEventItem::modelData
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
FWTextTableCellRenderer
Definition: FWTextTableCellRenderer.h:32
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FWCollectionSummaryTableManager::cellRenderer
FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const override
Definition: FWCollectionSummaryTableManager.cc:138
FWEventItem::ModelInfo
Definition: FWEventItem.h:58
alignCSCRings.s
s
Definition: alignCSCRings.py:92
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:157
FWCollectionSummaryTableManager.h
FWItemValueGetter
Definition: FWItemValueGetter.h:32
FWEventItem::modelType
const TClass * modelType() const
Definition: FWEventItem.cc:464
FWCollectionSummaryModelCellRenderer::setData
void setData(const FWEventItem *iItem, int iIndex)
Definition: FWCollectionSummaryModelCellRenderer.cc:90
FWCollectionSummaryTableManager::rowHeader
FWTableCellRendererBase * rowHeader(int iSortedRowNumber) const override
Returns the renderer for the row header for the sorted row number iSortedRowNumber.
Definition: FWCollectionSummaryTableManager.cc:158
FWCollectionSummaryModelCellRenderer::kMiss
Definition: FWCollectionSummaryModelCellRenderer.h:36
FWCollectionSummaryTableManager::m_sortedToUnsortedIndicies
std::vector< int > m_sortedToUnsortedIndicies
Definition: FWCollectionSummaryTableManager.h:70
FWCollectionSummaryTableManager::m_renderer
FWCollectionSummaryModelCellRenderer m_renderer
Definition: FWCollectionSummaryTableManager.h:72
edm::TypeWithDict
Definition: TypeWithDict.h:38
FWTableManagerBase::dataChanged
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes.
Definition: FWTableManagerBase.cc:63
FWCollectionSummaryWidget::itemColorClicked
void itemColorClicked(int iIndex, Int_t iRootX, Int_t iRootY)
Definition: FWCollectionSummaryWidget.cc:509
FWEventItem::itemChanged_
FWItemChangeSignal itemChanged_
Definition: FWEventItem.h:181
FWItemValueGetter::getTitles
std::vector< std::string > getTitles() const
Definition: FWItemValueGetter.cc:130
FWEventItem::ModelInfo::isSelected
bool isSelected() const
Definition: FWEventItem.h:65
FWCollectionSummaryModelCellRenderer::clickHit
ClickHit clickHit(int iX, int iY) const
Definition: FWCollectionSummaryModelCellRenderer.cc:100
FWItemValueGetter::precision
UInt_t precision(int idx) const
Definition: FWItemValueGetter.cc:128
FWTableCellRendererBase
Definition: FWTableCellRendererBase.h:44
FWEventItem::setDisplayProperties
void setDisplayProperties(int iIndex, const FWDisplayProperties &) const
Definition: FWEventItem.cc:247
FWEventItem.h
FWEventItem::ModelInfo::displayProperties
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
FWTextTableCellRenderer::setData
void setData(const std::string &, bool isSelected)
Definition: FWTextTableCellRenderer.cc:98
FWDisplayProperties
Definition: FWDisplayProperties.h:28
FWCollectionSummaryTableManager::unsortedRowNumber
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: FWCollectionSummaryTableManager.cc:134
FWCollectionSummaryTableManager::hasRowHeaders
bool hasRowHeaders() const override
Returns 'true' if this table has row headers. Defaults return value is false.
Definition: FWCollectionSummaryTableManager.cc:156
FWCollectionSummaryTableManager::buttonReleasedInRowHeader
void buttonReleasedInRowHeader(Int_t row, Event_t *event, Int_t relX, Int_t relY) override
Definition: FWCollectionSummaryTableManager.cc:104
FWCollectionSummaryModelCellRenderer::kHitCheck
Definition: FWCollectionSummaryModelCellRenderer.h:36
FWEventItem
Definition: FWEventItem.h:56
type
type
Definition: HCALResponse.h:21
FWItemValueGetter::valueFor
double valueFor(const void *, int idx) const
Definition: FWItemValueGetter.cc:122
FWCollectionSummaryWidget
Definition: FWCollectionSummaryWidget.h:49
FWCollectionSummaryTableManager::dataChanged
void dataChanged()
Definition: FWCollectionSummaryTableManager.cc:167
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FWCollectionSummaryTableManager::FWCollectionSummaryTableManager
FWCollectionSummaryTableManager(FWEventItem *iCollection, const TGGC *iContext, const TGGC *iHighlightContext, FWCollectionSummaryWidget *)
Definition: FWCollectionSummaryTableManager.cc:35
FWItemValueGetter::numValues
int numValues() const
Definition: FWItemValueGetter.cc:140
event
Definition: event.py:1
FWCollectionSummaryWidget.h
FWCollectionSummaryTableManager::~FWCollectionSummaryTableManager
~FWCollectionSummaryTableManager() override
Definition: FWCollectionSummaryTableManager.cc:58
FWEventItem::changed_
FWModelChangeSignal changed_
Definition: FWEventItem.h:178
FWCollectionSummaryTableManager::numberOfRows
int numberOfRows() const override
Number of rows in the table.
Definition: FWCollectionSummaryTableManager.cc:125
hit
Definition: SiStripHitEffFromCalibTree.cc:88
FWEventItem::size
size_t size() const
Definition: FWEventItem.cc:457
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443