当前位置: 首页>>代码示例>>C++>>正文


C++ QVector::front方法代码示例

本文整理汇总了C++中QVector::front方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::front方法的具体用法?C++ QVector::front怎么用?C++ QVector::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QVector的用法示例。


在下文中一共展示了QVector::front方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: extractStatsData

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenMDFWidget::extractStatsData(int index, StatsData* statsData, unsigned int phaseType)
{
  Q_UNUSED(index)
  VectorOfFloatArray arrays;
  if(phaseType == SIMPL::PhaseType::PrimaryPhase)
  {
    PrimaryStatsData* pp = PrimaryStatsData::SafePointerDownCast(statsData);
    arrays = pp->getMDF_Weights();
  }
  if(phaseType == SIMPL::PhaseType::PrecipitatePhase)
  {
    PrecipitateStatsData* pp = PrecipitateStatsData::SafePointerDownCast(statsData);
    arrays = pp->getMDF_Weights();
  }
  if(phaseType == SIMPL::PhaseType::TransformationPhase)
  {
    TransformationStatsData* tp = TransformationStatsData::SafePointerDownCast(statsData);
    arrays = tp->getMDF_Weights();
  }

  QVector<float> axis;
  QVector<float> angle;
  QVector<float> weights;

  for (int i = 0; i < arrays.size(); i++)
  {
    if(arrays[i]->getName().compare(SIMPL::StringConstants::Axis) == 0)
    {
       axis = QVector<float>(static_cast<int>(arrays[i]->getSize())); // This one is 3xn in size
      ::memcpy( &(axis.front()), arrays[i]->getVoidPointer(0), sizeof(float)*axis.size() );
    }

    if(arrays[i]->getName().compare(SIMPL::StringConstants::Angle) == 0)
    {
      angle = QVector<float>(static_cast<int>(arrays[i]->getNumberOfTuples()));
      ::memcpy( &(angle.front()), arrays[i]->getVoidPointer(0), sizeof(float)*angle.size() );
    }

    if(arrays[i]->getName().compare(SIMPL::StringConstants::Weight) == 0)
    {
      weights = QVector<float>(static_cast<int>(arrays[i]->getNumberOfTuples()));
      ::memcpy( &(weights.front()), arrays[i]->getVoidPointer(0), sizeof(float)*weights.size() );
    }
  }
    if (arrays.size() > 0)
    {
      // Load the data into the table model
      m_MDFTableModel->setTableData(angle, axis, weights);
    }

  on_m_MDFUpdateBtn_clicked();
}
开发者ID:BlueQuartzSoftware,项目名称:DREAM3D,代码行数:55,代码来源:StatsGenMDFWidget.cpp

示例2: download

void FileUploader::download(const QString &rootPath, const QVector<mtp::ObjectId> &objectIds)
{
	_model->moveToThread(&_workerThread);
	_total = 0;

	mtp::ObjectId currentParentId = _model->parentObjectId();

	QVector<QPair<QString, mtp::ObjectId> > input;
	for(auto id : objectIds)
		input.push_back(qMakePair(rootPath, id));

	QVector<QPair<QString, mtp::ObjectId> > files;
	while(!input.empty())
	{
		QString prefix = input.front().first;
		mtp::ObjectId id = input.front().second;
		input.pop_front();

		MtpObjectsModel::ObjectInfo oi = _model->getInfoById(id);
		if (oi.Format == mtp::ObjectFormat::Association)
		{
			//enumerate here
			QString dirPath = prefix + "/" + oi.Filename;
			mtp::SessionPtr session = _model->session();
			mtp::msg::ObjectHandles handles = session->GetObjectHandles(mtp::Session::AllStorages, mtp::ObjectFormat::Any, id);
			qDebug() << "found " << handles.ObjectHandles.size() << " objects in " << dirPath;
			for(mtp::ObjectId id : handles.ObjectHandles)
				input.push_back(qMakePair(dirPath, id));
		}
		else
		{
			_total += oi.Size;
			files.push_back(qMakePair(prefix + "/" + oi.Filename, id));
		}
	}

	qDebug() << "downloading " << files.size() << " file(s), " << _total << " bytes";
	_startedAt = QDateTime::currentDateTime();
	_aborted = false;
	if (_total < 1)
		_total = 1;

	for(const auto & file : files)
	{
		if (_aborted)
			break;
		emit executeCommand(new DownloadFile(file.first, file.second));
	}
	emit executeCommand(new FinishQueue(currentParentId));
}
开发者ID:dsimakov,项目名称:android-file-transfer-linux,代码行数:50,代码来源:fileuploader.cpp

