本文整理汇总了C++中QPolygon::removeLast方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::removeLast方法的具体用法?C++ QPolygon::removeLast怎么用?C++ QPolygon::removeLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::removeLast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readDetectionAreaFile
//.........这里部分代码省略.........
emit messageBroadcasted(errorMsg);
return false;
}
if(!doc.setContent(&areaFile)) {
QString errorMsg = tr("Error reading the detection area file %1").arg(areaFile.fileName());
areaFile.close();
emit messageBroadcasted(errorMsg);
return false;
}
areaFile.close();
root = doc.documentElement();
if (root.nodeName() != "detectionarealist") {
QString errorMsg = tr("Expected <detectionarealist> tag in detection area file but not found");
emit messageBroadcasted(errorMsg);
return false;
}
QDomNodeList areaList = root.childNodes();
if (areaList.count() > 1) {
QString errorMsg = tr("More than one detection areas defined, combining all together");
emit messageBroadcasted(errorMsg);
}
for (int i = 0; i < areaList.count(); i++) {
QDomNode area = areaList.at(i);
QDomNodeList areaNodes = area.childNodes();
if (area.nodeName() != "detectionarea") {
QString errorMsg = tr("Expected <detectionarea> tag in detection area file but not found.");
emit messageBroadcasted(errorMsg);
return false;
}
QDomNodeList cameraList = area.toElement().elementsByTagName("camera");
if (cameraList.count() != 1) {
QString errorMsg = tr("Expected single <camera> tag in detection area. Assuming camera index 0.");
emit messageBroadcasted(errorMsg);
}
for (int c = 0; c < cameraList.count(); c++) {
QDomElement cameraElement = cameraList.at(c).toElement();
cameraId = cameraElement.attribute("id").toInt();
cameraWidth = cameraElement.attribute("width").toInt();
cameraHeight = cameraElement.attribute("height").toInt();
if (cameraId == m_config->cameraIndex()) {
break;
}
}
cameraRectangle << QPoint(0, 0) << QPoint(0, cameraHeight - 1)
<< QPoint(cameraWidth - 1, cameraHeight - 1) << QPoint(cameraWidth - 1, 0);
while (!m_detectionAreaPolygons.isEmpty()) {
QPolygon* polygon = m_detectionAreaPolygons.takeLast();
delete polygon;
}
for (int a = 0; a < areaNodes.count(); a++) {
QDomNode areaSubNode = areaNodes.at(a);
if (areaSubNode.nodeName() == "polygon") {
QDomNodeList pointList = areaSubNode.childNodes();
QPolygon* polygon = new QPolygon();
for (int p = 0; p < pointList.count(); p++) {
QDomElement pointElement = pointList.at(p).toElement();
if (pointElement.nodeName() == "point") {
x = pointElement.attribute("x").toInt();
y = pointElement.attribute("y").toInt();
polygon->append(QPoint(x, y));
}
}
if (clipToCamera && polygon->size() &&
!cameraRectangle.boundingRect().contains(polygon->boundingRect()))
{
if (polygon->first() == polygon->last()) {
polygonWasClosed = true;
}
*polygon = polygon->intersected(cameraRectangle);
polygonsClipped = true;
if (!polygonWasClosed) {
// intersected() treats polygon as implicitly closed
// so extra node is added: remove it
if (polygon->first() == polygon->last()) {
polygon->removeLast();
}
}
}
m_detectionAreaPolygons.append(polygon);
}
}
}
if (polygonsClipped) {
QString warningMsg = tr("Detection area was clipped in order to fit the camera size.");
emit messageBroadcasted(warningMsg);
}
return true;
}