Esempio n. 1
0
Column* DatapickerCurve::appendColumn(const QString& name) {
	Column* col = new Column(i18n("Column"), AbstractColumn::Numeric);
	col->insertRows(0, m_datasheet->rowCount());
	col->setName(name);
	m_datasheet->addChild(col);

	return col;
}
Esempio n. 2
0
/**
 * \brief Implements column() function for tables.
 *
 * \arg \c columnPath Path to the column to read data from. See
 * resolveColumnPath().
 *
 * The row to read from is determined by the muParser variable "i" set during
 * iteration of a column
 * formula. For explicitly specifying the row, use cell() instead.
 *
 * \sa tableCellFunction()
 */
double MuParserScript::tableColumnFunction(const char *columnPath) {
  Column *column =
      s_currentInstance->resolveColumnPath(QString::fromUtf8(columnPath));
  if (!column) return NAN;  // failsafe, shouldn't happen
  int row = qRound(s_currentInstance->m_variables["i"]) - 1;
  if (column->isInvalid(row)) throw new EmptySourceError();
  return column->valueAt(row);
}
Esempio n. 3
0
void IOracle::extract(DoubleVector const & x, Column & column) {
  for (int v(0); v < _input->nV(); ++v) {
    if (x[v] > 0.5) {
      column.insert(v);
    }
  }
  column.cost() = column.computeCost();
}
Esempio n. 4
0
void SumAggregator::Apply(const Table::Ptr& table, const Value& row)
{
	Column column = table->GetColumn(m_SumAttr);

	Value value = column.ExtractValue(row);

	m_Sum += value;
}
Esempio n. 5
0
void fill(Column::Type type, QListWidget* lw, const QString& path){
    Column* column = Column::make(type);
        column->createRows(path);
        setWindowTitle(type, lw);
        lw->show();
        lw->addItems(column->getRows());
    delete column;
}
Esempio n. 6
0
    void ColumnSet::CalculateSize()
    {
        gfx::Size pref;
        // Reset the preferred and remaining sizes.
        for(std::vector<ViewState*>::iterator i = view_states_.begin();
            i!=view_states_.end(); ++i)
        {
            ViewState* view_state = *i;
            if(!view_state->pref_width_fixed || !view_state->pref_height_fixed)
            {
                pref = view_state->view->GetPreferredSize();
                if(!view_state->pref_width_fixed)
                {
                    view_state->pref_width = pref.width();
                }
                if(!view_state->pref_height_fixed)
                {
                    view_state->pref_height = pref.height();
                }
            }
            view_state->remaining_width = pref.width();
            view_state->remaining_height = pref.height();
        }

        // Let layout element reset the sizes for us.
        LayoutElement::ResetSizes(&columns_);

        // Distribute the size of each view with a col span == 1.
        std::vector<ViewState*>::iterator view_state_iterator =
            view_states_.begin();
        for(; view_state_iterator!=view_states_.end()&&
            (*view_state_iterator)->col_span==1; ++view_state_iterator)
        {
            ViewState* view_state = *view_state_iterator;
            Column* column = columns_[view_state->start_col];
            column->AdjustSize(view_state->pref_width);
            view_state->remaining_width -= column->Size();
        }

        // Make sure all linked columns have the same size.
        UnifySameSizedColumnSizes();

        // Distribute the size of each view with a column span > 1.
        for(; view_state_iterator!=view_states_.end(); ++view_state_iterator)
        {
            ViewState* view_state = *view_state_iterator;

            // Update the remaining_width from columns this view_state touches.
            UpdateRemainingWidth(view_state);

            // Distribute the remaining width.
            DistributeRemainingWidth(view_state);

            // Update the size of linked columns.
            // This may need to be combined with previous step.
            UnifySameSizedColumnSizes();
        }
    }
