CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
FWTableViewTableManager Class Reference

#include <Fireworks/Core/interface/FWTableViewTableManager.h>

Inheritance diagram for FWTableViewTableManager:
FWTableManagerBase

Public Member Functions

FWTableCellRendererBasecellRenderer (int iSortedRowNumber, int iCol) const override
 
void dataChanged ()
 Called if mouse button pressed in Row Header, defaults is to do nothing. More...
 
 FWTableViewTableManager (const FWTableView *)
 
 FWTableViewTableManager (const FWTableViewTableManager &)=delete
 
std::vector< std::string > getTitles () const override
 returns the title names for each column More...
 
bool hasRowHeaders () const override
 require all cells to be the same height More...
 
int numberOfColumns () const override
 Number of columns in the table. More...
 
int numberOfRows () const override
 Number of rows in the table. More...
 
const FWTableViewTableManageroperator= (const FWTableViewTableManager &)=delete
 
FWTableCellRendererBaserowHeader (int iSortedRowNumber) const override
 Returns the renderer for the row header for the sorted row number iSortedRowNumber. More...
 
int unsortedRowNumber (int iSortedRowNumber) const override
 
void updateEvaluators ()
 
 ~FWTableViewTableManager () override
 
- Public Member Functions inherited from FWTableManagerBase
virtual void buttonPressedInRowHeader (Int_t row, Event_t *event, Int_t relX, Int_t relY)
 Called if mouse button pressed in Row Header, defaults is to do nothing. More...
 
virtual void buttonReleasedInRowHeader (Int_t row, Event_t *event, Int_t relX, Int_t relY)
 
virtual bool cellDataIsSortable () const
 
virtual unsigned int cellHeight () const
 require all cells to be the same height More...
 
 ClassDefOverride (FWTableManagerBase, 0)
 
void dataChanged ()
 Classes which inherit from FWTableManagerBase must call this when their underlying data changes. More...
 
 FWTableManagerBase ()
 
virtual bool hasLabelHeaders () const
 
virtual std::vector< unsigned int > maxWidthForColumns () const
 for each column in the table this returns the present maximum width for that column More...
 
void sort (int iCol, bool iSortOrder)
 Call to have table sorted on values in column iCol with the sort order being descending if iSortOrder is 'true'. More...
 
int sortColumn (void)
 The current sort column. More...
 
bool sortOrder (void)
 The current sort order for the table. More...
 
void visualPropertiesChanged ()
 Classes which inherit from FWTableManagerBase must call this when how the data is shown (e.g. color) changes. More...
 
 ~FWTableManagerBase () override
 

Protected Member Functions

void implSort (int iCol, bool iSortOrder) override
 

Protected Attributes

bool m_caughtExceptionInCellRender
 
std::vector< FWExpressionEvaluatorm_evaluators
 
TGGC * m_graphicsContext
 
TGGC * m_highlightContext
 
FWTextTableCellRendererm_renderer
 
TGGC * m_rowContext
 
TGGC * m_rowFillContext
 
FWFramedTextTableCellRendererm_rowRenderer
 
std::vector< int > m_sortedToUnsortedIndices
 
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
 
const FWTableViewm_view
 

Friends

class FWTableView
 

Detailed Description

Definition at line 32 of file FWTableViewTableManager.h.

Constructor & Destructor Documentation

◆ FWTableViewTableManager() [1/2]

FWTableViewTableManager::FWTableViewTableManager ( const FWTableView view)

Definition at line 19 of file FWTableViewTableManager.cc.

References FWTextTableCellRenderer::kJustifyRight, FWFramedTextTableCellRenderer::kJustifyRight, m_graphicsContext, m_highlightContext, m_renderer, m_rowFillContext, m_rowRenderer, FWTableView::m_tableWidget, and m_view.

20  : m_view(view),
21  m_graphicsContext(nullptr),
22  m_renderer(nullptr),
23  m_rowContext(nullptr),
24  m_rowRenderer(nullptr),
25  m_tableFormats(nullptr),
27  GCValues_t gc = *(m_view->m_tableWidget->GetWhiteGC().GetAttributes());
28  m_graphicsContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc, kTRUE);
29  m_highlightContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc, kTRUE);
30  m_highlightContext->SetForeground(gVirtualX->GetPixel(kBlue));
31  m_highlightContext->SetBackground(gVirtualX->GetPixel(kBlue));
32  m_renderer =
34  //m_rowContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE);
35  //m_rowContext->SetForeground(gVirtualX->GetPixel(kWhite));
36  //m_rowContext->SetBackground(gVirtualX->GetPixel(kBlack));
37  m_rowFillContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc, kTRUE);
40 }
FWFramedTextTableCellRenderer * m_rowRenderer
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
FWTableWidget * m_tableWidget
Definition: FWTableView.h:91
FWTextTableCellRenderer * m_renderer

