65,208
社区成员
发帖
与我相关
我的任务
分享

///或许下位机发来的数据 间隔20毫秒
void myscen::getPath( ArNetPacket * packet )
{
int numPoints;
static bool firstpoint=false;
numPoints=packet->bufToByte2();
if (numPoints!=0)
{
mPath = QPainterPath();
firstpoint=true;
for (int num=0;num<numPoints;num++)
{
int pathx=packet->bufToByte4();
int pathy=packet->bufToByte4();
if (firstpoint)
{
//mPath.moveTo(mPath.currentPosition());
mPath.moveTo(QPointF(pathx,pathy));
firstpoint=false;
}
else
{
mPath.lineTo(QPointF(pathx,pathy));
}
}
mPath.currentPosition();
// myupdata=true;
}
}
/// 把绘制的mpath画的画布上
void myscen::drawForeground(QPainter *painter, const QRectF &rect)
{
if (!mPath.isEmpty())
{
painter->save();
mpathpen.setCosmetic(true);
mpathpen.setColor(Qt::blue);
mpathpen.setWidth(3);
painter->setPen(mpathpen);
painter->drawPath(mPath);
//painter->strokePath(mPath,mpathpen);
painter->restore();
//this->invalidate(rect ,QGraphicsScene::ForegroundLayer);
}
//painter=new QPainter();
//this->update(rect);
//this->invalidate(rect ,QGraphicsScene::ForegroundLayer);
}
