CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual FWTableCellRendererBasecellRenderer (int iSortedRowNumber, int iCol) const
 
void dataChanged ()
 Called if mouse button pressed in Row Header, defaults is to do nothing. More...
 
 FWTableViewTableManager (const FWTableView *)
 
virtual std::vector< std::string > getTitles () const
 returns the title names for each column More...
 
virtual bool hasRowHeaders () const
 require all cells to be the same height More...
 
virtual int numberOfColumns () const
 Number of columns in the table. More...
 
virtual int numberOfRows () const
 Number of rows in the table. More...
 
virtual FWTableCellRendererBaserowHeader (int iSortedRowNumber) const
 Returns the renderer for the row header for the sorted row number iSortedRowNumber. More...
 
virtual int unsortedRowNumber (int iSortedRowNumber) const
 
void updateEvaluators ()
 
virtual ~FWTableViewTableManager ()
 
- 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...
 
 ClassDef (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...
 
virtual ~FWTableManagerBase ()
 

Protected Member Functions

virtual void implSort (int iCol, bool iSortOrder)
 

Protected Attributes

bool m_caughtExceptionInCellRender
 
std::vector
< FWExpressionEvaluator
m_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 &)
 
const FWTableViewTableManageroperator= (const FWTableViewTableManager &)
 

Friends

class FWTableView
 

Detailed Description

Definition at line 33 of file FWTableViewTableManager.h.

Constructor & Destructor Documentation

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),
22  m_renderer(0),
23  m_rowContext(0),
24  m_rowRenderer(0),
25  m_tableFormats(0),
27 {
28  GCValues_t gc = *(m_view->m_tableWidget->GetWhiteGC().GetAttributes());
29  m_graphicsContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE);
30  m_highlightContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE);
31  m_highlightContext->SetForeground(gVirtualX->GetPixel(kBlue));
32  m_highlightContext->SetBackground(gVirtualX->GetPixel(kBlue));
36  //m_rowContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE);
37  //m_rowContext->SetForeground(gVirtualX->GetPixel(kWhite));
38  //m_rowContext->SetBackground(gVirtualX->GetPixel(kBlack));
39  m_rowFillContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE);
43 
44 }
FWFramedTextTableCellRenderer * m_rowRenderer
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
FWTableWidget * m_tableWidget
Definition: FWTableView.h:93
FWTextTableCellRenderer * m_renderer
FWTableViewTableManager::~FWTableViewTableManager ( )
virtual

Definition at line 46 of file FWTableViewTableManager.cc.

References m_renderer, and m_rowRenderer.

47 {
48  delete m_renderer;
49  delete m_rowRenderer;
50 }
FWFramedTextTableCellRenderer * m_rowRenderer
FWTextTableCellRenderer * m_renderer
FWTableViewTableManager::FWTableViewTableManager ( const FWTableViewTableManager )
private

Member Function Documentation

FWTableCellRendererBase * FWTableViewTableManager::cellRenderer ( int  iSortedRowNumber,
int  iCol 
) const
virtual
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 83 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::saveImageTo().

