CMS 3D CMS Logo

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