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


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

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


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

示例1: getArea

double RS_InfoArea::getArea(const QPolygon& polygon)
{
    double ret= 0.0;
    if(polygon.size()<3) return ret;

    for(int i=0;i<polygon.size(); ++i){
        const QPoint& p0=polygon.at(i);
        const QPoint& p1=polygon.at((i+1)%polygon.size());
        ret += p0.x()*p1.y()-p0.y()*p1.x();
    }
    return 0.5*fabs(ret);
}
开发者ID:CERobertson,项目名称:LibreCAD,代码行数:12,代码来源:rs_infoarea.cpp

示例2: isAxisAlignedRectangle

bool Selection::isAxisAlignedRectangle() const
{
    if(m_shape.size() != 4)
        return false;

    // When we create a rectangular polygon (see above), the points
    // are in clockwise order, starting from the top left.
    // 0-----1
    // |     |
    // 3-----2
    // This can be rotated 90, 180 or 210 degrees and still remain an
    // axis aligned rectangle, so we need to check:
    // 0==1 and 2==3 (X plane) and 0==3 and 1==2 (Y plane)
    // OR
    // 0==3 and 1==2 (X plane) and 0==1 and 2==3 (Y plane)

    QPolygon p = m_shape.toPolygon();

    return
        (
            // case 1
            p.at(0).y() == p.at(1).y() &&
            p.at(2).y() == p.at(3).y() &&
            p.at(0).x() == p.at(3).x() &&
            p.at(1).x() == p.at(2).x()
        ) || (
            // case 2
            p.at(0).y() == p.at(3).y() &&
            p.at(1).y() == p.at(2).y() &&
            p.at(0).x() == p.at(1).x() &&
            p.at(2).x() == p.at(3).x()
        );
}
开发者ID:nitrau,项目名称:Drawpile,代码行数:33,代码来源:selection.cpp

示例3: Actor

Bot::Bot(const QPolygon &path, Map *map, Scene *scene)
	: Actor("resources/guard.spb", scene),
	  m_map(map),
	  m_currentLine(0),
	  m_positionInLine(0),
	  m_movingForward(true),
//	  m_directionSwitchDelay(0),
	  m_visionCone(this, map, scene)
{
	for(int i = 0; i < path.count() - 1; i++)
		m_path.append(QLineF(path.at(i), path.at(i + 1)));

//	m_alarmSound.setSource(QUrl::fromLocalFile("resources/sound/alarm.wav"));
//	m_alarmSound.setVolume(0.5);
//	m_alarmSound.setLoopCount(3);
}
开发者ID:MemoryLeek,项目名称:ld27,代码行数:16,代码来源:Bot.cpp

示例4: toRect

QRect toRect(QPolygon polygon)
{
    if(polygon.size() != 4)
        return QRect();

    return QRect(polygon.first(), polygon.at(2));
}
开发者ID:NicolasSchnitzler,项目名称:dtk,代码行数:7,代码来源:dtkComposerCompass.cpp

示例5:

QDebug operator<<(QDebug dbg, const QPolygon &a)
{
    dbg.nospace() << "QPolygon(";
    for (int i = 0; i < a.count(); ++i)
        dbg.nospace() << a.at(i);
    dbg.nospace() << ')';
    return dbg.space();
}
开发者ID:cedrus,项目名称:qt,代码行数:8,代码来源:qpolygon.cpp

示例6: getZoomedPolygon

QPolygon Zoomer::getZoomedPolygon(const QPolygon &poly)
{
   QPolygon newPoly;
   for(int i=0; i<poly.size(); i++)
   {
      newPoly << getZoomedPoint(poly.at(i));
   }
   return newPoly;
}
开发者ID:Broentech,项目名称:sdraw,代码行数:9,代码来源:zoomer.cpp

示例7: qWarning

