本文整理汇总了C++中QVector::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::fill方法的具体用法?C++ QVector::fill怎么用?C++ QVector::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trainingDataChanged
void MainWindow::trainingDataChanged()
{
QList<QImage> maleTrainingImages = ui->lblMaleTraining->getImages();
QVector<int> maleLabels;
maleLabels.fill(MALEINDEX,maleTrainingImages.count());
QList<QImage> femaleTrainingImages = ui->lblFemaleTraining->getImages();
QVector<int> femaleLabels;
femaleLabels.fill(FEMALEINDEX,femaleTrainingImages.count());
if (maleTrainingImages.isEmpty()) {
ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Need male images..."));
}
if (femaleTrainingImages.isEmpty()) {
ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Need female images..."));
}
if (maleTrainingImages.isEmpty()||femaleTrainingImages.isEmpty())
return;
//
QList<QImage> trainingImages;
QVector<int> labels;
trainingImages << maleTrainingImages << femaleTrainingImages;
labels << maleLabels << femaleLabels;
//
ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Training..."));
recognizer->trainFaces(trainingImages, labels);
ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Training complete."));
reevaluateMale();
reevaluateFemale();
}
示例2:
lk_conv::lk_conv(int w, int h)
{
QVector < QVector < float > > newkernel;
QVector < float > nullrow;
nullrow.fill (0,h);
newkernel.fill (nullrow,w);
kernel = newkernel;
__width = w;
__height = h;
}
示例3: DelinearizeFloatValueFast
void LcmsColorProfileContainer::DelinearizeFloatValueFast(QVector <double> & Value) const
{
//we can only reliably delinearise in the 0-1.0 range, outside of that leave the value alone.
QVector <quint16> TRCtriplet(3);
TRCtriplet[0] = Value[0]*65535;
TRCtriplet[1] = Value[1]*65535;
TRCtriplet[2] = Value[2]*65535;
if (d->hasColorants) {
if (!cmsIsToneCurveLinear(d->redTRC) && Value[0]<1.0) {
TRCtriplet[0] = cmsEvalToneCurve16(d->redTRCReverse, TRCtriplet[0]);
Value[0] = TRCtriplet[0]/65535.0;
}
if (!cmsIsToneCurveLinear(d->greenTRC) && Value[1]<1.0) {
TRCtriplet[1] = cmsEvalToneCurve16(d->greenTRCReverse, TRCtriplet[1]);
Value[1] = TRCtriplet[1]/65535.0;
}
if (!cmsIsToneCurveLinear(d->blueTRC) && Value[2]<1.0) {
TRCtriplet[2] = cmsEvalToneCurve16(d->blueTRCReverse, TRCtriplet[2]);
Value[2] = TRCtriplet[2]/65535.0;
}
} else {
if (cmsIsTag(d->profile, cmsSigGrayTRCTag) && Value[0]<1.0) {
TRCtriplet[0] = (cmsEvalToneCurve16(d->grayTRCReverse, Value[0]*65535));
Value.fill(TRCtriplet[0]/65535.0);
}
}
}
示例4: fitToSize
void KoskoStudy::fitToSize(QVector<int> &intPath
, const QVector<bool> &isInc
, QVector<int> &newImg
, const int &leftCM
, const int &rightCM
, const int &upperCM
, const int &bottomCM)
{
int tmp, i;
for (i = 0; i < intPath.size(); i += 2) {
tmp = mXCMPos + (intPath[i] - leftCM) * ((double) (mWidth - 2 * mXCMPos)) / (rightCM - leftCM);
intPath[i] = tmp;
tmp = mYCMPos + (intPath[i + 1] - bottomCM) * ((double) (mHeight - 2 * mYCMPos)) / (upperCM - bottomCM);
intPath[i + 1] = tmp;
}
newImg.clear();
newImg.fill(0, mWidth * mHeight);
for (i = 0; i < intPath.size() - 2; i += 2) {
if (isInc[1 + i / 2]) {
makeLine(intPath.at(i)
, intPath.at(i + 1)
, intPath.at(i + 2)
, intPath.at(i + 3)
, mWidth
, mHeight
, newImg);
}
}
}
示例5: calcSpectrum
bool BassPlayer::calcSpectrum(QList<QVector<float> > & result) {
float fft[1024 * channels_count];
BASS_ChannelGetData(chan, fft, BASS_DATA_FFT2048 | BASS_DATA_FFT_INDIVIDUAL | BASS_DATA_FFT_REMOVEDC);
QVector<float> peaks;
int b0 = 0, x, z, peakNum;
for (x = 0; x < channels_count; x++)
result.append(QVector<float>());
for (x = 0; x < calcSpectrumBandsGroupCount(); x++) {
peaks.fill(0, channels_count);
int b1 = spectrumComplexPoints[x];
for (; b0 < b1; b0++) {
peakNum = b0 % channels_count;
if (peaks[peakNum] < fft[b0])
peaks[peakNum] = fft[b0];
}
for (z = 0; z < channels_count; z++)
result[z].append(sqrt(peaks[z]));
}
return true;
}
示例6:
void AdaptiveLayout::tKey::ArrangeProperties(const QHash<QString, int> &propsOrder, int max)
{
QVector<int> permutation;
permutation.resize(m_Properties.size());
for( QHash<QString, int>::iterator i = m_Properties.begin(); i != m_Properties.end(); ++i )
{
int indexFrom = i.value();
int indexTo = indexFrom;
QHash<QString, int>::const_iterator p = propsOrder.find(i.key());
if( p != propsOrder.end() ) // If we fail to find, the result may be incorrect
{
indexTo = p.value();
}
i.value() = indexTo;
permutation[indexFrom] = indexTo;
}
QVector<float> newProps;
newProps.resize(max + 1);
for( int iactor = 0; iactor < m_Actors.size(); iactor++ )
{
tActor& actor = m_Actors[iactor];
newProps.fill(0.f);
for( int i = 0; i < actor.props.size(); i++ )
{
newProps[permutation[i]] = actor.props[i];
}
actor.props = newProps;
}
}
示例7: mergeSort
QVector<quint8> EncryptorPrivate::mergeSort(const QVector<quint8> &array, quint32 salt, quint64 k)
{
int length = array.size();
if (length <= 1) {
return array;
}
int middle = length / 2;
QVector<quint8> left = array.mid(0, middle);
QVector<quint8> right = array.mid(middle);
left = mergeSort(left, salt, k);
right = mergeSort(right, salt, k);
int leftptr = 0;
int rightptr = 0;
QVector<quint8> sorted;
sorted.fill(0, length);
for (int i = 0; i < length; ++i) {
if (rightptr == right.size() || (leftptr < left.size() && randomCompare(left[leftptr], right[rightptr], salt, k) <= 0)) {
sorted[i] = left[leftptr++];
} else if (leftptr == left.size() || (rightptr < right.size() && randomCompare(right[rightptr], left[leftptr], salt, k) <= 0)) {
sorted[i] = right[rightptr++];
}
}
return sorted;
}
示例8: shuffleLabels
void PieDiagram::shuffleLabels( QRectF* textBoundingRect )
{
// things that could be improved here:
// - use a variable number (chosen using angle information) of neighbors to check
// - try harder to arrange the labels to look nice
// ideas:
// - leave labels that don't collide alone (only if they their offset is zero)
// - use a graphics view for collision detection
LabelPaintCache& lpc = d->labelPaintCache;
const int n = lpc.paintReplay.size();
bool modified = false;
qreal direction = 5.0;
QVector< qreal > offsets;
offsets.fill( 0.0, n );
for ( bool lastRoundModified = true; lastRoundModified; ) {
lastRoundModified = false;
for ( int i = 0; i < n; i++ ) {
const int neighborsToCheck = qMax( 10, lpc.paintReplay.size() - 1 );
const int minComp = wraparound( i - neighborsToCheck / 2, n );
const int maxComp = wraparound( i + ( neighborsToCheck + 1 ) / 2, n );
QPainterPath& path = lpc.paintReplay[ i ].labelArea;
for ( int j = minComp; j != maxComp; j = wraparound( j + 1, n ) ) {
if ( i == j ) {
continue;
}
QPainterPath& otherPath = lpc.paintReplay[ j ].labelArea;
while ( ( offsets[ i ] + direction > 0 ) && otherPath.intersects( path ) ) {
#ifdef SHUFFLE_DEBUG
qDebug() << "collision involving" << j << "and" << i << " -- n =" << n;
TextAttributes ta = lpc.paintReplay[ i ].attrs.textAttributes();
ta.setPen( QPen( Qt::white ) );
lpc.paintReplay[ i ].attrs.setTextAttributes( ta );
#endif
uint slice = lpc.paintReplay[ i ].index.column();
qreal angle = DEGTORAD( d->startAngles[ slice ] + d->angleLens[ slice ] / 2.0 );
qreal dx = cos( angle ) * direction;
qreal dy = -sin( angle ) * direction;
offsets[ i ] += direction;
path.translate( dx, dy );
lastRoundModified = true;
}
}
}
direction *= -1.07; // this can "overshoot", but avoids getting trapped in local minimums
modified = modified || lastRoundModified;
}
if ( modified ) {
for ( int i = 0; i < lpc.paintReplay.size(); i++ ) {
*textBoundingRect |= lpc.paintReplay[ i ].labelArea.boundingRect();
}
}
}
示例9: computeNestingContracted
void QmlProfilerRangeModel::computeNestingContracted()
{
int i;
int eventCount = count();
int nestingLevels = QmlDebug::Constants::QML_MIN_LEVEL;
int collapsedRowCount = nestingLevels + 1;
QVector<qint64> nestingEndTimes;
nestingEndTimes.fill(0, nestingLevels + 1);
for (i = 0; i < eventCount; i++) {
qint64 st = startTime(i);
// per type
if (nestingEndTimes[nestingLevels] > st) {
if (++nestingLevels == nestingEndTimes.size())
nestingEndTimes << 0;
if (nestingLevels == collapsedRowCount)
++collapsedRowCount;
} else {
while (nestingLevels > QmlDebug::Constants::QML_MIN_LEVEL &&
nestingEndTimes[nestingLevels-1] <= st)
nestingLevels--;
}
nestingEndTimes[nestingLevels] = st + duration(i);
m_data[i].displayRowCollapsed = nestingLevels;
}
setCollapsedRowCount(collapsedRowCount);
}
示例10: getOrigRegion
bool CMapDEM::getOrigRegion(QVector<qint16>& data,projXY &topLeft, projXY &bottomRight, int& w, int& h)
{
//memset(data, 0, sizeof(qint16) * h * w);
data.fill(0);
if(pjsrc == 0) return false;
// 1. convert top left and bottom right point into the projection system used by the DEM data
pj_transform(pjtar, pjsrc, 1, 0, &topLeft.u, &topLeft.v, 0);
pj_transform(pjtar, pjsrc, 1, 0, &bottomRight.u, &bottomRight.v, 0);
// 2. get floating point offset of topleft corner
double xoff1_f = (topLeft.u - xref1) / xscale;
double yoff1_f = (topLeft.v - yref1) / yscale;
// 3. truncate floating point offset into integer offset
int xoff1 = floor(xoff1_f); //qDebug() << "xoff1:" << xoff1 << xoff1_f;
int yoff1 = floor(yoff1_f); //qDebug() << "yoff1:" << yoff1 << yoff1_f;
// 4. get floating point offset of bottom right corner
double xoff2_f = (bottomRight.u - xref1) / xscale;
double yoff2_f = (bottomRight.v - yref1) / yscale;
// 5. truncate floating point offset into integer offset.
int xoff2 = ceil(xoff2_f); //qDebug() << "xoff2:" << xoff2 << xoff2_f;
int yoff2 = ceil(yoff2_f); //qDebug() << "yoff2:" << yoff2 << yoff2_f;
// 6. get width and height to read from file
qint32 w1 = xoff2 - xoff1 + 1;
//qDebug() << "w1:" << w1 << "h1:" << h1;
qint32 h1 = yoff2 - yoff1 + 1;
topLeft.u = xoff1 * xscale + xref1;
topLeft.v = yoff1 * yscale + yref1;
bottomRight.u = xoff2 * xscale + xref1;
bottomRight.v = yoff2 * yscale + yref1;
pj_transform(pjsrc, pjtar, 1, 0, &topLeft.u, &topLeft.v, 0);
pj_transform(pjsrc, pjtar, 1, 0, &bottomRight.u, &bottomRight.v, 0);
// memory sanity check
if(double(w1) * double(h1) > pow(2.0f,31)) return false;
if (w1 < w)
{
w = w1;
}
if (h1 < h)
{
h = h1;
}
Q_ASSERT(w1 <= w);
Q_ASSERT(h1 <= h);
// 7. read DEM data from file
CPLErr err = dataset->RasterIO(GF_Read, xoff1, yoff1, w1, h1, data.data(), w, h, GDT_Int16, 1, 0, 0, 0, 0);
return (err != CE_Failure);
}
示例11: printDLX
void DLXSolver::printDLX (bool forced)
{
#ifdef DLX_LOG
bool verbose = (forced || (mGraph->order() <= 5));
if ((mEndNodeNum < 0) || (mEndColNum < 0)) {
fprintf (stderr, "\nDLXSolver::printDLX(): EMPTY, mEndNodeNum %d, "
"mEndRowNum %d, mEndColNum %d\n\n",
mEndNodeNum, mEndRowNum, mEndColNum);
return;
}
// fprintf (stderr, "\nDLX Matrix has %d cols, %d rows and %d ones\n\n",
// mEndColNum + 1, mEndRowNum + 1, mEndNodeNum + 1);
DLXNode * colDLX = mCorner->right;
if (colDLX == mCorner) {
fprintf (stderr, "DLXSolver::printDLX(): ALL COLUMNS ARE HIDDEN\n");
return;
}
int totGap = 0;
int nRows = 0;
int nNodes = 0;
int lastCol = -1;
QVector<DLXNode *> rowsRemaining;
rowsRemaining.fill (0, mRows.count());
if (verbose) fprintf (stderr, "\n");
while (colDLX != mCorner) {
int col = mColumns.indexOf(colDLX);
if (verbose) fprintf (stderr, "Col %02d, %02d rows ",
col, mColumns.at(col)->value);
DLXNode * node = mColumns.at(col)->below;
while (node != colDLX) {
int rowNum = node->value;
if (verbose) fprintf (stderr, "%02d ", rowNum);
if (rowsRemaining.at (rowNum) == 0) {
nRows++;
}
rowsRemaining[rowNum] = mRows.at (rowNum);
nNodes++;
node = node->below;
}
int gap = col - (lastCol + 1);
if (gap > 0) {
if (verbose) fprintf (stderr, "covered %02d", gap);
totGap = totGap + gap;
}
if (verbose) fprintf (stderr, "\n");
colDLX = colDLX->right;
lastCol = col;
}
if (verbose) fprintf (stderr, "\n");
fprintf (stderr, "Matrix NOW has %d rows, %d columns and %d ones\n",
nRows, lastCol + 1 - totGap, nNodes);
#else
Q_UNUSED (forced);
#endif
}
示例12: return
QVector<bool> NewBuildingWizard::GetLayout()
{
if (field("NewSpecial").toBool())
{
return ((SpecialWizardPage*)page(SPECIAL_PAGE))->GetLayout();
}
QVector<bool> layout;
layout.fill(false, 9 * 9 * 21);
layout[0] = true;
return layout;
}
示例13: sampleFormatChanged
void MainWindow::sampleFormatChanged()
{
for (int i = 0; i < curves.size(); i++) {
curves[i].curve->detach();
delete curves[i].curve;
curves[i].data->clear();
delete curves[i].data;
}
curves.clear();
timeAxis.clear();
QList<sampleValue> sampleList = kwp.getSample();
int numSamples = settingsDialog->rate * settingsDialog->historySecs + 1;
timeAxis.clear();
for (int i = 0; i < numSamples; i++) {
timeAxis.prepend(-i / static_cast<double>(settingsDialog->rate));
}
int numColors = sizeof(colorList) / sizeof(QString);
for (int i = 0; i < sampleList.length(); i++) {
QwtPlotCurve* curve = new QwtPlotCurve;
QVector<double>* data = new QVector<double>();
data->reserve(numSamples+1);
data->fill(0, numSamples);
QColor curveColor;
curveColor.setNamedColor(colorList[i % numColors]);
int blockNum = sampleList.at(i).refs.at(0).blockNum;
int pos = sampleList.at(i).refs.at(0).pos;
blockLabels_t label = kwp.getBlockLabel(blockNum);
QString desc = label.desc[pos] + " " + label.subDesc[pos];
curve->setRenderHint(QwtPlotItem::RenderAntialiased);
curve->setPen(curveColor);
curve->setTitle(desc);
curve->setRawSamples(timeAxis.constData(), data->constData(), numSamples);
curve->attach(ui->plot);
// set legend checked
QwtLegendItem *legendItem = qobject_cast<QwtLegendItem*>(ui->plot->legend()->find(curve));
if (legendItem) {
legendItem->setChecked(true);
}
curveAndData tmp;
tmp.curve = curve;
tmp.data = data;
curves.append(tmp);
}
}
示例14: addHeaderSequence
static void addHeaderSequence(QVector<int> &p_sequence, int p_level, int p_baseLevel)
{
Q_ASSERT(p_level >= 1 && p_level < p_sequence.size());
if (p_level < p_baseLevel) {
p_sequence.fill(0);
return;
}
++p_sequence[p_level];
for (int i = p_level + 1; i < p_sequence.size(); ++i) {
p_sequence[i] = 0;
}
}
示例15: cEndsNForks
void WireCreator::cEndsNForks()
{
QVector<int> tempPoints;
tempPoints.fill(0,vertices.length());
for(auto pair : edges){
tempPoints[pair.first]++;
tempPoints[pair.second]++;
}
for(int i=0; i<tempPoints.length();i++){
if(tempPoints[i]==1)deadEnds.push_back(i);
if(tempPoints[i]>2)forks.push_back(i);
}
}