示例3: applyCorrespondence

void CorrespondenceSearch::applyCorrespondence(const PartsCorrespondence & correspondence)
{	
	QVector<ParticleMesh*> input; input << sA << sB;
	QVector<Particles> particles; 
	particles << sA->particles << sB->particles;

	for( auto & pairing : correspondence )
	{
		PartCorresponder::correspondSegments( pairing, input, particles );

		// DEBUG:
		if( true )
		{
			auto ls = new starlab::LineSegments(3);
			auto boxA = sA->segmentBoundingBox( input[0]->property["segments"].value<Segments>()[pairing.first] );
			auto boxB = sB->segmentBoundingBox( input[1]->property["segments"].value<Segments>()[pairing.second] );
			ls->addLine( Vector3( boxA.center() ), Vector3(boxB.center() + Vector3(1,0,0)), Qt::black );
			debug << ls;
		}
	}

	// Assign back
	sA->particles = particles.front();
	sB->particles = particles.back();
}
开发者ID:aaronzou,项目名称:ddtt-dev,代码行数:25,代码来源:CorrespondenceSearch.cpp

示例4: createStateFromLine

// 获取下一时刻所有目标的状态
std::vector<State> TargetDataReader::getNextStates()
{
    std::vector<State> re;
    QVector<QString> *dv;
    QString line;
    if (allDataVector.at(0)->size() > 0) {
//        QString line = dataVector.front();
//        State s = createStateFromLine(line);
//        if (re.size() == 0) {
//            re.push_back(s);
//            dataVector.pop_front();
//        } else {
//            State preState = re.back();
//            if (preState.getTime() == s.getTime()) {
//                re.push_back(s);
//                dataVector.pop_front();
//            }
//        }
        for(int i = 0; i < allDataVector.size();i++)
        {
            dv = allDataVector[i];
            if(dv->size() > 0){
                line = dv->front();
                State s = createStateFromLine(line);
                re.push_back(s);
                dv->pop_front();
            }
        }
    }
    return re;
}
开发者ID:kernelhcy,项目名称:targettracking,代码行数:32,代码来源:targetgenerator.cpp

示例5: render

void Scene::render()
{
    for(int i = -CWIDTH / 2; i < CWIDTH / 2; i ++)
    {
        qDebug() << i;
        for(int j = -CHEIGHT / 2; j < CHEIGHT / 2; j ++)
        {
            QVector<Ray*> rSeq = camera->pixelLight(i, j);
            int s = rSeq.size();
            Intensity rgb(0, 0, 0);
            while(!rSeq.empty())
            {
                Ray* tmp = rSeq.front();

                rgb = rgb + (1.0 / s) * getIntensity(tmp);
                rSeq.pop_front();
                if(tmp != NULL)
                {
                    delete tmp;
                    tmp = NULL;
                }
            }
            pixels[i + CWIDTH / 2][j + CHEIGHT / 2] = rgb.toRGB();

        }

    }
}
开发者ID:pertoX4726,项目名称:RayTracing,代码行数:28,代码来源:scene.cpp

示例6: updateEntityLod

void UpdateLevelOfDetailJob::updateEntityLod(Entity *entity)
{
    if (!entity->isEnabled())
        return; // skip disabled sub-trees, since their bounding box is probably not valid anyway

    QVector<LevelOfDetail *> lods = entity->renderComponents<LevelOfDetail>();
    if (!lods.empty()) {
        LevelOfDetail* lod = lods.front();  // other lods are ignored

        if (lod->isEnabled() && !lod->thresholds().isEmpty()) {
            switch (lod->thresholdType()) {
            case QLevelOfDetail::DistanceToCameraThreshold:
                updateEntityLodByDistance(entity, lod);
                break;
            case QLevelOfDetail::ProjectedScreenPixelSizeThreshold:
                updateEntityLodByScreenArea(entity, lod);
                break;
            default:
                Q_ASSERT(false);
                break;
            }
        }
    }

    const auto children = entity->children();
    for (Qt3DRender::Render::Entity *child : children)
        updateEntityLod(child);
}
开发者ID:RSATom,项目名称:Qt,代码行数:28,代码来源:updatelevelofdetailjob.cpp

