MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / indexToRowCol

Method indexToRowCol

qcustomplot/qcustomplot.cpp:4532–4561  ·  view source on GitHub ↗

! Converts the linear index to row and column indices and writes the result to \a row and \a column. The way the cells are indexed depends on \ref setFillOrder. If it is \ref foRowsFirst, the indices increase left to right and then top to bottom. If it is \ref foColumnsFirst, the indices increase top to bottom and then left to right. If there are no cells (i.e. column or row count is

Source from the content-addressed store, hash-verified

4530 \see rowColToIndex
4531*/
4532void QCPLayoutGrid::indexToRowCol(int index, int &row, int &column) const
4533{
4534 row = -1;
4535 column = -1;
4536 const int nCols = columnCount();
4537 const int nRows = rowCount();
4538 if (nCols == 0 || nRows == 0)
4539 return;
4540 if (index < 0 || index >= elementCount())
4541 {
4542 qDebug() << Q_FUNC_INFO << "index out of bounds:" << index;
4543 return;
4544 }
4545
4546 switch (mFillOrder)
4547 {
4548 case foRowsFirst:
4549 {
4550 column = index / nRows;
4551 row = index % nRows;
4552 break;
4553 }
4554 case foColumnsFirst:
4555 {
4556 row = index / nCols;
4557 column = index % nCols;
4558 break;
4559 }
4560 }
4561}
4562
4563/* inherits documentation from base class */
4564void QCPLayoutGrid::updateLayout()

Callers

nothing calls this directly

Calls 3

columnCountFunction · 0.85
rowCountFunction · 0.85
elementCountFunction · 0.85

Tested by

no test coverage detected