本文整理汇总了C++中cellAt函数的典型用法代码示例。如果您正苦于以下问题:C++ cellAt函数的具体用法?C++ cellAt怎么用?C++ cellAt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cellAt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _movewater
void _movewater(sim_Sim *s, int x, int y, double time) {
int i;
sim_Cell *cc, *bc;//center (x,y)
sim_Cell *currs[4]; //current up, down, left right
sim_Cell *buffs[4]; //next tick up, down, left right
double heightdiff[4]; //>0 means flowing in
double netflow;
cc = &cellAt (x, y, s);
bc = &cellAtBuff (x, y, s);
currs[UP] = &cellAt (x, y - 1, s);
buffs[UP] = &cellAtBuff (x, y - 1, s);
currs[DN] = &cellAt (x, y + 1, s);
buffs[DN] = &cellAtBuff (x, y + 1, s);
currs[LF] = &cellAt (x - 1, y, s);
buffs[LF] = &cellAtBuff (x - 1, y, s);
currs[RT] = &cellAt (x + 1, y, s);
buffs[RT] = &cellAtBuff (x + 1, y, s);
if(x == 0)
currs[LF] = NULL;
if(x == s->w - 1)
currs[RT] = NULL;
if(y == 0)
currs[UP] = NULL;
if(y == s->h - 1)
currs[DN] = NULL;
for(i = 0; i < 4; i++) {
bc->height -= bc->flow[i] * time;
}
}
开发者ID:gvorob,项目名称:wavemachine,代码行数:33,代码来源:sim.c
示例2: fgetc
bool Level::Private::cellsFromFile(FILE* in) {
cells.resize(size.x * size.y, Private::Floor);
Point read = { 0, 0 };
for (read.y = 0; read.y < size.y; ++read.y) {
for (read.x = 0; read.x < size.x + 1; ++read.x) {
char c = fgetc(in);
switch (c) {
case EOF: // Error: file is too short.
return false;
break;
case '\n': // End of line, read next.
if (read.x < size.x)
return false;
continue;
break;
case '+':
cellAt(read) = Private::Wood;
break;
case '#':
cellAt(read) = Private::Stone;
break;
case '@': // Spawner. Just a special floor cell.
spawns.push_back(read);
case ' ':
cellAt(read) = Private::Floor;
break;
};
}
}
return true;
}
开发者ID:answer-general,项目名称:hex2d,代码行数:34,代码来源:Level.cpp
示例3: areaIt
void PageItem_Table::updateSpans(int index, int number, ChangeType changeType)
{
// Loop through areas of merged cells.
QMutableListIterator<CellArea> areaIt(m_cellAreas);
while (areaIt.hasNext())
{
CellArea oldArea = areaIt.next();
// Get a copy of the area adjusted to the change.
CellArea newArea;
switch (changeType)
{
case RowsInserted:
newArea = oldArea.adjustedForRowInsertion(index, number);
break;
case RowsRemoved:
newArea = oldArea.adjustedForRowRemoval(index, number);
break;
case ColumnsInserted:
newArea = oldArea.adjustedForColumnInsertion(index, number);
break;
case ColumnsRemoved:
newArea = oldArea.adjustedForColumnRemoval(index, number);
break;
default:
break;
}
// Check if the area was affected by the change.
if (newArea != oldArea)
{
if (newArea.height() < 1 || newArea.width() < 1)
{
// Adjusted area was annihilated, so remove it.
areaIt.remove();
}
else if (newArea.height() == 1 && newArea.width() == 1)
{
// Adjusted area is 1x1, so remove it.
areaIt.remove();
// And reset row/column span of spanning cell to 1.
TableCell oldSpanningCell = cellAt(oldArea.row(), oldArea.column());
oldSpanningCell.setRowSpan(1);
oldSpanningCell.setColumnSpan(1);
}
else
{
// Replace the area with the adjusted copy.
areaIt.setValue(newArea);
// And set row/column spanning of spanning cell.
TableCell newSpanningCell = cellAt(newArea.row(), newArea.column());
newSpanningCell.setRowSpan(newArea.height());
newSpanningCell.setColumnSpan(newArea.width());
}
}
}
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:59,代码来源:pageitem_table.cpp
示例4: m_cells
Maze::Maze(int width,int height):m_width(width),m_height(height),
m_cells(std::vector<Cell>(width*height)){
for(int i=0;i<width;i++){
cellAt(Point(i,0))=cellAt(Point(i,0)).cellBySetWall(DirectionTop,true);
}
for(int i=0;i<height;i++){
cellAt(Point(0,i))=cellAt(Point(0,i)).cellBySetWall(DirectionLeft,true);
}
}
开发者ID:omochi,项目名称:MazeMouse,代码行数:9,代码来源:Maze.cpp
示例5: ASSERT_VALID
void PageItem_Table::mergeCells(int row, int column, int numRows, int numCols)
{
ASSERT_VALID();
if (!validCell(row, column) || !validCell(row + numRows - 1, column + numCols - 1))
return;
CellArea newArea(row, column, numCols, numRows);
// Unite intersecting areas.
QMutableListIterator<CellArea> areaIt(m_cellAreas);
while (areaIt.hasNext())
{
CellArea oldArea = areaIt.next();
if (newArea.intersects(oldArea))
{
// The two areas intersect, so unite them.
newArea = newArea.united(oldArea);
// Reset row/column span of old spanning cell, then remove old area.
TableCell oldSpanningCell = cellAt(oldArea.row(), oldArea.column());
oldSpanningCell.setRowSpan(1);
oldSpanningCell.setColumnSpan(1);
areaIt.remove();
}
}
// Set row/column span of new spanning cell, and add new area.
TableCell newSpanningCell = cellAt(newArea.row(), newArea.column());
newSpanningCell.setRowSpan(newArea.height());
newSpanningCell.setColumnSpan(newArea.width());
m_cellAreas.append(newArea);
// Update cells. TODO: Not for entire table.
updateCells();
// If merged area covers active position, move to the spanning cell.
if (newArea.contains(m_activeRow, m_activeColumn))
moveTo(newSpanningCell);
// Remove all cells covered by the merged area from the selection.
QMutableSetIterator<TableCell> cellIt(m_selection);
while (cellIt.hasNext())
{
TableCell cell = cellIt.next();
if (newArea.contains(cell.row(), cell.column()) &&
!(cell.row() == newArea.row() && cell.column() == newArea.column()))
cellIt.remove();
}
emit changed();
ASSERT_VALID();
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:54,代码来源:pageitem_table.cpp
示例6: insertRows
/*!
\fn void QTextTable::removeRows(int index, int rows)
Removes a number of \a rows starting with the row at the specified \a index.
\sa insertRows(), insertColumns(), resize(), removeColumns(), appendRows(), appendColumns()
*/
void QTextTable::removeRows(int pos, int num)
{
Q_D(QTextTable);
// qDebug() << "-------- removeRows" << pos << num;
if (num <= 0 || pos < 0)
return;
if (d->dirty)
d->update();
if (pos >= d->nRows)
return;
if (pos+num > d->nRows)
num = d->nRows - pos;
QTextDocumentPrivate *p = d->pieceTable;
QTextFormatCollection *collection = p->formatCollection();
p->beginEditBlock();
// delete whole table?
if (pos == 0 && num == d->nRows) {
const int pos = p->fragmentMap().position(d->fragment_start);
p->remove(pos, p->fragmentMap().position(d->fragment_end) - pos + 1);
p->endEditBlock();
return;
}
p->aboutToRemoveCell(cellAt(pos, 0).firstPosition(), cellAt(pos + num - 1, d->nCols - 1).lastPosition());
QList<int> touchedCells;
for (int r = pos; r < pos + num; ++r) {
for (int c = 0; c < d->nCols; ++c) {
int cell = d->grid[r*d->nCols + c];
if (touchedCells.contains(cell))
continue;
touchedCells << cell;
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
QTextCharFormat fmt = collection->charFormat(it->format);
int span = fmt.tableCellRowSpan();
if (span > 1) {
fmt.setTableCellRowSpan(span - 1);
p->setCharFormat(it.position(), 1, fmt);
} else {
// remove cell
int index = d->cells.indexOf(cell) + 1;
int f_end = index < d->cells.size() ? d->cells.at(index) : d->fragment_end;
p->remove(it.position(), p->fragmentMap().position(f_end) - it.position());
}
}
}
p->endEditBlock();
// qDebug() << "-------- end removeRows" << pos << num;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:60,代码来源:qtexttable.cpp
示例7: switch
void Maze::setWall(const Point &p,Direction d,bool exists){
switch(d){
case DirectionLeft:
case DirectionTop:
if(isInside(p)){
cellAt(p)=cellAt(p).cellBySetWall(d,exists);
}
break;
case DirectionRight:
case DirectionBottom:
return setWall(p.neighbor(d),DirectionReverse(d),exists);
}
}
开发者ID:omochi,项目名称:MazeMouse,代码行数:13,代码来源:Maze.cpp
示例8: puzzle
Puzzle *Sheet::toPuzzle() const
{
std::auto_ptr<Puzzle> puzzle(new Puzzle);
Grid &grid = puzzle->grid;
State &state = puzzle->state;
grid.height = grid_size.height();
grid.width = grid_size.width();
grid.vars.resize(layout()->count(), -1);
int hgrp = -1;
std::vector<int> vgrps(grid_size.width(), -1);
for(int n = grid_size.width() + 1, c = 1; n < layout()->count(); ++n)
{
if(cellAt(n).open())
{
if(hgrp == -1)
{
hgrp = state.grps++;
state.sum.push_back(cellAt(n - 1).hsum());
state.mem.resize(state.grps);
}
if(vgrps[c] == -1)
{
vgrps[c] = state.grps++;
state.sum.push_back(cellAt(n - grid_size.width()).vsum());
state.mem.resize(state.grps);
}
grid.vars[n] = state.vars;
state.cand.push_back(cellAt(n).cands());
state.hgrp.push_back(hgrp);
state.vgrp.push_back(vgrps[c]);
state.mem[hgrp].push_back(state.vars);
state.mem[vgrps[c]].push_back(state.vars);
++state.vars;
}
else
{
hgrp = vgrps[c] = -1;
}
if(++c == grid_size.width())
c = 0;
}
return puzzle.release();
}
开发者ID:maksverver,项目名称:kakuro,代码行数:48,代码来源:Sheet.cpp
示例9: _createflow
void _createflow(sim_Sim *s, int x, int y, double time) {//time elapsed in seconds
int i;
sim_Cell *cc, *bc;//center (x,y)
sim_Cell *currs[4]; //current up, down, left right
sim_Cell *buffs[4]; //next tick up, down, left right
double heightdiff[4]; //>0 means flowing in
double netflow;
cc = &cellAt (x, y, s);
bc = &cellAtBuff (x, y, s);
currs[UP] = &cellAt (x, y - 1, s);
buffs[UP] = &cellAtBuff (x, y - 1, s);
currs[DN] = &cellAt (x, y + 1, s);
buffs[DN] = &cellAtBuff (x, y + 1, s);
currs[LF] = &cellAt (x - 1, y, s);
buffs[LF] = &cellAtBuff (x - 1, y, s);
currs[RT] = &cellAt (x + 1, y, s);
buffs[RT] = &cellAtBuff (x + 1, y, s);
if(x == 0)
currs[LF] = NULL;
if(x == s->w - 1)
currs[RT] = NULL;
if(y == 0)
currs[UP] = NULL;
if(y == s->h - 1)
currs[DN] = NULL;
for(i = 0; i < 4; i++) {
if(currs[i]== NULL) {
heightdiff[i] = 0;
continue;
}
heightdiff[i] = currs[i]->height - cc->height;
}
//1 unit of flow = 1 height / second
//zflow =~ flow
netflow = 0;
for(i = 0; i < 4; i++) {
double temp = FLOWCONSTANT * sqrt(fabs(heightdiff[i])) * (heightdiff[i] < 0 ? 1 : -1);
double flowdiff;
flowdiff = temp - bc->flow[i];
bc->flow[i] += time * FLOWEQUALIZINGRATE * flowdiff;
netflow += bc->flow[i];
}
}
开发者ID:gvorob,项目名称:wavemachine,代码行数:48,代码来源:sim.c
示例10: cellAt
bool PickerCells::saveOpenCategories(std::list<std::list<std::string> >& masterList,
const std::list<std::string> &parentHier,
PickerCell *selectedCell) const {
bool hasSelectedCell=false;
for (int i=0; i<count(); i++) {
const PickerCell* cell = cellAt(i);
if (cell == selectedCell) {
hasSelectedCell=true;
}
if (!cell->hideChildren()) {
masterList.push_back(parentHier);
std::list<std::string> * newItem = &masterList.back();
(*newItem).push_back(cell->id());
PickerCells *newCells = cell->children();
bool savedCell=false;
if (newCells) {
savedCell = newCells->saveOpenCategories(masterList, (*newItem), selectedCell);
}
if (savedCell) {
(*newItem).push_back(selectedCell->id());
}
}
}
return hasSelectedCell;
}
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:25,代码来源:picker.cpp
示例11: empty
bool Sheet::empty()
{
for(int n = 0; n < grid_size.width()*grid_size.height(); ++n)
if(!cellAt(n).empty())
return false;
return true;
}
开发者ID:maksverver,项目名称:kakuro,代码行数:7,代码来源:Sheet.cpp
示例12: cellAt
void Field::generate(int x, int y)
{
Cell *banned = cellAt(x, y);
QVector<Cell*> bannedCells = banned->getNeighbors();
bannedCells.append(banned);
int minesToPlace = m_numberOfMines;
while (minesToPlace > 0) {
Cell *cell = m_cells.at(qrand() % m_cells.count());
if (cell->haveMine()) {
continue;
}
if (bannedCells.contains(cell)){
continue;
}
cell->setHaveMine(true);
--minesToPlace;
}
m_generated = true;
}
开发者ID:Deadlymouse1,项目名称:Mines,代码行数:27,代码来源:Field.cpp
示例13: cellAt
/**************************************
* Definition: Whether or not we can occupy the cell at x,y
*
* Parameters: x and y as ints
*
* Returns: true if we can, false if not
**************************************/
bool Map::canOccupy(int x, int y) {
Cell *moveCell = NULL;
moveCell = cellAt(x, y);
if (moveCell == NULL) {
return false;
}
return !moveCell->isBlocked();
}
开发者ID:Zhangziyang14,项目名称:CS1567,代码行数:15,代码来源:map.cpp
示例14: selectCell
void PageItem_Table::selectCell(int row, int column)
{
if (!validCell(row, column))
return;
m_selection.insert(cellAt(row, column));
emit selectionChanged();
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:8,代码来源:pageitem_table.cpp
示例15: setUpdatesEnabled
void Sheet::setPuzzle(const Puzzle &puzzle)
{
setUpdatesEnabled(false);
int W = puzzle.grid.width, H = puzzle.grid.height;
QSize new_size(W, H);
if(grid_size != new_size)
setGridSize(QSize(W, H));
for(int n = 0; n < W*H; ++n)
{
int v = puzzle.grid.vars[n];
if(v >= 0)
{
cellAt(n).setOpen(true);
cellAt(n).setCands(puzzle.state.cand[v]);
cellAt(n - W).setVsum(puzzle.state.sum[puzzle.state.vgrp[v]]);
cellAt(n - 1).setHsum(puzzle.state.sum[puzzle.state.hgrp[v]]);
}
else
{
cellAt(n).setOpen(false);
cellAt(n).setHsum(0);
cellAt(n).setVsum(0);
}
}
setUpdatesEnabled(true);
}
开发者ID:maksverver,项目名称:kakuro,代码行数:28,代码来源:Sheet.cpp
示例16: activateCell
void PageItem_Table::moveUp()
{
if (m_activeCell.row() < 1)
return;
// Move active position up and activate cell at new position.
// m_activeRow = m_activeCell.row() - 1;
activateCell(cellAt(m_activeCell.row() - 1, m_activeColumn));
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:9,代码来源:pageitem_table.cpp
示例17: setState
void Field::prepare()
{
m_generated = false;
m_MarkFlags = 0;
m_numberOfOpenedCells = 0;
setState(StateIdle);
for (int i = 0; i < m_cells.size();i++) {
m_cells[i]->reset();
QVector<Cell*> neighbors;
for (int x = m_cells[i]->x() - 1; x <= m_cells[i]->x() + 1; ++x) {
maybeAddCell(&neighbors, cellAt(x, m_cells[i]->y() - 1));
maybeAddCell(&neighbors, cellAt(x, m_cells[i]->y() + 1));
}
maybeAddCell(&neighbors, cellAt(m_cells[i]->x() - 1, m_cells[i]->y()));
maybeAddCell(&neighbors, cellAt(m_cells[i]->x() + 1, m_cells[i]->y()));
m_cells[i]->setNeighbors(neighbors);
}
}
开发者ID:Deadlymouse1,项目名称:Mines,代码行数:20,代码来源:Field.cpp
示例18: getTransform
TableCell PageItem_Table::cellAt(const QPointF& point) const
{
QPointF gridPoint = getTransform().inverted().map(point) - gridOffset();
if (!QRectF(0, 0, tableWidth(), tableHeight()).contains(gridPoint))
return TableCell(); // Outside table grid.
return cellAt(
qUpperBound(m_rowPositions, gridPoint.y()) - m_rowPositions.begin() - 1,
qUpperBound(m_columnPositions, gridPoint.x()) - m_columnPositions.begin() - 1);
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:11,代码来源:pageitem_table.cpp
示例19: cellAt
double PageItem_Table::maxLeftBorderWidth() const
{
double maxWidth = 0.0;
TableCell cell;
for (int row = 0; row < rows(); row += cell.rowSpan())
{
cell = cellAt(row, 0);
maxWidth = qMax(maxWidth, TableUtils::collapseBorders(cell.leftBorder(), leftBorder()).width());
}
return maxWidth;
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:11,代码来源:pageitem_table.cpp
示例20: rowEnd
/*!
\fn QTextCursor QTextTable::rowStart(const QTextCursor &cursor) const
Returns a cursor pointing to the start of the row that contains the
given \a cursor.
\sa rowEnd()
*/
QTextCursor QTextTable::rowStart(const QTextCursor &c) const
{
Q_D(const QTextTable);
QTextTableCell cell = cellAt(c);
if (!cell.isValid())
return QTextCursor();
int row = cell.row();
QTextDocumentPrivate *p = d->pieceTable;
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), d->grid[row*d->nCols]);
return QTextCursor(p, it.position());
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:20,代码来源:qtexttable.cpp
注:本文中的cellAt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论