Beispiel #1
0
void Grid::SetDimension(uint32_t width, uint32_t height)
{
	int cellCountDiff = width * height - dimension.x * dimension.y;

	// Add cells
	if (cellCountDiff >= 0)
	{
		for (int i = 0; i < cellCountDiff; ++i)
		{
			Gui* cell = AddGui();
			cell->DisableHover();
			cells.push_back(cell);
		}
	}
	else // Remove cells
	{
		for (int i = 0; i < -cellCountDiff; ++i)
		{
			Gui* cell = cells[cells.size() - 1 - i];
			cell->RemoveFromParent();
		}
		cells.resize(cells.size() + cellCountDiff);
	}

	Vec2i dimensionDiff = Vec2i(width - dimension.x, height - dimension.y);

	// Add columns
	if (dimensionDiff.x >= 0)
	{
		for (int i = 0; i < dimensionDiff.x; ++i)
			columns.push_back(GridColumn(columns.size() + i, this));
	}
	else // Remove columns
	{
		columns.resize(columns.size() + dimensionDiff.x);
	}

	// Add rows
	if (dimensionDiff.y >= 0)
	{
		for (int i = 0; i < dimensionDiff.y; ++i)
			rows.push_back(GridRow(rows.size() + i, this));
	}
	else // Remove rows
	{
		rows.resize(rows.size() + dimensionDiff.y);
	}

	dimension = Vec2u(width, height);
}
Beispiel #2
0
inline int GridInit( int bHandle, const AbstractDistMatrix<scalarType>& A )
{
    if( A.ColDist() != MC || A.RowDist() != MR )
        LogicError
        ("Only (MC,MR) distributions are currently supported with ScaLAPACK");
    const int context =
      GridInit
      ( bHandle, A.Grid().Order()==COLUMN_MAJOR, A.ColStride(), A.RowStride() );
    DEBUG_ONLY(
      if( A.ColStride() != GridHeight(context) )
          LogicError("Grid height did not match BLACS");
      if( A.RowStride() != GridWidth(context) )
          LogicError("Grid width did not match BLACS");
      if( A.ColRank() != GridRow(context) )
          LogicError("Grid row did not match BLACS");
      if( A.RowRank() != GridCol(context) )
          LogicError("Grid col did not match BLACS");
    )
    return context;
Beispiel #3
0
GridMap dilate(const GridMap& map, int amount) {
	const int w = map[0].size(), h = map.size();
	SDL_Surface* surf = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0xff, 0);
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (map[y][x]) {
				filledCircleColor(surf, x, y, amount, 0xffffff);
			}
		}
	}
	GridMap out(h, GridRow(w));
	for (int y = 0; y < h; y++) {
		Uint32* srcrow = reinterpret_cast<Uint32*>(static_cast<char*>(surf->pixels) + surf->pitch * y);
		GridRow& dstrow = out[y];
		for (int x = 0; x < w; x++) {
			if (srcrow[x])
				dstrow[x] = true;
		}
	}
	return out;
}
typename Grid<ValueType>::GridRow Grid<ValueType>::operator[](int row) {
   return GridRow(this, row);
}