本文整理汇总了C++中QPolygon::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::size方法的具体用法?C++ QPolygon::size怎么用?C++ QPolygon::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: PolygonSize
// public static
kpCommandSize::SizeType kpCommandSize::PolygonSize (const QPolygon &points)
{
#if DEBUG_KP_COMMAND_SIZE && 1
qCDebug(kpLogCommands) << "kpCommandSize::PolygonSize() points.size="
<< points.size ()
<< " sizeof(QPoint)=" << sizeof (QPoint)
<< endl;
#endif
return ((SizeType) points.size () * sizeof (QPoint));
}
示例3: 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);
}
示例4: 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;
}
示例5: drawAidPolygon
void CDrawBase::drawAidPolygon(QPolygon _polygon, QPen *pen)
{
if(!aidBufferRegistered)
{
return;
}
if(_polygon.size() >= 2)
{
// draw new aid polyline
QPainter painter(m_aidBuffer);
QPen usePen;
if (0 != pen)
{
usePen = *pen;
}
else
{
usePen = QPen(Qt::lightGray, 1);
usePen.setStyle(Qt::DashLine);
}
painter.setPen(usePen);
painter.drawPolygon(_polygon);
}
emit requestUpdate();
}
示例6: trackerTextF
//将位置转换成字符串
QwtText RectPicker::trackerTextF(const QPointF &pos) const
{
QwtText text;
const QPolygon points = selection();//选择的点
if (!points.isEmpty())
{
QString num;
QPoint point = points[0];
QPointF point2 = invTransform(point);
num = QString("(%1,%2),(,)").arg(point2.x()).arg(point2.y());
QColor bg(Qt::white);
bg.setAlpha(200);
if (points.size() == 2)
{
QPointF point0 = invTransform(points[0]);
QPointF point1 = invTransform(points[1]);
num = QString("(%1,%2),(%3,%4)").arg(point0.x()).arg(point0.y()).arg(point1.x()).arg(point1.y());
}
text.setBackgroundBrush(QBrush(bg));
text.setText(num);
}
return text;
}
示例7: toRect
QRect toRect(QPolygon polygon)
{
if(polygon.size() != 4)
return QRect();
return QRect(polygon.first(), polygon.at(2));
}
示例8: addPoint
inline void GraphPolygonClipper::addPoint(
QPolygon &pa, uint pos, const QPoint &point) const
{
if ( uint(pa.size()) <= pos )
pa.resize(pos + 5);
pa.setPoint(pos, point);
}
示例9: getZoomedPolygon
QPolygon Zoomer::getZoomedPolygon(const QPolygon &poly)
{
QPolygon newPoly;
for(int i=0; i<poly.size(); i++)
{
newPoly << getZoomedPoint(poly.at(i));
}
return newPoly;
}
示例10: to_sexp
SEXP to_sexp(QPolygon polygon) {
SEXP rpolygon = allocMatrix(INTSXP, polygon.size(), 2);
int nr = nrows(rpolygon);
for (int i = 0; i < nr; i++) {
INTEGER(rpolygon)[i] = polygon[i].x();
INTEGER(rpolygon)[i + nr] = polygon[i].y();
}
return rpolygon;
}
示例11: Mat
RegionMask::RegionMask(int height, int width, const QPolygon &boundary, const QList<QPolygon> &holes) : Mat(height,
width,
CV_8UC1, cvScalarAll(0)),
boundary(
boundary),
holes(holes) {
assert(boundary.size() > 0);
QPolygon2Mask(*this, boundary, holes);
}
示例12:
QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule)
{
if (a.size() < 3) {
d = &shared_empty;
d->ref.ref();
} else {
d = new QRegionData;
d->ref = 1;
d->rgn = qt_tryCreatePolygonRegion(a, fillRule);
}
}
示例13: map
QPolygon QMatrix::map(const QPolygon &a) const
{
int size = a.size();
int i;
QPolygon p(size);
const QPoint *da = a.constData();
QPoint *dp = p.data();
for(i = 0; i < size; i++) {
MAPINT(da[i].x(), da[i].y(), dp[i].rx(), dp[i].ry());
}
return p;
}
示例14: qt_tryCreatePolygonRegion
HRGN qt_tryCreatePolygonRegion(const QPolygon &a, Qt::FillRule fillRule)
{
const int tries = 10;
for (int i = 0; i < tries; ++i) {
HRGN region = CreatePolygonRgn(reinterpret_cast<const POINT*>(a.data()), a.size(),
fillRule == Qt::OddEvenFill ? ALTERNATE : WINDING);
if (region) {
if (GetRegionData(region, 0, 0))
return region;
else
DeleteObject(region);
}
}
return 0;
}
示例15: 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);
}