本文整理汇总了C++中QPolygonF::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::isEmpty方法的具体用法?C++ QPolygonF::isEmpty怎么用?C++ QPolygonF::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygonF
的用法示例。
在下文中一共展示了QPolygonF::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMiddlePoint
QPointF Meshing::addMiddlePoint(int id)
{
QPointF point(0,0);
QPolygonF poly = mesh_.at(id);
if(poly.isEmpty())
return point;
if(!poly.isClosed())
poly << poly.at(0);
mesh_.removeAt(id);
for(int i=0;i<poly.size()-1;i++)
point += poly.at(i);
point /= (double)(poly.size()-1);
/*while(!poly.containsPoint(point,Qt::WindingFill)){
point += QPointF(-50+rand()%100,-50+rand()%100);
}*/
for(int i=0;i<poly.size()-1;i++){
QPolygonF p;
p << poly.at(i) << poly.at(i+1) << point << poly.at(i);
mesh_.push_back(p);
}
return point;
}
示例2: ENP_centroid
static void ENP_centroid( const QPolygonF &pX, double &cx, double &cy )
{
// http://stackoverflow.com/questions/2792443/finding-the-centroid-of-a-polygon/2792459#2792459
cx = 0;
cy = 0;
if ( pX.isEmpty() )
return;
double signedArea = 0.0;
// For all vertices except last
int i = 0;
for ( ; i < pX.size() - 1; ++i )
{
ENP_centroid_step( pX, cx, cy, signedArea, i, i + 1 );
}
// Do last vertex separately to avoid performing an expensive
// modulus operation in each iteration.
ENP_centroid_step( pX, cx, cy, signedArea, i, 0 );
signedArea *= 0.5;
cx /= ( 6.0 * signedArea );
cy /= ( 6.0 * signedArea );
}
示例3: resizeTitle
void TableTitleView::resizeTitle(float width, float height)
{
QPolygonF pol;
pol=box->polygon();
if(pol.isEmpty())
{
pol.append(QPointF(0.0f,0.0f));
pol.append(QPointF(1.0f,0.0f));
pol.append(QPointF(1.0f,1.0f));
pol.append(QPointF(0.0f,1.0f));
}
this->resizePolygon(pol, width, height);
box->setPolygon(pol);
if(schema_name->text()==" ")
obj_name->setPos((box->boundingRect().width() - obj_name->boundingRect().width())/2.0f, VERT_SPACING);
else
{
schema_name->setPos((box->boundingRect().width() - (schema_name->boundingRect().width() + obj_name->boundingRect().width()))/2.0f, VERT_SPACING);
obj_name->setPos(schema_name->pos().x() + schema_name->boundingRect().width(), VERT_SPACING);
obj_name->setPos(schema_name->pos().x() + schema_name->boundingRect().width(), VERT_SPACING);
}
this->bounding_rect.setTopLeft(this->pos());
this->bounding_rect.setSize(QSizeF(box->boundingRect().width(), box->boundingRect().height()));
}
示例4: modelDataChanged
void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
return;
AbstractProfilePolygonItem::modelDataChanged(topLeft, bottomRight);
// Add 2 points to close the polygon.
QPolygonF poly = polygon();
if (poly.isEmpty())
return;
QPointF p1 = poly.first();
QPointF p2 = poly.last();
poly.prepend(QPointF(p1.x(), vAxis->posAtValue(0)));
poly.append(QPointF(p2.x(), vAxis->posAtValue(0)));
setPolygon(poly);
QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
pat.setColorAt(1, getColor(CALC_CEILING_DEEP));
setPen(QPen(QBrush(Qt::NoBrush), 0));
setBrush(pat);
gradientFactor->setX(poly.boundingRect().width() / 2 + poly.boundingRect().x());
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
if (plannerModel->isPlanner()) {
struct diveplan &diveplan = plannerModel->getDiveplan();
gradientFactor->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh));
} else {
gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
}
}
示例5: l
void QgsMarkerLineSymbolLayerV2::renderOffsetVertexAlongLine( const QPolygonF &points, int vertex, double distance, QgsSymbolV2RenderContext& context )
{
if ( points.isEmpty() )
return;
QgsRenderContext& rc = context.renderContext();
double origAngle = mMarker->angle();
if ( distance == 0 )
{
// rotate marker (if desired)
if ( mRotateMarker )
{
bool isRing = false;
if ( points.first() == points.last() )
isRing = true;
double angle = markerAngle( points, isRing, vertex );
mMarker->setAngle( origAngle + angle * 180 / M_PI );
}
mMarker->renderPoint( points[vertex], context.feature(), rc, -1, context.selected() );
return;
}
int pointIncrement = distance > 0 ? 1 : -1;
QPointF previousPoint = points[vertex];
int startPoint = distance > 0 ? qMin( vertex + 1, points.count() - 1 ) : qMax( vertex - 1, 0 );
int endPoint = distance > 0 ? points.count() - 1 : 0;
double distanceLeft = qAbs( distance );
for ( int i = startPoint; pointIncrement > 0 ? i <= endPoint : i >= endPoint; i += pointIncrement )
{
const QPointF& pt = points[i];
if ( previousPoint == pt ) // must not be equal!
continue;
// create line segment
MyLine l( previousPoint, pt );
if ( distanceLeft < l.length() )
{
//destination point is in current segment
QPointF markerPoint = previousPoint + l.diffForInterval( distanceLeft );
// rotate marker (if desired)
if ( mRotateMarker )
{
mMarker->setAngle( origAngle + ( l.angle() * 180 / M_PI ) );
}
mMarker->renderPoint( markerPoint, context.feature(), rc, -1, context.selected() );
return;
}
distanceLeft -= l.length();
previousPoint = pt;
}
//didn't find point
return;
}
示例6: testShapedGradientPainterImpl
void testShapedGradientPainterImpl(const QPolygonF &selectionPolygon,
const QString &testName,
const QPolygonF &selectionErasePolygon = QPolygonF())
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
QRect imageRect(0,0,300,300);
KisSelectionSP selection = new KisSelection();
KisPixelSelectionSP pixelSelection = selection->pixelSelection();
KisPainter selPainter(pixelSelection);
selPainter.setFillStyle(KisPainter::FillStyleForegroundColor);
selPainter.setPaintColor(KoColor(Qt::white, pixelSelection->colorSpace()));
selPainter.paintPolygon(selectionPolygon);
if (!selectionErasePolygon.isEmpty()) {
selPainter.setCompositeOp(COMPOSITE_ERASE);
selPainter.setPaintColor(KoColor(Qt::white, pixelSelection->colorSpace()));
selPainter.paintPolygon(selectionErasePolygon);
}
selPainter.end();
pixelSelection->invalidateOutlineCache();
pixelSelection->convertToQImage(0, imageRect).save("sgt_selection.png");
QLinearGradient testGradient;
testGradient.setColorAt(0.0, Qt::white);
testGradient.setColorAt(0.5, Qt::green);
testGradient.setColorAt(1.0, Qt::black);
testGradient.setSpread(QGradient::ReflectSpread);
QScopedPointer<KoStopGradient> gradient(
KoStopGradient::fromQGradient(&testGradient));
KisGradientPainter gc(dev, selection);
gc.setGradient(gradient.data());
gc.setGradientShape(KisGradientPainter::GradientShapePolygonal);
gc.paintGradient(selectionPolygon.boundingRect().topLeft(),
selectionPolygon.boundingRect().bottomRight(),
KisGradientPainter::GradientRepeatNone,
0,
false,
imageRect.x(),
imageRect.y(),
imageRect.width(),
imageRect.height());
QVERIFY(TestUtil::checkQImageExternal(dev->convertToQImage(0, imageRect),
"shaped_gradient",
"fill",
testName, 1, 1, 0));
}
示例7: polygonFromPath
QPolygonF polygonFromPath(potrace_path_t *path,
int bezierPrecision)
{
QPolygonF poly;
if(!path) return poly;
int n = path->curve.n;
int *tag = path->curve.tag;
potrace_dpoint_t (*c)[3] = path->curve.c;
for(int i = 0; i < n; ++i)
{
switch (tag[i])
{
case POTRACE_CORNER:
poly << QPointF(c[i][1].x, c[i][1].y)
<< QPointF(c[i][2].x, c[i][2].y);
break;
case POTRACE_CURVETO:
{
QPointF pa, pb, pc, pd;
pa = poly.isEmpty()? QPointF(c[n-1][2].x, c[n-1][2].y) :
poly.last();
pb = QPointF(c[i][0].x, c[i][0].y);
pc = QPointF(c[i][1].x, c[i][1].y);
pd = QPointF(c[i][2].x, c[i][2].y);
for(int i = 1; i <= bezierPrecision; ++i)
{
poly << bezier(pa, pb, pc, pd, static_cast<qreal>(i)/bezierPrecision);
}
}
break;
}
}
if(!poly.isEmpty() && poly.first() == poly.last())
{
poly.remove(poly.size()-1);
}
return poly;
}
示例8: paintContents
void LineWidthItem::paintContents(QPainter *p) {
static QPolygonF pp;
if (pp.isEmpty())
for (double x=10; x<22.1; x+=0.5)
pp << QPointF(x, 16-(x-16)-sin(.7*(x-12)));
p->setPen(QPen(c, lw));
p->setBrush(Qt::NoBrush);
if (straight)
p->drawLine(QLineF(QPointF(10, 22), QPointF(22, 10)));
else
p->drawPolyline(pp);
}
示例9: showPlot
/**
* @brief Function to show the plot
*
* @param _plot
* @param _residualVO
* @param _points
* @return QPolygonF
*/
QPolygonF ResidualTabHelper::showPlot(QwtPlot * _plot, SolverResidualVO * _residualVO,
QPolygonF _points)
{
if (_points.isEmpty())
_points << QPointF(0,0) ;
int _iteration = _residualVO->getIteration();
_points << QPointF(50+_iteration,100+_iteration );
_curve->setSamples(_points);
_curve->attach(_plot );
_plot->replot();
_plot->show();
return _points;
}
示例10: if
void QgsMarkerLineSymbolLayerV2::renderPolylineVertex( const QPolygonF& points, QgsSymbolV2RenderContext& context, Placement placement )
{
if ( points.isEmpty() )
return;
QgsRenderContext& rc = context.renderContext();
double origAngle = mMarker->angle();
int i, maxCount;
bool isRing = false;
if ( placement == FirstVertex )
{
i = 0;
maxCount = 1;
}
else if ( placement == LastVertex )
{
i = points.count() - 1;
maxCount = points.count();
}
else
{
i = 0;
maxCount = points.count();
if ( points.first() == points.last() )
isRing = true;
}
for ( ; i < maxCount; ++i )
{
if ( isRing && placement == Vertex && i == points.count() - 1 )
{
continue; // don't draw the last marker - it has been drawn already
}
// rotate marker (if desired)
if ( mRotateMarker )
{
double angle = markerAngle( points, isRing, i );
mMarker->setAngle( origAngle + angle * 180 / M_PI );
}
mMarker->renderPoint( points.at( i ), context.feature(), rc, -1, context.selected() );
}
// restore original rotation
mMarker->setAngle( origAngle );
}
示例11: testRouteSimple
void TestConnection::testRouteSimple()
{
MockCanvas canvas;
KShapeManager manager(&canvas);
KShape shape1;
shape1.setPosition(30, 50);
shape1.setSize(100, 200);
manager.addShape(&shape1);
KShapeConnection connection;
connection.setStartPoint(&shape1, 0);
connection.setEndPoint(150, 300);
QPolygonF path = manager.routeConnection(&connection);
QVERIFY(!path.isEmpty());
// TODO need to start at start and end at end
}
示例12: toTikzPath
QString QTikzPicturePrivate::toTikzPath(const QPolygonF & polygon) const
{
if (polygon.isEmpty()) return QString();
const int end = polygon.size() - polygon.isClosed() ? 1 : 0;
QString path;
for (int i = 0; i < end; ++i) {
if (i == 0) {
path = toCoord(polygon[i]);
} else if (i == end - 1) {
path += " -- cycle";
} else {
path += " -- " + toCoord(polygon[i]);
}
}
return path;
}
示例13: projector
/**
* Extends or shrinks a line segment in such a way that if you draw perpendicular
* lines through its endpoints, the given polygon would be squeezed between these
* two perpendiculars. This ensures that the resulting line segment intersects
* all the polygon edges it can possibly intersect.
*/
QLineF
PageLayout::extendToCover(QLineF const& line, QPolygonF const& poly)
{
if (poly.isEmpty()) {
return line;
}
// Project every vertex of the polygon onto the line and take extremas.
double min = NumericTraits<double>::max();
double max = NumericTraits<double>::min();
ToLineProjector const projector(line);
BOOST_FOREACH(QPointF const& pt, poly) {
double const scalar = projector.projectionScalar(pt);
if (scalar < min) {
min = scalar;
}
if (scalar > max) {
max = scalar;
}
}
示例14: isPointOnPathBorder
// Check whether a point is on the border
static bool isPointOnPathBorder(const QPolygonF& border, const QPointF& p)
{
// null border doesn't contain points
if (border.isEmpty())
return false;
QPointF p1 = border.at(0);
QPointF p2;
for (int i = 1; i < border.size(); ++i) {
p2 = border.at(i);
if (areCollinear(p, p1, p2)
// Once we know that the points are collinear we
// only need to check one of the coordinates
&& (qAbs(p2.x() - p1.x()) > qAbs(p2.y() - p1.y()) ?
withinRange(p.x(), p1.x(), p2.x()) :
withinRange(p.y(), p1.y(), p2.y()))) {
return true;
}
p1 = p2;
}
return false;
}
示例15: splitToPolygons
static QList<QPolygonF> splitToPolygons(const QList<QPointF> &line)
{
QList<QPolygonF> results;
QPolygonF polygon;
foreach (const QPointF &pt, line)
{
// if (!QIG::isNullValue(pt.y())) // y为时间轴或者深度轴
// {
// polygon.append(pt);
// }
// else if (!polygon.isEmpty())
// {
// results.append(polygon);
// polygon.clear();
// }
}
if (!polygon.isEmpty())
{
results.append(polygon);
}
return results;
}