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


C++ QPolygon::append方法代码示例

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


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

示例1:

QPolygon &RegionMask::Mask2QPolygon(const cv::Mat &img, QPolygon &poly, QList<QPolygon> &holes) {
    poly.clear();
    vector<vector<cv::Point> > contours;
    vector<cv::Vec4i> hierarchy;
    cv::findContours(img.clone(), contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_TC89_KCOS, cv::Point(0, 0));

    //assert(contours.size() > 0);

    if (contours.size() > 0) {
        for (unsigned int i = 0; i < contours[0].size(); i++) {
            poly.append(QPoint(contours[0][i].x, contours[0][i].y));
        }

        int idHole = hierarchy[0][2];
        for (; idHole != -1; idHole = hierarchy[idHole][0]) {
            QPolygon pnew;
            for (unsigned int i = 0; i < contours[idHole].size(); i++) {
                pnew.append(QPoint(contours[idHole][i].x, contours[idHole][i].y));
            }
            holes.append(pnew);
        }
    }

    return poly;
}
开发者ID:lopespt,项目名称:PhD-Thesis,代码行数:25,代码来源:RegionMask.cpp

示例2: map

// The new function using fixed point multiplication
QPolygon MapMatrix::map(const QPolygon &a) const
{
  int size = a.size();
  int64_t fx;
  int64_t fy;
  int32_t curx;
  int32_t cury;
  int32_t lastx = 0;
  int32_t lasty = 0;

  QPolygon p;

  for( int i = 0; i < size; i++ )
    {
      a.point(i, &curx, &cury);
      fx = itofp24p8( curx );
      fy = itofp24p8( cury );
      // some cheating involved; multiplication with the "wrong" macro
      // after "left shifting" the "m" value in createMatrix
      curx = fp24p8toi( mulfp8p24(m11,fx) + mulfp8p24(m21,fy) + dx);
      cury = fp24p8toi( mulfp8p24(m22,fy) + mulfp8p24(m12,fx) + dy);

      if ( (i==0) | ( ((curx - lastx) | (cury - lasty)) != 0) )
        {
          p.append(QPoint(curx, cury));
          lastx = curx;
          lasty = cury;
        }
    }

  return p;
}
开发者ID:Exadios,项目名称:Cumulus,代码行数:33,代码来源:mapmatrix.cpp

示例3: polygonQt

QPolygon drawerQt::polygonQt( const std::vector<scigraphics::wpoint> &Points )
{
  QPolygon Polygon;
  for ( unsigned i = 0; i < Points.size(); i++ )
    Polygon.append( pointQt( Points[i] ) );
  return Polygon;
}
开发者ID:syntheticpp,项目名称:scigraphics,代码行数:7,代码来源:qt4plot.cpp

示例4: draw

	void LineString::draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &screensize, const QPoint offset)
	{
		if (!visible)
			return;
	
		QPolygon p = QPolygon();
	
		QPointF c;
		for (int i=0; i<vertices.size(); i++)
		{
			c = vertices[i]->coordinate();
			p.append(mapadapter->coordinateToDisplay(c));
		}
		if (mypen != 0)
		{
			painter->save();
			painter->setPen(*mypen);
		}
		painter->drawPolyline(p);
		if (mypen != 0)
		{
			painter->restore();
		}
		for (int i=0; i<vertices.size(); i++)
		{
			vertices[i]->draw(painter, mapadapter, screensize, offset);
		}
	}
开发者ID:JulianRamos,项目名称:qgroundcontrol,代码行数:28,代码来源:linestring.cpp

示例5: fromString

Area Area::fromString(const QString& str)
{
  Area result;
  QStringList list = str.split(',', QString::SkipEmptyParts);
  if (list.isEmpty())
    return result;
  AreaTypeFlag type = (AreaTypeFlag) list.takeFirst().toInt();
  switch (type)
  {
  case TypeRectangle:
    if (list.size() != 4)
      break;
    {
      int values[4];
      values[0] = list.takeFirst().toInt();
      values[1] = list.takeFirst().toInt();
      values[2] = list.takeFirst().toInt();
      values[3] = list.takeFirst().toInt();
      result = Area(QRect(values[0],
                          values[1],
                          values[2],
                          values[3]));
    }
    break;
  case TypePolygon:
    {
      int size = list.takeFirst().toInt();
      if (list.size() != 2 * size)
        break;
      QPolygon poly;
      for (int i = 0;i < size;++i)
      {
        int values[2];
        values[0] = list.takeFirst().toInt();
        values[1] = list.takeFirst().toInt();
        poly.append(QPoint(values[0], values[1]));
      }
      result = Area(poly);
    }
    break;
  case TypeEllipse:
    if (list.size() != 4)
      break;
    {
      int values[4];
      values[0] = list.takeFirst().toInt();
      values[1] = list.takeFirst().toInt();
      values[2] = list.takeFirst().toInt();
      values[3] = list.takeFirst().toInt();
      result = Area(Ellipse(QPoint(values[0],
                                   values[1]),
                            values[2],
                            values[3]));
    }
    break;
  default:
    break;
  }
  return result;
}
开发者ID:SidneyTTW,项目名称:ImageProcessor,代码行数:60,代码来源:area.cpp

