CMS 3D CMS Logo

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 }
FWTriggerTableViewTableManager.h
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
FWTriggerTableViewTableManager::~FWTriggerTableViewTableManager
~FWTriggerTableViewTableManager() override
Definition: FWTriggerTableViewTableManager.cc:16
FWTriggerTableView.h
FWTriggerTableViewTableManager::cellRenderer
FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const override
Definition: FWTriggerTableViewTableManager.cc:43
FWTriggerTableViewTableManager::implSort
void implSort(int iCol, bool iSortOrder) override
Definition: FWTriggerTableViewTableManager.cc:86
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cuy.col
col
Definition: cuy.py:1010
FWTriggerTableViewTableManager::m_renderer
FWTextTableCellRenderer * m_renderer
Definition: FWTriggerTableViewTableManager.h:56
FWTriggerTableView
Definition: FWTriggerTableView.h:33
FWTriggerTableViewTableManager::m_view
const FWTriggerTableView * m_view
Definition: FWTriggerTableViewTableManager.h:54
FWTriggerTableView::backgroundColor
Color_t backgroundColor() const
Definition: FWTriggerTableView.h:49
FWTextTableCellRenderer
Definition: FWTextTableCellRenderer.h:32
FWTriggerTableViewTableManager::dataChanged
void dataChanged()
Definition: FWTriggerTableViewTableManager.cc:60
FWColorManager.h
FWTableWidget.h
cms::dd::accepted
bool accepted(std::vector< std::regex > const &, std::string_view)
FWTriggerTableView::m_tableWidget
FWTableWidget * m_tableWidget
Definition: FWTriggerTableView.h:87
FWTriggerTableViewTableManager::numberOfColumns
int numberOfColumns() const override
Number of columns in the table.
Definition: FWTriggerTableViewTableManager.cc:25
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWTableManagerBase::dataChanged
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes.
Definition: FWTableManagerBase.cc:63
FWTriggerTableView::m_columns
std::vector< Column > m_columns
Definition: FWTriggerTableView.h:69
createfilelist.int
int
Definition: createfilelist.py:10
FWTriggerTableViewTableManager::FWTriggerTableViewTableManager
FWTriggerTableViewTableManager(const FWTriggerTableView *)
Definition: FWTriggerTableViewTableManager.cc:9
FWTableCellRendererBase
Definition: FWTableCellRendererBase.h:44
FWTriggerTableViewTableManager::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: FWTriggerTableViewTableManager.cc:37
FWTableManagerBase::sortOrder
bool sortOrder(void)
The current sort order for the table.
Definition: FWTableManagerBase.h:102
FWTriggerTableViewTableManager::numberOfRows
int numberOfRows() const override
Number of rows in the table.
Definition: FWTriggerTableViewTableManager.cc:18
FWTextTableCellRenderer::setData
void setData(const std::string &, bool isSelected)
Definition: FWTextTableCellRenderer.cc:98
FWTriggerTableViewTableManager::getTitles
std::vector< std::string > getTitles() const override
returns the title names for each column
Definition: FWTriggerTableViewTableManager.cc:27
FWTriggerTableViewTableManager::m_sortedToUnsortedIndices
std::vector< int > m_sortedToUnsortedIndices
Definition: FWTriggerTableViewTableManager.h:52
FWTriggerTableViewTableManager::m_graphicsContext
TGGC * m_graphicsContext
Definition: FWTriggerTableViewTableManager.h:55
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46