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 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),
21  m_renderer(0),
22  m_rowContext(0),
23  m_rowRenderer(0),
24  m_tableFormats(0),
26 {
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));
35  //m_rowContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE);
36  //m_rowContext->SetForeground(gVirtualX->GetPixel(kWhite));
37  //m_rowContext->SetBackground(gVirtualX->GetPixel(kBlack));
38  m_rowFillContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE);
42 
43 }
FWFramedTextTableCellRenderer * m_rowRenderer
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
FWTableWidget * m_tableWidget
Definition: FWTableView.h:92
FWTextTableCellRenderer * m_renderer
FWTableViewTableManager::~FWTableViewTableManager ( )
virtual

Definition at line 45 of file FWTableViewTableManager.cc.

References m_renderer, and m_rowRenderer.

46 {
47  delete m_renderer;
48  delete m_rowRenderer;
49 }
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 82 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::saveImageTo().

83 {
84  const int realRowNumber = unsortedRowNumber(iSortedRowNumber);
85  if (m_view->item() != 0 &&
86  m_view->item()->size() &&
87  m_view->item()->modelData(realRowNumber) != 0 &&
88  iCol < (int)m_evaluators.size()) {
89  double ret;
90  try {
91 // printf("iCol %d, size %d\n", iCol, m_evaluators.size());
92  ret = m_evaluators[iCol].evalExpression(m_view->item()->modelData(realRowNumber));
93  } catch (...) {
95  fwLog(fwlog::kError) << "Error: caught exception in the cell renderer while evaluating an expression. Return -999. Error is suppressed in future\n";
96  }
98  ret = -999;
99  }
100  int precision = m_tableFormats->at(iCol).precision;
101  char s[100];
102  char fs[100];
103  switch (precision) {
105  snprintf(s, sizeof(s), "%d", int(rint(ret)));
106  break;
108  snprintf(s, sizeof(s), "0x%x", int(rint(ret)));
109  break;
111  snprintf(s, sizeof(s), int(rint(ret)) != 0 ? "true" : "false");
112  break;
113  default:
114  snprintf(fs, sizeof(fs), "%%.%df", precision);
115  snprintf(s, sizeof(s), fs, ret);
116  break;
117  }
118  if (not m_view->item()->modelInfo(realRowNumber).isSelected()) {
119  if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible())
120  if (m_view->m_manager->colorManager().background() == kBlack) {
122  SetForeground(gVirtualX->GetPixel(kWhite));
123  } else {
125  SetForeground(gVirtualX->GetPixel(kBlack));
126  }
127  else {
128  if (m_view->m_manager->colorManager().background() == kBlack) {
129  m_graphicsContext->SetForeground(0x888888);
130  } else {
131  m_graphicsContext->SetForeground(0x888888);
132  }
133  }
135  } else {
137  SetForeground(0xffffff);
139  }
140  m_renderer->setData(s, m_view->item()->modelInfo(realRowNumber).isSelected());
141  } else {
142  m_renderer->setData("invalid", false);
143  }
144  return m_renderer;
145 }
tuple ret
prodAgent to be discontinued
Color_t background() const
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
FWTableViewManager * m_manager
Definition: FWTableView.h:90
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:550
#define fwLog(_level_)
Definition: fwLog.h:50
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:569
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:537
edm::Service< TFileService > fs
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 225 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::dataChanged().

226 {
227  if (0!=m_view->item()) {
228  std::vector<int> visible;
229  visible.reserve(m_view->item()->size());
230  std::vector<int> invisible;
231  invisible.reserve(m_view->item()->size());
233  m_sortedToUnsortedIndices.reserve(m_view->item()->size());
234  for(int i=0; i< static_cast<int>(m_view->item()->size()); ++i) {
236  visible.push_back(i);
237  else invisible.push_back(i);
238  }
240  visible.begin(), visible.end());
242  invisible.begin(), invisible.end());
244  } else {
246  }
248 }
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
std::vector< int > m_sortedToUnsortedIndices
assert(m_qm.get())
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:550
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:537
std::vector< std::string > FWTableViewTableManager::getTitles ( ) const
virtual

returns the title names for each column

Implements FWTableManagerBase.

Definition at line 63 of file FWTableViewTableManager.cc.

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

64 {
65  unsigned int n = numberOfColumns();
66  std::vector<std::string> ret;
67  ret.reserve(n);
68  for (unsigned int i = 0; i < n; ++i) {
69  ret.push_back(m_tableFormats->at(i).name);
70 // printf("%s\n", ret.back().c_str());
71  }
72  return ret;
73 }
int i
Definition: DBlmapReader.cc:9
tuple ret
prodAgent to be discontinued
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 275 of file FWTableViewTableManager.cc.

276 {
277  return true;
278 }
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 206 of file FWTableViewTableManager.cc.

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

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

Number of columns in the table.

Implements FWTableManagerBase.

Definition at line 58 of file FWTableViewTableManager.cc.

References m_evaluators.

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

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

Number of rows in the table.

Implements FWTableManagerBase.

Definition at line 51 of file FWTableViewTableManager.cc.

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

Referenced by FWTableView::saveImageTo().

52 {
53  if (m_view->item() != 0)
54  return m_view->item()->size();
55  else return 0;
56 }
const FWEventItem * item() const
Definition: FWTableView.cc:579
size_t size() const
Definition: FWEventItem.cc:550
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 279 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().

280 {
281  const int realRowNumber = unsortedRowNumber(iSortedRowNumber);
282  if (m_view->item() != 0 &&
283  m_view->item()->size() &&
284  m_view->item()->modelData(realRowNumber) != 0) {
285  if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible()) {
286  if (m_view->m_manager->colorManager().background() == kBlack) {
288  SetForeground(gVirtualX->GetPixel(kWhite));
289  } else {
291  SetForeground(gVirtualX->GetPixel(kBlack));
292  }
294  SetForeground(gVirtualX->GetPixel(m_view->item()->modelInfo(realRowNumber).
295  displayProperties().color()));
296  } else {
297  m_graphicsContext->SetForeground(0x888888);
299  }
300 
301  std::ostringstream s;
302  s<<realRowNumber;
303  m_rowRenderer->setData(s.str().c_str());
304  } else {
305  m_rowRenderer->setData("");
306  }
307  return m_rowRenderer;
308 }
Color_t background() const
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
FWTableViewManager * m_manager
Definition: FWTableView.h:90
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:550
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:569
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:537
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 75 of file FWTableViewTableManager.cc.

References m_sortedToUnsortedIndices.

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

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

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

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

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 114 of file FWTableViewTableManager.h.

Referenced by cellRenderer().

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

Definition at line 100 of file FWTableViewTableManager.h.

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

TGGC* FWTableViewTableManager::m_highlightContext
protected

Definition at line 101 of file FWTableViewTableManager.h.

Referenced by FWTableViewTableManager().

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

Definition at line 104 of file FWTableViewTableManager.h.

TGGC* FWTableViewTableManager::m_rowFillContext
protected

Definition at line 105 of file FWTableViewTableManager.h.

Referenced by FWTableViewTableManager(), and rowHeader().

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

Definition at line 97 of file FWTableViewTableManager.h.

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

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