CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | 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 *)
 
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...
 
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
 

Private Member Functions

 FWTableViewTableManager (const FWTableViewTableManager &)=delete
 
const FWTableViewTableManageroperator= (const FWTableViewTableManager &)=delete
 

Friends

class FWTableView
 

Detailed Description

Definition at line 32 of file FWTableViewTableManager.h.

Constructor & Destructor Documentation

FWTableViewTableManager::FWTableViewTableManager ( const FWTableView view)

Definition at line 18 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.

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

Definition at line 41 of file FWTableViewTableManager.cc.

References m_renderer, and m_rowRenderer.

41  {
42  delete m_renderer;
43  delete m_rowRenderer;
44 }
FWFramedTextTableCellRenderer * m_rowRenderer
FWTextTableCellRenderer * m_renderer
FWTableViewTableManager::FWTableViewTableManager ( const FWTableViewTableManager )
privatedelete

Member Function Documentation

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 72 of file FWTableViewTableManager.cc.

References FWColorManager::background(), FWTableViewManager::TableEntry::BOOL, FWViewManagerBase::colorManager(), FWEventItem::ModelInfo::displayProperties(), fwLog, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, 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(), common_cff::precision, runTheMatrix::ret, alignCSCRings::s, FWTextTableCellRenderer::setData(), FWTextTableCellRenderer::setGraphicsContext(), FWEventItem::size(), findQualityFiles::size, and unsortedRowNumber().

Referenced by FWTableView::saveImageTo().

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

References 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().

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

returns the title names for each column

Implements FWTableManagerBase.

Definition at line 55 of file FWTableViewTableManager.cc.

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

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

249 { return true; }
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 183 of file FWTableViewTableManager.cc.

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

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

Number of columns in the table.

Implements FWTableManagerBase.

Definition at line 53 of file FWTableViewTableManager.cc.

References m_evaluators.

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

53 { return m_evaluators.size(); }
std::vector< FWExpressionEvaluator > m_evaluators
int FWTableViewTableManager::numberOfRows ( ) const
overridevirtual

Number of rows in the table.

Implements FWTableManagerBase.

Definition at line 46 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::saveImageTo().

46  {
47  if (m_view->item() != nullptr)
48  return m_view->item()->size();
49  else
50  return 0;
51 }
const FWEventItem * item() const
Definition: FWTableView.cc:544
size_t size() const
Definition: FWEventItem.cc:457
const FWTableViewTableManager& FWTableViewTableManager::operator= ( const FWTableViewTableManager )
privatedelete
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 250 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().

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

References m_sortedToUnsortedIndices.

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

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

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

Definition at line 223 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::updateEvaluators().

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

Friends And Related Function Documentation

friend class FWTableView
friend

Definition at line 33 of file FWTableViewTableManager.h.

Member Data Documentation

bool FWTableViewTableManager::m_caughtExceptionInCellRender
mutableprotected

Definition at line 115 of file FWTableViewTableManager.h.

Referenced by cellRenderer().

std::vector<FWExpressionEvaluator> FWTableViewTableManager::m_evaluators
protected
TGGC* FWTableViewTableManager::m_graphicsContext
protected

Definition at line 101 of file FWTableViewTableManager.h.

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

TGGC* FWTableViewTableManager::m_highlightContext
protected

Definition at line 102 of file FWTableViewTableManager.h.

Referenced by FWTableViewTableManager().

FWTextTableCellRenderer* FWTableViewTableManager::m_renderer
protected
TGGC* FWTableViewTableManager::m_rowContext
protected

Definition at line 105 of file FWTableViewTableManager.h.

TGGC* FWTableViewTableManager::m_rowFillContext
protected

Definition at line 106 of file FWTableViewTableManager.h.

Referenced by FWTableViewTableManager(), and rowHeader().

FWFramedTextTableCellRenderer* FWTableViewTableManager::m_rowRenderer
protected
std::vector<int> FWTableViewTableManager::m_sortedToUnsortedIndices
protected

Definition at line 98 of file FWTableViewTableManager.h.

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

std::vector<FWTableViewManager::TableEntry>* FWTableViewTableManager::m_tableFormats
protected
const FWTableView* FWTableViewTableManager::m_view
protected