◆ ~FWTableViewTableManager()

FWTableViewTableManager::~FWTableViewTableManager ( )
override

Definition at line 42 of file FWTableViewTableManager.cc.

References m_renderer, and m_rowRenderer.

42  {
43  delete m_renderer;
44  delete m_rowRenderer;
45 }
FWFramedTextTableCellRenderer * m_rowRenderer
FWTextTableCellRenderer * m_renderer

◆ FWTableViewTableManager() [2/2]

FWTableViewTableManager::FWTableViewTableManager ( const FWTableViewTableManager )
delete

Member Function Documentation

◆ cellRenderer()

FWTableCellRendererBase * FWTableViewTableManager::cellRenderer ( int  iSortedRowNumber,
int  iCol 
) const
overridevirtual

Returns the particular renderer used to handle the requested cell. Arguments: iSortedRowNumber: the row number from the present sort (i.e. the cell number of the view) iCol: the column number of the cell. The returned value must be used immediately and not held onto since the same Renderer can be used for subsequent calls

Implements FWTableManagerBase.

Definition at line 73 of file FWTableViewTableManager.cc.

References FWColorManager::background(), FWTableViewManager::TableEntry::BOOL, FWViewManagerBase::colorManager(), FWEventItem::ModelInfo::displayProperties(), compareTotals::fs, fwLog, createfilelist::int, FWTableViewManager::TableEntry::INT, FWTableViewManager::TableEntry::INT_HEX, FWEventItem::ModelInfo::isSelected(), FWDisplayProperties::isVisible(), FWTableView::item(), fwlog::kError, m_caughtExceptionInCellRender, m_evaluators, m_graphicsContext, FWTableView::m_manager, m_renderer, m_tableFormats, m_view, FWEventItem::modelData(), FWEventItem::modelInfo(), hcalRecHitTable_cff::precision, runTheMatrix::ret, alignCSCRings::s, FWTextTableCellRenderer::setData(), FWTextTableCellRenderer::setGraphicsContext(), FWEventItem::size(), and unsortedRowNumber().

Referenced by FWTableView::saveImageTo().

73  {
74  const int realRowNumber = unsortedRowNumber(iSortedRowNumber);
75  if (m_view->item() != nullptr && m_view->item()->size() && m_view->item()->modelData(realRowNumber) != nullptr &&
76  iCol < (int)m_evaluators.size()) {
77  double ret;
78  try {
79  // printf("iCol %d, size %d\n", iCol, m_evaluators.size());
80  ret = m_evaluators[iCol].evalExpression(m_view->item()->modelData(realRowNumber));
81  } catch (...) {
83  fwLog(fwlog::kError) << "Error: caught exception in the cell renderer while evaluating an expression. Return "
84  "-999. Error is suppressed in future\n";
85  }
87  ret = -999;
88  }
89  int precision = m_tableFormats->at(iCol).precision;
90  char s[100];
91  char fs[100];
92  switch (precision) {
94  snprintf(s, sizeof(s), "%d", int(rint(ret)));
95  break;
97  snprintf(s, sizeof(s), "0x%x", int(rint(ret)));
98  break;
100  snprintf(s, sizeof(s), int(rint(ret)) != 0 ? "true" : "false");
101  break;
102  default:
103  snprintf(fs, sizeof(fs), "%%.%df", precision);
104  snprintf(s, sizeof(s), fs, ret);
105  break;
106  }
107  if (not m_view->item()->modelInfo(realRowNumber).isSelected()) {
108  if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible())
109  if (m_view->m_manager->colorManager().background() == kBlack) {
110  m_graphicsContext->SetForeground(gVirtualX->GetPixel(kWhite));
111  } else {
112  m_graphicsContext->SetForeground(gVirtualX->GetPixel(kBlack));
113  }
114  else {
115  if (m_view->m_manager->colorManager().background() == kBlack) {
116  m_graphicsContext->SetForeground(0x888888);
117  } else {
118  m_graphicsContext->SetForeground(0x888888);
119  }
120  }
122  } else {
123  m_graphicsContext->SetForeground(0xffffff);
125  }
126  m_renderer->setData(s, m_view->item()->modelInfo(realRowNumber).isSelected());
127  } else {
128  m_renderer->setData("invalid", false);
129  }
130  return m_renderer;
131 }
size_t size() const
Definition: FWEventItem.cc:457
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
FWTableViewManager * m_manager
Definition: FWTableView.h:89
ret
prodAgent to be discontinued
FWColorManager & colorManager() const
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
Color_t background() const
int unsortedRowNumber(int iSortedRowNumber) const override
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
std::vector< FWExpressionEvaluator > m_evaluators
bool isSelected() const
Definition: FWEventItem.h:65
void setGraphicsContext(const TGGC *iContext)
FWTextTableCellRenderer * m_renderer
void setData(const std::string &, bool isSelected)
#define fwLog(_level_)
Definition: fwLog.h:45
const FWEventItem * item() const
Definition: FWTableView.cc:545
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446

