本文整理汇总了C++中QVector::back方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::back方法的具体用法?C++ QVector::back怎么用?C++ QVector::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void run() {
AVThread *avt = demux_thread->videoThread();
avt->packetQueue()->clear(); // clear here
if (pts <= 0) {
demux_thread->demuxer->seek(qint64(-pts*1000.0) - 500LL);
QVector<qreal> ts;
qreal t = -1.0;
while (t < -pts) {
demux_thread->demuxer->readFrame();
if (demux_thread->demuxer->stream() != demux_thread->demuxer->videoStream())
continue;
t = demux_thread->demuxer->packet().pts;
ts.push_back(t);
}
const qreal t0 = ts.back();
ts.pop_back();
const qreal dt = t0 - ts.back();
pts = ts.back();
// FIXME: sometimes can not seek to the previous pts, the result pts is always current pts, so let the target pts a little earlier
pts -= dt/2.0;
}
qDebug("step backward: %lld, %f", qint64(pts*1000.0), pts);
demux_thread->video_thread->setDropFrameOnSeek(false);
demux_thread->seekInternal(qint64(pts*1000.0), AccurateSeek);
}
示例2: pointsFromData
/** Returns a list of points on the bandwidth graph based on the supplied set
* of rsdht or alldht values. */
void RSGraphWidget::pointsFromData(const std::vector<QPointF>& values,QVector<QPointF>& points)
{
points.clear();
int x = _rec.width();
int y = _rec.height();
float time_step = 1.0f ; // number of seconds per pixel
/* Translate all data points to points on the graph frame */
// take 0 as the origin, otherwise the different curves are not aligned properly
float last = 0;//values.back().x();
//std::cerr << "Got " << values.size() << " values for index 0" << std::endl;
float last_px = SCALE_WIDTH ;
float last_py = 0.0f ;
for (uint i = 0; i < values.size(); ++i)
{
//std::cerr << "Value: (" << values[i].x() << " , " << values[i].y() << ")" << std::endl;
// compute point in pixels
qreal px = x - (values[i].x()-last)*_time_scale ;
qreal py = y - valueToPixels(values[i].y()) ;
if(px >= SCALE_WIDTH && last_px < SCALE_WIDTH)
{
float alpha = (SCALE_WIDTH - last_px)/(px - last_px) ;
float ipx = SCALE_WIDTH ;
float ipy = (1-alpha)*last_py + alpha*py ;
points << QPointF(ipx,y) ;
points << QPointF(ipx,ipy) ;
}
else if(i==0)
points << QPointF(px,y) ;
last_px = px ;
last_py = py ;
if(px < SCALE_WIDTH)
continue ;
_maxValue = std::max(_maxValue,values[i].y()) ;
// remove midle point when 3 consecutive points have the same value.
if(points.size() > 1 && points[points.size()-2].y() == points.back().y() && points.back().y() == py)
points.pop_back() ;
points << QPointF(px,py) ;
if(i==values.size()-1)
points << QPointF(px,y) ;
}
}
示例3: qSort
QVector<double> DataContainer::combineXVectors(const QVector<double> x1, const QVector<double> x2)
{
//union of xdata
// QVector<double> ret;
// ret.resize(std::max(x1.size(), x2.size()));
// int ind1 = 0;
// int ind2 = 0;
// while (ind1 < x1.size() || ind2 < x2.size()) {
// if (ind1 == x1.size()) {
// ret.push_back(x2[ind2++]);
// } else if (ind2 == x2.size()) {
// ret.push_back(x1[ind1++]);
// } else {
// if (x1[ind1] < x2[ind2])
// ret.push_back(x1[ind1++]);
// else
// ret.push_back(x2[ind2++]);
// }
// }
//TODO - make algorithm more optimal
if (x1.isEmpty() | x2.isEmpty())
return QVector<double>();
if (x1.size() == x2.size()) {
if (x1 == x2)
return x1;
}
QVector<double> retBuf = x1;
retBuf += x2;
qSort(retBuf.begin(), retBuf.end());
// double xlow = std::max(x1[0], x2[0]);
// double xhigh = std::min(x1[x1.size() - 1], x2[x2.size() - 1]);
double xlow = std::max(x1[0], x2[0]);
double xhigh = std::min(x1.back(), x2.back());
QVector<double> ret;
ret.reserve(std::max(x1.size(), x2.size()) / 2);
foreach (double x, retBuf) {
if (x >= xlow && x <= xhigh) {
// if (ret.size() == 0 || x != ret[ret.size() - 1]) //avoiding equal numbers
// ret.push_back(x);
if (ret.size() == 0 || x != ret.back()) //avoiding equal numbers
ret.push_back(x);
}
}
return ret;
}
示例4: appendMessage
void appendMessage(const QString &text, OutputFormat format) final
{
const bool isTrace = (format == StdErrFormat
|| format == StdErrFormatSameLine)
&& (text.startsWith("Traceback (most recent call last):")
|| text.startsWith("\nTraceback (most recent call last):"));
if (!isTrace) {
OutputFormatter::appendMessage(text, format);
return;
}
const QTextCharFormat frm = charFormat(format);
const Core::Id id(PythonErrorTaskCategory);
QVector<Task> tasks;
const QStringList lines = text.split('\n');
unsigned taskId = unsigned(lines.size());
for (const QString &line : lines) {
const QRegularExpressionMatch match = filePattern.match(line);
if (match.hasMatch()) {
QTextCursor tc = plainTextEdit()->textCursor();
tc.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
tc.insertText('\n' + match.captured(1));
tc.insertText(match.captured(2), linkFormat(frm, match.captured(2)));
const auto fileName = FileName::fromString(match.captured(3));
const int lineNumber = match.capturedRef(4).toInt();
Task task(Task::Warning,
QString(), fileName, lineNumber, id);
task.taskId = --taskId;
tasks.append(task);
} else {
if (!tasks.isEmpty()) {
Task &task = tasks.back();
if (!task.description.isEmpty())
task.description += ' ';
task.description += line.trimmed();
}
OutputFormatter::appendMessage('\n' + line, format);
}
}
if (!tasks.isEmpty()) {
tasks.back().type = Task::Error;
for (auto rit = tasks.crbegin(), rend = tasks.crend(); rit != rend; ++rit)
TaskHub::addTask(*rit);
}
}
示例5: 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();
}
示例6: query
QVector<chatMes> sql::getHistoryChat(QMap<QString, QVariant> map)
{
QSqlQuery query(db);
QVector<chatMes> mesVec;
int userID = getFriendID(map["friendQQ"].toLongLong()) ;
int friendID = getFriendID(map["meQQ"].toLongLong());
int offset = map[ "offset" ].toInt();
if ( !query.exec(sql_statement::historyChat_str(userID,friendID,offset) ) ) {
qDebug()<<"getHistoryChat fail: "<<query.lastError().text();
return mesVec;
} qDebug()<<sql_statement::historyChat_str(userID,friendID,offset);
int size = query.size();
if (size==0) {
return mesVec;
}
int i=0;
while(query.next()) {
chatMes mes;
int fromID = query.value(0).toInt();
mes.fromAccount = QString::number(fromID+N);
mes.content = query.value(1).toString();
mes.time=QDateTime::fromString(query.value(2).toString(),"yyyy-MM-dd hh:mm");
mes.type = query.value(3).toInt();
mesVec.push_back(mes);
qDebug()<<" getHistoryChat"<<mesVec.count() <<mesVec.back().fromAccount<< " "<<mesVec.back().content;
}
return mesVec;
}
示例7: 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);
}
示例8:
value_type *AddVariable(const char_type *varName, void *userData)
{
(void)varName;
QVector<value_type> *vec = (QVector<value_type> *)userData;
vec->push_back(0);
return &vec->back();
}
示例9: waypointsChanged
void PaintWidget::waypointsChanged()
{
m_request.target = RoutingLogic::instance()->target();
QVector< UnsignedCoordinate > waypoints = RoutingLogic::instance()->waypoints();
if ( waypoints.size() > 0 && RoutingLogic::instance()->target() == waypoints.back() )
waypoints.pop_back();
m_request.waypoints = waypoints;
update();
}
示例10: createWaveFormPic
void Record::createWaveFormPic(Ffmpeg_t *ffmpeg, QString recortPath) {
std::pair<std::vector<double>, std::vector<double> > dataWaveForm = ffmpeg->getSamplesForWaveformPlotting(recortPath + "/" + m_Name);
QCustomPlot Plotter;
Plotter.setBackground(QBrush(Qt::transparent) );
Plotter.xAxis->setVisible(false);
Plotter.yAxis->setVisible(false);
Plotter.axisRect()->setAutoMargins(QCP::msNone);
Plotter.axisRect()->setMargins(QMargins(0, 5, 0, 5));
QCPGraph *Waveform = Plotter.addGraph();
Waveform->setPen(QPen(Qt::green) );
if (!Waveform)
{
qDebug("addGraph failed\n");
}
QVector<double> Amplitudes(QVector<double>::fromStdVector(dataWaveForm.first) );
QVector<double> Time;
double CurrentTime = 0;
auto TimeSlotCount = Amplitudes.size();
for (int64_t i = 1; i < TimeSlotCount; i++)
{
Time.append(CurrentTime);
CurrentTime += 0.5;
}
Waveform->setData(Time, Amplitudes);
Plotter.xAxis->setRange(0, Time.back() );
Plotter.yAxis->setRange(SHRT_MIN, SHRT_MAX);
QByteArray ByteArray;
QBuffer Buffer(&ByteArray);
Buffer.open(QBuffer::WriteOnly);
uint32_t time = m_EndTime - m_StartTime;
for (int i = 1; i < 10000; i*=10) {
Plotter.toPixmap(time/(i), this->height()).save(&Buffer, "PNG", 0);
//Plotter.saveJpg(recortPath + "/plot" + QString::number(m_Id) + QString::number(i) + ".jpg", time/(i), this->height());
QPixmap Pixmap;
Pixmap.loadFromData(ByteArray, "PNG");
v_PixWaves.append(Pixmap);
ByteArray.clear();
Buffer.reset();
}
Buffer.close();
qDebug() << m_WavePic->margin();
// místo 2 podle toho jaký zoom
m_WavePic->setPixmap(v_PixWaves[2]);
}
示例11: 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 );
}
}
示例12: checkVColour
void checkVColour(QVector< QVector<Candy*> > board, int dimension) {
QVector<Candy*> same;
for (int j = 0; j < dimension; j++) {
for (int i = 0; i < dimension; i++) {
if (same.empty())
same.push_back(board[i][j]);
else if (!same.empty()) {
if (same.size() == 5) {
same = checkXColour(board, same);
for (int k = 0; k < 5; k++)
same[k]->setCandy(0);
same.clear();
same.push_back(board[i][j]);
}
else if (board[i][j]->getCol() == same.back()->getCol() + 1) {
if (board[i][j]->getCandy() == same.back()->getCandy())
same.push_back(board[i][j]);
else {
same.clear();
same.push_back(board[i][j]);
}
}
}
}
if (same.size() == 5) {
for (int k = 0; k < 5; k++)
same[k]->setCandy(0);
}
same.clear();
}
}
示例13:
void OsmAnd::RoutePlanner::addRouteSegmentToRoute( QVector< std::shared_ptr<RouteSegment> >& route, const std::shared_ptr<RouteSegment>& segment, bool reverse )
{
if (segment->startPointIndex == segment->endPointIndex)
return;
if (route.size() > 0)
{
auto last = route.back();
if (last->road->id == segment->road->id)
{
if (combineTwoSegmentResult(segment, last, reverse))
return;
}
}
route.push_back(segment);
}
示例14: computeGccStandardMacros
QVector<rpp::pp_macro*> computeGccStandardMacros(bool withStdCpp0x = true)
{
QVector<rpp::pp_macro*> ret;
//Get standard macros from gcc
KProcess proc;
proc.setOutputChannelMode(KProcess::MergedChannels);
// The output of the following gcc commands is several line in the format:
// "#define MACRO [definition]", where definition may or may not be present.
// Parsing each line sequentially, we can easily build the macro set.
proc << "gcc";
if (withStdCpp0x) {
// see also: https://bugs.kde.org/show_bug.cgi?id=298252
proc << "-std=c++0x";
}
proc << "-xc++" << "-E" << "-dM" <<NULL_DEVICE;
if (proc.execute(5000) == 0) {
QString line;
while (proc.canReadLine()) {
QByteArray buff = proc.readLine();
if (!buff.isEmpty()) {
line = buff;
if (line.startsWith("#define ")) {
line = line.right(line.length() - 8).trimmed();
int pos = line.indexOf(' ');
ret.append(new rpp::pp_macro);
rpp::pp_macro& macro(*ret.back());
if (pos != -1) {
macro.name = IndexedString( line.left(pos) );
macro.setDefinitionText( line.right(line.length() - pos - 1).toUtf8() );
} else {
macro.name = IndexedString( line );
}
}
}
}
} else if (withStdCpp0x) {
// fallback to macro computation without -std=c++0x arg for old gcc versions
return computeGccStandardMacros(false);
} else {
kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
}
return ret;
}
示例15: 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() );
}
}