本文整理汇总了C++中QBitArray::testBit方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitArray::testBit方法的具体用法?C++ QBitArray::testBit怎么用?C++ QBitArray::testBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBitArray
的用法示例。
在下文中一共展示了QBitArray::testBit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant ChannelModel::data(const QModelIndex& index, int role) const
{
if (m_currentLayer.isValid() && index.isValid())
{
QList<KoChannelInfo*> channels = m_currentLayer->colorSpace()->channels();
int channelIndex = KoChannelInfo::displayPositionToChannelIndex(index.row(), channels);
switch (role) {
case Qt::DisplayRole:
{
return channels.at(channelIndex)->name();
}
case Qt::CheckStateRole: {
Q_ASSERT(index.row() < rowCount());
Q_ASSERT(index.column() < columnCount());
if (index.column() == 0) {
QBitArray flags = m_currentLayer->channelFlags();
return (flags.isEmpty() || flags.testBit(channelIndex)) ? Qt::Checked : Qt::Unchecked;
}
QBitArray flags = dynamic_cast<const KisPaintLayer*>(m_currentLayer.data())->channelLockFlags();
return (flags.isEmpty() || flags.testBit(channelIndex)) ? Qt::Unchecked : Qt::Checked;
}
}
}
return QVariant();
}
示例2: progressChanged
void
VolumeMask::erodeBitmask(int mind, int maxd,
int minw, int maxw,
int minh, int maxh)
{
// QProgressDialog progress("Eroding Tag Mask",
// "Cancel",
// 0, 100,
// 0);
QBitArray bitcopy = m_bitmask;
for(int d=mind; d<=maxd; d++)
{
emit progressChanged((int)(100.0*(float)d/(float)m_depth));
qApp->processEvents();
for(int w=minw; w<=maxw; w++)
for(int h=minh; h<=maxh; h++)
{
qint64 bidx = (d*m_width*m_height +
w*m_height + h);
if (bitcopy.testBit(bidx))
{
int d0 = qMax(d-1, mind);
int d1 = qMin(d+1, maxd);
int w0 = qMax(w-1, minw);
int w1 = qMin(w+1, maxw);
int h0 = qMax(h-1, minh);
int h1 = qMin(h+1, maxh);
bool ok = true;
for(int d2=d0; d2<=d1; d2++)
for(int w2=w0; w2<=w1; w2++)
for(int h2=h0; h2<=h1; h2++)
{
qint64 idx = d2*m_width*m_height +
w2*m_height + h2;
ok &= bitcopy.testBit(idx);
}
if (!ok) // surface voxel
m_bitmask.setBit(bidx, false); // set bit to 0
}
}
}
emit progressReset();
}
示例3: checkMaskFile
void
VolumeMask::tagDSlice(int d, QBitArray bitmask, uchar *usermask)
{
checkMaskFile();
int nbytes = m_width*m_height;
uchar *mask = new uchar[nbytes];
int tag = Global::tag();
uchar *mslice = m_maskFileManager.getSlice(d);
memcpy(mask, mslice, nbytes);
qint64 idx = 0;
for(int w=0; w<m_width; w++)
for(int h=0; h<m_height; h++)
{
qint64 midx = d*m_width*m_height + w*m_height + h;
if (bitmask.testBit(midx))
{
if (usermask[4*idx] > 0)
mask[idx] = tag;
}
idx ++;
}
m_maskFileManager.setSlice(d, mask);
delete [] mask;
}
示例4: addMonthlyPos
void Recurrence::addMonthlyPos( short pos, const QBitArray &days )
{
// Allow 53 for yearly!
if ( d->mRecurReadOnly || pos > 53 || pos < -53 ) {
return;
}
RecurrenceRule *rrule = defaultRRule( false );
if ( !rrule ) {
return;
}
bool changed = false;
QList<RecurrenceRule::WDayPos> positions = rrule->byDays();
for ( int i = 0; i < 7; ++i ) {
if ( days.testBit( i ) ) {
RecurrenceRule::WDayPos p( pos, i + 1 );
if ( !positions.contains( p ) ) {
changed = true;
positions.append( p );
}
}
}
if ( changed ) {
rrule->setByDays( positions );
updated();
}
}
示例5:
void
TrisetObject::paint(QGLViewer *viewer,
QBitArray doodleMask,
float *depthMap,
Vec tcolor, float tmix)
{
int swd = viewer->camera()->screenWidth();
int sht = viewer->camera()->screenHeight();
for(int i=0; i<m_tvertices.count(); i++)
{
Vec scr = viewer->camera()->projectedCoordinatesOf(m_tvertices[i]);
int tx = scr.x;
int ty = sht-scr.y;
float td = scr.z;
if (tx>0 && tx<swd && ty>0 && ty<sht)
{
int idx = ty*swd + tx;
if (doodleMask.testBit(idx))
{
float zd = depthMap[idx];
if (fabs(zd-td) < 0.0002)
m_vcolor[i] = tmix*tcolor + (1.0-tmix)*m_vcolor[i];
}
}
}
}
示例6: while
QList<QWidget *> FatherBlock::GetEnableBlocksWidget(int theStatusIndex)
{
QList<QWidget *>theBlockWidgets;
if(theStatusIndex == -1)
{
theStatusIndex = m_current_status_index;
}
if(theStatusIndex < m_status_list.count())
{
QBitArray theStatus = m_status_list[theStatusIndex];
int count = theStatus.count()-1;
while(count >= 0)
{
if(theStatus.testBit(count) == true)
{
QWidget *ChildBlockWidget = GetSingleBlock(m_block_type);
ChildBlockWidget->setStyleSheet(m_BlockStyleSheet);
ChildBlockWidget->setGeometry(m_blocks_list[count]->geometry());
ChildBlockWidget->setGeometry(ChildBlockWidget->x()+this->x(),ChildBlockWidget->y()+this->y(),ChildBlockWidget->width(),ChildBlockWidget->height());
theBlockWidgets.append(ChildBlockWidget);
}
count--;
}
}
return theBlockWidgets;
}
示例7: spread
/**
* Spread contacts in the blockmap to any touched neighbors.
*
* @param box Map space region in which to perform spreading.
*/
void spread(AABoxd const &box)
{
BlockmapCellBlock const cellBlock = _blockmap.toCellBlock(box);
BlockmapCell cell;
for(cell.y = cellBlock.min.y; cell.y < cellBlock.max.y; ++cell.y)
for(cell.x = cellBlock.min.x; cell.x < cellBlock.max.x; ++cell.x)
{
if(_spreadBlocks)
{
// Should we skip this cell?
int cellIndex = _blockmap.toCellIndex(cell.x, cell.y);
if(_spreadBlocks->testBit(cellIndex))
continue;
// Mark the cell as processed.
_spreadBlocks->setBit(cellIndex);
}
_blockmap.forAllInCell(cell, [this] (void *element)
{
spreadContact(*static_cast<Contact *>(element));
return LoopContinue;
});
}
}
示例8: sendPieceList
// Sends the complete list of pieces that we have downloaded.
void PeerWireClient::sendPieceList(const QBitArray &bitField)
{
// The bitfield message may only be sent immediately after the
// handshaking sequence is completed, and before any other
// messages are sent.
if (!sentHandShake)
sendHandShake();
// Don't send the bitfield if it's all zeros.
if (bitField.count(true) == 0)
return;
int bitFieldSize = bitField.size();
int size = (bitFieldSize + 7) / 8;
QByteArray bits(size, '\0');
for (int i = 0; i < bitFieldSize; ++i) {
if (bitField.testBit(i)) {
quint32 byte = quint32(i) / 8;
quint32 bit = quint32(i) % 8;
bits[byte] = uchar(bits.at(byte)) | (1 << (7 - bit));
}
}
char message[] = {0, 0, 0, 1, 5};
toNetworkData(bits.size() + 1, &message[0]);
write(message, sizeof(message));
write(bits);
}
示例9: setParticleSelection
/******************************************************************************
* Replaces the particle selection.
******************************************************************************/
void ParticleSelectionSet::setParticleSelection(const PipelineFlowState& state, const QBitArray& selection, SelectionMode mode)
{
// Make a backup of the old snapshot so it may be restored.
if(dataset()->undoStack().isRecording())
dataset()->undoStack().push(new ReplaceSelectionOperation(this));
ParticlePropertyObject* identifierProperty = ParticlePropertyObject::findInState(state, ParticleProperty::IdentifierProperty);
if(identifierProperty && useIdentifiers()) {
OVITO_ASSERT(selection.size() == identifierProperty->size());
_selection.clear();
int index = 0;
if(mode == SelectionReplace) {
_selectedIdentifiers.clear();
for(int id : identifierProperty->constIntRange()) {
if(selection.testBit(index++))
_selectedIdentifiers.insert(id);
}
}
else if(mode == SelectionAdd) {
for(int id : identifierProperty->constIntRange()) {
if(selection.testBit(index++))
_selectedIdentifiers.insert(id);
}
}
else if(mode == SelectionSubtract) {
for(int id : identifierProperty->constIntRange()) {
if(selection.testBit(index++))
_selectedIdentifiers.remove(id);
}
}
}
else {
_selectedIdentifiers.clear();
if(mode == SelectionReplace)
_selection = selection;
else if(mode == SelectionAdd) {
_selection.resize(selection.size());
_selection |= selection;
}
else if(mode == SelectionSubtract) {
_selection.resize(selection.size());
_selection &= ~selection;
}
}
notifyDependents(ReferenceEvent::TargetChanged);
}
示例10: growRegion
QRect ImageOverlayRegionFinder::growRegion(int row, int column, QBitArray &mask)
{
QRect region;
region.setCoords(column, row, column, row);
QQueue<int> queue;
queue.enqueue(getDataIndex(row, column));
while (!queue.isEmpty())
{
int i = queue.dequeue();
if (m_overlay.getData()[i] > 0 && !mask.testBit(i))
{
mask.setBit(i);
row = getRowIndex(i);
column = getColumnIndex(i);
if (row < region.top())
{
region.setTop(row);
}
if (row > region.bottom())
{
region.setBottom(row);
}
if (column < region.left())
{
region.setLeft(column);
}
if (column > region.right())
{
region.setRight(column);
}
if (column - 1 >= 0)
{
queue.enqueue(getDataIndex(row, column - 1));
}
if (column + 1 < static_cast<signed>(m_overlay.getColumns()))
{
queue.enqueue(getDataIndex(row, column + 1));
}
if (row - 1 >= 0)
{
queue.enqueue(getDataIndex(row - 1, column));
}
if (row + 1 < static_cast<signed>(m_overlay.getRows()))
{
queue.enqueue(getDataIndex(row + 1, column));
}
}
}
return region;
}
示例11: continueNumbering
bool KoList::continueNumbering(int level) const
{
Q_ASSERT(level > 0 && level <= 10);
level = qMax(qMin(level, 10), 1);
QBitArray bitArray = d->properties.value(ContinueNumbering).toBitArray();
if (bitArray.isEmpty())
return false;
return bitArray.testBit(level-1);
}
示例12: typeFromBitArray
T typeFromBitArray(QBitArray &array) {
Q_ASSERT(sizeof(T) <= sizeof(quint64));
quint64 mask = 0x0000000000000001;
T resultVector(0);
for (uint i = 0; i < 8 * sizeof (T); ++i) {
if (array.testBit(i))
resultVector |= mask;
mask <<= 1;
}
return resultVector;
}
示例13: setNumDigits
void QLCDNumber::setNumDigits( int numDigits )
{
if ( numDigits > 99 ) {
#if defined(QT_CHECK_RANGE)
qWarning( "QLCDNumber::setNumDigits: (%s) Max 99 digits allowed",
name( "unnamed" ) );
#endif
numDigits = 99;
}
if (numDigits < 0 ) {
#if defined(QT_CHECK_RANGE)
qWarning( "QLCDNumber::setNumDigits: (%s) Min 0 digits allowed",
name( "unnamed" ) );
#endif
numDigits = 0;
}
if ( digitStr.isNull() ) { // from constructor
ndigits = numDigits;
digitStr.fill( ' ', ndigits );
points.fill( 0, ndigits );
digitStr[ndigits - 1] = '0'; // "0" is the default number
} else {
bool doDisplay = ndigits == 0;
if ( numDigits == ndigits ) // no change
return;
register int i;
int dif;
if ( numDigits > ndigits ) { // expand
dif = numDigits - ndigits;
QString buf;
buf.fill( ' ', dif );
digitStr.insert( 0, buf );
points.resize( numDigits );
for ( i=numDigits-1; i>=dif; i-- )
points.setBit( i, points.testBit(i-dif) );
for ( i=0; i<dif; i++ )
points.clearBit( i );
} else { // shrink
dif = ndigits - numDigits;
digitStr = digitStr.right( numDigits );
QBitArray tmpPoints = points.copy();
points.resize( numDigits );
for ( i=0; i<(int)numDigits; i++ )
points.setBit( i, tmpPoints.testBit(i+dif) );
}
ndigits = numDigits;
if ( doDisplay )
display( value() );
update();
}
}
示例14: setDigitCount
/*!
Sets the current number of digits to \a numDigits. Must
be in the range 0..99.
*/
void QLCDNumber::setDigitCount(int numDigits)
{
Q_D(QLCDNumber);
if (numDigits > 99) {
qWarning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed",
objectName().toLocal8Bit().constData());
numDigits = 99;
}
if (numDigits < 0) {
qWarning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed",
objectName().toLocal8Bit().constData());
numDigits = 0;
}
if (d->digitStr.isNull()) { // from constructor
d->ndigits = numDigits;
d->digitStr.fill(QLatin1Char(' '), d->ndigits);
d->points.fill(0, d->ndigits);
d->digitStr[d->ndigits - 1] = QLatin1Char('0'); // "0" is the default number
} else {
bool doDisplay = d->ndigits == 0;
if (numDigits == d->ndigits) // no change
return;
int i;
int dif;
if (numDigits > d->ndigits) { // expand
dif = numDigits - d->ndigits;
QString buf;
buf.fill(QLatin1Char(' '), dif);
d->digitStr.insert(0, buf);
d->points.resize(numDigits);
for (i=numDigits-1; i>=dif; i--)
d->points.setBit(i, d->points.testBit(i-dif));
for (i=0; i<dif; i++)
d->points.clearBit(i);
} else { // shrink
dif = d->ndigits - numDigits;
d->digitStr = d->digitStr.right(numDigits);
QBitArray tmpPoints = d->points;
d->points.resize(numDigits);
for (i=0; i<(int)numDigits; i++)
d->points.setBit(i, tmpPoints.testBit(i+dif));
}
d->ndigits = numDigits;
if (doDisplay)
display(value());
update();
}
}
示例15: ba
err_info *Pagemodel::commit (void)
{
Desktopmodel *contents = (Desktopmodel *)_contents;
QModelIndex index = _stackindex; // may be invalid
int del_count = 0;
QVector<Pageinfo> *pages = &_pages;
bool lost = _lost_scan;
if (lost)
{
pages = &_scan_pages;
_lost_scan = false;
contents = (Desktopmodel *)_lost_contents;
_lost_contents = 0;
}
if (!contents)
return NULL;
// delete any pages marked for deletion
QBitArray ba (pages->size ());
for (int i = 0; i < pages->size (); i++)
if ((*pages) [i].toRemove ())
{
ba.setBit (i);
del_count++;
}
// process on our local model (reverse order)
if (!lost) for (int i = pages->size () - 1; i >= 0; i--)
if (ba.testBit (i))
removeRow (i, QModelIndex ());
// update any annotation data
if (!lost && index.isValid ())
contents->updateAnnot (index, _annot_updates);
//FIXME: need to write ocr text somewhere also, but needs to be page-based
//FIXME: should only update annotations if they have changed
//FIXME: what happens if they delete all pages? Should delete the stack
/* now delete the pages we don't want, or trash the whole stack if
we want none of them. This function also handles the case where
contents points to another directory */
// this may invalidate _stackIndex
// also this function copes with an invalid index
return contents->scanCommitPages (index, del_count, ba, !lost);
}