◆ dataChanged()

void FWTableViewTableManager::dataChanged ( )

Called if mouse button pressed in Row Header, defaults is to do nothing.

Call to have table sorted on values in column iCol with the sort order being descending if iSortOrder is 'true' Classes which inherit from FWTableViewTableManager must call this when their underlying data changes

Definition at line 201 of file FWTableViewTableManager.cc.

References cms::cuda::assert(), FWTableManagerBase::dataChanged(), FWEventItem::ModelInfo::displayProperties(), mps_fire::i, FWDisplayProperties::isVisible(), FWTableView::item(), m_sortedToUnsortedIndices, m_view, FWEventItem::modelInfo(), and FWEventItem::size().

Referenced by FWTableView::dataChanged().

201  {
202  if (nullptr != m_view->item()) {
203  std::vector<int> visible;
204  visible.reserve(m_view->item()->size());
205  std::vector<int> invisible;
206  invisible.reserve(m_view->item()->size());
208  m_sortedToUnsortedIndices.reserve(m_view->item()->size());
209  for (int i = 0; i < static_cast<int>(m_view->item()->size()); ++i) {
211  visible.push_back(i);
212  else
213  invisible.push_back(i);
214  }
215  m_sortedToUnsortedIndices.insert(m_sortedToUnsortedIndices.end(), visible.begin(), visible.end());
216  m_sortedToUnsortedIndices.insert(m_sortedToUnsortedIndices.end(), invisible.begin(), invisible.end());
218  } else {
220  }
222 }
size_t size() const
Definition: FWEventItem.cc:457
std::vector< int > m_sortedToUnsortedIndices
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
assert(be >=bs)
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
const FWEventItem * item() const
Definition: FWTableView.cc:545
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446

◆ getTitles()

std::vector< std::string > FWTableViewTableManager::getTitles ( ) const
overridevirtual

returns the title names for each column

Implements FWTableManagerBase.

Definition at line 56 of file FWTableViewTableManager.cc.

References mps_fire::i, m_tableFormats, dqmiodumpmetadata::n, numberOfColumns(), and runTheMatrix::ret.

56  {
57  unsigned int n = numberOfColumns();
58  std::vector<std::string> ret;
59  ret.reserve(n);
60  for (unsigned int i = 0; i < n; ++i) {
61  ret.push_back(m_tableFormats->at(i).name);
62  // printf("%s\n", ret.back().c_str());
63  }
64  return ret;
65 }
ret
prodAgent to be discontinued
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
int numberOfColumns() const override
Number of columns in the table.

◆ hasRowHeaders()

bool FWTableViewTableManager::hasRowHeaders ( ) const
overridevirtual

require all cells to be the same height

for each column in the table this returns the present maximum width for that column Returns 'true' if this table has row headers. Defaults return value is false.

Reimplemented from FWTableManagerBase.

Definition at line 250 of file FWTableViewTableManager.cc.

250 { return true; }

◆ implSort()

void FWTableViewTableManager::implSort ( int  iCol,
bool  iSortOrder 
)
overrideprotectedvirtual

Called by 'sort' method to actually handle the sorting of the rows. Arguments are the same as 'sort'

Implements FWTableManagerBase.

Definition at line 184 of file FWTableViewTableManager.cc.