示例7: nodePruneAction_impl

// Returns true if this node is to be deleted.
static bool nodePruneAction_impl(
        Process::MessageNode& node,
        const Id<Process::ProcessModel>& proc,
        QVector<Process::ProcessStateData>& vec,
        const QVector<Process::ProcessStateData>& other_vec)
{
    int vec_size = vec.size();
    if(vec_size > 1)
    {
        // We just remove the element
        // corresponding to this process.
        auto it = find_if(vec,
                      [&] (const auto& data) {
            return data.process == proc;
        });

        if(it != vec.end())
        {
            vec.erase(it);
        }
    }
    else if(vec_size == 1)
    {
        // We may be able to remove the whole node
        if(vec.front().process == proc)
            vec.clear();

        // If false, nothing is removed.
        return vec.isEmpty()
            && other_vec.isEmpty()
            && !node.values.userValue;
    }

    return false;
}
开发者ID:himito,项目名称:i-score,代码行数:36,代码来源:MessageItemModelAlgorithms.cpp

示例8: mergeChunks

void PartCorresponder::match1DGridChunk( QVector< QVector<SliceChunk> > sortedChunk, const QVector<ParticleMesh *> & input, QVector<Particles> & particles )
{
	QVector< QVector<SliceChunk> > readyChunkPairs;

	auto & sortedChunkFront = sortedChunk.front();
	auto & sortedChunkBack = sortedChunk.back();

	// Different number of chunks
	if( sortedChunkFront.size() != sortedChunkBack.size() )
	{
		int targetSize = std::min( sortedChunkFront.size(), sortedChunkBack.size() );

		if(targetSize == 1)
		{
			QVector<SliceChunk> chunkPairs;
			if( sortedChunkFront.size() == 1 ) chunkPairs.push_back( sortedChunkFront.front() );
			else chunkPairs.push_back( mergeChunks( sortedChunkFront, input.front(), particles.front() ) );

			if( sortedChunkBack.size() == 1) chunkPairs.push_back( sortedChunkBack.front() );
			else chunkPairs.push_back( mergeChunks( sortedChunkBack, input.back(), particles.back() ) );

			readyChunkPairs.push_back( chunkPairs );
		}
		else
		{
			// For now we use basic matching.. later we should either split / merge
			for(auto v : distributeVectors(sortedChunkFront.size(), sortedChunkBack.size()))
			{
				QVector<SliceChunk> p;
				p << sortedChunkFront[v.first] << sortedChunkBack[v.second];
				readyChunkPairs.push_back( p );
			}
		}
	}
	else
	{
		// Same number of elements, simply match them up
		for(size_t i = 0; i < sortedChunk.front().size(); i++)
		{
			readyChunkPairs.push_back( QVector<SliceChunk>() << sortedChunkFront.at(i) << sortedChunkBack.at(i) );
		}
	}

	// Match each pair of chunks
	for(auto & pairChunk : readyChunkPairs)
		matchChunk(pairChunk, input, particles);
}
开发者ID:ialhashim,项目名称:ddtt-dev,代码行数:47,代码来源:PartCorresponder.cpp

示例9: prepareGrowShrinkSheet

void TaskSheet::prepareGrowShrinkSheet()
{
    Structure::Node * n = node();
    QVector<Structure::Link*> edges = filterEdges(n, active->getEdges(n->id));

	property["edges"].setValue( active->getEdgeIDs(edges) );

    if (edges.size() == 1)
    {
        prepareSheetOneEdge( edges.front() );
    }

    if (edges.size() == 2)
    {
        prepareSheetTwoEdges( edges.front(), edges.back() );
    }
}
开发者ID:BigkoalaZhu,项目名称:StBl,代码行数:17,代码来源:TaskSheet.cpp

示例10: if