Esempio n. 7
0
void MinAggregator::Apply(const Table::Ptr& table, const Value& row)
{
	Column column = table->GetColumn(m_MinAttr);

	Value value = column.ExtractValue(row);

	if (value < m_Min)
		m_Min = value;
}
Esempio n. 8
0
void AvgAggregator::Apply(const Table::Ptr& table, const Value& row)
{
	Column column = table->GetColumn(m_AvgAttr);

	Value value = column.ExtractValue(row);

	m_Avg += value;
	m_AvgCount++;
}
Esempio n. 9
0
void PostgreSqlDbAdapter::ConvertTable(Table* pTab) {
	SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
	while( node ) {
		if( node->GetData()->IsKindOf( CLASSINFO(Column)) )  {
			Column* col = (Column*) node->GetData();
			col->SetType(ConvertType(col->GetType()));
		}
		node = node->GetNext();
	}
}
Esempio n. 10
0
void Table::setPrimaryKey(string colName) {
	
	Column *theCol = findColumn(colName);

	if(theCol == NULL) {
		throw DatabaseException(20, colName + " does not exist.");
	}

	theCol->setPrimary(true);
}
Esempio n. 11
0
void SumAggregator::Apply(const Table::Ptr& table, const Value& row, AggregatorState **state)
{
	Column column = table->GetColumn(m_SumAttr);

	Value value = column.ExtractValue(row);

	SumAggregatorState *pstate = EnsureState(state);

	pstate->Sum += value;
}
Esempio n. 12
0
std::string * Row::GetValue(const std::string & column_name)
{
	Column * col = _tbl->GetColumn(column_name);
	if (!col)
	{
		return nullptr;
	}

	return GetValue(col->GetIndex(), false);
}
Esempio n. 13
0
/*!
  Returns the data stored in the row in the column named \a column or an invalid
  QVariant if this column does not exist in the table of the row.
  */
QVariant Row::data(const QString &column) const
{
    Q_D(const Row);

    Column *c = d->table->column(column);
    if(!c)
        return QVariant();

    return data(c->index());
}
Esempio n. 14
0
/*!
  Sets the content stored in the database in this row in the Column with the
  name \a column to \a data.
  Does nothing if no such column exists in the table of the row.
  */