References FWTableWidget::dataChanged(), HLT_2024v13_cff::doSort, createfilelist::int, FWTableView::item(), m_evaluators, m_sortedToUnsortedIndices, FWTableView::m_tableWidget, m_view, and alignCSCRings::s.

184  {
185  static const bool sort_down = true;
186  if (iCol >= (int)m_evaluators.size())
187  return;
188  if (nullptr != m_view->item()) {
189  // printf("sorting %s\n", iSortOrder == sort_down ? "down" : "up");
190  if (iSortOrder == sort_down) {
191  std::multimap<std::pair<bool, double>, int, itemOrderGt> s;
193  } else {
194  std::multimap<std::pair<bool, double>, int, itemOrderLt> s;
196  }
197  }
199 }
std::vector< int > m_sortedToUnsortedIndices
std::vector< FWExpressionEvaluator > m_evaluators
FWTableWidget * m_tableWidget
Definition: FWTableView.h:91
const FWEventItem * item() const
Definition: FWTableView.cc:545

◆ numberOfColumns()

int FWTableViewTableManager::numberOfColumns ( ) const
overridevirtual

Number of columns in the table.

Implements FWTableManagerBase.

Definition at line 54 of file FWTableViewTableManager.cc.

References m_evaluators.

Referenced by getTitles(), FWTableView::saveImageTo(), and FWTableView::setFrom().

54 { return m_evaluators.size(); }
std::vector< FWExpressionEvaluator > m_evaluators

◆ numberOfRows()

int FWTableViewTableManager::numberOfRows ( ) const
overridevirtual

Number of rows in the table.

Implements FWTableManagerBase.

Definition at line 47 of file FWTableViewTableManager.cc.

References FWTableView::item(), m_view, and FWEventItem::size().

Referenced by FWTableView::saveImageTo().

47  {
48  if (m_view->item() != nullptr)
49  return m_view->item()->size();
50  else
51  return 0;
52 }
size_t size() const
Definition: FWEventItem.cc:457
const FWEventItem * item() const
Definition: FWTableView.cc:545

◆ operator=()

const FWTableViewTableManager& FWTableViewTableManager::operator= ( const FWTableViewTableManager )
delete

◆ rowHeader()

FWTableCellRendererBase * FWTableViewTableManager::rowHeader ( int  iSortedRowNumber) const
overridevirtual

Returns the renderer for the row header for the sorted row number iSortedRowNumber.

Reimplemented from FWTableManagerBase.

Definition at line 251 of file FWTableViewTableManager.cc.

References FWColorManager::background(), FWDisplayProperties::color(), FWViewManagerBase::colorManager(), FWEventItem::ModelInfo::displayProperties(), FWDisplayProperties::isVisible(), FWTableView::item(), m_graphicsContext, FWTableView::m_manager, m_rowFillContext, m_rowRenderer, m_view, FWEventItem::modelData(), FWEventItem::modelInfo(), alignCSCRings::s, FWFramedTextTableCellRenderer::setData(), FWEventItem::size(), and unsortedRowNumber().

251  {
252  const int realRowNumber = unsortedRowNumber(iSortedRowNumber);
253  if (m_view->item() != nullptr && m_view->item()->size() && m_view->item()->modelData(realRowNumber) != nullptr) {
254  if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible()) {
255  if (m_view->m_manager->colorManager().background() == kBlack) {
256  m_graphicsContext->SetForeground(gVirtualX->GetPixel(kWhite));
257  } else {
258  m_graphicsContext->SetForeground(gVirtualX->GetPixel(kBlack));
259  }
260  m_rowFillContext->SetForeground(
261  gVirtualX->GetPixel(m_view->item()->modelInfo(realRowNumber).displayProperties().color()));
262  } else {
263  m_graphicsContext->SetForeground(0x888888);
265  }
266 
267  std::ostringstream s;
268  s << realRowNumber;
269  m_rowRenderer->setData(s.str());
270  } else {
271  m_rowRenderer->setData("");
272  }
273  return m_rowRenderer;
274 }
size_t size() const
Definition: FWEventItem.cc:457
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
FWTableViewManager * m_manager
Definition: FWTableView.h:89
FWFramedTextTableCellRenderer * m_rowRenderer
FWColorManager & colorManager() const
Color_t background() const
int unsortedRowNumber(int iSortedRowNumber) const override
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
const FWEventItem * item() const
Definition: FWTableView.cc:545
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446

◆ unsortedRowNumber()

