本文整理汇总了C++中QPolygon::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::isEmpty方法的具体用法?C++ QPolygon::isEmpty怎么用?C++ QPolygon::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::isEmpty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: grabRect
void FreeRegionGrabber::grabRect()
{
QPolygon pol = selection;
if ( !pol.isEmpty() )
{
grabbing = true;
int xOffset = pixmap.rect().x() - pol.boundingRect().x();
int yOffset = pixmap.rect().y() - pol.boundingRect().y();
QPolygon translatedPol = pol.translated(xOffset, yOffset);
QPixmap pixmap2(pol.boundingRect().size());
pixmap2.fill(Qt::transparent);
QPainter pt;
pt.begin(&pixmap2);
if (pt.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
pt.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform, true);
pt.setBrush(Qt::black);
pt.setPen(QPen(QBrush(Qt::black), 0.5));
pt.drawPolygon(translatedPol);
pt.setCompositionMode(QPainter::CompositionMode_SourceIn);
} else {
pt.setClipRegion(QRegion(translatedPol));
pt.setCompositionMode(QPainter::CompositionMode_Source);
}
pt.drawPixmap(pixmap2.rect(), pixmap, pol.boundingRect());
pt.end();
emit freeRegionUpdated(pol);
emit freeRegionGrabbed(pixmap2);
}
}
示例3: 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
}
示例4: trackerTextF
virtual QwtText trackerTextF( const QPointF &pos ) const
{
QwtText text;
const QPolygon points = selection();
if ( !points.isEmpty() )
{
QString num;
num.setNum( QLineF( pos, invTransform( points[0] ) ).length() );
QColor bg( Qt::green );
bg.setAlpha( 200 );
text.setBackgroundBrush( QBrush( bg ) );
text.setText( num );
}
return text;
}
示例5: updateData
void NodeElement::updateData()
{
Element::updateData();
if (!mMoving) {
QPointF newpos = mGraphicalAssistApi.position(id());
QPolygon newpoly = mGraphicalAssistApi.configuration(id());
QRectF newRect; // Use default ((0,0)-(0,0))
// QPolygon::boundingRect is buggy :-(
if (!newpoly.isEmpty()) {
int minx = newpoly[0].x();
int miny = newpoly[0].y();
int maxx = newpoly[0].x();
int maxy = newpoly[0].y();
for (int i = 1; i < newpoly.size(); ++i) {
if (minx > newpoly[i].x()) {
minx = newpoly[i].x();
}
if (maxx < newpoly[i].x()) {
maxx = newpoly[i].x();
}
if (miny > newpoly[i].y()) {
miny = newpoly[i].y();
}
if (maxy < newpoly[i].y()) {
maxy = newpoly[i].y();
}
}
newRect = QRectF(QPoint(minx, miny), QSize(maxx - minx, maxy - miny));
}
setGeometry(newRect.translated(newpos));
}
mElementImpl->updateData(this);
updateLabels();
update();
}
示例6: iteration
bool SeamCarver::iteration()
{
QList<QPolygon *> listLignes;
QPoint item;
int strengthValue;
QList<int> listStrengthValue;
QList<int> listOrderedStrengthValue;
QPolygon *polyg;
bool route_bloquee;
for(int h=0;h<imgOrigine->height();h++){
route_bloquee=false;
if (b_Pos_interdit[h][0] == false)
{
polyg = new QPolygon();
item = QPoint(0,h);
*polyg << item;
strengthValue = getPointEnergy(h,0);
for (int w=1; w<(imgOrigine->width()-1); w++) {
item = leastRouteNextPointAt(item,strengthValue);
if (item.y() < 0) //Cas 3 routes bloquées
{
w=imgOrigine->width();
route_bloquee=true;
} else
*polyg << item;
}
if (route_bloquee==false)
{
*polyg << QPoint(imgOrigine->width()-1,item.y());
listStrengthValue << strengthValue;
listOrderedStrengthValue << strengthValue;
listLignes <<polyg;
} else
delete polyg;
}
}
if (listOrderedStrengthValue.isEmpty())
return false;
qSort(listOrderedStrengthValue);
int strLeast;
int index=1;
polyg = NULL;
strLeast = listOrderedStrengthValue.takeFirst();
index = listStrengthValue.indexOf(strLeast);
listStrengthValue.takeAt(index);
polyg = listLignes.takeAt(index);
listLignesMostSuitable << polyg;
if ((polyg != NULL) && (!polyg->isEmpty()))
{
QVectorIterator<QPoint> qit(*polyg);
while (qit.hasNext())
{
item=qit.next();
b_Pos_interdit[item.y()][item.x()]= true;
}
}
qDeleteAll(listLignes);
return true;
}