本文整理汇总了C++中QPolygonF::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::append方法的具体用法?C++ QPolygonF::append怎么用?C++ QPolygonF::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygonF
的用法示例。
在下文中一共展示了QPolygonF::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()));
}
示例2: createItem
QGraphicsItem* CGraphicsDiamondItem::createItem()
{
QGraphicsPolygonItem* pItem = new QGraphicsPolygonItem(m_Parent);
drawPen(pItem);
drawBrush(pItem);
qreal x;
qreal y;
qreal w;
qreal h;
x = GET_VALUE(x).toFloat();
y = GET_VALUE(y).toFloat();
w = GET_VALUE(w).toFloat();
h = GET_VALUE(h).toFloat();
QPolygonF d;
d.append(QPointF(x + w/2,y));
d.append(QPointF(x + w,y + h/2));
d.append(QPointF(x + w/2,y + h));
d.append(QPointF(x,y + h/2));
pItem->setPolygon(d);
return pItem;
}
示例3: startNewMapObject
void CreateObjectTool::startNewMapObject(const QPointF &pos,
ObjectGroup *objectGroup)
{
Q_ASSERT(!mNewMapObjectItem);
MapObject *newMapObject = new MapObject;
newMapObject->setPosition(pos);
if (mMode == CreatePolygon || mMode == CreatePolyline) {
MapObject::Shape shape = mMode == CreatePolygon ? MapObject::Polygon
: MapObject::Polyline;
QPolygonF polygon;
polygon.append(QPointF());
newMapObject->setPolygon(polygon);
newMapObject->setShape(shape);
polygon.append(QPointF()); // The last point is connected to the mouse
mOverlayPolygonObject->setPolygon(polygon);
mOverlayPolygonObject->setShape(shape);
mOverlayPolygonObject->setPosition(pos);
mOverlayPolygonItem = new MapObjectItem(mOverlayPolygonObject,
mapDocument());
mapScene()->addItem(mOverlayPolygonItem);
}
objectGroup->addObject(newMapObject);
mNewMapObjectItem = new MapObjectItem(newMapObject, mapDocument());
mapScene()->addItem(mNewMapObjectItem);
}
示例4: modelDataChanged
void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
if (!shouldCalculateStuff(topLeft, bottomRight))
return;
QPolygonF p;
p.append(QPointF(hAxis->posAtValue(0), vAxis->posAtValue(0)));
plot_data *entry = dataModel->data().entry;
for (int i = 0, count = dataModel->rowCount(); i < count; i++, entry++) {
if (entry->in_deco && entry->stopdepth) {
p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(qMin(entry->stopdepth, entry->depth))));
} else {
p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0)));
}
}
setPolygon(p);
QLinearGradient pat(0, p.boundingRect().top(), 0, p.boundingRect().bottom());
// does the user want the ceiling in "surface color" or in red?
if (prefs.redceiling) {
pat.setColorAt(0, getColor(CEILING_SHALLOW));
pat.setColorAt(1, getColor(CEILING_DEEP));
} else {
pat.setColorAt(0, getColor(BACKGROUND_TRANS));
pat.setColorAt(1, getColor(BACKGROUND_TRANS));
}
setPen(QPen(QBrush(Qt::NoBrush), 0));
setBrush(pat);
}
示例5: triangulatePolygon
// ============================================================================
/// Converts polygon into set of triangles.
QList<QPolygonF> triangulatePolygon( const QPolygonF& polygon )
{
QList<QPolygonF> triangles;
if ( polygon.size() < 3 )
{
qDebug("Can't create shape from polygon with less than 3 vertices!");
return triangles;
}
if ( polygon.size() == 3 )
{
triangles.append( polygon );
return triangles;
}
//qDebug("Triangulating polygon with %d vertices", polygon.size() );
// triangulate here
// create GPC polygon from QPolygonF
gpc_vertex_list vertexList;
gpc_polygon gpcpolygon;
vertexList.num_vertices = polygon.size();
vertexList.vertex = new gpc_vertex[ polygon.size() ];
for( int i = 0; i < vertexList.num_vertices; i++ )
{
vertexList.vertex[i].x = polygon[i].x();
vertexList.vertex[i].y = polygon[i].y();
}
gpcpolygon.num_contours = 1;
gpcpolygon.hole = NULL;
gpcpolygon.contour = &vertexList;
// request triangles
gpc_tristrip tristrip;
gpc_polygon_to_tristrip( &gpcpolygon, &tristrip );
// create triangles from tristrups
for( int s = 0; s < tristrip.num_strips; s++ )
{
gpc_vertex_list& strip = tristrip.strip[s];
int numTriangles = strip.num_vertices - 2;
for ( int t = 0; t < numTriangles; t++ )
{
QPolygonF triangle;
triangle.append( QPointF( strip.vertex[t].x, strip.vertex[t].y ) );
triangle.append( QPointF( strip.vertex[t+1].x, strip.vertex[t+1].y ) );
triangle.append( QPointF( strip.vertex[t+2].x, strip.vertex[t+2].y ) );
triangles.append( triangle );
}
}
// release polygon
delete[] vertexList.vertex;
gpc_free_tristrip( &tristrip );
//qDebug("%d triangles created", triangles.size() );
return triangles;
}
示例6: hoverMoveEvent
void BaseTableView::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
/* Case the table itself is not selected shows the child selector
at mouse position */
if(!this->isSelected())
{
QList<QGraphicsItem *> items;
float cols_height, item_idx, ext_height=0;
QRectF rect, rect1;
items.append(columns->childItems());
if(!hide_ext_attribs)
{
items.append(ext_attribs->childItems());
ext_height=ext_attribs->boundingRect().height();
}
//Calculates the default item height
cols_height=roundf((columns->boundingRect().height() + ext_height) / static_cast<float>(items.size()));
//Calculates the item index based upon the mouse position
rect=this->mapRectToItem(title, title->boundingRect());
item_idx=(event->pos().y() - rect.bottom()) / cols_height;
//If the index is invalid clears the selection
if(item_idx < 0 || item_idx >= items.size())
{
this->hoverLeaveEvent(event);
this->setToolTip(this->table_tooltip);
}
else if(!items.isEmpty())
{
QPolygonF pol;
BaseObjectView *item=dynamic_cast<TableObjectView *>(items[item_idx]);
//Configures the selection with the item's dimension
if(obj_selection->boundingRect().height()!=item->boundingRect().height())
{
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, title->boundingRect().width() - (2.5 * HORIZ_SPACING),
item->boundingRect().height());
obj_selection->setPolygon(pol);
}
//Sets the selection position as same as item's position
rect1=this->mapRectToItem(item, item->boundingRect());
obj_selection->setVisible(true);
obj_selection->setPos(QPointF(title->pos().x() + HORIZ_SPACING,-rect1.top()));
//Stores the selected child object
sel_child_obj=dynamic_cast<TableObject *>(item->getSourceObject());
this->setToolTip(item->toolTip());
}
}
}
示例7: getTransformedPoints
void HgTransformedQuad::getTransformedPoints(QPolygonF& poly) const
{
poly.clear();
poly.append(mTransformedPoints[0].toPointF());
poly.append(mTransformedPoints[1].toPointF());
poly.append(mTransformedPoints[2].toPointF());
poly.append(mTransformedPoints[3].toPointF());
}
示例8: modelDataChanged
void DiveProfileItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
if(!shouldCalculateStuff(topLeft, bottomRight))
return;
AbstractProfilePolygonItem::modelDataChanged(topLeft, bottomRight);
if (polygon().isEmpty())
return;
show_reported_ceiling = prefs.profile_dc_ceiling;
reported_ceiling_in_red = prefs.profile_red_ceiling;
/* Show any ceiling we may have encountered */
if (prefs.profile_dc_ceiling && !prefs.profile_red_ceiling) {
QPolygonF p = polygon();
plot_data *entry = dataModel->data().entry + dataModel->rowCount()-1;
for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
if (!entry->in_deco) {
/* not in deco implies this is a safety stop, no ceiling */
p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0)));
} else if (entry->stopdepth < entry->depth) {
p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->stopdepth)));
} else {
p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth)));
}
}
setPolygon(p);
}
// This is the blueish gradient that the Depth Profile should have.
// It's a simple QLinearGradient with 2 stops, starting from top to bottom.
QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
pat.setColorAt(1, getColor(DEPTH_BOTTOM));
pat.setColorAt(0, getColor(DEPTH_TOP));
setBrush(QBrush(pat));
int last = -1;
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
struct plot_data *entry = dataModel->data().entry+i;
if (entry->depth < 2000)
continue;
if ((entry == entry->max[2]) && entry->depth / 100 != last) {
plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_DEEP));
last = entry->depth / 100;
}
if ((entry == entry->min[2]) && entry->depth / 100 != last) {
plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_SHALLOW));
last = entry->depth / 100;
}
if (entry->depth != last)
last = -1;
}
}
示例9: shape
QPainterPath Edge::shape() const
{
QPainterPath path ;
QPolygonF poly;
poly.append(tarP_-(QPointF(2,2)));
poly.append(tarP_+(QPointF(2,2)));
poly.append(srcP_-(QPointF(2,2)));
poly.append(srcP_+(QPointF(2,2)));
path.addPolygon(poly);
return path;
}
示例10: triangleAddQPolygonF
void GraphScaled::triangleAddQPolygonF(QList<V_Triangle> triangle,QList<QPolygonF> &polygon){
V_Triangle v;
for(int i = 0;i<triangle.length();i++){
v = triangle.at(i);
QPolygonF p = QPolygonF();
p.append(QPoint(v.x1,v.y1));
p.append(QPoint(v.x2,v.y2));
p.append(QPoint(v.x3,v.y3));
polygon.append(p);
}
}
示例11: toBox
QPolygonF QGVEdge::toBox(const QLineF &line) const
{
QLineF n = line.normalVector();
QPointF o(n.dx() * 0.5, n.dy() * 0.5);
QPolygonF polygon;
polygon.append(line.p1() + o);
polygon.append(line.p2() + o);
polygon.append(line.p2() - o);
polygon.append(line.p1() - o);
return polygon;
}
示例12: shape
QPainterPath CopyFilterGUIConnectionItem::shape() const
{
QLineF l = line();
QPainterPath path;
path.setFillRule(Qt::WindingFill);
double length = line().length();
if (length > 0)
{
double offset = min(length, maxArrowSize);
QLineF unit = l.unitVector();
QLineF normal = l.normalVector().unitVector();
QPointF v(unit.dx(), unit.dy());
QPointF n(normal.dx(), normal.dy());
QPointF p2 = l.p2();
QPointF p3 = p2 - v * offset + 0.5 * n * offset;
QPointF p4 = p2 - v * offset - 0.5 * n * offset;
QPolygonF polygon;
polygon.append(p4);
polygon.append(p3);
polygon.append(p2);
path.addPolygon(polygon);
QPolygonF polygon2;
QPointF p1 = l.p1();
polygon2.append(p2 + 3 * n);
polygon2.append(p2 - 2 * n);
polygon2.append(p1 - 2 * n);
polygon2.append(p1 + 3 * n);
path.addPolygon(polygon2);
if (factor != 1.0 || isDecibel)
{
QFont font;
font.setPixelSize(10);
QPointF center = (l.p1() + l.p2()) / 2;
QString text = QString("%1").arg(factor);
if (isDecibel)
text += " dB";
QFontMetrics fontMetrics(font);
QSizeF size = fontMetrics.size(0, text);
size += QSizeF(2, 0);
QRectF rect;
rect.setSize(size);
rect.moveCenter(center);
path.addRoundedRect(rect.adjusted(-0.5, 0.5, 0.5, 0.5), 3, 3);
}
}
return path;
}
示例13: paint
void ArrowItem::paint(QPainter *painter) {
painter->drawLine(line());
QBrush b = brush();
b.setStyle(Qt::SolidPattern);
b.setColor(pen().color());
setBrush(b);
start.clear();
end.clear();
if (_startArrowHead) {
qreal deltax = view()->scaledFontSize(_startArrowScale, *painter->device())*0.5; // in points
deltax *= painter->device()->logicalDpiX()/72.0; // convert to 'pixels'.
qreal theta = atan2(qreal(line().y2() - line().y1()), qreal(line().x2() - line().x1())) - M_PI / 2.0;
qreal sina = sin(theta);
qreal cosa = cos(theta);
qreal yin = sqrt(3.0) * deltax;
qreal x1, y1, x2, y2;
QMatrix m(cosa, sina, -sina, cosa, 0.0, 0.0);
m.map( deltax, yin, &x1, &y1);
m.map(-deltax, yin, &x2, &y2);
QPolygonF pts;
pts.append(line().p1());
pts.append(line().p1() + QPointF(x1, y1));
pts.append(line().p1() + QPointF(x2, y2));
painter->drawPolygon(pts);
start = pts;
}
if (_endArrowHead) {
qreal deltax = view()->scaledFontSize(_endArrowScale, *painter->device())*0.5;
deltax *= painter->device()->logicalDpiX()/72.0; // convert points to 'pixels'.
qreal theta = atan2(qreal(line().y1() - line().y2()), qreal(line().x1() - line().x2())) - M_PI / 2.0;
qreal sina = sin(theta);
qreal cosa = cos(theta);
qreal yin = sqrt(3.0) * deltax;
qreal x1, y1, x2, y2;
QMatrix m(cosa, sina, -sina, cosa, 0.0, 0.0);
m.map( deltax, yin, &x1, &y1);
m.map(-deltax, yin, &x2, &y2);
QPolygonF pts;
pts.append(line().p2());
pts.append(line().p2() + QPointF(x1, y1));
pts.append(line().p2() + QPointF(x2, y2));
painter->drawPolygon(pts);
end = pts;
}
}
示例14: loadSVGFiles
void QARehabFileControlWidget::loadSVGFiles(void)
{
QGraphicsScene * scene = this->scene();
scene->setSceneRect(0, 0, this->width(), this->height());
scene->setBackgroundBrush(QBrush(QColor(100, 100, 100, 255)));
containerRect = new QGraphicsRectItem(0, 0, this->width(), this->height());
containerRect->setPen(Qt::NoPen);
containerRect->setBrush(QBrush(QColor(200, 200, 200, 50), Qt::CrossPattern));
QPolygonF polygon;
polygon.append(QPointF(80, 0));
polygon.append(QPointF(0, 80));
polygon.append(QPointF(400, 80));
polygon.append(QPointF(320, 0));
itemBtContainer = new QGraphicsPolygonItem(polygon, containerRect);
itemBtContainer->setPen(Qt::NoPen);
itemBtContainer->setBrush(QBrush(QColor(200, 200, 200, 100)));
svgRestart = new QSVGInteractiveItem(":/svg/restart.svg", itemBtContainer);
svgPlayPause = new QSVGInteractiveItem(":/svg/play.svg", itemBtContainer);
svgPlayPause->setCheckable(true);
svgKinectMaximize = new QSVGInteractiveItem(":/svg/maximize.svg", itemBtContainer);
svgKinectMaximize->setCheckable(true);
itemTimeline = new QGraphicsRectItem(0, 0, this->width() - 160, 5, containerRect);
itemTimeline->setPen(Qt::NoPen);
itemTimeline->setBrush(QBrush(QColor(200, 200, 255, 200)));
itemCuttingInterval = new QGraphicsRectItem(0, 0, this->width() - 160, 20, containerRect);
itemCuttingInterval->setPen(Qt::NoPen);
itemCuttingInterval->setBrush(QBrush(QColor(100, 200, 0, 100)));
svgLeftSelector = new QSVGInteractiveItem(":/svg/intervalLeft.svg", containerRect);
svgRightSelector = new QSVGInteractiveItem(":/svg/intervalRight.svg", containerRect);
QFont font("Verdana", 8);
itemTXModelLeftValue = new QGraphicsSimpleTextItem("Left", this->svgLeftSelector);
itemTXModelLeftValue->setFont(font);
itemTXModelLeftValue->setPen(Qt::NoPen);
itemTXModelLeftValue->setBrush(QBrush(QColor(200, 200, 200, 200)));
itemTXModelRightValue = new QGraphicsSimpleTextItem("Right", this->svgRightSelector);
itemTXModelRightValue->setFont(font);
itemTXModelRightValue->setPen(Qt::NoPen);
itemTXModelRightValue->setBrush(QBrush(QColor(200, 200, 200, 200)));
itemTXModelRightValue->setText(QString::number(this->model.rightValue));
itemTXModelLeftValue->setText(QString::number(this->model.leftValue));
scene->addItem(containerRect);
}
示例15: toPolygon
QPolygonF Mesh::toPolygon() const
{
QPolygonF polygon;
for (int i=0; i<nColumns(); i++)
polygon.append(getVertex2d(i, 0));
for (int i=0; i<nRows(); i++)
polygon.append(getVertex2d(nColumns()-1, i));
for (int i=nColumns()-1; i>=0; i--)
polygon.append(getVertex2d(i, nRows()-1));
for (int i=nRows()-1; i>=1; i--)
polygon.append(getVertex2d(0, i));
return polygon;
}