int FWTableViewTableManager::unsortedRowNumber ( int  iSortedRowNumber) const
overridevirtual

when passed the index to the sorted order of the rows it returns the original row number from the underlying data

Implements FWTableManagerBase.

Definition at line 67 of file FWTableViewTableManager.cc.

References m_sortedToUnsortedIndices.

Referenced by cellRenderer(), rowHeader(), and FWTableView::saveImageTo().

67  {
68  if (iSortedRowNumber >= (int)m_sortedToUnsortedIndices.size())
69  return 0;
70  return m_sortedToUnsortedIndices[iSortedRowNumber];
71 }
std::vector< int > m_sortedToUnsortedIndices

◆ updateEvaluators()

void FWTableViewTableManager::updateEvaluators ( )

Classes which inherit from FWTableViewTableManager must call this when how the data is shown (e.g. color) changes

Definition at line 224 of file FWTableViewTableManager.cc.

References mps_fire::end, makeMEIFBenchmarkPlots::ev, fwLog, mps_fire::i, B2GTnPMonitor_cfi::item, FWTableViewManager::items(), fwlog::kError, m_evaluators, FWTableView::m_iColl, FWTableView::m_manager, m_tableFormats, and m_view.

Referenced by FWTableView::updateEvaluators().

224  {
225  if (m_view->m_iColl == -1) {
226  //printf("what should I do with collection -1?\n");
227  m_evaluators.clear();
228  return;
229  }
231  if (nullptr == item) {
232  return;
233  }
234  std::vector<FWExpressionEvaluator> &ev = m_evaluators;
235  ev.clear();
236  for (std::vector<FWTableViewManager::TableEntry>::const_iterator i = m_tableFormats->begin(),
237  end = m_tableFormats->end();
238  i != end;
239  ++i) {
240  try {
241  ev.push_back(FWExpressionEvaluator(i->expression, item->modelType()->GetName()));
242  } catch (...) {
243  fwLog(fwlog::kError) << "expression " << i->expression << " is not valid, skipping\n";
244  ev.push_back(FWExpressionEvaluator("0", item->modelType()->GetName()));
245  }
246  }
247  //printf("Got evaluators\n");
248 }
FWTableViewManager * m_manager
Definition: FWTableView.h:89
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
std::vector< FWExpressionEvaluator > m_evaluators
const Items & items() const
#define fwLog(_level_)
Definition: fwLog.h:45

Friends And Related Function Documentation

◆ FWTableView

friend class FWTableView
friend

Definition at line 33 of file FWTableViewTableManager.h.

Member Data Documentation

◆ m_caughtExceptionInCellRender

bool FWTableViewTableManager::m_caughtExceptionInCellRender
mutableprotected

Definition at line 115 of file FWTableViewTableManager.h.

Referenced by cellRenderer().

◆ m_evaluators

std::vector<FWExpressionEvaluator> FWTableViewTableManager::m_evaluators
protected

◆ m_graphicsContext

TGGC* FWTableViewTableManager::m_graphicsContext
protected

Definition at line 101 of file FWTableViewTableManager.h.

Referenced by cellRenderer(), FWTableViewTableManager(), and rowHeader().

◆ m_highlightContext

TGGC* FWTableViewTableManager::m_highlightContext
protected

Definition at line 102 of file FWTableViewTableManager.h.

Referenced by FWTableViewTableManager().

◆ m_renderer

FWTextTableCellRenderer* FWTableViewTableManager::m_renderer
protected

◆ m_rowContext

TGGC* FWTableViewTableManager::m_rowContext
protected

Definition at line 105 of file FWTableViewTableManager.h.

◆ m_rowFillContext

TGGC* FWTableViewTableManager::m_rowFillContext
protected

Definition at line 106 of file FWTableViewTableManager.h.

Referenced by FWTableViewTableManager(), and rowHeader().

◆ m_rowRenderer

FWFramedTextTableCellRenderer* FWTableViewTableManager::m_rowRenderer
protected

◆ m_sortedToUnsortedIndices

std::vector<int> FWTableViewTableManager::m_sortedToUnsortedIndices
protected

Definition at line 98 of file FWTableViewTableManager.h.

Referenced by dataChanged(), implSort(), and unsortedRowNumber().

◆ m_tableFormats

std::vector<FWTableViewManager::TableEntry>* FWTableViewTableManager::m_tableFormats
protected

◆ m_view

const FWTableView* FWTableViewTableManager::m_view
protected