/** If count is greater than the current number of rows extra rows are added to
   the bottom of the table.
    Otherwise rows at the end are erased to reach the new size.
    @param count :: New number of rows.
*/
void TableWorkspace::setRowCount(size_t count) {
  if (count == rowCount())
    return;
  for (auto &column : m_columns)
    resizeColumn(column.get(), count);
  m_rowCount = count;
}
/** @param type :: Data type of the column.
    @param name :: Column name.
    @return A shared pointer to the created column (will be null on failure).
*/
API::Column_sptr TableWorkspace::addColumn(const std::string &type,
                                           const std::string &name) {
  API::Column_sptr c;
  if (type.empty()) {
    g_log.error("Empty string passed as type argument of createColumn.");
    return c;
  }
  if (name.empty()) {
    g_log.error("Empty string passed as name argument of createColumn.");
    return c;
  }
  // Check that there is no column with the same name.
  auto ci = std::find_if(m_columns.begin(), m_columns.end(), FindName(name));
  if (ci != m_columns.end()) {
    g_log.error() << "Column with name " << name << " already exists.\n";
    return c;
  }
  try {
    c = API::ColumnFactory::Instance().create(type);
    m_columns.push_back(c);
    c->setName(name);
    resizeColumn(c.get(), rowCount());
  } catch (Kernel::Exception::NotFoundError &e) {
    g_log.error() << "Column of type " << type << " and name " << name
                  << " has not been created.\n";
    g_log.error() << e.what() << '\n';
    return c;
  }
  return c;
}
Beispiel #3
0
/** If count is greater than the current number of rows extra rows are added to
   the bottom of the table.
    Otherwise rows at the end are erased to reach the new size.
    @param count :: New number of rows.
*/
void TableWorkspace::setRowCount(size_t count) {
  if (count == rowCount())
    return;
  for (column_it ci = m_columns.begin(); ci != m_columns.end(); ci++)
    resizeColumn(ci->get(), count);
  m_rowCount = count;
}
Beispiel #4
0
void PageItem_Table::distributeColumns(int startColumn, int endColumn)
{
	if (startColumn < 0 || endColumn > columns() - 1 || startColumn > endColumn)
		return;

	const int numColumns = endColumn - startColumn + 1;
	const double newWidth = (columnPosition(endColumn) + columnWidth(endColumn) - columnPosition(startColumn)) / numColumns;

	for (int column = startColumn; column <= endColumn; ++column)
		resizeColumn(column, newWidth);
}