Shot::Shot(Common::Person person, const QPoint& pos, int height, const QVector<QPixmap>& vecPix, QGraphicsItem* parent) : AbstractSprite(parent)
    , m_rectSprite(QRect(pos.x(), pos.y(), vecPix.front().width(), vecPix.front().width()))
    , m_person(person)
{
    if(person == Common::Person::Player)
    {
        m_posBoundingSprite = QPoint(pos.x(), pos.y() - vecPix.front().height() + 4);
        QSound::play(":sound/resource/sound/playerShot.wav");
    }
    else if(person == Common::Person::Enemy)
    {
        m_posBoundingSprite = pos;
        QSound::play(":sound/resource/sound/enemyShot.wav");
    }
    m_pixSprite_ = vecPix;
    m_heightBounding = height;
    setSpeed(5);
}
开发者ID:kissofblood,项目名称:AlienAttack,代码行数:18,代码来源:shot.cpp

示例11: UpdateComputedWidths

	void SeparateTabBar::UpdateComputedWidths () const
	{
		const auto cnt = count ();
		ComputedWidths_.resize (cnt);

		const auto maxTabWidth = width () / 4;

		struct TabInfo
		{
			int Idx_;
			int WidthHint_;
		};
		QVector<TabInfo> infos;
		for (int i = 0; i < cnt - 1; ++i)
			infos.push_back ({ i, std::min (QTabBar::tabSizeHint (i).width (), maxTabWidth) });
		std::sort (infos.begin (), infos.end (),
				[] (const TabInfo& l, const TabInfo& r) { return l.WidthHint_ < r.WidthHint_; });

		const auto hspace = std::max (style ()->pixelMetric (QStyle::PM_TabBarTabHSpace), 10);
		const auto btnWidth = AddTabButton_ ? AddTabButton_->sizeHint ().width () + hspace : 30;

		auto remainder = width () - btnWidth;

		while (!infos.isEmpty ())
		{
			auto currentMax = remainder / infos.size ();
			if (infos.front ().WidthHint_ > currentMax)
				break;

			const auto& info = infos.front ();
			remainder -= info.WidthHint_;
			ComputedWidths_ [info.Idx_] = info.WidthHint_;
			infos.pop_front ();
		}

		if (infos.isEmpty ())
			return;

		const auto uniform = remainder / infos.size ();
		for (const auto& info : infos)
			ComputedWidths_ [info.Idx_] = uniform;
	}
开发者ID:eringus,项目名称:leechcraft,代码行数:42,代码来源:separatetabbar.cpp

示例12: executeCrossingSheet

void TaskSheet::executeCrossingSheet( double t )
{
	Node *n = node(), *tn = targetNode();

	QVector<Link*> edges = active->getEdges( property["edges"].value< QVector<int> >() );

	if (property.contains("path"))
	{
		Vector3 p0 = n->position(Vec4d(0,0,0,0));
		Vector3 delta(0,0,0);

		if(!edges.isEmpty())
		{
			p0 = edges.front()->position(n->id);

			// Blend Deltas
			Structure::Link *slink = edges.front();
			Structure::Link* tlink = target->getEdge(slink->property["correspond"].toInt());
			Vector3 d1 = slink->position(n->id) - slink->positionOther(n->id);
			Vector3 d2 = tlink->position(tn->id) - tlink->positionOther(tn->id);
			delta = AlphaBlend(t, d1, d2);
		}

		executeMorphSheet(t);
		
		// Cancel any absolute movement
		if(!edges.isEmpty())
			n->moveBy(p0 - edges.front()->position(n->id));

		// Move it to the correct position
		Array1D_Vector3 path = property["path"].value< Array1D_Vector3 >();
		int idx = t * (path.size() - 1);

		Vector3 oldPosOnMe = p0;
		Vector3 newPosOnMe = path[idx] + delta;

		n->moveBy(newPosOnMe - p0);
	}
}
开发者ID:BigkoalaZhu,项目名称:StBl,代码行数:39,代码来源:TaskSheet.cpp

示例13: multipl