84 {
85  const int realRowNumber = unsortedRowNumber(iSortedRowNumber);
86  if (m_view->item() != 0 &&
87  m_view->item()->size() &&
88  m_view->item()->modelData(realRowNumber) != 0 &&
89  iCol < (int)m_evaluators.size()) {
90  double ret;
91  try {
92 // printf("iCol %d, size %d\n", iCol, m_evaluators.size());
93  ret = m_evaluators[iCol].evalExpression(m_view->item()->modelData(realRowNumber));
94  } catch (...) {
96  fwLog(fwlog::kError) << "Error: caught exception in the cell renderer while evaluating an expression. Return -999. Error is suppressed in future\n";
97  }
99  ret = -999;
100  }
101  int precision = m_tableFormats->at(iCol).precision;
102  char s[100];
103  char fs[100];
104  switch (precision) {
106  snprintf(s, sizeof(s), "%d", int(rint(ret)));
107  break;
109  snprintf(s, sizeof(s), "0x%x", int(rint(ret)));
110  break;
112  snprintf(s, sizeof(s), int(rint(ret)) != 0 ? "true" : "false");
113  break;
114  default:
115  snprintf(fs, sizeof(fs), "%%.%df", precision);
116  snprintf(s, sizeof(s), fs, ret);
117  break;
118  }
119  if (not m_view->item()->modelInfo(realRowNumber).isSelected()) {
120  if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible())
121  if (m_view->m_manager->colorManager().background() == kBlack) {
123  SetForeground(gVirtualX->GetPixel(kWhite));
124  } else {
126  SetForeground(gVirtualX->GetPixel(kBlack));
127  }
128  else {
129  if (m_view->m_manager->colorManager().background() == kBlack) {
130  m_graphicsContext->SetForeground(0x888888);
131  } else {
132  m_graphicsContext->SetForeground(0x888888);
133  }
134  }
136  } else {
138  SetForeground(0xffffff);
140  }
141  m_renderer->setData(s, m_view->item()->modelInfo(realRowNumber).isSelected());
142  } else {
143  m_renderer->setData("invalid", false);
144  }
145  return m_renderer;
146 }
Color_t background() const
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
FWTableViewManager * m_manager
Definition: FWTableView.h:91
virtual int unsortedRowNumber(int iSortedRowNumber) const
bool isSelected() const
Definition: FWEventItem.h:71
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
FWColorManager & colorManager() const
std::vector< FWExpressionEvaluator > m_evaluators
const FWEventItem * item() const
Definition: FWTableView.cc:579
void setGraphicsContext(const TGGC *iContext)
FWTextTableCellRenderer * m_renderer
void setData(const std::string &, bool isSelected)
size_t size() const
Definition: FWEventItem.cc:549
#define fwLog(_level_)
Definition: fwLog.h:51
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:568
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:536
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 226 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::dataChanged().

227 {
228  if (0!=m_view->item()) {
229  std::vector<int> visible;
230  visible.reserve(m_view->item()->size());
231  std::vector<int> invisible;
232  invisible.reserve(m_view->item()->size());
234  m_sortedToUnsortedIndices.reserve(m_view->item()->size());
235  for(int i=0; i< static_cast<int>(m_view->item()->size()); ++i) {
237  visible.push_back(i);
238  else invisible.push_back(i);
239  }
241  visible.begin(), visible.end());
243  invisible.begin(), invisible.end());
244  assert(m_sortedToUnsortedIndices.size() == m_view->item()->size());
245  } else {
247  }
249 }
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
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:579
size_t size() const
Definition: FWEventItem.cc:549
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:536
std::vector< std::string > FWTableViewTableManager::getTitles ( ) const
virtual

returns the title names for each column

Implements FWTableManagerBase.

Definition at line 64 of file FWTableViewTableManager.cc.

References i, m_tableFormats, n, numberOfColumns(), and run_regression::ret.

65 {
66  unsigned int n = numberOfColumns();
67  std::vector<std::string> ret;
68  ret.reserve(n);
69  for (unsigned int i = 0; i < n; ++i) {
70  ret.push_back(m_tableFormats->at(i).name);
71 // printf("%s\n", ret.back().c_str());
72  }
73  return ret;
74 }
int i
Definition: DBlmapReader.cc:9
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
virtual int numberOfColumns() const
Number of columns in the table.
bool FWTableViewTableManager::hasRowHeaders ( ) const
virtual

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

277 {
278  return true;
279 }
void FWTableViewTableManager::implSort ( int  iCol,
bool  iSortOrder 
)
protectedvirtual

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

Implements FWTableManagerBase.

Definition at line 207 of file FWTableViewTableManager.cc.

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

208 {
209  static const bool sort_down = true;
210  if (iCol >= (int)m_evaluators.size())
211  return;
212  if (0!=m_view->item()) {
213  // printf("sorting %s\n", iSortOrder == sort_down ? "down" : "up");
214  if (iSortOrder == sort_down) {
215  std::multimap<std::pair<bool, double>, int, itemOrderGt> s;
216  doSort(*m_view->item(), iCol, m_evaluators, s, m_sortedToUnsortedIndices);
217  } else {
218  std::multimap<std::pair<bool, double>, int, itemOrderLt> s;
219  doSort(*m_view->item(), iCol, m_evaluators, s, m_sortedToUnsortedIndices);
220  }
221  }
223 }
std::vector< int > m_sortedToUnsortedIndices
std::vector< FWExpressionEvaluator > m_evaluators
const FWEventItem * item() const
Definition: FWTableView.cc:579
FWTableWidget * m_tableWidget
Definition: FWTableView.h:93
int FWTableViewTableManager::numberOfColumns ( ) const
virtual