示例6: toPolygon

QPolygon QPolygonF::toPolygon() const
{
    QPolygon a;
    a.reserve(size());
    for (int i=0; i<size(); ++i)
        a.append(at(i).toPoint());
    return a;
}
开发者ID:fluxer,项目名称:katie,代码行数:8,代码来源:qpolygon.cpp

示例7: start

void IntersectionTest::start() {
    QPolygon poly;
    poly.append(QPoint(0,0));
    poly.append(QPoint(0,100));
    poly.append(QPoint(100,100));
    poly.append(QPoint(100,0));
    cv::Mat mat(200,200, CV_8UC1);

    ShapeSignatureFeatureFactory factory(5, 5);
    //factory.CreateFromRegion();
    QImageCV image(mat.clone());
    Region r(&image, mat);
    Utils::QPolygon2Mask(mat, poly);
    cv::imshow("img", mat);
    cv::waitKey(0);


}
开发者ID:lopespt,项目名称:PhD-Thesis,代码行数:18,代码来源:IntersectionTest.cpp

示例8: points

	QPolygon PointListWidget::points() const
	{
		QPolygon back;

		for(int index = 0; index < ui->list->rowCount(); ++index)
			back.append(QPoint(ui->list->item(index, 0)->text().toInt(),
							   ui->list->item(index, 1)->text().toInt()));

		return back;
	}
开发者ID:Danielweber7624,项目名称:actiona,代码行数:10,代码来源:pointlistwidget.cpp

示例9: UpdatePosition

