本文整理汇总了C++中QPolygon::back方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::back方法的具体用法?C++ QPolygon::back怎么用?C++ QPolygon::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: small
vector<int> PerimeterWindow::boundaryFromPolygon(QPolygon poly, int xo, int yo, int gw){
// not sure of the best way of doing this, but lets have a go..
vector<int> points;
if(poly.size() < 2){
cerr << "PerimeterWindow::boundaryFromPolygon, points is too small (less than 2) " << poly.size() << endl;
return(points);
}
for(uint i=1; i < poly.size(); i++){
// Fill in the points from i-1 to i
QPoint p1 = poly[i-1];
QPoint p2 = poly[i];
// points.push_back((p1.y() + yo) * gw + p1.x() + xo);
// then work out how to get the other points..
int dx = p2.x() - p1.x();
int dy = p2.y() - p1.y();
int stepNo = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
// in the funny world of pixels a diagonal is only as long as the longer side..
for(int i=0; i < stepNo; i++){
int lx = p1.x() + (i * dx)/stepNo;
int ly = p1.y() + (i * dy)/stepNo;
// then convert and push back..
points.push_back((ly + yo) * gw + lx + xo);
}
}
// but at this point we have not added the last point so we need to do that..
QPoint p = poly.back();
points.push_back( (p.y() + yo) * gw + p.x() + xo);
return(points);
}