void Row::setData(const QString &column, const QVariant &data)
{
    Q_D(const Row);

    Column *c = d->table->column(column);
    if(!c)
        return;

    setData(c->index(), data);
}
Esempio n. 15
0
void StdAggregator::Apply(const Table::Ptr& table, const Value& row)
{
	Column column = table->GetColumn(m_StdAttr);

	Value value = column.ExtractValue(row);

	m_StdSum += value;
	m_StdQSum += pow(value, 2);
	m_StdCount++;
}
Esempio n. 16
0
Column* TableSettings::GetColumn(const wxString& name)
{
    for( SerializableList::iterator it = m_lstColumns.begin();
         it != m_lstColumns.end(); ++it ) {

        Column *c = wxDynamicCast( *it, Column );
        if( c && ( c->GetName() == name ) ) return c;
    }

    return NULL;
}
Esempio n. 17
0
////////////////////////////////////////////////////////////////////////////////
// Supports the complete column definition:
//
//   <type>[.<format>]
//
Column* Column::factory (const std::string& name, const std::string& report)
{
  // Decompose name into type and style.
  std::string::size_type dot = name.find ('.');
  std::string column_name;
  std::string column_style;
  if (dot != std::string::npos)
  {
    column_name = name.substr (0, dot);
    column_style = name.substr (dot + 1);
  }
  else
  {
    column_name = name;
    column_style = "default";
  }

  Column* c;
       if (column_name == "depends")     c = new ColumnDepends ();
  else if (column_name == "description") c = new ColumnDescription ();
  else if (column_name == "due")         c = new ColumnDue ();
  else if (column_name == "end")         c = new ColumnEnd ();
  else if (column_name == "entry")       c = new ColumnEntry ();
  else if (column_name == "id")          c = new ColumnID ();
  else if (column_name == "imask")       c = new ColumnIMask ();
  else if (column_name == "mask")        c = new ColumnMask ();
  else if (column_name == "modified")    c = new ColumnModified ();
  else if (column_name == "parent")      c = new ColumnParent ();
  else if (column_name == "priority")    c = new ColumnPriority ();
  else if (column_name == "project")     c = new ColumnProject ();
  else if (column_name == "recur")       c = new ColumnRecur ();
  else if (column_name == "scheduled")   c = new ColumnScheduled ();
  else if (column_name == "start")       c = new ColumnStart ();
  else if (column_name == "status")      c = new ColumnStatus ();
  else if (column_name == "tags")        c = new ColumnTags ();
  else if (column_name == "until")       c = new ColumnUntil ();
  else if (column_name == "urgency")     c = new ColumnUrgency ();
  else if (column_name == "uuid")        c = new ColumnUUID ();
  else if (column_name == "wait")        c = new ColumnWait ();

  // Special non-task column.
  else if (column_name == "string")      c = new ColumnString ();

  // UDA.
  else if (context.config.get ("uda." + column_name + ".type") != "")
    c = Column::uda (column_name);

  else
    throw format (STRING_COLUMN_BAD_NAME, column_name);

  c->setReport (report);
  c->setStyle (column_style);
  return c;
}
Esempio n. 18
0
Column *ColumnManager::AddExprColumn(common::Type::TypeId type, int size, std::string name,
                                     bool inlined) {
  LOG_TRACE("Adding expr column: %s, type %d, size %d, inlined %s",
            name.c_str(), type, size,
            inlined ? "yes" : "no");
  Column *col = new ExprColumn(next_column_id++, type, size, name, inlined);

  id_to_column.insert(std::pair<ColumnID, Column *>(col->ID(), col));
  columns.push_back(col);
  return col;
}
Esempio n. 19
0
void AvgAggregator::Apply(const Table::Ptr& table, const Value& row, AggregatorState **state)
{
	Column column = table->GetColumn(m_AvgAttr);

	Value value = column.ExtractValue(row);

	AvgAggregatorState *pstate = EnsureState(state);

	pstate->Avg += value;
	pstate->AvgCount++;
}
Esempio n. 20
0
numeric_t Sheet::totalRowValue(const RowId& rowId) const
{
  numeric_t rowTotal = 0.0;

  Column* pColumn = NULL;
  foreach(pColumn, m_columns)
  {
    ICell* pCell = pColumn->cellAt(rowId);
    if (pCell && pCell->isNumeric() && pCell->isPartOfTotal())
      rowTotal += pCell->getValue(NULL); //pass here the total column? useless
  }
Esempio n. 21
0
void StdAggregator::Apply(const Table::Ptr& table, const Value& row, AggregatorState **state)
{
	Column column = table->GetColumn(m_StdAttr);

	Value value = column.ExtractValue(row);

	StdAggregatorState *pstate = EnsureState(state);

	pstate->StdSum += value;
	pstate->StdQSum += pow(value, 2);
	pstate->StdCount++;
}
Esempio n. 22
0
void QtUnit::_ToggleConnections(bool flag)
{
    if (toggled == flag)
        return;
    toggled = flag;
    Column *col = (Column *)node;
    DendriteSegment *segment = col->GetProximalDendriteSegment();
    std::vector<Synapse *> prox_syns = segment->GetSynapses();
    int rfs = col->GetRecFieldSz();
    //for (int i=0; i<rfs; i++)
    //    prox_syns[i]->ShowSynapse(flag);
}
bool InvalidationWatcher::CheckInvalidation(const Column& column)
{
   int invalidation_count = column.GetInvalidated();
   int x = column.GetX();
   int z = column.GetZ();
   if(invalidation_count > mInvalidationCounters[x][z])
   {
      mInvalidationCounters[x][z] = invalidation_count;
      return true;
   }
   return false;
}
Esempio n. 24
0
/////////BDB//////Check for matching number of columns/////////////////////
void Table::addRow(vector<string> columnNames, vector<string> rowData) {
	for(int i = 0; i < columnNames.size(); i++) {
		Column *thisCol = findColumn(columnNames[i]);
		if(thisCol == NULL) {
			throw DatabaseException(20, "Column " + columnNames[i] + " does not exist.");
		}
		if(thisCol->isPrimaryKey() && thisCol->valExists(rowData[i])) {
			throw DatabaseException(21, rowData[i] + " already exists in column" + columnNames[i] + ".");
		}
		thisCol->addRow(rowData[i]);
	}
}
Esempio n. 25
0
bool Folder::readChildAspectElement(XmlStreamReader * reader)
{
	bool loaded = false;
	Q_ASSERT(reader->isStartElement() && reader->name() == "child_aspect");

	if (!reader->skipToNextTag()) return false;
	if (reader->isEndElement() && reader->name() == "child_aspect") return true; // empty element tag
	QString element_name = reader->name().toString();
	if (element_name == "folder")
	{
		Folder * folder = new Folder(tr("Folder %1").arg(1));
		if (!folder->load(reader))
		{
			delete folder;
			return false;
		}
		addChild(folder);
		loaded = true;
	}
	else if (element_name == "column")
	{
		Column * column = new Column(tr("Column %1").arg(1), SciDAVis::Text);
		if (!column->load(reader))
		{
			delete column;
			return false;
		}
		addChild(column);
		loaded = true;
	}
	else
	{
		foreach(QObject * plugin, QPluginLoader::staticInstances()) 
		{
			XmlElementAspectMaker * maker = qobject_cast<XmlElementAspectMaker *>(plugin);
			if (maker && maker->canCreate(element_name))
			{
				AbstractAspect * aspect = maker->createAspectFromXml(reader);
				if (aspect)
				{
					addChild(aspect);
					loaded = true;
					break;
				}
				else
				{
					reader->raiseError(tr("creation of aspect from element '%1' failed").arg(element_name));
					return false;
				}
			}
		}
	}
void CursorPositioningAction::Tick(TickParameters& tp)
{
   if(mEventRcvr && mEventRcvr->GetClicked())
   {
      Vector3f ray_origin;
      Vector3f ray_unit;
      TouchData td = mEventRcvr->GetClick();
      tp.camera->GetRay(td.GetTouchCentre(), ray_origin, ray_unit);

      //Now check if collision occurs on each block
      Vector3f intersect_point;
      Vector3f intersection_normal;
      Vector3f closest_intersect_point;
      Vector3f closest_intersect_normal;
      float intersect_distance;
      
      float min_intersect_distance = FLT_MAX;
      for (int x = 0; x < WORLD_WIDTH; x++)
      {
         for (int z = 0; z < WORLD_BREADTH; z++)
         {
            Column col = mWorld->getColumn(x, z);
            
            for(int y = 0; y < WORLD_HEIGHT; y++)
            {
               Block block = col.Get(y);
               if(block.blockType.Value() == BlockType::Empty)
                  continue;
               
               if(Collisions3f::RayIntersectsAABB(ray_origin, ray_unit, Vector3f(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z)), Vector3f(1.0f, 1.0f, 1.0f), intersect_point, intersect_distance, intersection_normal))
               {
                  if(min_intersect_distance > intersect_distance)
                  {
                     closest_intersect_point = Vector3f(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z));
                     closest_intersect_normal = intersection_normal;
                     min_intersect_distance = intersect_distance;
                  }
               }
            }
         }
      }

      if (min_intersect_distance < FLT_MAX)
      {
         // Cursor to top of stack
         Column col = mWorld->getColumn(static_cast<int>(closest_intersect_point.x), static_cast<int>(closest_intersect_point.z));
         closest_intersect_point.y = static_cast<float>(col.GetHeight()) + 1.0f;
         tp.msg.GetHub<CursorMoveMessage>().Broadcast(CursorMoveMessage(closest_intersect_point));
         Log::Debug(__FILE__, "Intersection at (%f,%f,%f)", closest_intersect_point.x, closest_intersect_point.y, closest_intersect_point.z);
      }
   }
}
void MainObjectMenuMetadataItemVisitor::visitColumn(Column& column)
{
    addGenerateCodeMenu(column);
    // do not show for system tables or views
    if (!column.isSystem() && column.getTable() != 0)
    {
        addSeparator();
        addDropItem(column);
        addSeparator();
        // TODO: addRefreshItem();
        addPropertiesItem();
    }
}
Esempio n. 28
0
/**
 * \brief Implements cell_() function for tables.
 *
 * \arg \c columnIndex 1-based index of column to read data from.
 * \arg \c rowIndex 1-based index of row to read data from.
 *
 * It is preferable to use cell() instead of this function where possible, because referring to
 * columns via index silently breaks when moving columns.
 *
 * \sa tableColumn_Function()
 */
