#include <Fireworks/Core/interface/FWTableViewTableManager.h>
Public Member Functions | |
virtual FWTableCellRendererBase * | cellRenderer (int iSortedRowNumber, int iCol) const |
void | dataChanged () |
Called if mouse button pressed in Row Header, defaults is to do nothing. | |
FWTableViewTableManager (const FWTableView *) | |
virtual std::vector< std::string > | getTitles () const |
returns the title names for each column | |
virtual bool | hasRowHeaders () const |
require all cells to be the same height | |
virtual int | numberOfColumns () const |
Number of columns in the table. | |
virtual int | numberOfRows () const |
Number of rows in the table. | |
virtual FWTableCellRendererBase * | rowHeader (int iSortedRowNumber) const |
Returns the renderer for the row header for the sorted row number iSortedRowNumber. | |
virtual int | unsortedRowNumber (int iSortedRowNumber) const |
void | updateEvaluators () |
virtual | ~FWTableViewTableManager () |
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 |
FWTextTableCellRenderer * | m_renderer |
TGGC * | m_rowContext |
TGGC * | m_rowFillContext |
FWFramedTextTableCellRenderer * | m_rowRenderer |
std::vector< int > | m_sortedToUnsortedIndices |
std::vector < FWTableViewManager::TableEntry > * | m_tableFormats |
const FWTableView * | m_view |
Private Member Functions | |
FWTableViewTableManager (const FWTableViewTableManager &) | |
const FWTableViewTableManager & | operator= (const FWTableViewTableManager &) |
Friends | |
class | FWTableView |
Definition at line 33 of file FWTableViewTableManager.h.
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.
: m_view(view), m_graphicsContext(0), m_renderer(0), m_rowContext(0), m_rowRenderer(0), m_tableFormats(0), m_caughtExceptionInCellRender(false) { GCValues_t gc = *(m_view->m_tableWidget->GetWhiteGC().GetAttributes()); m_graphicsContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE); m_highlightContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE); m_highlightContext->SetForeground(gVirtualX->GetPixel(kBlue)); m_highlightContext->SetBackground(gVirtualX->GetPixel(kBlue)); m_renderer = new FWTextTableCellRenderer(m_graphicsContext, m_highlightContext, FWTextTableCellRenderer::kJustifyRight); //m_rowContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE); //m_rowContext->SetForeground(gVirtualX->GetPixel(kWhite)); //m_rowContext->SetBackground(gVirtualX->GetPixel(kBlack)); m_rowFillContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&gc,kTRUE); m_rowRenderer = new FWFramedTextTableCellRenderer(m_graphicsContext, m_rowFillContext, FWFramedTextTableCellRenderer::kJustifyRight); }
FWTableViewTableManager::~FWTableViewTableManager | ( | ) | [virtual] |
Definition at line 45 of file FWTableViewTableManager.cc.
References m_renderer, and m_rowRenderer.
{ delete m_renderer; delete m_rowRenderer; }
FWTableViewTableManager::FWTableViewTableManager | ( | const FWTableViewTableManager & | ) | [private] |
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(), fwLog, FWTableViewManager::TableEntry::INT, FWTableViewManager::TableEntry::INT_HEX, 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().
{ const int realRowNumber = unsortedRowNumber(iSortedRowNumber); if (m_view->item() != 0 && m_view->item()->size() && m_view->item()->modelData(realRowNumber) != 0 && iCol < (int)m_evaluators.size()) { double ret; try { // printf("iCol %d, size %d\n", iCol, m_evaluators.size()); ret = m_evaluators[iCol].evalExpression(m_view->item()->modelData(realRowNumber)); } catch (...) { if (!m_caughtExceptionInCellRender){ fwLog(fwlog::kError) << "Error: caught exception in the cell renderer while evaluating an expression. Return -999. Error is suppressed in future\n"; } m_caughtExceptionInCellRender = true; ret = -999; } int precision = m_tableFormats->at(iCol).precision; char s[100]; char fs[100]; switch (precision) { case FWTableViewManager::TableEntry::INT: snprintf(s, sizeof(s), "%d", int(rint(ret))); break; case FWTableViewManager::TableEntry::INT_HEX: snprintf(s, sizeof(s), "0x%x", int(rint(ret))); break; case FWTableViewManager::TableEntry::BOOL: snprintf(s, sizeof(s), int(rint(ret)) != 0 ? "true" : "false"); break; default: snprintf(fs, sizeof(fs), "%%.%df", precision); snprintf(s, sizeof(s), fs, ret); break; } if (not m_view->item()->modelInfo(realRowNumber).isSelected()) { if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible()) if (m_view->m_manager->colorManager().background() == kBlack) { m_graphicsContext-> SetForeground(gVirtualX->GetPixel(kWhite)); } else { m_graphicsContext-> SetForeground(gVirtualX->GetPixel(kBlack)); } else { if (m_view->m_manager->colorManager().background() == kBlack) { m_graphicsContext->SetForeground(0x888888); } else { m_graphicsContext->SetForeground(0x888888); } } m_renderer->setGraphicsContext(m_graphicsContext); } else { m_graphicsContext-> SetForeground(0xffffff); m_renderer->setGraphicsContext(m_graphicsContext); } m_renderer->setData(s, m_view->item()->modelInfo(realRowNumber).isSelected()); } else { m_renderer->setData("invalid", false); } return m_renderer; }
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
Reimplemented from FWTableManagerBase.
Definition at line 225 of file FWTableViewTableManager.cc.
References i, FWTableView::item(), m_sortedToUnsortedIndices, m_view, FWEventItem::modelInfo(), and FWEventItem::size().
Referenced by FWTableView::dataChanged().
{ if (0!=m_view->item()) { std::vector<int> visible; visible.reserve(m_view->item()->size()); std::vector<int> invisible; invisible.reserve(m_view->item()->size()); m_sortedToUnsortedIndices.clear(); m_sortedToUnsortedIndices.reserve(m_view->item()->size()); for(int i=0; i< static_cast<int>(m_view->item()->size()); ++i) { if (m_view->item()->modelInfo(i).displayProperties().isVisible()) visible.push_back(i); else invisible.push_back(i); } m_sortedToUnsortedIndices.insert(m_sortedToUnsortedIndices.end(), visible.begin(), visible.end()); m_sortedToUnsortedIndices.insert(m_sortedToUnsortedIndices.end(), invisible.begin(), invisible.end()); assert(m_sortedToUnsortedIndices.size() == m_view->item()->size()); } else { m_sortedToUnsortedIndices.clear(); } FWTableManagerBase::dataChanged(); }
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, n, numberOfColumns(), and run_regression::ret.
{ unsigned int n = numberOfColumns(); std::vector<std::string> ret; ret.reserve(n); for (unsigned int i = 0; i < n; ++i) { ret.push_back(m_tableFormats->at(i).name); // printf("%s\n", ret.back().c_str()); } return ret; }
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.
{ return true; }
void FWTableViewTableManager::implSort | ( | int | iCol, |
bool | iSortOrder | ||
) | [protected, virtual] |
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.
{ static const bool sort_down = true; if (iCol >= (int)m_evaluators.size()) return; if (0!=m_view->item()) { // printf("sorting %s\n", iSortOrder == sort_down ? "down" : "up"); if (iSortOrder == sort_down) { std::multimap<std::pair<bool, double>, int, itemOrderGt> s; doSort(*m_view->item(), iCol, m_evaluators, s, m_sortedToUnsortedIndices); } else { std::multimap<std::pair<bool, double>, int, itemOrderLt> s; doSort(*m_view->item(), iCol, m_evaluators, s, m_sortedToUnsortedIndices); } } m_view->m_tableWidget->dataChanged(); }
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().
{ return m_evaluators.size(); }
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().
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(), 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().
{ const int realRowNumber = unsortedRowNumber(iSortedRowNumber); if (m_view->item() != 0 && m_view->item()->size() && m_view->item()->modelData(realRowNumber) != 0) { if (m_view->item()->modelInfo(realRowNumber).displayProperties().isVisible()) { if (m_view->m_manager->colorManager().background() == kBlack) { m_graphicsContext-> SetForeground(gVirtualX->GetPixel(kWhite)); } else { m_graphicsContext-> SetForeground(gVirtualX->GetPixel(kBlack)); } m_rowFillContext-> SetForeground(gVirtualX->GetPixel(m_view->item()->modelInfo(realRowNumber). displayProperties().color())); } else { m_graphicsContext->SetForeground(0x888888); m_rowFillContext->SetForeground(m_view->m_manager->colorManager().background()); } std::ostringstream s; s<<realRowNumber; m_rowRenderer->setData(s.str().c_str()); } else { m_rowRenderer->setData(""); } return m_rowRenderer; }
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().
{ if (iSortedRowNumber >= (int)m_sortedToUnsortedIndices.size()) return 0; return m_sortedToUnsortedIndices[iSortedRowNumber]; }
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, 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().
{ if (m_view->m_iColl == -1) { //printf("what should I do with collection -1?\n"); m_evaluators.clear(); return; } const FWEventItem *item = m_view->m_manager->items()[m_view->m_iColl]; if(0==item) { return;} std::vector<FWExpressionEvaluator> &ev = m_evaluators; ev.clear(); for (std::vector<FWTableViewManager::TableEntry>::const_iterator i = m_tableFormats->begin(), end = m_tableFormats->end(); i != end; ++i) { try { ev.push_back(FWExpressionEvaluator(i->expression, item->modelType()->GetName())); } catch (...) { fwLog(fwlog::kError) << "expression "<< i->expression << " is not valid, skipping\n"; ev.push_back(FWExpressionEvaluator("0", item->modelType()->GetName())); } } //printf("Got evaluators\n"); }
friend class FWTableView [friend] |
Definition at line 34 of file FWTableViewTableManager.h.
bool FWTableViewTableManager::m_caughtExceptionInCellRender [mutable, protected] |
Definition at line 115 of file FWTableViewTableManager.h.
Referenced by cellRenderer().
std::vector<FWExpressionEvaluator> FWTableViewTableManager::m_evaluators [protected] |
Definition at line 109 of file FWTableViewTableManager.h.
Referenced by cellRenderer(), implSort(), numberOfColumns(), and updateEvaluators().
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().
Definition at line 103 of file FWTableViewTableManager.h.
Referenced by cellRenderer(), FWTableViewTableManager(), and ~FWTableViewTableManager().
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().
Definition at line 107 of file FWTableViewTableManager.h.
Referenced by FWTableViewTableManager(), rowHeader(), and ~FWTableViewTableManager().
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] |
Definition at line 110 of file FWTableViewTableManager.h.
Referenced by FWTableView::addColumn(), cellRenderer(), FWTableView::columnSelected(), FWTableView::deleteColumn(), getTitles(), FWTableView::modifyColumn(), FWTableView::saveImageTo(), FWTableView::selectCollection(), and updateEvaluators().
const FWTableView* FWTableViewTableManager::m_view [protected] |
Definition at line 100 of file FWTableViewTableManager.h.
Referenced by cellRenderer(), dataChanged(), FWTableViewTableManager(), implSort(), numberOfRows(), rowHeader(), and updateEvaluators().