CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWTriggerTableViewTableManager.cc
Go to the documentation of this file.
1 
2 #include <cassert>
3 #include "TGClient.h"
8 
10  : m_view(view), m_graphicsContext(nullptr), m_renderer(nullptr) {
11  GCValues_t gc = *(m_view->m_tableWidget->GetWhiteGC().GetAttributes());
12  m_graphicsContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc, kTRUE);
14 }
15 
17 
19  if (!m_view->m_columns.empty())
20  return m_view->m_columns.front().values.size();
21  else
22  return 0;
23 }
24 
26 
27 std::vector<std::string> FWTriggerTableViewTableManager::getTitles() const {
28  unsigned int n = numberOfColumns();
29  std::vector<std::string> ret;
30  ret.reserve(n);
31  for (unsigned int i = 0; i < n; ++i) {
32  ret.push_back(m_view->m_columns.at(i).title);
33  }
34  return ret;
35 }
36 
37 int FWTriggerTableViewTableManager::unsortedRowNumber(int iSortedRowNumber) const {
38  if (iSortedRowNumber >= (int)m_sortedToUnsortedIndices.size())
39  return 0;
40  return m_sortedToUnsortedIndices[iSortedRowNumber];
41 }
42 
44  const int realRowNumber = unsortedRowNumber(iSortedRowNumber);
45  const int acceptColumn = 1;
46  if (!m_view->m_columns.empty() && int(m_view->m_columns.size()) > iCol &&
47  int(m_view->m_columns.front().values.size()) > realRowNumber) {
48  bool accepted = std::string(m_view->m_columns.at(acceptColumn).values.at(realRowNumber)) == "1";
49  if ((m_view->backgroundColor() == kBlack) == accepted)
50  m_graphicsContext->SetForeground(0xe0e0e0);
51  else
52  m_graphicsContext->SetForeground(0x404040);
53  m_renderer->setData(m_view->m_columns.at(iCol).values.at(realRowNumber), false);
54  } else {
55  m_renderer->setData("invalid", false);
56  }
57  return m_renderer;
58 }
59 
62  for (int i = 0; i < numberOfRows(); ++i)
63  m_sortedToUnsortedIndices.push_back(i);
65 }
66 
67 namespace {
68  template <typename TMap>
69  void doSort(int col,
70  const std::vector<FWTriggerTableView::Column>& iData,
71  TMap& iOrdered,
72  std::vector<int>& oRowToIndex) {
73  unsigned int index = 0;
74  for (std::vector<std::string>::const_iterator it = iData.at(col).values.begin(), itEnd = iData.at(col).values.end();
75  it != itEnd;
76  ++it, ++index) {
77  iOrdered.insert(std::make_pair(*it, index));
78  }
79  unsigned int row = 0;
80  for (typename TMap::iterator it = iOrdered.begin(), itEnd = iOrdered.end(); it != itEnd; ++it, ++row) {
81  oRowToIndex[row] = it->second;
82  }
83  }
84 } // namespace
85 
86 void FWTriggerTableViewTableManager::implSort(int col, bool sortOrder) {
87  if (sortOrder) {
88  std::multimap<std::string, int, std::greater<std::string> > ordered;
89  doSort(col, m_view->m_columns, ordered, m_sortedToUnsortedIndices);
90  } else {
91  std::multimap<std::string, int> ordered;
92  doSort(col, m_view->m_columns, ordered, m_sortedToUnsortedIndices);
93  }
94 }
tuple ret
prodAgent to be discontinued
FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const override
std::vector< Column > m_columns
int numberOfColumns() const override
Number of columns in the table.
void implSort(int iCol, bool iSortOrder) override
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
FWTableWidget * m_tableWidget
int numberOfRows() const override
Number of rows in the table.
FWTriggerTableViewTableManager(const FWTriggerTableView *)
Color_t backgroundColor() const
void setData(const std::string &, bool isSelected)
std::vector< std::string > getTitles() const override
returns the title names for each column
int col
Definition: cuy.py:1009
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...