double MuParserScript::tableCell_Function(double columnIndex, double rowIndex) {
	Table *thisTable = qobject_cast<Table*>(s_currentInstance->Context);
	if (!thisTable)
		throw mu::Parser::exception_type(qPrintable(tr("cell() works only on tables and matrices!")));
	Column *column = thisTable->d_future_table->column(qRound(columnIndex) - 1);
	if (!column)
		throw mu::Parser::exception_type(qPrintable(tr("There's no column %1 in table %2!")
					.arg(qRound(columnIndex)).arg(thisTable->objectName())));
	int row = qRound(rowIndex) - 1;
	if (column->isInvalid(row))
		throw new EmptySourceError();
	return column->valueAt(row);
}
Esempio n. 29
0
std::string renderAttribute (const std::string& name, const std::string& value)
{
    Column* col = context.columns[name];
    if (col                    &&
            col->type () == "date" &&
            value != "")
    {
        Date d ((time_t)strtol (value.c_str (), NULL, 10));
        return d.toString (context.config.get ("dateformat"));
    }

    return value;
}
Esempio n. 30
0
void TableSettings::FillRefTableColums(Table* tab)
{
    if( tab ) {
        m_choiceRefCol->Clear();
        m_choiceRefCol->Append( wxT("") );

        for( SerializableList::iterator it = tab->GetChildrenList().begin();
             it != tab->GetChildrenList().end(); ++it ) {

            Column *c = wxDynamicCast( *it, Column );
            if( c ) m_choiceRefCol->Append( c->GetName() );
        }
    }
}