void GuiDomain::UpdatePosition()
{
    //LOG(LOG_VERBOSE, "Updating position of GUI domain %s", mDomain->GetDomainAddress().c_str());

    QPolygon tPolygon;
    GuiNode* tGuiNode;
    foreach(tGuiNode, mGuiNodes)
    {
        QPointF tPoint = mapFromItem(tGuiNode, 0, 0);
        tPoint.setX(tPoint.x() + tGuiNode->GetWidth() / 2);
        tPoint.setY(tPoint.y() + tGuiNode->GetHeight() / 2);
        tPolygon.append(tPoint.toPoint());
    }
开发者ID:IcedLolly,项目名称:Homer-Conferencing,代码行数:13,代码来源:OverviewNetworkSimulationWidget.cpp

示例10: drawLine

// public static
void kpPixmapFX::drawLine (QImage *image,
        int x1, int y1, int x2, int y2,
        const kpColor &color, int penWidth,
        const kpColor &stippleColor)
{
    QPolygon points;
    points.append (QPoint (x1, y1));
    points.append (QPoint (x2, y2));

    drawPolyline (image,
        points,
        color, penWidth,
        stippleColor);
}
开发者ID:KDE,项目名称:kolourpaint,代码行数:15,代码来源:kpPixmapFX_DrawShapes.cpp

示例11: paintShape

void WmfExport::paintShape(KoShape * shape)
{
    QList<QPolygonF> subpaths = shape->outline().toFillPolygons(shape->absoluteTransformation(0));

    if (! subpaths.count())
        return;

    QList<QPolygon> polygons;
    foreach(const QPolygonF & subpath, subpaths) {
        QPolygon p;
        uint pointCount = subpath.count();
        for (uint i = 0; i < pointCount; ++i)
            p.append(QPoint(coordX(subpath[i].x()), coordY(subpath[i].y())));

        polygons.append(p);
    }
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:16,代码来源:WmfExport.cpp

示例12: createPolygon

/*----------------------------------------------------------------------------*/
QPolygon ChannelEdit :: createPolygon(int x)
{
  QPolygon pol;
  const int w = 32;
  const int h = 32;
  pol.append(QPoint(x-w/2, 0));
  pol.append(QPoint(x+w/2, 0));
  pol.append(QPoint(x+w/2, h));
  pol.append(QPoint(x+3, rect().bottom() - 5));
  pol.append(QPoint(x+2, rect().bottom() - 3));
  pol.append(QPoint(x+1, rect().bottom() - 1));
  pol.append(QPoint(x, rect().bottom()));
  pol.append(QPoint(x-1, rect().bottom() - 1));
  pol.append(QPoint(x-2, rect().bottom() - 3));
  pol.append(QPoint(x-3, rect().bottom() - 5));
  pol.append(QPoint(x-w/2, h));
  return pol;
}
开发者ID:olegyurchenko,项目名称:audio-illuminated,代码行数:19,代码来源:channel_edit.cpp

示例13: draw

//-------------------------------------------------------------------------------------------------
void Obstacle::draw(QPainter & painter, const Projector & projector, const Plane3D & plane) {    

    QPoints Ps(8, QPoint(0, 0));
    for (int I = 0; I < tops.size(); ++I)
        Ps[I] = projector(tops[I]);

    int invisible = findInvisible(plane);
    for (Edge & edge : edges)
        if (! edge.isInvisible(invisible))
            painter.drawLine(Ps[edge.from], Ps[edge.to]);

    for (Facet & facet : facets)
        if (! facet.isInvisible(invisible)) {
            QPolygon polygon;

            for (int index : facet.tops)
                polygon.append(Ps[index]);

            painter.setBrush(QBrush(* texture));
            painter.drawPolygon(polygon);
        }
}
开发者ID:xammi,项目名称:Curs_Fire,代码行数:23,代码来源:Obstacle.cpp

示例14: requestImage

QImage ImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
    QImage result;
    const QStringList idSegments = id.split(QLatin1Char('/'));
    if (requestedSize.width() < 1 || requestedSize.height() < 1) {
        qDebug() << Q_FUNC_INFO << " requestedSize is invalid!" << requestedSize << id;
        return QImage();
    }
    if (idSegments.count() < 2) {
        qDebug() << Q_FUNC_INFO << "Not enough parameters for the image provider: " << id;
        return QImage();
    }
    const QString &elementId = idSegments.at(1);
    if (idSegments.first() == QStringLiteral("background")) {
        return renderedSvgElement(elementId, designRenderer(), Qt::KeepAspectRatioByExpanding, size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("title")) {
        if (elementId == QStringLiteral("textmask"))
            result = renderedSvgElement(idSegments.first(), designRenderer(), Qt::KeepAspectRatio, size, requestedSize);
        else
            result = spectrum(size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("specialbutton")) {
        result = renderedSvgElement(elementId, designRenderer(), Qt::IgnoreAspectRatio, size, requestedSize);
    } else if (idSegments.first() == buttonString) {
        result = renderedDesignElement(DesignElementTypeButton, elementId.toInt(), size, requestedSize);
    } else if (idSegments.first() == frameString) {
        result = renderedDesignElement(DesignElementTypeFrame, 0, size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("object")) {
        result = renderedSvgElement(elementId, objectRenderer(), Qt::KeepAspectRatio, size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("clock")) {
        if (idSegments.count() != 4) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for clock images:" << id;
            return QImage();
        }
        result = clock(idSegments.at(1).toInt(), idSegments.at(2).toInt(), idSegments.at(3).toInt(), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("notes")) {
        result = notes(elementId.split(QLatin1Char(','), QString::SkipEmptyParts), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("quantity")) {
        if (idSegments.count() != 3) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for quantity images:" << id;
            return QImage();
        }
        result = quantity(idSegments.at(1).toInt(), idSegments.at(2), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("lessonicon")) {
        if (idSegments.count() != 3) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for lessonicon:" << id;
            return QImage();
        }
        result = renderedLessonIcon(idSegments.at(1), idSegments.at(2).toInt(), size, requestedSize);
    } else if (idSegments.first() == QStringLiteral("color")) {
        if (idSegments.count() != 3) {
            qDebug() << Q_FUNC_INFO << "Wrong number of parameters for color:" << id;
            return QImage();
        }
        const QColor color(idSegments.at(1));
        result = colorBlot(color, idSegments.at(2).toInt(), size, requestedSize);
    } else {
        qDebug() << Q_FUNC_INFO << "invalid image Id:" << id;
    }
#if 0
    if (idSegments.first() == QStringLiteral("object")) {
        QPainter p(&result);
        QPolygon points;
        for (int i = 0; i < result.width(); i += 2)
            for (int j = 0; j < result.height(); j += 2)
                points.append(QPoint(i, j));
        p.drawPoints(points);
        p.setPen(Qt::white);
        p.translate(1, 1);
        p.drawPoints(points);
    }
#endif
    return result;
}
开发者ID:fawzi,项目名称:qtouchandlearn,代码行数:73,代码来源:imageprovider.cpp

示例15: readDetectionAreaFile

bool DataManager::readDetectionAreaFile(bool clipToCamera) {
    QFile areaFile(m_config->detectionAreaFile());
    QDomDocument doc;
    QDomElement root;
    int x = 0;
    int y = 0;
    int cameraId = m_config->cameraIndex();
    int cameraWidth = m_config->cameraWidth();
    int cameraHeight = m_config->cameraHeight();
    QPolygon cameraRectangle;
    bool polygonsClipped = false;
    bool polygonWasClosed = false;

    if(!areaFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QString errorMsg = tr("Failed to open the detection area file %1. Please create it in Settings dialog or manually.").arg(areaFile.fileName());
        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
//.........这里部分代码省略.........
开发者ID:UFOID,项目名称:UFO-Detector,代码行数:101,代码来源:datamanager.cpp


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