Number of columns in the table.

Implements FWTableManagerBase.

Definition at line 59 of file FWTableViewTableManager.cc.

References m_evaluators.

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

60 {
61  return m_evaluators.size();
62 }
std::vector< FWExpressionEvaluator > m_evaluators
int FWTableViewTableManager::numberOfRows ( ) const
virtual

Number of rows in the table.

Implements FWTableManagerBase.

Definition at line 52 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::saveImageTo().

53 {
54  if (m_view->item() != 0)
55  return m_view->item()->size();
56  else return 0;
57 }
const FWEventItem * item() const
Definition: FWTableView.cc:579
size_t size() const
Definition: FWEventItem.cc:549
const FWTableViewTableManager& FWTableViewTableManager::operator= ( const FWTableViewTableManager )
private
FWTableCellRendererBase * FWTableViewTableManager::rowHeader ( int  iSortedRowNumber) const
virtual

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

Reimplemented from FWTableManagerBase.

Definition at line 280 of file FWTableViewTableManager.cc.

References FWColorManager::background(), 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().

281 {
282  const int realRowNumber = unsortedRowNumber(iSortedRowNumber);
283  if (m_view->item() != 0 &&
284  m_view->item()->size() &&
285  m_view->item()->modelData(realRowNumber) != 0) {
286  if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible()) {
287  if (m_view->m_manager->colorManager().background() == kBlack) {
289  SetForeground(gVirtualX->GetPixel(kWhite));
290  } else {
292  SetForeground(gVirtualX->GetPixel(kBlack));
293  }
295  SetForeground(gVirtualX->GetPixel(m_view->item()->modelInfo(realRowNumber).
296  displayProperties().color()));
297  } else {
298  m_graphicsContext->SetForeground(0x888888);
300  }
301 
302  std::ostringstream s;
303  s<<realRowNumber;
304  m_rowRenderer->setData(s.str().c_str());
305  } else {
306  m_rowRenderer->setData("");
307  }
308  return m_rowRenderer;
309 }
Color_t background() const
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
FWTableViewManager * m_manager
Definition: FWTableView.h:91
virtual int unsortedRowNumber(int iSortedRowNumber) const
FWFramedTextTableCellRenderer * m_rowRenderer
FWColorManager & colorManager() const
const FWEventItem * item() const
Definition: FWTableView.cc:579
size_t size() const
Definition: FWEventItem.cc:549
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:568
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:536
int FWTableViewTableManager::unsortedRowNumber ( int  iSortedRowNumber) const
virtual

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

References m_sortedToUnsortedIndices.

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

77 {
78  if (iSortedRowNumber >= (int)m_sortedToUnsortedIndices.size())
79  return 0;
80  return m_sortedToUnsortedIndices[iSortedRowNumber];
81 }
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 251 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::updateEvaluators().

252 {
253  if (m_view->m_iColl == -1) {
254  //printf("what should I do with collection -1?\n");
255  m_evaluators.clear();
256  return;
257  }
258  const FWEventItem *item = m_view->m_manager->items()[m_view->m_iColl];
259  if(0==item) { return;}
260  std::vector<FWExpressionEvaluator> &ev = m_evaluators;
261  ev.clear();
262  for (std::vector<FWTableViewManager::TableEntry>::const_iterator
263  i = m_tableFormats->begin(),
264  end = m_tableFormats->end();
265  i != end; ++i) {
266  try {
267  ev.push_back(FWExpressionEvaluator(i->expression, item->modelType()->GetName()));
268  } catch (...) {
269  fwLog(fwlog::kError) << "expression "<< i->expression << " is not valid, skipping\n";
270  ev.push_back(FWExpressionEvaluator("0", item->modelType()->GetName()));
271  }
272  }
273  //printf("Got evaluators\n");
274 }
int i
Definition: DBlmapReader.cc:9
FWTableViewManager * m_manager
Definition: FWTableView.h:91
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
std::vector< FWExpressionEvaluator > m_evaluators
const Items & items() const
#define end
Definition: vmac.h:38
#define fwLog(_level_)
Definition: fwLog.h:51
const TClass * modelType() const
Definition: FWEventItem.cc:562

Friends And Related Function Documentation

friend class FWTableView
friend

Definition at line 34 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