QDebug operator<<(QDebug dbg, const QPolygon &a)
{
#ifndef Q_BROKEN_DEBUG_STREAM
    dbg.nospace() << "QPolygon(";
    for (int i = 0; i < a.count(); ++i)
        dbg.nospace() << a.at(i);
    dbg.nospace() << ')';
    return dbg.space();
#else
    qWarning("This compiler doesn't support streaming QPolygon to QDebug");
    return dbg;
    Q_UNUSED(a);
#endif
}
开发者ID:fluxer,项目名称:katie,代码行数:14,代码来源:qpolygon.cpp

示例8: qDrawWinArrow

static void qDrawWinArrow(QPainter *p, Qt::ArrowType type, bool down,
                           int x, int y, int w, int h,
                           const QPalette &pal, bool enabled)
{
    QPolygon a;                                // arrow polygon
    switch (type) {
    case Qt::UpArrow:
        a.setPoints(7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2);
        break;
    case Qt::DownArrow:
        a.setPoints(7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2);
        break;
    case Qt::LeftArrow:
        a.setPoints(7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0);
        break;
    case Qt::RightArrow:
        a.setPoints(7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0);
        break;
    default:
        break;
    }
    if (a.isEmpty())
        return;

    if (down) {
        x++;
        y++;
    }

    QPen savePen = p->pen();                        // save current pen
    if (down)
        p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
    p->fillRect(x, y, w, h, pal.brush(QPalette::Button));
    if (down)
        p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
    if (enabled) {
        a.translate(x+w/2, y+h/2);
        p->setPen(pal.foreground().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
    } else {
        a.translate(x+w/2+1, y+h/2+1);
        p->setPen(pal.light().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
        a.translate(-1, -1);
        p->setPen(pal.mid().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
    }
    p->setPen(savePen);                        // restore pen
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:55,代码来源:qdrawutil.cpp

示例9: painter

/*!
 * \see drawBoundingBoxes(QPainter *aPainter, QPen *aPen)
 * \see drawPolygons(QPainter *aPainter, QPen *aPen)
 *
 * It contains drawing of the confirmed and not confirmed selections either.
 */
void
ImageHolder::paintEvent(QPaintEvent *anEvent)
{
	QLabel::paintEvent(anEvent);

	QPainter painter(this);
	painter.setRenderHint(QPainter::Antialiasing);
	//painter.setRenderHint(QPainter::SmoothPixmapTransform);
	QPen pen;

	if (NoTool != tool_) {
		pen.setWidth(1);
		pen.setColor(QColor(Qt::black));
		pen.setStyle(Qt::DashLine);
		painter.setPen(pen);

		if (BoundingBoxTool == tool_) {
			/* scaling */
			QRect bbox = bounding_box_.rect;
			QPoint bboxTopLeft = bbox.topLeft() * scale_;
			QPoint bboxBottomRight = bbox.bottomRight() * scale_;

			bbox.setTopLeft(bboxTopLeft);
			bbox.setBottomRight(bboxBottomRight);

			painter.drawRect(bbox);
		}
		else if (PolygonTool == tool_) {
			/* scaling */
			QPoint point;
			QPolygon poly = polygon_.poly;
			for (int i = 0; i < poly.size(); i++) {
				point.setX(poly.at(i).x());
				point.setY(poly.at(i).y());
				point *= scale_;
				poly.remove(i);
				poly.insert(i, point);
			}
			painter.drawPolygon(poly);
		}
	}

	/* drawing bounding boxes */
	drawBoundingBoxes(&painter, &pen);
	drawPolygons(&painter, &pen);
}
开发者ID:gavlig,项目名称:Image-labeling-tool,代码行数:52,代码来源:ImageHolder.cpp

示例10: makeEllipse

void tst_QPolygon::makeEllipse()
{
    // create an ellipse with R1 = R2 = R, i.e. a circle
    QPolygon pa;
    const int R = 50; // radius
    QPainterPath path;
    path.addEllipse(0, 0, 2*R, 2*R);
    pa = path.toSubpathPolygons().at(0).toPolygon();

    int i;
    // make sure that all points are R+-1 away from the center
    bool err = FALSE;
    for (i = 1; i < pa.size(); i++) {
        QPoint p = pa.at( i );
        double r = sqrt( pow( double(p.x() - R), 2.0 ) + pow( double(p.y() - R), 2.0 ) );
        // ### too strict ? at least from visual inspection it looks
        // quite odd around the main axes. 2.0 passes easily.
        err |= ( qAbs( r - double(R) ) > 2.0 );
    }
    QVERIFY( !err );
}
开发者ID:KDE,项目名称:android-qt,代码行数:21,代码来源:tst_qpolygon.cpp

示例11: paintEvent

void Storage::paintEvent(QPaintEvent *anEvent)
{
    QLabel::paintEvent(anEvent);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    //painter.setRenderHint(QPainter::SmoothPixmapTransform);
    QPen pen;

    if (NoTool != tool_) {
        pen.setWidth(5);
        pen.setColor(QColor(Qt::white));
        pen.setStyle(Qt::DashLine);
        painter.setPen(pen);

        if (BoundingBoxTool == tool_) {
            /* с учётом масштаба */
            QRect bbox = rect.getCoordinates();
            QPoint bboxTopLeft = bbox.topLeft() * scale_;
            QPoint bboxBottomRight = bbox.bottomRight() * scale_;

            bbox.setTopLeft(bboxTopLeft);
            bbox.setBottomRight(bboxBottomRight);

            painter.drawRect(bbox);
        }
        else if (EllipseTool == tool_) {
            /* с учётом масштаба */
            QRect elli = ell.getCoordinates().normalized();
            QPoint ellTopLeft = elli.topLeft() * scale_;
            QPoint ellBottomRight = elli.bottomRight() * scale_;

            elli.setTopLeft(ellTopLeft);
            elli.setBottomRight(ellBottomRight);

            if(1 < elli.height() && 1 < elli.width() )
            {
                painter.drawEllipse(elli);
            }
//            painter.drawRect(ell);
        }
        else if (ArrowTool == tool_) {
            /* с учётом масштаба */
            QLineF line = arrow.getCoordinates();
            QPointF p1 = line.p1() * scale_;
            QPointF p2 = line.p2() * scale_;

            line.setP1(p1);
            line.setP2(p2);

            if(1 < line.length())
            {
                double angle = ::acos(line.dx() / line.length());
                qreal Pi = atan(1)*4;
                if (line.dy() >= 0)
                    angle = (Pi * 2) - angle;

                QPointF arrowP1 = line.p1() + QPointF(sin(angle + Pi / 3) * arrow_size_,
                                                cos(angle + Pi / 3) * arrow_size_);
                QPointF arrowP2 = line.p1() + QPointF(sin(angle + Pi - Pi / 3) * arrow_size_,
                                                cos(angle + Pi - Pi / 3) * arrow_size_);

                QPolygonF arrowTop;
                arrowTop.clear();
                arrowTop << line.p1() << arrowP1 << arrowP2;

                painter.drawLine(line);
                painter.drawPolygon(arrowTop);///111
                qDebug() << "arrowTop" << arrowTop;
                arrow_top_ = arrowTop;
            }

            }
        else if (PolygonTool == tool_) {
            /* с учётом масштаба */
            QPoint point;
            QPolygon pol = poly.getCoordinates();
            for (int i = 0; i < pol.size(); i++) {
                point.setX(pol.at(i).x());
                point.setY(pol.at(i).y());
                point *= scale_;
                pol.remove(i);
                pol.insert(i, point);
            }
            painter.drawPolygon(pol);
        }
    }

    /* рисуем фигуры */
    drawBoundingBoxes(&painter, &pen);
    drawPolygons(&painter, &pen);
    drawEllipses(&painter, &pen);
    drawArrows(&painter, &pen);
}
开发者ID:RISK46kaf,项目名称:Practise,代码行数:94,代码来源:storage.cpp

示例12: exportToPNG

void ModelExportHelper::exportToPNG(ObjectsScene *scene, const QString &filename, float zoom, bool show_grid, bool show_delim)
{
	if(!scene)
		throw Exception(ERR_ASG_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	try
	{
		QPixmap pix;
		QRectF ret=scene->itemsBoundingRect();
		bool shw_grd, shw_dlm, align_objs;
		QGraphicsView viewp(scene);
		QRect retv;
		QPolygon pol;

		//Clear the object scene selection to avoid drawing the selectoin rectangle of the objects
		scene->clearSelection();

		//Make a backup of the current scene options
		ObjectsScene::getGridOptions(shw_grd, align_objs, shw_dlm);

		//Sets the options passed by the user
		ObjectsScene::setGridOptions(show_grid, false, show_delim);

		//Updates the scene to apply the change on grid and delimiter
		scene->update();

		//Configures the viewport alignment to top-left coordinates.
		viewp.setAlignment(Qt::AlignLeft | Qt::AlignTop);

		//Apply the zoom factor on the viewport
		viewp.resetTransform();
		viewp.centerOn(0,0);
		viewp.scale(zoom, zoom);

		//Convert the objects bounding rect to viewport coordinates to correctly draw them onto pixmap
		pol=viewp.mapFromScene(ret);

		//Configure the viewport area to be copied
		retv.setTopLeft(pol.at(0));
		retv.setTopRight(pol.at(1));
		retv.setBottomRight(pol.at(2));
		retv.setBottomLeft(pol.at(3));

		//Creates the output pixmap
		pix=QPixmap(retv.size());
		pix.fill();
		QPainter p(&pix);

		//Setting optimizations on the painter
		p.setRenderHint(QPainter::Antialiasing, true);
		p.setRenderHint(QPainter::TextAntialiasing, true);
		p.setRenderHint(QPainter::SmoothPixmapTransform, true);

		emit s_progressUpdated(50, trUtf8("Rendering objects onto the output pixmap..."), BASE_OBJECT);

		//Render the entire viewport onto the pixmap
		viewp.render(&p, QRectF(QPointF(0,0), pix.size()), retv);

		//Restore the scene options
		ObjectsScene::setGridOptions(shw_grd, align_objs, shw_dlm);

		//Updates the scene to apply the restoration of grid and delimiter statuses
		scene->update();

		//If the pixmap is not saved raises an error
		if(!pix.save(filename))
			throw Exception(Exception::getErrorMessage(ERR_FILE_NOT_WRITTEN).arg(Utf8String::create(filename)),
											ERR_FILE_NOT_WRITTEN,__PRETTY_FUNCTION__,__FILE__,__LINE__);

		emit s_exportFinished();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
开发者ID:Haptomai,项目名称:pgmodeler,代码行数:76,代码来源:modelexporthelper.cpp

示例13: segmentSize

C2DPixmapSegment* CDraw2D::createSubpixmapFromPolygon(QPolygon &polygon, EPolygonConversion conv)
{
   if(polygon.size() < 2)
   {
      return 0;
   }

   

   int sizeOffset = qFloor(static_cast<qreal>(CDrawSettings_2D::getInstance()->penSettings().getWidth())/2.);

   // get the polygons relative to its bounding rectangle
   QPolygon normalizedPolygon = normalizePolygon(polygon, sizeOffset);
   QRect boundingRect = polygon.boundingRect();
   QRect normalizedBoundingRect = normalizedPolygon.boundingRect();
   QSize segmentSize(
      boundingRect.size().width() +  2 * sizeOffset + 1, 
      boundingRect.size().height() + 2 * sizeOffset + 1
      );

   // create segment
   QPixmap segmentContent(segmentSize);
   segmentContent.fill(Qt::transparent);
   QPainter segmentPainter(&segmentContent);
   segmentPainter.setPen(CDrawSettings_2D::getInstance()->penSettings().getPen());
   segmentPainter.setRenderHint(QPainter::Antialiasing,_settings.getAntialiasing());
   
   QPoint firstPt;
   QPoint secondPt;
   switch(conv)
   {
   case(NO_CONVERSION):
      segmentPainter.drawPolyline(normalizedPolygon);
      break;

   case(TO_LINES):
      firstPt = normalizedPolygon.at(0);
      for (int i = 1; i<normalizedPolygon.size(); i++)
      {
         secondPt = normalizedPolygon.at(i);
         if(firstPt == secondPt)
         {
            continue;
         }
         segmentPainter.drawLine(firstPt, secondPt);
         firstPt = secondPt;
      }
      break;

   case(TO_RECT):
      segmentPainter.drawRect(normalizedBoundingRect);
      break;

   case(TO_ROUNDED_RECT):
      segmentPainter.drawRoundedRect(
      normalizedBoundingRect,
      CDrawSettings_2D::getInstance()->getRoundedRectRadius_X(),
      CDrawSettings_2D::getInstance()->getRoundedRectRadius_Y()
      );
      break;

   case(TO_ELLIPSE):
      segmentPainter.drawEllipse(normalizedBoundingRect);
      break;

   case(TO_PIE):
      segmentPainter.drawPie(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   case(TO_ARC):
      segmentPainter.drawArc(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   case(TO_CHORD):
      segmentPainter.drawChord(normalizedBoundingRect, alphaDegrees * 16, betaDegrees * 16);
      break;

   default:
      segmentPainter.drawPolyline(normalizedPolygon);
      break;
   }

   segmentPainter.end();

   //DebugImageDialog DBG(segmentContent);
   //DBG.exec();

   C2DPixmapSegment *segment = new C2DPixmapSegment(&segmentContent, &boundingRect, 1, sizeOffset);
   return segment;
}
开发者ID:Broentech,项目名称:sdraw,代码行数:90,代码来源:draw_2D.cpp

示例14: drawRegion

void Airspace::drawRegion( QPainter* targetP, qreal opacity )
{
  // qDebug("Airspace::drawRegion(): TypeId=%d, opacity=%f, Name=%s",
  //         typeID, opacity, getInfoString().toLatin1().data() );

  if( ! GeneralConfig::instance()->getItemDrawingEnabled(typeID) ||
      ! glConfig->isBorder(typeID) || ! isVisible())
    {
      return;
    }

  if( m_flarmAlertZone.isValid() )
    {
      // A Flarm Alert zone has to be drawn.
      drawFlarmAlertZone( targetP, opacity );
      return;
    }

  QPolygon mP = glMapMatrix->map(projPolygon);

  if( mP.size() < 3 )
    {
      return;
    }

  QPainterPath pp;

  pp.moveTo( mP.at(0) );

  for( int i = 1; i < mP.size(); i++ )
    {
      pp.lineTo( mP.at(i) );
    }

  pp.closeSubpath();

  QBrush drawB( glConfig->getDrawBrush(typeID) );

  if( opacity <= 100.0 )
    {
      // use solid filled air regions
      drawB.setStyle( Qt::SolidPattern );
    }

  QPen drawP = glConfig->getDrawPen(typeID);
  drawP.setJoinStyle(Qt::RoundJoin);

  int lw = GeneralConfig::instance()->getAirspaceLineWidth();

  extern MapConfig* _globalMapConfig;

  if( lw > 1 && _globalMapConfig->useSmallIcons() )
    {
      lw = (lw + 1) / 2;
    }

  drawP.setWidth(lw);

  targetP->setPen(drawP);
  targetP->setBrush(drawB);

  if( opacity <= 100.0 && opacity > 0.0 )
    {
      // Draw airspace filled with opacity factor
      targetP->setOpacity( opacity/100.0 );
      targetP->drawPolygon(mP);

      // Reset opacity, that a solid line is drawn as next
      targetP->setBrush(Qt::NoBrush);
      targetP->setOpacity( 1.0 );
    }
  else if( opacity == 0.0 )
    {
      // draw only airspace borders without any filling inside
      targetP->setBrush(Qt::NoBrush);
      targetP->setOpacity( 1.0 );
    }

  // Draw the outline of the airspace with the selected brush
  targetP->drawPath(pp);
}
开发者ID:Exadios,项目名称:Cumulus,代码行数:81,代码来源:airspace.cpp

示例15: reserve

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


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