QVector<QVector<double>> multipl(QVector<QVector<double>> a, QVector<QVector<double>> b)
{
    int m = a.size();
    int n = b.front().size();

    if(a.front().size()!=b.size())
    {
        qDebug() << "mxn";
    }

    QVector<double> e(n,0);
    QVector<QVector<double>> ab(m,e);

    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j< n;j++)
        {
            ab[i][j]=product(a,b,i,j);
        }
    }
    return ab;
}
开发者ID:NikoOtiN,项目名称:coursework,代码行数:22,代码来源:matrix_func.cpp

示例14: DECOFUNC

//Input Port #0: Buffer_Size = 1, Params_Type = ProcessorMulti_Processor_SimpleCollect_Params, Data_Type = ProcessorMulti_Processor_SimpleCollect_Data
bool DECOFUNC(processMonoDrainData)(void * paramsPtr, void * varsPtr, QVector<void *> drainParams, QVector<void *> drainData)
{
	VisualizationMono_Processor_SimpleCollect_Params * params=(VisualizationMono_Processor_SimpleCollect_Params *)paramsPtr;
	VisualizationMono_Processor_SimpleCollect_Vars * vars=(VisualizationMono_Processor_SimpleCollect_Vars *)varsPtr;
	QVector<ProcessorMulti_Processor_SimpleCollect_Params *> drainparams; copyQVector(drainparams,drainParams);
	QVector<ProcessorMulti_Processor_SimpleCollect_Data *> draindata; copyQVector(draindata,drainData);
	if(draindata.size()==0){return 0;}
	/*======Please Program below======*/
	/*
	Function: process draindata.
	*/
    vars->label->setText(draindata.front()->simplestatus);
	return 1;
}
开发者ID:dog2cat,项目名称:autowheel,代码行数:15,代码来源:VisualizationMono_Processor_SimpleCollect_PrivFunc.cpp

示例15: executeGrowShrinkSheet

void TaskSheet::executeGrowShrinkSheet(double t)
{
	Structure::Sheet* structure_sheet = ((Structure::Sheet*)node());
	QVector<Link*> edges = active->getEdges( property["edges"].value< QVector<int> >() );

	/// Single edge case
	if ( property.contains("deltas") )
	{
		Array2D_Vector3 cpts = property["orgCtrlPoints"].value<Array2D_Vector3>();
		Array2D_Vector3 deltas = property["deltas"].value<Array2D_Vector3>();

		// Grow sheet
		for(size_t u = 0; u < structure_sheet->surface.mNumUCtrlPoints; u++)
			for(size_t v = 0; v < structure_sheet->surface.mNumVCtrlPoints; v++)
				structure_sheet->surface.mCtrlPoint[u][v] = cpts[u][v] + (deltas[u][v] * t);
	}

	/// Two edges case
	if( property.contains("pathA") && property.contains("pathB") && property.contains("cpCoords") )
	{
		QVector< GraphDistance::PathPointPair > pathA = property["pathA"].value< QVector< GraphDistance::PathPointPair > >();
		QVector< GraphDistance::PathPointPair > pathB = property["pathB"].value< QVector< GraphDistance::PathPointPair > >();
		if(pathA.size() == 0 || pathB.size() == 0)	return;

		double dt = t;
		if(type == SHRINK) dt = 1 - t;

		double decodeT = qMin(1.0, dt * 2.0);

		int idxA = dt * (pathA.size() - 1);
		int idxB = dt * (pathB.size() - 1);

		// Move to next step
		Vector3 pointA = pathA[idxA].position(active);
		Vector3 pointB = pathB[idxB].position(active);

		Structure::Link *linkA = edges.front(), *linkB = edges.back();
		if (type == GROW){
			linkA = target->getEdge(linkA->property["correspond"].toInt());
			linkB = target->getEdge(linkB->property["correspond"].toInt());
		}

		Vector3d deltaA = linkA->property["delta"].value<Vector3d>() * dt;
		Vector3d deltaB = linkB->property["delta"].value<Vector3d>() * dt;

		Array1D_Vector3 decoded = Curve::decodeCurve(property["cpCoords"].value<CurveEncoding>(), pointA + deltaA, pointB + deltaB, decodeT);
		structure_sheet->setControlPoints( decoded );
	}
}
开发者ID:BigkoalaZhu,项目名称:StBl,代码行数:49,代码来源:TaskSheet.cpp


注:本文中的QVector::front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。